Fix bug: wrong version number check for av_frame_alloc(), ...

This commit is contained in:
Johns 2015-06-19 01:06:52 +02:00
parent f0d31ad33c
commit 396d5fac05
2 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,7 @@
User johns User johns
Date: Date:
Fix bug: wrong version number check for av_frame_alloc(), ...
Workaround for ffmpeg 2.6 artifacts. Workaround for ffmpeg 2.6 artifacts.
Fix bug: brightness and .. are calculated wrong. Fix bug: brightness and .. are calculated wrong.
Add automatic frame rate detection for older ffmpeg versions. Add automatic frame rate detection for older ffmpeg versions.

26
codec.c
View File

@ -635,13 +635,13 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
decoder->FirstKeyFrame++; decoder->FirstKeyFrame++;
if (frame->key_frame) { if (frame->key_frame) {
Debug(3, "codec: key frame after %d frames\n", Debug(3, "codec: key frame after %d frames\n",
decoder->FirstKeyFrame); decoder->FirstKeyFrame);
decoder->FirstKeyFrame = 0; decoder->FirstKeyFrame = 0;
}
} else {
//DisplayPts(video_ctx, frame);
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
} }
} else {
//DisplayPts(video_ctx, frame);
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
}
#else #else
//DisplayPts(video_ctx, frame); //DisplayPts(video_ctx, frame);
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame); VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
@ -714,7 +714,7 @@ struct _audio_decoder_
int HwSampleRate; ///< hw sample rate int HwSampleRate; ///< hw sample rate
int HwChannels; ///< hw channels int HwChannels; ///< hw channels
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,28,1) #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1)
AVFrame *Frame; ///< decoded audio frame buffer AVFrame *Frame; ///< decoded audio frame buffer
#endif #endif
@ -794,7 +794,7 @@ AudioDecoder *CodecAudioNewDecoder(void)
if (!(audio_decoder = calloc(1, sizeof(*audio_decoder)))) { if (!(audio_decoder = calloc(1, sizeof(*audio_decoder)))) {
Fatal(_("codec: can't allocate audio decoder\n")); Fatal(_("codec: can't allocate audio decoder\n"));
} }
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,28,1) #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1)
if (!(audio_decoder->Frame = av_frame_alloc())) { if (!(audio_decoder->Frame = av_frame_alloc())) {
Fatal(_("codec: can't allocate audio decoder frame buffer\n")); Fatal(_("codec: can't allocate audio decoder frame buffer\n"));
} }
@ -810,7 +810,7 @@ AudioDecoder *CodecAudioNewDecoder(void)
*/ */
void CodecAudioDelDecoder(AudioDecoder * decoder) void CodecAudioDelDecoder(AudioDecoder * decoder)
{ {
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,28,1) #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1)
av_frame_free(&decoder->Frame); // callee does checks av_frame_free(&decoder->Frame); // callee does checks
#endif #endif
free(decoder); free(decoder);
@ -1637,6 +1637,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
*/ */
static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts) static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
{ {
#ifdef USE_AUDIO_DRIFT_CORRECTION
struct timespec nowtime; struct timespec nowtime;
int64_t delay; int64_t delay;
int64_t tim_diff; int64_t tim_diff;
@ -1751,6 +1752,9 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
audio_decoder->DriftCorr, drift * 1000 / 90, corr); audio_decoder->DriftCorr, drift * 1000 / 90, corr);
} }
} }
#else
AudioSetClock(pts);
#endif
} }
/** /**
@ -1836,7 +1840,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
{ {
AVCodecContext *audio_ctx; AVCodecContext *audio_ctx;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,28,1) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,28,1)
AVFrame frame[1]; AVFrame frame[1];
#else #else
AVFrame *frame; AVFrame *frame;
@ -1849,7 +1853,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
// FIXME: don't need to decode pass-through codecs // FIXME: don't need to decode pass-through codecs
// new AVFrame API // new AVFrame API
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,28,1) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,28,1)
avcodec_get_frame_defaults(frame); avcodec_get_frame_defaults(frame);
#else #else
frame = audio_decoder->Frame; frame = audio_decoder->Frame;