From: gferry Date: Wed, 20 Feb 2013 13:19:55 +0000 (+0100) Subject: fix for OpenCV issue #2815 X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1314^2~1487^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3803f9985af65978ab044e06cd2fd571ac23723;p=platform%2Fupstream%2Fopencv.git fix for OpenCV issue #2815 - libavcodec issue - some decoders alter AVCodecContext width/height values, in a wrong way - eg. in issue 2815, vp6f decoder changes these values, resulting in distorted / invalid frames - this patch forces default AVCodecContext values --- diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp index 0c9c950..e590cd2 100644 --- a/modules/highgui/src/cap_ffmpeg_impl.hpp +++ b/modules/highgui/src/cap_ffmpeg_impl.hpp @@ -560,6 +560,10 @@ bool CvCapture_FFMPEG::open( const char* _filename ) if( AVMEDIA_TYPE_VIDEO == enc->codec_type && video_stream < 0) { + // backup encoder' width/height + int enc_width = enc->width; + int enc_height = enc->height; + AVCodec *codec = avcodec_find_decoder(enc->codec_id); if (!codec || #if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0) @@ -570,6 +574,10 @@ bool CvCapture_FFMPEG::open( const char* _filename ) < 0) goto exit_func; + // checking width/height (since decoder can sometimes alter it, eg. vp6f) + if (enc_width && (enc->width != enc_width)) { enc->width = enc_width; } + if (enc_height && (enc->height != enc_height)) { enc->height = enc_height; } + video_stream = i; video_st = ic->streams[i]; picture = avcodec_alloc_frame();