Fix bug: CodecVideoDecode destroys avpkt.

This commit is contained in:
Johns 2011-12-29 13:43:12 +01:00
parent 23300b0383
commit f179264468
5 changed files with 36 additions and 26 deletions

View File

@ -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

8
Todo
View File

@ -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?

33
codec.c
View File

@ -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)));

View File

@ -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);

View File

@ -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