[FFmpeg-devel] [PATCH] avcodec/er: remove check for fields

Michael Niedermayer michael at niedermayer.cc
Mon Apr 3 02:53:25 EEST 2023


On Mon, Mar 27, 2023 at 08:56:43AM +0200, J. Dekker wrote:
> On 23 Mar 2023, at 10:18, J. Dekker wrote:
> 
> > This change on its own is almost certainly not correct; however, in
> > testing many samples show notable improvement.
> > ---
> >
> >  The warning spams a bit when decoding using due to there being multiple
> >  ERContexts used but it doesn't seem that excessive and it will be
> >  removed soon (hopefully).
> >
> >  libavcodec/error_resilience.c | 9 +++++++--
> >  libavcodec/error_resilience.h | 1 +
> >  2 files changed, 8 insertions(+), 2 deletions(-)
> >
> 
> Pushed.

why was this pushed ?
the commit even says "This change on its own is almost certainly not correct;"

and in fact after this commit out of array reads and writes occurr

heres an example:
ffmpeg   -y -i  fate-suite/mpeg2/mpeg2_field_encoding.ts -i fate-suite/real/rv30.rm -r 30000/1001 -c:v:1 mpeg4 -map 0:0 -map 1:1 -c:v:0 mpeg2video test.avi

[mpeg2video @ 0x2d084040] Warning MVs not available
[mpeg2video @ 0x2d084040] concealing 90 DC, 90 AC, 90 MV errors in P frame
==15798== Invalid read of size 8
==15798==    at 0xD81A2A: ??? (in ffmpeg_g)
==15798==  Address 0x6071bc48 is 8 bytes inside a block of size 24 free'd
==15798==    at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x116332A: av_buffer_unref (in ffmpeg_g)
==15798==    by 0x116F5B5: av_frame_unref (in ffmpeg_g)
==15798==    by 0xFFC690: ff_mpeg_unref_picture (in ffmpeg_g)
==15798==    by 0xA340B5: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798==  Block was alloc'd at
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x117D3E8: av_mallocz (in ffmpeg_g)
==15798==    by 0x11631C7: av_buffer_create (in ffmpeg_g)
==15798==    by 0x8338CC: ff_attach_decode_data (in ffmpeg_g)
==15798==    by 0x833AE4: ff_get_buffer (in ffmpeg_g)
==15798==    by 0xFFC832: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid read of size 8
==15798==    at 0xD81A30: ??? (in ffmpeg_g)
==15798==  Address 0x6071bf48 is 584 bytes inside a block of size 1,658 free'd
==15798==    at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x116333E: av_buffer_unref (in ffmpeg_g)
==15798==    by 0x1163675: av_buffer_replace (in ffmpeg_g)
==15798==    by 0xFFCEA0: ff_update_picture_tables (in ffmpeg_g)
==15798==    by 0xFFD01A: ff_mpeg_ref_picture (in ffmpeg_g)
==15798==    by 0xA34384: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798==  Block was alloc'd at
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x1163245: av_buffer_alloc (in ffmpeg_g)
==15798==    by 0x11632BD: av_buffer_allocz (in ffmpeg_g)
==15798==    by 0xFFCB88: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid write of size 8
==15798==    at 0xD81A79: ??? (in ffmpeg_g)
==15798==  Address 0x6071bc48 is 8 bytes inside a block of size 24 free'd
==15798==    at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x116332A: av_buffer_unref (in ffmpeg_g)
==15798==    by 0x116F5B5: av_frame_unref (in ffmpeg_g)
==15798==    by 0xFFC690: ff_mpeg_unref_picture (in ffmpeg_g)
==15798==    by 0xA340B5: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798==  Block was alloc'd at
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x117D3E8: av_mallocz (in ffmpeg_g)
==15798==    by 0x11631C7: av_buffer_create (in ffmpeg_g)
==15798==    by 0x8338CC: ff_attach_decode_data (in ffmpeg_g)
==15798==    by 0x833AE4: ff_get_buffer (in ffmpeg_g)
==15798==    by 0xFFC832: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid write of size 8
==15798==    at 0xD81A8C: ??? (in ffmpeg_g)
==15798==  Address 0x6071bf48 is 584 bytes inside a block of size 1,658 free'd
==15798==    at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x116333E: av_buffer_unref (in ffmpeg_g)
==15798==    by 0x1163675: av_buffer_replace (in ffmpeg_g)
==15798==    by 0xFFCEA0: ff_update_picture_tables (in ffmpeg_g)
==15798==    by 0xFFD01A: ff_mpeg_ref_picture (in ffmpeg_g)
==15798==    by 0xA34384: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798==  Block was alloc'd at
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x1163245: av_buffer_alloc (in ffmpeg_g)
==15798==    by 0x11632BD: av_buffer_allocz (in ffmpeg_g)
==15798==    by 0xFFCB88: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid read of size 8
==15798==    at 0xD81A08: ??? (in ffmpeg_g)
==15798==  Address 0x606e4e90 is 1 bytes after a block of size 442,447 alloc'd
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x1163245: av_buffer_alloc (in ffmpeg_g)
==15798==    by 0x11632BD: av_buffer_allocz (in ffmpeg_g)
==15798==    by 0x1163AA4: av_buffer_pool_get (in ffmpeg_g)
==15798==    by 0x8D80C4: avcodec_default_get_buffer2 (in ffmpeg_g)
==15798==    by 0x833ACA: ff_get_buffer (in ffmpeg_g)
==15798==    by 0xFFC832: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid write of size 8
==15798==    at 0xD81A6B: ??? (in ffmpeg_g)
==15798==  Address 0x606e4e90 is 1 bytes after a block of size 442,447 alloc'd
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x1163245: av_buffer_alloc (in ffmpeg_g)
==15798==    by 0x11632BD: av_buffer_allocz (in ffmpeg_g)
==15798==    by 0x1163AA4: av_buffer_pool_get (in ffmpeg_g)
==15798==    by 0x8D80C4: avcodec_default_get_buffer2 (in ffmpeg_g)
==15798==    by 0x833ACA: ff_get_buffer (in ffmpeg_g)
==15798==    by 0xFFC832: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid write of size 8
==15798==    at 0xD81A74: ??? (in ffmpeg_g)
==15798==  Address 0x6071b688 is 110,664 bytes inside a block of size 110,671 alloc'd
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x1163245: av_buffer_alloc (in ffmpeg_g)
==15798==    by 0x11632BD: av_buffer_allocz (in ffmpeg_g)
==15798==    by 0x1163AA4: av_buffer_pool_get (in ffmpeg_g)
==15798==    by 0x8D80C4: avcodec_default_get_buffer2 (in ffmpeg_g)
==15798==    by 0x833ACA: ff_get_buffer (in ffmpeg_g)
==15798==    by 0xFFC832: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid read of size 8
==15798==    at 0xD81A1E: ??? (in ffmpeg_g)
==15798==  Address 0x6071b698 is 9 bytes after a block of size 110,671 alloc'd
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x1163245: av_buffer_alloc (in ffmpeg_g)
==15798==    by 0x11632BD: av_buffer_allocz (in ffmpeg_g)
==15798==    by 0x1163AA4: av_buffer_pool_get (in ffmpeg_g)
==15798==    by 0x8D80C4: avcodec_default_get_buffer2 (in ffmpeg_g)
==15798==    by 0x833ACA: ff_get_buffer (in ffmpeg_g)
==15798==    by 0xFFC832: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid read of size 8
==15798==    at 0xD81A24: ??? (in ffmpeg_g)
==15798==  Address 0x6071b998 is 0 bytes after a block of size 88 alloc'd
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x117D3E8: av_mallocz (in ffmpeg_g)
==15798==    by 0x11639EB: av_buffer_pool_get (in ffmpeg_g)
==15798==    by 0x8D80C4: avcodec_default_get_buffer2 (in ffmpeg_g)
==15798==    by 0x833ACA: ff_get_buffer (in ffmpeg_g)
==15798==    by 0xFFC832: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)
==15798== 
==15798== Invalid write of size 8
==15798==    at 0xD81A87: ??? (in ffmpeg_g)
==15798==  Address 0x6071b998 is 0 bytes after a block of size 88 alloc'd
==15798==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15798==    by 0x117D232: av_malloc (in ffmpeg_g)
==15798==    by 0x117D3E8: av_mallocz (in ffmpeg_g)
==15798==    by 0x11639EB: av_buffer_pool_get (in ffmpeg_g)
==15798==    by 0x8D80C4: avcodec_default_get_buffer2 (in ffmpeg_g)
==15798==    by 0x833ACA: ff_get_buffer (in ffmpeg_g)
==15798==    by 0xFFC832: ff_alloc_picture (in ffmpeg_g)
==15798==    by 0xA34257: ff_mpv_frame_start (in ffmpeg_g)
==15798==    by 0x9FC981: decode_chunks (in ffmpeg_g)
==15798==    by 0x9FD024: mpeg_decode_frame (in ffmpeg_g)
==15798==    by 0x8316BE: decode_receive_frame_internal (in ffmpeg_g)
==15798==    by 0x83226F: avcodec_send_packet (in ffmpeg_g)
==15798==    by 0x31B10B: decode_video (in ffmpeg_g)
==15798==    by 0x31D048: transcode (in ffmpeg_g)
==15798==    by 0x2EF743: main (in ffmpeg_g)




[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20230403/9b4641e1/attachment.sig>


More information about the ffmpeg-devel mailing list