On 08/19/2016 04:54 AM, ssshukla26 wrote:
For example let suppose "decoder->dst_data[0]" has YUV buffer and its
alignment is 1.

-----------------------------------------------------------------------------------------------------------------------

//Allocate AVFrame data and linesize

av_image_alloc(avframe->data, avframe->linesize,
    decoder->video_resolution.frame_width,
decoder->video_resolution.frame_height,
    AV_PIX_FMT_YUV420P, 1);


Below are the 3 methods to fill data array of avframe.

-----------------------------------------------------------------------------------------------------------------------

//1) if your Y, U, V buffers are contiguous and have the correct size, This
is deprecated
avpicture_fill((AVPicture*) avframe, decoder->dst_data[0], avframe->format,
avframe->width, avframe->height);

-----------------------------------------------------------------------------------------------------------------------

//2) if your Y, U, V buffers are non-contiguous, This is deprecated
// Initialize avframe->linesize
avpicture_fill((AVPicture*) avframe, NULL, avframe->format, avframe->width,
avframe->height);

//Set avframe->data pointers manually
avframe->data[0] = decoder->dst_data[0];//Y-Buffer
avframe->data[1] = decoder->dst_data[1];//U-Buffer
avframe->data[2] = decoder->dst_data[2];//V-Buffer

-----------------------------------------------------------------------------------------------------------------------

//3) Fill data array of avframe, as decoder->dst_data[0] alignment is 1 use
the same alignment.
av_image_fill_arrays(avframe->data, avframe->linesize, decoder->dst_data[0],
avframe->format, avframe->width, avframe->height, *1*);


Good explanation.

I figured out #3 yesterday and avoided the deprecated call

      m_out_bufers[ m_buf_idx ] = (uint8_t*) av_malloc( 
av_image_get_buffer_size( AV_PIX_FMT_RGB24,
                                                        m_avcodec_ctx->width,
                                                        m_avcodec_ctx->height, 
1 ) );
      if ( !m_out_bufers[ m_buf_idx ] )[...]
      av_image_fill_arrays( m_avframeRGB[ m_buf_idx ]->data,
                            m_avframeRGB[ m_buf_idx ]->linesize,
                            m_out_bufers[ m_buf_idx ],
                            AV_PIX_FMT_RGB24,
                            m_avcodec_ctx->width,
                            m_avcodec_ctx->height, 1
                          );

Can I replace the av_malloc for out_buffers with an input pointer?
size_t required_size = av_image_get_buffer_size( AV_PIX_FMT_RGB24, 
m_avcodec_ctx->width, m_avcodec_ctx->height, 1 );
if ( required_size <= in_buff.size ) m_out_bufers[ m_buf_idx ] = in_buff.data;

Thanks
cco

_______________________________________________
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to