From f1792644685a6ba8f8233ae5b5f4a3faab35a1a3 Mon Sep 17 00:00:00 2001 From: Johns Date: Thu, 29 Dec 2011 13:43:12 +0100 Subject: [PATCH] Fix bug: CodecVideoDecode destroys avpkt. --- ChangeLog | 13 +++++++++++++ Todo | 8 +++++--- codec.c | 33 ++++++++++++--------------------- codec.h | 4 ++-- softhddev.c | 4 ++++ 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index e24c421..0677169 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,17 @@ User johns +Date: + + Fix bug: CodecVideoDecode destroys avpkt. + +Date: Thu Dec 29 00:55:57 CET 2011 + + Release Version 0.1.3 + Add missing VdpauDecoderDestroy. + Cleanup video packet ringbuffer. + Allow build without VDPAU. + Fix bug: swapped end and start. + Support other than "PCM" alsa mixer channels. + Date: Sat Dec 24 15:26:27 CET 2011 Release Version 0.1.2 diff --git a/Todo b/Todo index fb54979..8b7ea29 100644 --- a/Todo +++ b/Todo @@ -11,7 +11,6 @@ missing: vdpau: 1080i with temporal spatial too slow GT 520 VdpPreemptionCallback handling - Loose a surface libva-intel-driver: intel still has hangups most with 1080i @@ -36,7 +35,7 @@ x11: audio/alsa: video/audio asyncron - random crash in av_parser_parse2, when switching channels + FIXED? random crash in av_parser_parse2, when switching channels playback of >2 channels on 2 channel hardware done? @@ -48,6 +47,9 @@ playback of recording play back is too fast setup: - Setup menu parameters aren't automatic loaded? + Setup of decoder type. + Setup of output type. + Setup of display type. + Setup 4:3 zoom type Setup parameters are not used until restart. Can a notice be added to the setup menu? diff --git a/codec.c b/codec.c index 6e04918..5fb2fcf 100644 --- a/codec.c +++ b/codec.c @@ -483,32 +483,28 @@ void DisplayPts(AVCodecContext * video_ctx, AVFrame * frame) ** ** @param decoder video decoder data ** @param avpkt video packet -** -** @note this version destroys avpkt!! */ -void CodecVideoDecode(VideoDecoder * decoder, AVPacket * avpkt) +void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt) { AVCodecContext *video_ctx; AVFrame *frame; int used; int got_frame; + AVPacket pkt[1]; video_ctx = decoder->VideoCtx; frame = decoder->Frame; + *pkt = *avpkt; // use copy next_part: // FIXME: this function can crash with bad packets - used = avcodec_decode_video2(video_ctx, frame, &got_frame, avpkt); - Debug(4, "%s: %p %d -> %d %d\n", __FUNCTION__, avpkt->data, avpkt->size, - used, got_frame); + used = avcodec_decode_video2(video_ctx, frame, &got_frame, pkt); + Debug(4, "%s: %p %d -> %d %d\n", __FUNCTION__, pkt->data, pkt->size, used, + got_frame); if (got_frame) { // frame completed //DisplayPts(video_ctx, frame); - if (video_ctx->hwaccel_context) { - VideoRenderFrame(decoder->HwDecoder, video_ctx, frame); - } else { - VideoRenderFrame(decoder->HwDecoder, video_ctx, frame); - } + VideoRenderFrame(decoder->HwDecoder, video_ctx, frame); } else { // some frames are needed for references, interlaced frames ... // could happen with h264 dvb streams, just drop data. @@ -516,23 +512,18 @@ void CodecVideoDecode(VideoDecoder * decoder, AVPacket * avpkt) Debug(4, "codec: %8d incomplete interlaced frame %d bytes used\n", video_ctx->frame_number, used); } - if (used != avpkt->size) { - if (used == 0) { - goto next_part; - } + if (used != pkt->size) { if (used >= 0) { // some tv channels, produce this Debug(4, "codec: ooops didn't use complete video packet used %d of %d\n", - used, avpkt->size); - avpkt->data += used; - avpkt->size -= used; + used, pkt->size); + pkt->data += used; + pkt->size -= used; goto next_part; } Debug(3, "codec: bad frame %d\n", used); } - - return; } //---------------------------------------------------------------------------- @@ -663,7 +654,7 @@ void CodecAudioClose(AudioDecoder * audio_decoder) ** @param audio_decoder audio_Decoder data ** @param avpkt audio packet */ -void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt) +void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt) { int16_t buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 4 + FF_INPUT_BUFFER_PADDING_SIZE] __attribute__ ((aligned(16))); diff --git a/codec.h b/codec.h index 855738d..b171a1b 100644 --- a/codec.h +++ b/codec.h @@ -47,7 +47,7 @@ extern void CodecVideoOpen(VideoDecoder *, const char *, int); extern void CodecVideoClose(VideoDecoder *); /// Decode a video packet -extern void CodecVideoDecode(VideoDecoder *, AVPacket * pkt); +extern void CodecVideoDecode(VideoDecoder *, const AVPacket * pkt); /// Allocate a new audio decoder context. extern AudioDecoder *CodecAudioNewDecoder(void); @@ -59,7 +59,7 @@ extern void CodecAudioOpen(AudioDecoder *, const char *, int); extern void CodecAudioClose(AudioDecoder *); /// Decode an audio packet -extern void CodecAudioDecode(AudioDecoder *, AVPacket * pkt); +extern void CodecAudioDecode(AudioDecoder *, const AVPacket * pkt); /// Setup and initialize codec module. extern void CodecInit(void); diff --git a/softhddev.c b/softhddev.c index 16bf21e..02e6674 100644 --- a/softhddev.c +++ b/softhddev.c @@ -44,7 +44,11 @@ static char BrokenThreadsAndPlugins; ///< broken vdr threads and plugins +#ifdef USE_VDPAU static char ConfigVdpauDecoder = 1; ///< use vdpau decoder, if possible +#else +#define ConfigVdpauDecoder 0 ///< no vdpau decoder configured +#endif ////////////////////////////////////////////////////////////////////////////// // Audio