Fix opening sequences in YUV420 when odd resolutions
This commit is contained in:
1 parent
4af83f229d
commit
2b749e3da0
7 files changed
+152
-92
No files matched your search
+46
-17
@@ -295,31 +295,60 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt&
|
||||
Bool LibAvContextHandle::decodeAvFormat()
|
||||
{
|
||||
Int got_frame;
|
||||
Int decResult;
|
||||
/* read frames from the file */
|
||||
while( av_read_frame( fmt_ctx, &pkt ) >= 0 )
|
||||
{
|
||||
if( pkt.stream_index == video_stream_idx )
|
||||
AVPacket orig_pkt = pkt;
|
||||
do
|
||||
{
|
||||
/* decode video frame */
|
||||
Int ret = avcodec_decode_video2( video_dec_ctx, frame, &got_frame, &pkt );
|
||||
if( ret < 0 )
|
||||
if( pkt.stream_index == video_stream_idx )
|
||||
{
|
||||
fprintf( stderr, "Error decoding video frame\n" );
|
||||
return false;
|
||||
}
|
||||
/* decode video frame */
|
||||
decResult = avcodec_decode_video2( video_dec_ctx, frame, &got_frame, &pkt );
|
||||
if( decResult < 0 )
|
||||
{
|
||||
fprintf( stderr, "Error decoding video frame\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( got_frame )
|
||||
{
|
||||
av_image_copy_to_buffer( m_pchFrameBuffer, m_uiFrameBufferSize, frame->data, frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
|
||||
video_dec_ctx->height, 1 );
|
||||
|
||||
/* copy decoded frame to destination buffer:
|
||||
* this is required since rawvideo expects non aligned data */
|
||||
// av_image_copy( video_dst_data, video_dst_linesize, ( const uint8_t ** )( frame->data ), frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
|
||||
// video_dec_ctx->height );
|
||||
if( got_frame )
|
||||
{
|
||||
av_image_copy_to_buffer( m_pchFrameBuffer, m_uiFrameBufferSize, frame->data, frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
|
||||
video_dec_ctx->height, 1 );
|
||||
}
|
||||
}
|
||||
pkt.data += decResult;
|
||||
pkt.size -= decResult;
|
||||
}
|
||||
av_free_packet( &pkt );
|
||||
while( pkt.size > 0 );
|
||||
av_free_packet( &orig_pkt );
|
||||
|
||||
// /* read frames from the file */
|
||||
// while( av_read_frame( fmt_ctx, &pkt ) >= 0 )
|
||||
// {
|
||||
// if( pkt.stream_index == video_stream_idx )
|
||||
// {
|
||||
// /* decode video frame */
|
||||
// Int ret = avcodec_decode_video2( video_dec_ctx, frame, &got_frame, &pkt );
|
||||
// if( ret < 0 )
|
||||
// {
|
||||
// fprintf( stderr, "Error decoding video frame\n" );
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if( got_frame )
|
||||
// {
|
||||
// av_image_copy_to_buffer( m_pchFrameBuffer, m_uiFrameBufferSize, frame->data, frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
|
||||
// video_dec_ctx->height, 1 );
|
||||
//
|
||||
// /* copy decoded frame to destination buffer:
|
||||
// * this is required since rawvideo expects non aligned data */
|
||||
// // av_image_copy( video_dst_data, video_dst_linesize, ( const uint8_t ** )( frame->data ), frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
|
||||
// // video_dec_ctx->height );
|
||||
// }
|
||||
// }
|
||||
// av_free_packet( &pkt );
|
||||
if( got_frame )
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user