1
0
mirror of https://github.com/jojo61/vdr-plugin-softhdcuvid.git synced 2023-10-10 13:37:41 +02:00
vdr-plugin-softhdcuvid/codec.h

173 lines
4.9 KiB
C
Raw Normal View History

2018-08-19 11:45:46 +02:00
///
/// @file codec.h @brief Codec module headerfile
2018-08-19 11:45:46 +02:00
///
/// Copyright (c) 2009 - 2013, 2015 by Johns. All Rights Reserved.
2018-08-19 11:45:46 +02:00
///
/// Contributor(s):
2018-08-19 11:45:46 +02:00
///
/// License: AGPLv3
2018-08-19 11:45:46 +02:00
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
2018-08-19 11:45:46 +02:00
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU Affero General Public License for more details.
2018-08-19 11:45:46 +02:00
///
/// $Id: bdb4d18dbe371e497d039e45faa7c134b019860a $
2018-08-19 11:45:46 +02:00
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup Codec
/// @{
//----------------------------------------------------------------------------
// Defines
2018-08-19 11:45:46 +02:00
//----------------------------------------------------------------------------
#define CodecPCM 0x01 ///< PCM bit mask
#define CodecMPA 0x02 ///< MPA bit mask (planned)
#define CodecAC3 0x04 ///< AC-3 bit mask
#define CodecEAC3 0x08 ///< E-AC-3 bit mask
#define CodecDTS 0x10 ///< DTS bit mask (planned)
2018-08-19 11:45:46 +02:00
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
enum HWAccelID {
HWACCEL_NONE = 0,
HWACCEL_AUTO,
HWACCEL_VDPAU,
HWACCEL_DXVA2,
HWACCEL_VDA,
HWACCEL_VIDEOTOOLBOX,
HWACCEL_QSV,
HWACCEL_VAAPI,
HWACCEL_CUVID,
2018-08-19 11:45:46 +02:00
};
2018-09-06 16:21:25 +02:00
extern AVBufferRef *hw_device_ctx;
2018-08-19 11:45:46 +02:00
///
/// Video decoder structure.
2018-08-19 11:45:46 +02:00
///
struct _video_decoder_ {
VideoHwDecoder *HwDecoder; ///< video hardware decoder
int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec
AVCodecContext *VideoCtx; ///< video codec context
2019-10-28 21:43:37 +01:00
// #ifdef FFMPEG_WORKAROUND_ARTIFACTS
int FirstKeyFrame; ///< flag first frame
2019-10-28 21:43:37 +01:00
// #endif
// AVFrame *Frame; ///< decoded video frame
int filter; // flag for deint filter
/* hwaccel options */
enum HWAccelID hwaccel_id;
char *hwaccel_device;
enum AVPixelFormat hwaccel_output_format;
/* hwaccel context */
enum HWAccelID active_hwaccel_id;
void *hwaccel_ctx;
void (*hwaccel_uninit)(AVCodecContext *s);
int (*hwaccel_get_buffer)(AVCodecContext *s, AVFrame *frame, int flags);
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
enum AVPixelFormat hwaccel_pix_fmt;
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
AVBufferRef *hw_frames_ctx;
void *hwdec_priv;
// For HDR side-data caching
double cached_hdr_peak;
// From VO
struct mp_hwdec_devices *hwdec_devs;
2018-08-19 11:45:46 +02:00
};
//----------------------------------------------------------------------------
// Typedefs
2018-08-19 11:45:46 +02:00
//----------------------------------------------------------------------------
2019-10-28 21:43:37 +01:00
/// Video decoder typedef.
2018-08-19 11:45:46 +02:00
typedef struct _video_decoder_ VideoDecoder;
2019-10-28 21:43:37 +01:00
/// Audio decoder typedef.
2018-08-19 11:45:46 +02:00
typedef struct _audio_decoder_ AudioDecoder;
2018-09-28 17:02:56 +02:00
//----------------------------------------------------------------------------
// Variables
//----------------------------------------------------------------------------
2019-10-28 21:43:37 +01:00
/// x11 display name
2018-09-28 17:02:56 +02:00
extern const char *X11DisplayName;
2019-10-28 21:43:37 +01:00
/// HW device context from video module
2018-09-28 17:02:56 +02:00
extern AVBufferRef *HwDeviceContext;
2018-08-19 11:45:46 +02:00
//----------------------------------------------------------------------------
// Variables
2018-08-19 11:45:46 +02:00
//----------------------------------------------------------------------------
2019-10-28 21:43:37 +01:00
/// Flag prefer fast xhannel switch
2018-08-19 11:45:46 +02:00
extern char CodecUsePossibleDefectFrames;
//----------------------------------------------------------------------------
// Prototypes
2018-08-19 11:45:46 +02:00
//----------------------------------------------------------------------------
2019-10-28 21:43:37 +01:00
/// Allocate a new video decoder context.
2018-08-19 11:45:46 +02:00
extern VideoDecoder *CodecVideoNewDecoder(VideoHwDecoder *);
2019-10-28 21:43:37 +01:00
/// Deallocate a video decoder context.
2018-08-19 11:45:46 +02:00
extern void CodecVideoDelDecoder(VideoDecoder *);
2019-10-28 21:43:37 +01:00
/// Open video codec.
2018-08-19 11:45:46 +02:00
extern void CodecVideoOpen(VideoDecoder *, int);
2019-10-28 21:43:37 +01:00
/// Close video codec.
2018-08-19 11:45:46 +02:00
extern void CodecVideoClose(VideoDecoder *);
2019-10-28 21:43:37 +01:00
/// Decode a video packet.
2018-08-19 11:45:46 +02:00
extern void CodecVideoDecode(VideoDecoder *, const AVPacket *);
2019-10-28 21:43:37 +01:00
/// Flush video buffers.
2018-08-19 11:45:46 +02:00
extern void CodecVideoFlushBuffers(VideoDecoder *);
2019-10-28 21:43:37 +01:00
/// Allocate a new audio decoder context.
2018-08-19 11:45:46 +02:00
extern AudioDecoder *CodecAudioNewDecoder(void);
2019-10-28 21:43:37 +01:00
/// Deallocate an audio decoder context.
2018-08-19 11:45:46 +02:00
extern void CodecAudioDelDecoder(AudioDecoder *);
2019-10-28 21:43:37 +01:00
/// Open audio codec.
2018-08-19 11:45:46 +02:00
extern void CodecAudioOpen(AudioDecoder *, int);
2019-10-28 21:43:37 +01:00
/// Close audio codec.
2018-08-19 11:45:46 +02:00
extern void CodecAudioClose(AudioDecoder *);
2019-10-28 21:43:37 +01:00
/// Set audio drift correction.
2018-08-19 11:45:46 +02:00
extern void CodecSetAudioDrift(int);
2019-10-28 21:43:37 +01:00
/// Set audio pass-through.
2018-08-19 11:45:46 +02:00
extern void CodecSetAudioPassthrough(int);
2019-10-28 21:43:37 +01:00
/// Set audio downmix.
2018-08-19 11:45:46 +02:00
extern void CodecSetAudioDownmix(int);
2019-10-28 21:43:37 +01:00
/// Decode an audio packet.
2018-08-19 11:45:46 +02:00
extern void CodecAudioDecode(AudioDecoder *, const AVPacket *);
2019-10-28 21:43:37 +01:00
/// Flush audio buffers.
2018-08-19 11:45:46 +02:00
extern void CodecAudioFlushBuffers(AudioDecoder *);
2019-10-28 21:43:37 +01:00
/// Setup and initialize codec module.
2018-08-19 11:45:46 +02:00
extern void CodecInit(void);
2019-10-28 21:43:37 +01:00
/// Cleanup and exit codec module.
2018-08-19 11:45:46 +02:00
extern void CodecExit(void);
/// @}