mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
Merge pull request #4 from dnehring7/master
Code cleanup for newer ffmpeg versions
This commit is contained in:
commit
ce294f55e8
69
codec.c
69
codec.c
@ -63,16 +63,6 @@
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavutil/mem.h>
|
||||
|
||||
// support old ffmpeg versions <1.0
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,18,102)
|
||||
#define AVCodecID CodecID
|
||||
#define AV_CODEC_ID_AC3 CODEC_ID_AC3
|
||||
#define AV_CODEC_ID_EAC3 CODEC_ID_EAC3
|
||||
#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO
|
||||
#define AV_CODEC_ID_H264 CODEC_ID_H264
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_SWRESAMPLE
|
||||
#include <libswresample/swresample.h>
|
||||
#endif
|
||||
@ -95,16 +85,6 @@
|
||||
#include "audio.h"
|
||||
#include "codec.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// correct is AV_VERSION_INT(56,35,101) but some gentoo i* think
|
||||
// they must change it.
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,26,100)
|
||||
/// ffmpeg 2.6 started to show artifacts after channel switch
|
||||
/// to SDTV channels
|
||||
#define FFMPEG_WORKAROUND_ARTIFACTS 1
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Global
|
||||
//----------------------------------------------------------------------------
|
||||
@ -141,9 +121,6 @@ struct _video_decoder_
|
||||
int GetFormatDone; ///< flag get format called!
|
||||
AVCodec *VideoCodec; ///< video codec
|
||||
AVCodecContext *VideoCtx; ///< video codec context
|
||||
#ifdef FFMPEG_WORKAROUND_ARTIFACTS
|
||||
int FirstKeyFrame; ///< flag first frame
|
||||
#endif
|
||||
AVFrame *Frame; ///< decoded video frame
|
||||
};
|
||||
#endif
|
||||
@ -194,10 +171,6 @@ static int Codec_get_buffer2(AVCodecContext * video_ctx, AVFrame * frame, int fl
|
||||
|
||||
decoder = video_ctx->opaque;
|
||||
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,86,100)
|
||||
// ffmpeg has this already fixed
|
||||
// libav 0.8.5 53.35.0 still needs this
|
||||
#endif
|
||||
if (!decoder->GetFormatDone) { // get_format missing
|
||||
enum AVPixelFormat fmts[2];
|
||||
|
||||
@ -426,9 +399,6 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
|
||||
#ifdef YADIF
|
||||
decoder->filter = 0;
|
||||
#endif
|
||||
#ifdef FFMPEG_WORKAROUND_ARTIFACTS
|
||||
decoder->FirstKeyFrame = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -621,26 +591,9 @@ next_part:
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef FFMPEG_WORKAROUND_ARTIFACTS
|
||||
|
||||
if (!CodecUsePossibleDefectFrames && decoder->FirstKeyFrame) {
|
||||
decoder->FirstKeyFrame++;
|
||||
if (frame->key_frame || (decoder->FirstKeyFrame > 3)) { // key frame is not reliable
|
||||
Debug(3, "codec: key frame after %d frames\n",decoder->FirstKeyFrame);
|
||||
decoder->FirstKeyFrame = 0;
|
||||
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
|
||||
}
|
||||
// av_frame_unref(frame);
|
||||
} else {
|
||||
//DisplayPts(video_ctx, frame);
|
||||
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
|
||||
// av_frame_unref(frame);
|
||||
}
|
||||
#else
|
||||
//DisplayPts(video_ctx, frame);
|
||||
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
|
||||
// av_frame_unref(frame);
|
||||
#endif
|
||||
} else {
|
||||
av_frame_free(&frame);
|
||||
// printf("codec: got no frame %d send %d\n",ret,ret1);
|
||||
@ -698,9 +651,7 @@ struct _audio_decoder_
|
||||
int HwSampleRate; ///< hw sample rate
|
||||
int HwChannels; ///< hw channels
|
||||
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1)
|
||||
AVFrame *Frame; ///< decoded audio frame buffer
|
||||
#endif
|
||||
|
||||
#if !defined(USE_SWRESAMPLE) && !defined(USE_AVRESAMPLE)
|
||||
ReSampleContext *ReSample; ///< old resampling context
|
||||
@ -778,11 +729,9 @@ AudioDecoder *CodecAudioNewDecoder(void)
|
||||
if (!(audio_decoder = calloc(1, sizeof(*audio_decoder)))) {
|
||||
Fatal(_("codec: can't allocate audio decoder\n"));
|
||||
}
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1)
|
||||
if (!(audio_decoder->Frame = av_frame_alloc())) {
|
||||
Fatal(_("codec: can't allocate audio decoder frame buffer\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
return audio_decoder;
|
||||
}
|
||||
@ -794,9 +743,7 @@ AudioDecoder *CodecAudioNewDecoder(void)
|
||||
*/
|
||||
void CodecAudioDelDecoder(AudioDecoder * decoder)
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1)
|
||||
av_frame_free(&decoder->Frame); // callee does checks
|
||||
#endif
|
||||
free(decoder);
|
||||
}
|
||||
|
||||
@ -824,24 +771,11 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, int codec_id)
|
||||
}
|
||||
|
||||
if (CodecDownmix) {
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,61,100)
|
||||
audio_decoder->AudioCtx->request_channels = 2;
|
||||
#endif
|
||||
audio_decoder->AudioCtx->request_channel_layout =
|
||||
AV_CH_LAYOUT_STEREO_DOWNMIX;
|
||||
}
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,61,100)
|
||||
// this has no effect (with ffmpeg and libav)
|
||||
// audio_decoder->AudioCtx->request_sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
#endif
|
||||
pthread_mutex_lock(&CodecLockMutex);
|
||||
// open codec
|
||||
#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(53,5,0)
|
||||
if (avcodec_open(audio_decoder->AudioCtx, audio_codec) < 0) {
|
||||
pthread_mutex_unlock(&CodecLockMutex);
|
||||
Fatal(_("codec: can't open audio codec\n"));
|
||||
}
|
||||
#else
|
||||
if (1) {
|
||||
AVDictionary *av_dict;
|
||||
|
||||
@ -856,7 +790,6 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, int codec_id)
|
||||
}
|
||||
av_dict_free(&av_dict);
|
||||
}
|
||||
#endif
|
||||
pthread_mutex_unlock(&CodecLockMutex);
|
||||
Debug(3, "codec: audio '%s'\n", audio_decoder->AudioCodec->long_name);
|
||||
|
||||
@ -1919,9 +1852,7 @@ void CodecInit(void)
|
||||
#else
|
||||
(void)CodecNoopCallback;
|
||||
#endif
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,9,100)
|
||||
avcodec_register_all(); // register all formats and codecs
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
13
softhddev.c
13
softhddev.c
@ -44,19 +44,6 @@
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavutil/mem.h>
|
||||
// support old ffmpeg versions <1.0
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,18,102)
|
||||
#define AVCodecID CodecID
|
||||
#define AV_CODEC_ID_AAC CODEC_ID_AAC
|
||||
#define AV_CODEC_ID_AAC_LATM CODEC_ID_AAC_LATM
|
||||
#define AV_CODEC_ID_AC3 CODEC_ID_AC3
|
||||
#define AV_CODEC_ID_EAC3 CODEC_ID_EAC3
|
||||
#define AV_CODEC_ID_H264 CODEC_ID_H264
|
||||
#define AV_CODEC_ID_MP2 CODEC_ID_MP2
|
||||
#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO
|
||||
#define AV_CODEC_ID_NONE CODEC_ID_NONE
|
||||
#define AV_CODEC_ID_PCM_DVD CODEC_ID_PCM_DVD
|
||||
#endif
|
||||
|
||||
#ifndef __USE_GNU
|
||||
#define __USE_GNU
|
||||
|
34
video.c
34
video.c
@ -188,7 +188,6 @@ typedef void *EGLImageKHR;
|
||||
#include <libplacebo/renderer.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libswscale/swscale.h>
|
||||
|
||||
@ -198,23 +197,22 @@ typedef void *EGLImageKHR;
|
||||
#include <libavutil/opt.h>
|
||||
#endif
|
||||
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54,86,100)
|
||||
///
|
||||
/// ffmpeg version 1.1.1 calls get_format with zero width and height
|
||||
/// for H264 codecs.
|
||||
/// since version 1.1.3 get_format is called twice.
|
||||
/// ffmpeg 1.2 still buggy
|
||||
///
|
||||
#define FFMPEG_BUG1_WORKAROUND ///< get_format bug workaround
|
||||
#endif
|
||||
|
||||
#include "iatomic.h" // portable atomic_t
|
||||
#include "misc.h"
|
||||
#include "video.h"
|
||||
#include "audio.h"
|
||||
#include "codec.h"
|
||||
|
||||
|
||||
#if defined(APIVERSNUM) && APIVERSNUM < 20400
|
||||
#error "VDR 2.4.0 or greater is required!"
|
||||
#endif
|
||||
|
||||
#define HAS_FFMPEG_3_4_API (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57,107,100))
|
||||
#define HAS_FFMPEG_4_API (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,18,100))
|
||||
|
||||
#if !HAS_FFMPEG_3_4_API
|
||||
#error "FFmpeg 3.4 or greater is required!"
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Declarations
|
||||
@ -2557,7 +2555,9 @@ int init_filters(AVCodecContext * dec_ctx,CuvidDecoder * decoder,AVFrame *frame)
|
||||
AVFilterInOut *inputs = avfilter_inout_alloc();
|
||||
AVBufferSrcParameters *src_params;
|
||||
|
||||
#ifdef YADIF
|
||||
enum AVPixelFormat pix_fmts[] = { format, AV_PIX_FMT_NONE };
|
||||
#endif
|
||||
|
||||
if (decoder->filter_graph)
|
||||
avfilter_graph_free(&decoder->filter_graph);
|
||||
@ -3163,7 +3163,6 @@ static void CuvidRenderFrame(CuvidDecoder * decoder,
|
||||
}
|
||||
|
||||
// update aspect ratio changes
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,60,100)
|
||||
if (decoder->InputWidth && decoder->InputHeight
|
||||
&& av_cmp_q(decoder->InputAspect, frame->sample_aspect_ratio)) {
|
||||
Debug(3, "video/vdpau: aspect ratio changed\n");
|
||||
@ -3172,15 +3171,6 @@ static void CuvidRenderFrame(CuvidDecoder * decoder,
|
||||
//printf("new aspect %d:%d\n",frame->sample_aspect_ratio.num,frame->sample_aspect_ratio.den);
|
||||
CuvidUpdateOutput(decoder);
|
||||
}
|
||||
#else
|
||||
if (decoder->InputWidth && decoder->InputHeight
|
||||
&& av_cmp_q(decoder->InputAspect, video_ctx->sample_aspect_ratio)) {
|
||||
Debug(3, "video/vdpau: aspect ratio changed\n");
|
||||
|
||||
decoder->InputAspect = video_ctx->sample_aspect_ratio;
|
||||
CuvidUpdateOutput(decoder);
|
||||
}
|
||||
#endif
|
||||
|
||||
color = frame->colorspace;
|
||||
if (color == AVCOL_SPC_UNSPECIFIED) // if unknown
|
||||
|
2
video.h
2
video.h
@ -55,7 +55,6 @@ extern VideoHwDecoder *VideoNewHwDecoder(VideoStream *);
|
||||
/// Deallocate video hardware decoder.
|
||||
extern void VideoDelHwDecoder(VideoHwDecoder *);
|
||||
|
||||
#ifdef LIBAVCODEC_VERSION
|
||||
/// Get and allocate a video hardware surface.
|
||||
extern unsigned VideoGetSurface(VideoHwDecoder *, const AVCodecContext *);
|
||||
|
||||
@ -78,7 +77,6 @@ extern void *VideoGetHwAccelContext(VideoHwDecoder *);
|
||||
extern void VideoDrawRenderState(VideoHwDecoder *,
|
||||
struct vdpau_render_state *);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENGLOSD
|
||||
/// Set callback funktion to notify VDR about VideoEvents
|
||||
|
Loading…
Reference in New Issue
Block a user