#650 closed defect (fixed)
Segmentation Fault when using av_opt_set to set h264 options
Reported by: | apolychrono | Owned by: | Michael Niedermayer |
---|---|---|---|
Priority: | normal | Component: | avutil |
Version: | git-master | Keywords: | h264 |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Tested with ffmpeg latest release. I use the av_opt_set as below:
static AVStream *add_video_stream(AVFormatContext *oc, enum CodecID codec_id) { AVCodecContext *c; AVStream *st; st = av_new_stream(oc, 0); if (!st) { fprintf(stderr, "Could not alloc stream\n"); exit(1); } c = st->codec; c->flags = CODEC_FLAG_GLOBAL_HEADER; /* default-setting for x264 */ c->me_range = 16; c->max_qdiff = 4; c->qmin = 10; c->qmax = 51; c->qcompress = 0.6; c->codec_id = codec_id; c->codec_type = AVMEDIA_TYPE_VIDEO; c->bit_rate = 200000; c->width = WIDTH; c->height = HEIGHT; c->time_base.den = STREAM_FRAME_RATE; c->time_base.num = 1; c->gop_size = STREAM_FRAME_RATE; c->pix_fmt = STREAM_PIX_FMT; if (c->codec_id == CODEC_ID_MPEG2VIDEO) { c->max_b_frames = 2; } if (c->codec_id == CODEC_ID_MPEG1VIDEO){ c->mb_decision=2; } if (oc->oformat->flags & AVFMT_GLOBALHEADER) c->flags |= CODEC_FLAG_GLOBAL_HEADER; if(codec_id == CODEC_ID_H264) av_opt_set(c->priv_data, "preset", "slow", 0); return st; }
Below is the gdb report:
apolychrono@apolychrono-desktop:~/Software/ffmpeg-14-11-2011/doc/examples$ gdb muxing GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/apolychrono/Software/ffmpeg-14-11-2011/doc/examples/muxing...done. (gdb) run ~/Videos/yuv/sample_352x288@10_YUV420p.yuv Starting program: /home/apolychrono/Software/ffmpeg-14-11-2011/doc/examples/muxing ~/Videos/yuv/sample_352x288@10_YUV420p.yuv [Thread debugging using libthread_db enabled] total-frames: 526 pixels: 101376 Program received signal SIGSEGV, Segmentation fault. av_opt_find2 (obj=0x0, name=0xbb236e "preset", unit=0x0, search_flags=0, target_obj=0x7fffffffd9d8, opt_flags=<value optimized out>) at libavutil/opt.c:756 756 const AVClass *c = *(AVClass**)obj; (gdb) bt #0 av_opt_find2 (obj=0x0, name=0xbb236e "preset", unit=0x0, search_flags=0, target_obj=0x7fffffffd9d8, opt_flags=<value optimized out>) at libavutil/opt.c:756 #1 0x0000000000baab05 in av_opt_set (obj=0x0, name=0xbb236e "preset", val=0xbb2369 "slow", search_flags=0) at libavutil/opt.c:228 #2 0x0000000000432792 in add_video_stream (oc=0x1520040, codec_id=CODEC_ID_H264) at muxing.c:282 #3 0x00000000004333e1 in main (argc=2, argv=0x7fffffffe0d8) at muxing.c:625 (gdb) disass $pc-32,$pc+32 Dump of assembler code from 0xba9f9d to 0xba9fdd: 0x0000000000ba9f9d <set_string_binary+349>: pop %rsp 0x0000000000ba9f9e <set_string_binary+350>: retq 0x0000000000ba9f9f: nop 0x0000000000ba9fa0 <av_opt_find2+0>: push %r15 0x0000000000ba9fa2 <av_opt_find2+2>: mov %ecx,%r15d 0x0000000000ba9fa5 <av_opt_find2+5>: push %r14 0x0000000000ba9fa7 <av_opt_find2+7>: mov %rdi,%r14 0x0000000000ba9faa <av_opt_find2+10>: push %r13 0x0000000000ba9fac <av_opt_find2+12>: mov %rdx,%r13 0x0000000000ba9faf <av_opt_find2+15>: push %r12 0x0000000000ba9fb1 <av_opt_find2+17>: push %rbp 0x0000000000ba9fb2 <av_opt_find2+18>: push %rbx 0x0000000000ba9fb3 <av_opt_find2+19>: mov %rsi,%rbx 0x0000000000ba9fb6 <av_opt_find2+22>: sub $0x28,%rsp 0x0000000000ba9fba <av_opt_find2+26>: test $0x1,%cl => 0x0000000000ba9fbd <av_opt_find2+29>: mov (%rdi),%rbp 0x0000000000ba9fc0 <av_opt_find2+32>: mov %r8,0x8(%rsp) 0x0000000000ba9fc5 <av_opt_find2+37>: je 0xbaa02e <av_opt_find2+142> 0x0000000000ba9fc7 <av_opt_find2+39>: xor %r12d,%r12d 0x0000000000ba9fca <av_opt_find2+42>: test $0x2,%cl 0x0000000000ba9fcd <av_opt_find2+45>: je 0xbaa0f7 <av_opt_find2+343> 0x0000000000ba9fd3 <av_opt_find2+51>: movq $0x0,0x18(%rsp) 0x0000000000ba9fdc <av_opt_find2+60>: xor %edi,%edi End of assembler dump. (gdb) info all-registers rax 0x0 0 rbx 0xbb236e 12264302 rcx 0x0 0 rdx 0x0 0 rsi 0xbb236e 12264302 rdi 0x0 0 rbp 0xbb2369 0xbb2369 rsp 0x7fffffffd970 0x7fffffffd970 r8 0x7fffffffd9d8 140737488345560 r9 0x8000000000000000 -9223372036854775808 r10 0x8000000000000000 -9223372036854775808 r11 0x8000000000000000 -9223372036854775808 r12 0x432044 4399172 r13 0x0 0 r14 0x0 0 r15 0x0 0 rip 0xba9fbd 0xba9fbd <av_opt_find2+29> eflags 0x10246 [ PF ZF IF RF ] cs 0x33 51 ss 0x2b 43 ds 0x0 0 es 0x0 0 fs 0x0 0 gs 0x0 0 st0 0 (raw 0x00000000000000000000) st1 0 (raw 0x00000000000000000000) st2 0 (raw 0x00000000000000000000) st3 0 (raw 0x00000000000000000000) st4 0 (raw 0x00000000000000000000) st5 0 (raw 0x00000000000000000000) st6 0 (raw 0x00000000000000000000) st7 0 (raw 0x00000000000000000000) fctrl 0x37f 895 fstat 0x0 0 ftag 0xffff 65535 fiseg 0x0 0 fioff 0x0 0 foseg 0x0 0 fooff 0x0 0 fop 0x0 0 xmm0 {v4_float = {0x0, 0x1, 0x0, 0x0}, v2_double = {0x1, 0x0}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf0, 0x3f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x0, 0x0, 0x0, 0x3ff0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x3ff00000, 0x0, 0x0}, v2_int64 = {0x3ff0000000000000, 0x0}, uint128 = 0x00000000000000003ff0000000000000} xmm1 {v4_float = {0x0, 0xffffffff, 0x0, 0x0}, v2_double = {0xffffffffffffffff, 0x8000000000000000}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf0, 0xbf, 0xff, 0xff, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff}, v8_int16 = {0x0, 0x0, 0x0, 0xbff0, 0xffff, 0xff00, 0xffff, 0xffff}, v4_int32 = {0x0, 0xbff00000, 0xff00ffff, 0xffffffff}, v2_int64 = {0xbff0000000000000, 0xffffffffff00ffff}, uint128 = 0xffffffffff00ffffbff0000000000000} xmm2 {v4_float = {0x0, 0x1, 0x0, 0x0}, v2_double = {0x1, 0x8000000000000000}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf0, 0x3f, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x66}, v8_int16 = {0x0, 0x0, 0x0, 0x3ff0, 0x6173, 0x706d, 0x656c, 0x665f}, v4_int32 = {0x0, 0x3ff00000, 0x706d6173, 0x665f656c}, v2_int64 = {0x3ff0000000000000, 0x665f656c706d6173}, uint128 = 0x665f656c706d61733ff0000000000000} xmm3 {v4_float = {0x0, 0xffffffff, 0x0, 0x0}, v2_double = {0xffffffffffffffff, 0x0}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf0, 0xbf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x0, 0x0, 0x0, 0xbff0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0xbff00000, 0x0, 0x0}, v2_int64 = {0xbff0000000000000, 0x0}, uint128 = 0x0000000000000000bff0000000000000} xmm4 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x8000000000000000, 0x8000000000000000}, v16_int8 = {0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x66, 0x6d, 0x74, 0x0, 0x38, 0x2d, 0x62, 0x69, 0x74}, v8_int16 = {0x6173, 0x706d, 0x656c, 0x665f, 0x746d, 0x3800, 0x622d, 0x7469}, v4_int32 = {0x706d6173, 0x665f656c, 0x3800746d, 0x7469622d}, v2_int64 = {0x665f656c706d6173, 0x7469622d3800746d}, uint128 = 0x7469622d3800746d665f656c706d6173} xmm5 {v4_float = {0x0, 0x1, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0, 0x0, 0x0, 0xe0, 0x95, 0x9c, 0xe7, 0x3f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x0, 0xe000, 0x9c95, 0x3fe7, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0xe0000000, 0x3fe79c95, 0x0, 0x0}, v2_int64 = {0x3fe79c95e0000000, 0x0}, uint128 = 0x00000000000000003fe79c95e0000000} xmm6 {v4_float = {0x0, 0x1, 0x0, 0x0}, v2_double = {0x1, 0x0}, v16_int8 = {0x6d, 0x7d, 0xbf, 0xbb, 0x27, 0xaf, 0xf5, 0x3f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x7d6d, 0xbbbf, 0xaf27, 0x3ff5, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0xbbbf7d6d, 0x3ff5af27, 0x0, 0x0}, v2_int64 = {0x3ff5af27bbbf7d6d, 0x0}, uint128 = 0x00000000000000003ff5af27bbbf7d6d} xmm7 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x68, 0xc8, 0xbc, 0x3b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x0, 0x0, 0xc868, 0x3bbc, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x3bbcc868, 0x0, 0x0}, v2_int64 = {0x3bbcc86800000000, 0x0}, uint128 = 0x00000000000000003bbcc86800000000} xmm8 {v4_float = {0x0, 0xfffffffd, 0x0, 0x0}, v2_double = {0xffffffffffffffd2, 0x0}, v16_int8 = {0xe0, 0xe6, 0x35, 0x67, 0x9e, 0x6, 0x47, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0xe6e0, 0x6735, 0x69e, 0xc047, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x6735e6e0, 0xc047069e, 0x0, 0x0}, v2_int64 = {0xc047069e6735e6e0, 0x0}, uint128 = 0x0000000000000000c047069e6735e6e0} xmm9 {v4_float = {0x0, 0x1, 0x0, 0x0}, v2_double = {0x1, 0x0}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf0, 0x3f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x0, 0x0, 0x0, 0x3ff0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x3ff00000, 0x0, 0x0}, v2_int64 = {0x3ff0000000000000, 0x0}, uint128 = 0x00000000000000003ff0000000000000} xmm10 {v4_float = {0x0, 0xffffffff, 0x0, 0x0}, v2_double = {0xffffffffffffffff, 0x0}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf0, 0xbf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x0, 0x0, 0x0, 0xbff0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0xbff00000, 0x0, 0x0}, v2_int64 = {0xbff0000000000000, 0x0}, uint128 = 0x0000000000000000bff0000000000000} xmm11 {v4_float = {0x9689a800, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x6a, 0xa2, 0x65, 0x50, 0xf2, 0xea, 0x8f, 0xbd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0xa26a, 0x5065, 0xeaf2, 0xbd8f, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x5065a26a, ---Type <return> to continue, or q <return> to quit--- 0xbd8feaf2, 0x0, 0x0}, v2_int64 = {0xbd8feaf25065a26a, 0x0}, uint128 = 0x0000000000000000bd8feaf25065a26a} xmm12 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x29, 0xf2, 0x88, 0x6c, 0xa6, 0x49, 0xde, 0x3e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0xf229, 0x6c88, 0x49a6, 0x3ede, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x6c88f229, 0x3ede49a6, 0x0, 0x0}, v2_int64 = {0x3ede49a66c88f229, 0x0}, uint128 = 0x00000000000000003ede49a66c88f229} xmm13 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0xb3, 0x12, 0x58, 0x17, 0x64, 0x46, 0xe6, 0x3b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x12b3, 0x1758, 0x4664, 0x3be6, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x175812b3, 0x3be64664, 0x0, 0x0}, v2_int64 = {0x3be64664175812b3, 0x0}, uint128 = 0x00000000000000003be64664175812b3} xmm14 {v4_float = {0x0, 0x3, 0x0, 0x0}, v2_double = {0x2d, 0x0}, v16_int8 = {0xc0, 0x9, 0xf2, 0x16, 0xb5, 0xdf, 0x46, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x9c0, 0x16f2, 0xdfb5, 0x4046, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x16f209c0, 0x4046dfb5, 0x0, 0x0}, v2_int64 = {0x4046dfb516f209c0, 0x0}, uint128 = 0x00000000000000004046dfb516f209c0} xmm15 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000} mxcsr 0x1fa0 [ PE IM DM ZM OM UM PM ]
Thanks in advance.
Change History (2)
comment:1 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 2 years ago
Keywords: | h264 added; av_set_opt av_opt_find2 h265 options removed |
---|
Note:
See TracTickets
for help on using tickets.
Crash fixed locally, will be in git master in a moment
About the usage
You need to call one of the functions that allocates the private context.
avcodec_get_context_defaults3() for example or use avformat_new_stream() and pass it the AVCodec
also see doc/examples/decoding_encoding.c for some examples
also patches improving our docs are welcome!