[FFmpeg-trac] #8792(avcodec:new): mpeg2video decode "end mismatch" errors and corrupted image output
FFmpeg
trac at avcodec.org
Thu Jul 16 21:41:09 EEST 2020
#8792: mpeg2video decode "end mismatch" errors and corrupted image output
---------------------------------+--------------------------------------
Reporter: tmm1 | Type: defect
Status: new | Priority: normal
Component: avcodec | Version: git-master
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
---------------------------------+--------------------------------------
Summary of the bug:
I have an mpeg2 720p sample which fails to decode correctly with
avcodec/mpeg12dec.c, producing visible corruption on the bottom of
generated images. Using other hardware decoders, no such corruption is
visible.
How to reproduce:
{{{
ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.3 (clang-1103.0.32.62)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3_3 --enable-shared
--enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-
cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl
--enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame
--enable-libopus --enable-librav1e --enable-librubberband --enable-
libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora
--enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp
--enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid
--enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r
--enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr
--enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mpegts, from 'https://tmm1.s3.amazonaws.com/mpeg12dec-err.ts':
Duration: 00:00:00.52, start: 32081.276567, bitrate: 5539 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions,
59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Side data:
cpb: bitrate max/min/avg: 80000000/0/0 buffer size: 9781248
vbv_delay: N/A
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: wrapped_avframe, yuv420p, 1280x720 [SAR 1:1 DAR
16:9], q=2-31, 200 kb/s, 59.94 fps, 59.94 tbn, 59.94 tbc
Metadata:
encoder : Lavc58.91.100 wrapped_avframe
[mpeg2video @ 0x7fd90200b400] end mismatch left=29 2 at 0 45
[mpeg2video @ 0x7fd90200b400] Warning MVs not available
[mpeg2video @ 0x7fd90200b400] concealing 80 DC, 80 AC, 80 MV errors in B
frame
https://tmm1.s3.amazonaws.com/mpeg12dec-err.ts: corrupt decoded frame in
stream 0
[mpeg2video @ 0x7fd90200b400] end mismatch left=30 3E at 0 45
[mpeg2video @ 0x7fd90200b400] Warning MVs not available
[mpeg2video @ 0x7fd90200b400] concealing 80 DC, 80 AC, 80 MV errors in B
frame
https://tmm1.s3.amazonaws.com/mpeg12dec-err.ts: corrupt decoded frame in
stream 0
frame= 31 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.51 bitrate=N/A
speed=0.826x
video:16kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown
}}}
The visual corruption can be seen in the bottom 16 pixels of
mpeg12decframe-005.png as generated by this command:
{{{
ffmpeg -i mpeg12dec-err.ts -map v -vframes 5 -y mpeg12decframe-%03d.png
}}}
A workaround is to disable the error as follows, which fixes the generated
images:
{{{
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1889,9 +1889,12 @@ static int mpeg_decode_slice(MpegEncContext *s, int
mb_y,
if (left < 0 ||
(left && show_bits(&s->gb, FFMIN(left, 23)) &&
!is_d10) ||
((avctx->err_recognition & (AV_EF_BITSTREAM |
AV_EF_AGGRESSIVE)) && left > 8)) {
+ /*
av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X
at %d %d\n",
left, left>0 ? show_bits(&s->gb, FFMIN(left,
23)) : 0, s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
+ */
+ goto eos;
} else
goto eos;
}
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8792>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list