[FFmpeg-devel] [FFmpeg-cvslog] r11071 - in trunk: ffmpeg.c ffplay.c ffserver.c libavformat/4xm.c libavformat/adtsenc.c libavformat/aiff.c libavformat/amr.c libavformat/apc.c libavformat/ape.c libavformat/asf-enc.c libavformat/asf.c libavformat/au.c libavformat/avformat.h libavformat/avidec.c libavformat/avienc.c libavformat/avio.h libavformat/aviobuf.c libavformat/avs.c libavformat/bethsoftvid.c libavformat/c93.c libavformat/crcenc.c libavformat/daud.c libavformat/dsicin.c libavformat/dv.c libavformat/dvenc.c libavformat/dxa.c libavformat/eacdata.c libavformat/electronicarts.c libavformat/ffm.c libavformat/flic.c libavformat/flvdec.c libavformat/flvenc.c libavformat/framecrcenc.c libavformat/gif.c libavformat/gifdec.c libavformat/gxf.c libavformat/gxfenc.c libavformat/idcin.c libavformat/idroq.c libavformat/img2.c libavformat/ipmovie.c libavformat/libnut.c libavformat/matroskadec.c libavformat/matroskaenc.c libavformat/mm.c libavformat/mmf.c libavformat/mov.c libavformat/movenc.c libavformat/mp3.c libavformat/mpc.c libavformat/mpc8.c libavformat/mpeg.c libavformat/mpegenc.c libavformat/mpegts.c libavformat/mpegtsenc.c libavformat/mpjpeg.c libavformat/mtv.c libavformat/mxf.c libavformat/nsvdec.c libavformat/nutdec.c libavformat/nutenc.c libavformat/nuv.c libavformat/oggdec.c libavformat/oggenc.c libavformat/psxstr.c libavformat/raw.c libavformat/rmdec.c libavformat/rmenc.c libavformat/rtp.c libavformat/rtsp.c libavformat/segafilm.c libavformat/sierravmd.c libavformat/siff.c libavformat/smacker.c libavformat/sol.c libavformat/swf.c libavformat/thp.c libavformat/tiertexseq.c libavformat/tta.c libavformat/txd.c libavformat/utils.c libavformat/vocdec.c libavformat/vocenc.c libavformat/wav.c libavformat/wc3movie.c libavformat/westwood.c libavformat/wv.c libavformat/yuv4mpeg.c output_example.c

Björn Axelsson bjorn.axelsson
Thu Nov 29 10:48:46 CET 2007


On Wed, 2007-11-28 at 21:10 +0100, matthieu castet wrote:
> Andreas ?man wrote:
> > Hi,
> > 
> > matthieu castet wrote:
> >> Now ic->pb is set to NULL, and this cause crashes for application like 
> >> vdr soft device that use av_open_input_file & AVFMT_NOFILE.
> > 
> > Exactly where does it crash?
> > 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0xa7d0b8d0 (LWP 13960)]
> get_byte (s=0x0) at aviobuf.c:323
> 323         if (s->buf_ptr < s->buf_end) {
> (gdb) p s
> $1 = (ByteIOContext *) 0x0
> (gdb) bt
> #0  get_byte (s=0x0) at aviobuf.c:323
> #1  0xa7560d9e in mpegps_read_header (s=0x834a700, ap=0xafe10e4c) at 
> mpeg.c:125
> #2  0xa752217f in av_open_input_stream (ic_ptr=0x82e6c9c, pb=0x0,
>      filename=0xa7b28928 "null", fmt=0xa759d2a0, ap=0xafe10e4c) at 
> utils.c:380
> #3  0xa7526d8a in av_open_input_file (ic_ptr=0x82e6c9c,
>      filename=0xa7b28928 "null", fmt=0xa759d2a0, buf_size=0, ap=0x0)
>      at utils.c:485
> #4  0xa7b0f330 in cMpeg2Decoder::initStream (this=0x82e6c20)
>      at mpeg2decoder.c:1118
> #5  0xa7b0f494 in cMpeg2Decoder::Start (this=0x82e6c20, GetMutex=true)
>      at mpeg2decoder.c:1333
> #6  0xa7b0a4e8 in cSoftDevice::SetPlayMode (this=0x82807b0,
>      PlayMode=pmAudioVideo) at softdevice.c:448
> #7  0x0809e396 in cDevice::AttachPlayer (this=0x82807b0, Player=0x8318b74)
>      at device.c:960
> #8  0x080d6013 in cControl::Attach () at player.c:80
> #9  0x08106ef3 in main (argc=Cannot access memory at address 0x0
> ) at vdr.c:684
> (gdb) up
> #1  0xa7560d9e in mpegps_read_header (s=0x834a700, ap=0xafe10e4c) at 
> mpeg.c:125
> 125             v = get_byte(s->pb);
> (gdb) p s->pb
> $2 = (ByteIOContext *) 0x0

Hmm. That ic->pb is NULL for AVFMT_NOFILE formats was a design decision,
since formats without files shouldn't need an ByteIOContext. 
For better backwards compability it could be changed to allocate a dummy
ByteIOContext for those AVInputContexts, but that mainly helps broken
applications that access the invalid ByteIOContext.

After looking at the stack trace and then at the softdevice source code
it seems to me that "vdr-softdevice" misuses the libavformat API in
several ways: 

>From [1]:
> void cMpeg2Decoder::initStream() {
>   AVInputFormat *fmt;
>
>   LastSize=0;
>   av_register_all();
>
>   fmt=av_find_input_format("mpeg");
>   fmt->flags |= AVFMT_NOFILE;

Changing the declared properties of a demuxer can't ever be a good idea.

>   if ( int err=av_open_input_file(&ic, "null",fmt,0,NULL) ) {
>       printf("Failed to open input stream.Error %d\n",err);
>   };
>   init_put_byte(&ic->pb, NULL,dvb_buf_size[setupStore->bufferMode]/2, 0, this,
>       read_packet_RingBuffer,NULL,seek_RingBuffer);
>   ic->pb.buf_end=NULL;
>   ic->pb.is_streamed=true;

The correct way to do this would be to first allocate and set up the
ByteIOContext, and then to call av_open_input_stream() on it, since
there is no file.

I don't believe that the recent changes broke av_open_input_file(). I do
agree that they broke some backwards compatibility, but that is why the
major version number was bumped.

[1]
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/softdevice/softdevice/mpeg2decoder.c?rev=1.77&content-type=text/vnd.viewcvs-markup
-- 
Bj?rn Axelsson                    Phone: +46-(0)90-18 98 97
Intinor AB                          Fax: +46-(0)920-757 10
www.intinor.se
Interactive Television & Digital Media Distribution





More information about the ffmpeg-devel mailing list