Crash in libswscale when reading a 800x600 AVI (I420 codec)

Any other question that don't fit into the other support categorizes.
Post Reply
ccaltagi
Posts: 19
Joined: Thu Sep 13, 2012 12:28 am

Crash in libswscale when reading a 800x600 AVI (I420 codec)

Post by ccaltagi »

I am observing a crash when I try to read back an 800x600 AVI that was encoded with either the I420, YV12 or IYUV codecs. The crash happens in yuv2rgb.c (libswscale), in the LOADCHROMA(0) macro that is called in YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t, 0)

Unhandled exception at 0x5eb32510 (opencv_ffmpeg240.dll)
Access violation reading location 0x0ff02820

I am using FFmpeg 1.0.0, called through the OpenCV wrapper.
Has anyone experienced that?
Are there any limitation in size when using the I420 or similar YUV codec?
It works fine when I create an AVI with 640x480 images.

I am also seeing something weird with the debug opencv_ffmpeg240.dll: with the I420 codec, the 640x480 image returned is all pink. I don't see the problem with the release version.

Any help is greatly appreciated. I have a hard deadline on this project next week and can't ship with that crash.

Thanks!

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: Crash in libswscale when reading a 800x600 AVI (I420 cod

Post by rogerdpack »

I'd try it with git master, if it's still there, ping the ffmpeg-user mailing list or file a trac [?]

ccaltagi
Posts: 19
Joined: Thu Sep 13, 2012 12:28 am

Re: Crash in libswscale when reading a 800x600 AVI (I420 cod

Post by ccaltagi »

Roger, thanks for the quick answer.
I am not familiar with git master. Are you suggesting I am trying the latest source code using git?

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: Crash in libswscale when reading a 800x600 AVI (I420 cod

Post by rogerdpack »

ccaltagi wrote:Roger, thanks for the quick answer.
I am not familiar with git master. Are you suggesting I am trying the latest source code using git?
basically the latest and greatest source, yeah.

ccaltagi
Posts: 19
Joined: Thu Sep 13, 2012 12:28 am

Re: Crash in libswscale when reading a 800x600 AVI (I420 cod

Post by ccaltagi »

Hi,

I just wanted to post an update. It seems that the bug is in the openCV wrapper.
In the file cap_ffmpeg_impl.hpp, in the function, CvCapture_FFMPEG::grabFrame,
the developper called av_free_packet twice: once at the beginning of the function, and once at the end. It seems that the call at the end of the function (line 496) should be removed. The packet is freed, but picture->data still referenced the data that was freed in the packet, causing the crash later on. It seems that commented out this call fixes both issues that I am reporting (invalid images returned in debug mode when the image size is 640x480) and crash in both debug and release mode when the image size is bigger.
Removing that line of code does not introduce any leak, since the packet is freed at the beginning of the function, prior to creating a new one, and also in the close.
It would be great is someone could confirm that my assessment and suggested fix are correct.

Thanks!

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: Crash in libswscale when reading a 800x600 AVI (I420 cod

Post by rogerdpack »

has this been fixed yet? If you send me a patch I can submit it...

Post Reply