changeset 29451:6aca83f5ba73

Fix a crash when playing some H264 over rtsp streams: Do pass an AVCodecContext to the H264 parser.
author cehoyos
date Tue, 11 Aug 2009 18:28:26 +0000
parents 85bea9f80e86
children e8d71beb79b9
files libmpdemux/demux_rtp.cpp libmpdemux/demux_rtp_codec.cpp
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_rtp.cpp	Tue Aug 11 18:21:31 2009 +0000
+++ b/libmpdemux/demux_rtp.cpp	Tue Aug 11 18:28:26 2009 +0000
@@ -117,6 +117,7 @@
 #endif
 
 extern int rtsp_port;
+extern void *avcctx;
 
 extern "C" int audio_id, video_id, dvdsub_id;
 extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
@@ -388,6 +389,9 @@
   delete rtpState->videoBufferQueue;
   delete rtpState->sdpDescription;
   delete rtpState;
+#ifdef CONFIG_LIBAVCODEC
+  av_free(avcctx);
+#endif
 
   env->reclaim(); delete scheduler;
 }
@@ -561,7 +565,7 @@
     }
     if (headersize == 3 && h264parserctx) { // h264
       consumed = h264parserctx->parser->parser_parse(h264parserctx,
-                               NULL,
+                               (AVCodecContext *)avcctx,
                                &poutbuf, &poutbuf_size,
                                dp->buffer, dp->len);
 
--- a/libmpdemux/demux_rtp_codec.cpp	Tue Aug 11 18:21:31 2009 +0000
+++ b/libmpdemux/demux_rtp_codec.cpp	Tue Aug 11 18:28:26 2009 +0000
@@ -30,6 +30,7 @@
 #ifdef CONFIG_LIBAVCODEC
 AVCodecParserContext * h264parserctx;
 #endif
+void *avcctx;
 
 // Copied from vlc
 static unsigned char* parseH264ConfigStr( char const* configStr,
@@ -137,6 +138,7 @@
 #ifdef CONFIG_LIBAVCODEC
     avcodec_register_all();
     h264parserctx = av_parser_init(CODEC_ID_H264);
+    avcctx = avcodec_alloc_context();
 #endif
     needVideoFrameRate(demuxer, subsession);
   } else if (strcmp(subsession->codecName(), "H261") == 0) {