Opened 4 years ago

Closed 3 years ago

#2760 closed defect (fixed)

prores_ks encoder segfaults encoding image with alpha

Reported by: MarkZV Owned by:
Priority: important Component: avcodec
Version: git-master Keywords: prores alpha crash SIGSEGV
Cc: christophe.gisquet@gmail.com Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

A segmentation fault is encountered encoding a png with alpha to prores using prores_ks. The issue can be reproduced using git master and this png input file (resized to 480x480): http://ffmpeg.org/favicon.png

$ ffmpeg -v 9 -loglevel 99 -i x.png -s 480x480 -c:v prores_ks -y out.mov
ffmpeg version 1.1.git-44d0e52 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul  7 2013 21:14:56 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/gcc-4.2 --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-nonfree --enable-libfdk-aac --enable-libfaac
  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 11.101 / 55. 11.101
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 78.103 /  3. 78.103
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input file with argument 'x.png'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '480x480'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'prores_ks'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option 'out.mov' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file x.png.
Successfully parsed a group of options.
Opening an input file: x.png.
[AVIOContext @ 0x1025226a0] Statistics: 855 bytes read, 0 seeks
Input #0, image2, from 'x.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0, 1, 1/25: Video: png, rgba, 16x16, 1/25, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: output file out.mov.
Applying option s (set frame size (WxH or abbreviation)) with argument 480x480.
Applying option c:v (codec name) with argument prores_ks.
Successfully parsed a group of options.
Opening an output file: out.mov.
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0x1033003a0] Setting 'video_size' to value '16x16'
[graph 0 input from stream 0:0 @ 0x1033003a0] Setting 'pix_fmt' to value '28'
[graph 0 input from stream 0:0 @ 0x1033003a0] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 0x1033003a0] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x1033003a0] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x1033003a0] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x1033003a0] w:16 h:16 pixfmt:rgba tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[scaler for output stream 0:0 @ 0x103300960] Setting 'w' to value '480'
[scaler for output stream 0:0 @ 0x103300960] Setting 'h' to value '480'
[scaler for output stream 0:0 @ 0x103300960] Setting 'flags' to value '0x4'
[scaler for output stream 0:0 @ 0x103300960] w:480 h:480 flags:'0x4' interl:0
[format @ 0x103300e60] compat: called with args=[yuv422p10le|yuv444p10le|yuva444p10le]
[format @ 0x103300e60] Setting 'pix_fmts' to value 'yuv422p10le|yuv444p10le|yuva444p10le'
[AVFilterGraph @ 0x102521920] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed
[scaler for output stream 0:0 @ 0x103300960] picking yuva444p10le out of 3 ref:rgba alpha:1
[scaler for output stream 0:0 @ 0x103300960] w:16 h:16 fmt:rgba sar:0/1 -> w:480 h:480 fmt:yuva444p10le sar:0/1 flags:0x4
[prores_ks @ 0x10280f400] profile 2, 150 slices, interlacing: no, 1050 bits per MB
[prores_ks @ 0x10280f400] frame size upper bound: 159200
Output #0, mov, to 'out.mov':
  Metadata:
    encoder         : Lavf55.11.101
    Stream #0:0, 0, 1/12800: Video: prores (prores_ks) (apcn / 0x6E637061), yuva444p10le, 480x480, 1/25, q=2-31, 200 kb/s, 12800 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> prores_ks)
Press [q] to stop, [?] for help
Segmentation fault
$

A debug version of ffmpeg with assertions enabled produces the following assertion:

Assertion s->buf_ptr+3<s->buf_end failed at libavcodec/put_bits.h:168

Program received signal SIGABRT, Aborted.
0x00007fff87f720b6 in __kill ()
(gdb) bt
#0  0x00007fff87f720b6 in __kill ()
#1  0x00007fff880129f6 in abort ()
#2  0x0000000100876368 in put_bits (s=0x7fff5fbfeb30, n=9, value=493) at put_bits.h:168
#3  0x0000000100876bef in encode_vlc_codeword (pb=0x7fff5fbfeb30, codebook=112, val=493) at libavcodec/proresenc_kostya.c:344
#4  0x0000000100876b09 in encode_dcs (pb=0x7fff5fbfeb30, blocks=0x103065510, blocks_per_slice=8, scale=24) at libavcodec/proresenc_kostya.c:377
#5  0x0000000100876e88 in encode_slice_plane (ctx=0x103065400, pb=0x7fff5fbfeb30, src=0x103b49b80, linesize=960, mbs_per_slice=2, blocks=0x103065410, blocks_per_mb=4, plane_size_factor=3, qmat=0x103069910) at libavcodec/proresenc_kostya.c:430
#6  0x0000000100877555 in encode_slice (avctx=0x10300f400, pic=0x103d00000, pb=0x7fff5fbfeb30, sizes=0x7fff5fbfeb60, x=28, y=18, quant=6, mbs_per_slice=2) at libavcodec/proresenc_kostya.c:560
#7  0x00000001008792d3 in encode_frame (avctx=0x10300f400, pkt=0x7fff5fbfee50, pic=0x103d00000, got_packet=0x7fff5fbfeef8) at libavcodec/proresenc_kostya.c:1022
#8  0x0000000100951026 in avcodec_encode_video2 (avctx=0x10300f400, avpkt=0x7fff5fbfee50, frame=0x103d00000, got_packet_ptr=0x7fff5fbfeef8) at libavcodec/utils.c:1756
#9  0x0000000100012001 in do_video_out (s=0x10300ee00, ost=0x102b22b40, in_picture=0x103d00000) at ffmpeg.c:946
#10 0x000000010001297d in reap_filters () at ffmpeg.c:1090
#11 0x000000010001c649 in transcode_step () at ffmpeg.c:3168
#12 0x000000010001c705 in transcode () at ffmpeg.c:3211
#13 0x000000010001cbef in main (argc=13, argv=0x7fff5fbff158) at ffmpeg.c:3389

Change History (2)

comment:1 Changed 4 years ago by cehoyos

  • Keywords SIGSEGV added
  • Priority changed from normal to important
  • Reproduced by developer set
  • Status changed from new to open

comment:2 Changed 3 years ago by kurosu

  • Analyzed by developer set
  • Cc christophe.gisquet@gmail.com added
  • Resolution set to fixed
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.