From bb6c23de0c3d2a76325f365efe25128482d004b0 Mon Sep 17 00:00:00 2001 From: cehoyos Date: Tue, 11 Aug 2009 18:28:26 +0000 Subject: Fix a crash when playing some H264 over rtsp streams: Do pass an AVCodecContext to the H264 parser. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29493 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_rtp.cpp | 6 +++++- libmpdemux/demux_rtp_codec.cpp | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libmpdemux/demux_rtp.cpp b/libmpdemux/demux_rtp.cpp index c59bf5bf7e..513307e5c9 100644 --- a/libmpdemux/demux_rtp.cpp +++ b/libmpdemux/demux_rtp.cpp @@ -117,6 +117,7 @@ int rtsp_transport_tcp = 0; #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 @@ extern "C" void demux_close_rtp(demuxer_t* demuxer) { delete rtpState->videoBufferQueue; delete rtpState->sdpDescription; delete rtpState; +#ifdef CONFIG_LIBAVCODEC + av_free(avcctx); +#endif env->reclaim(); delete scheduler; } @@ -561,7 +565,7 @@ static demux_packet_t* getBuffer(demuxer_t* demuxer, demux_stream_t* ds, } if (headersize == 3 && h264parserctx) { // h264 consumed = h264parserctx->parser->parser_parse(h264parserctx, - NULL, + (AVCodecContext *)avcctx, &poutbuf, &poutbuf_size, dp->buffer, dp->len); diff --git a/libmpdemux/demux_rtp_codec.cpp b/libmpdemux/demux_rtp_codec.cpp index bb129c0dc3..fbfbb3258f 100644 --- a/libmpdemux/demux_rtp_codec.cpp +++ b/libmpdemux/demux_rtp_codec.cpp @@ -30,6 +30,7 @@ extern "C" { #ifdef CONFIG_LIBAVCODEC AVCodecParserContext * h264parserctx; #endif +void *avcctx; // Copied from vlc static unsigned char* parseH264ConfigStr( char const* configStr, @@ -137,6 +138,7 @@ void rtpCodecInitialize_video(demuxer_t* demuxer, #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) { -- cgit v1.2.3