FFmpeg
Macros | Functions | Variables
amfdec.c File Reference
#include "libavutil/hwcontext_amf.h"
#include "libavutil/hwcontext_amf_internal.h"
#include "amfdec.h"
#include "codec_internal.h"
#include "hwconfig.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/time.h"
#include "decode.h"
#include "libavutil/mastering_display_metadata.h"
#include <dlfcn.h>

Go to the source code of this file.

Macros

#define AMF_VIDEO_DECODER_OUTPUT_FORMAT   L"OutputDecodeFormat"
 
#define OFFSET(x)   offsetof(AMFDecoderContext, x)
 
#define VD   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
#define DEFINE_AMF_DECODER(x, X, bsf_name)
 

Functions

static void amf_free_amfsurface (void *opaque, uint8_t *data)
 
static int amf_legacy_driver_no_bitness_detect (AVAMFDeviceContext *amf_device_ctx)
 
static int amf_init_decoder (AVCodecContext *avctx)
 
static int amf_decode_close (AVCodecContext *avctx)
 
static int amf_init_frames_context (AVCodecContext *avctx, int sw_format, int new_width, int new_height)
 
static int amf_decode_init (AVCodecContext *avctx)
 
static AMF_RESULT amf_get_property_buffer (AMFData *object, const wchar_t *name, AMFBuffer **val)
 
static int amf_amfsurface_to_avframe (AVCodecContext *avctx, AMFSurface *surface, AVFrame *frame)
 
static AMF_RESULT amf_receive_frame (AVCodecContext *avctx, AVFrame *frame)
 
static AMF_RESULT amf_update_buffer_properties (AVCodecContext *avctx, AMFBuffer *buffer, const AVPacket *pkt)
 
static AMF_RESULT amf_buffer_from_packet (AVCodecContext *avctx, const AVPacket *pkt, AMFBuffer **buffer)
 
static int amf_decode_frame (AVCodecContext *avctx, struct AVFrame *frame)
 
static void amf_decode_flush (AVCodecContext *avctx)
 

Variables

enum AVPixelFormat amf_dec_pix_fmts []
 
static const AVCodecHWConfigInternal *const amf_hw_configs []
 
static const AVOption options []
 
static const AVClass amf_decode_class
 

Macro Definition Documentation

◆ AMF_VIDEO_DECODER_OUTPUT_FORMAT

#define AMF_VIDEO_DECODER_OUTPUT_FORMAT   L"OutputDecodeFormat"

Definition at line 44 of file amfdec.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(AMFDecoderContext, x)

Definition at line 659 of file amfdec.c.

◆ VD

Definition at line 660 of file amfdec.c.

◆ DEFINE_AMF_DECODER

#define DEFINE_AMF_DECODER (   x,
  X,
  bsf_name 
)
Value:
const FFCodec ff_##x##_amf_decoder = { \
.p.name = #x "_amf", \
CODEC_LONG_NAME(#X " AMD AMF video decoder"), \
.priv_data_size = sizeof(AMFDecoderContext), \
.p.type = AVMEDIA_TYPE_VIDEO, \
.p.id = AV_CODEC_ID_##X, \
.init = amf_decode_init, \
.flush = amf_decode_flush, \
.close = amf_decode_close, \
.bsfs = bsf_name, \
.p.priv_class = &amf_decode_class, \
.p.pix_fmts = amf_dec_pix_fmts, \
.hw_configs = amf_hw_configs, \
.p.wrapper_name = "amf", \
}; \

Definition at line 694 of file amfdec.c.

Function Documentation

◆ amf_free_amfsurface()

static void amf_free_amfsurface ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 67 of file amfdec.c.

Referenced by amf_amfsurface_to_avframe().

◆ amf_legacy_driver_no_bitness_detect()

static int amf_legacy_driver_no_bitness_detect ( AVAMFDeviceContext amf_device_ctx)
static

Definition at line 73 of file amfdec.c.

Referenced by amf_decode_init(), and amf_init_decoder().

◆ amf_init_decoder()

static int amf_init_decoder ( AVCodecContext avctx)
static

Color Range (Support for older Drivers)

Definition at line 82 of file amfdec.c.

Referenced by amf_decode_init().

◆ amf_decode_close()

static int amf_decode_close ( AVCodecContext avctx)
static

Definition at line 220 of file amfdec.c.

Referenced by amf_decode_init().

◆ amf_init_frames_context()

static int amf_init_frames_context ( AVCodecContext avctx,
int  sw_format,
int  new_width,
int  new_height 
)
static

Definition at line 236 of file amfdec.c.

Referenced by amf_decode_frame(), and amf_decode_init().

◆ amf_decode_init()

static int amf_decode_init ( AVCodecContext avctx)
static

Definition at line 266 of file amfdec.c.

◆ amf_get_property_buffer()

static AMF_RESULT amf_get_property_buffer ( AMFData *  object,
const wchar_t *  name,
AMFBuffer **  val 
)
static

Definition at line 336 of file amfdec.c.

Referenced by amf_amfsurface_to_avframe().

◆ amf_amfsurface_to_avframe()

static int amf_amfsurface_to_avframe ( AVCodecContext avctx,
AMFSurface *  surface,
AVFrame frame 
)
static

Definition at line 357 of file amfdec.c.

Referenced by amf_receive_frame().

◆ amf_receive_frame()

static AMF_RESULT amf_receive_frame ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 474 of file amfdec.c.

Referenced by amf_decode_frame().

◆ amf_update_buffer_properties()

static AMF_RESULT amf_update_buffer_properties ( AVCodecContext avctx,
AMFBuffer *  buffer,
const AVPacket pkt 
)
static

Definition at line 508 of file amfdec.c.

Referenced by amf_buffer_from_packet().

◆ amf_buffer_from_packet()

static AMF_RESULT amf_buffer_from_packet ( AVCodecContext avctx,
const AVPacket pkt,
AMFBuffer **  buffer 
)
static

Definition at line 522 of file amfdec.c.

Referenced by amf_decode_frame().

◆ amf_decode_frame()

static int amf_decode_frame ( AVCodecContext avctx,
struct AVFrame frame 
)
static

Definition at line 551 of file amfdec.c.

◆ amf_decode_flush()

static void amf_decode_flush ( AVCodecContext avctx)
static

Definition at line 653 of file amfdec.c.

Variable Documentation

◆ amf_dec_pix_fmts

enum AVPixelFormat amf_dec_pix_fmts[]

◆ amf_hw_configs

const AVCodecHWConfigInternal* const amf_hw_configs[]
static
Initial value:

Definition at line 54 of file amfdec.c.

◆ options

const AVOption options[]
static
Initial value:
= {
{ "decoder_mode", "Decoder mode", OFFSET(decoder_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, AMF_VIDEO_DECODER_MODE_LOW_LATENCY, VD, "decoder_mode" },
{ "regular", "DPB delay is based on number of reference frames + 1", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_DECODER_MODE_REGULAR }, 0, 0, VD, "decoder_mode" },
{ "compliant", "DPB delay is based on profile - up to 16", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_DECODER_MODE_COMPLIANT }, 0, 0, VD, "decoder_mode" },
{ "low_latency", "DPB delay is 0", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_DECODER_MODE_LOW_LATENCY }, 0, 0, VD, "decoder_mode" },
{ "timestamp_mode", "Timestamp mode", OFFSET(timestamp_mode), AV_OPT_TYPE_INT, { .i64 = AMF_TS_SORT }, -1, AMF_TS_DECODE, VD, "timestamp_mode" },
{ "presentation", "Preserve timestamps from input to output", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_TS_PRESENTATION }, 0, 0, VD, "timestamp_mode" },
{ "sort", "Resort PTS list", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_TS_SORT }, 0, 0, VD, "timestamp_mode" },
{ "decode", "Decode order", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_TS_DECODE }, 0, 0, VD, "timestamp_mode" },
{ "surface_pool_size", "Number of surfaces in the decode pool", OFFSET(surface_pool_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VD, NULL },
{ "dpb_size", "Minimum number of surfaces for reordering", OFFSET(dpb_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 32, VD, NULL },
{ "lowlatency", "Low latency", OFFSET(lowlatency), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VD, NULL },
{ "smart_access_video", "Smart Access Video", OFFSET(smart_access_video), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VD, NULL },
{ "skip_transfer_sav", "Skip transfer on another GPU when SAV enabled", OFFSET(skip_transfer_sav), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VD, NULL },
{ "copy_output", "Copy Output", OFFSET(copy_output), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VD, NULL },
{ NULL }
}

Definition at line 662 of file amfdec.c.

◆ amf_decode_class

const AVClass amf_decode_class
static
Initial value:
= {
.class_name = "amf",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 687 of file amfdec.c.

AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
amf_decode_frame
static int amf_decode_frame(AVCodecContext *avctx, struct AVFrame *frame)
Definition: amfdec.c:551
amf_decode_init
static int amf_decode_init(AVCodecContext *avctx)
Definition: amfdec.c:266
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:35
FFCodec
Definition: codec_internal.h:127
AV_PIX_FMT_AMF_SURFACE
@ AV_PIX_FMT_AMF_SURFACE
HW acceleration through AMF.
Definition: pixfmt.h:477
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
The codec supports this format via the hw_frames_ctx interface.
Definition: codec.h:326
AV_HWDEVICE_TYPE_AMF
@ AV_HWDEVICE_TYPE_AMF
Definition: hwcontext.h:41
dpb_size
int dpb_size
Definition: h264_levels.c:111
AMFDecoderContext
AMF decoder context.
Definition: amfdec.h:39
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
OFFSET
#define OFFSET(x)
Definition: amfdec.c:659
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
Definition: codec.h:313
AV_PIX_FMT_P012
#define AV_PIX_FMT_P012
Definition: pixfmt.h:569
X
@ X
Definition: vf_addroi.c:27
AVCodecHWConfigInternal
Definition: hwconfig.h:25
amf_dec_pix_fmts
enum AVPixelFormat amf_dec_pix_fmts[]
Definition: amfdec.c:46
VD
#define VD
Definition: amfdec.c:660
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
amf_decode_flush
static void amf_decode_flush(AVCodecContext *avctx)
Definition: amfdec.c:653
amf_hw_configs
static const AVCodecHWConfigInternal *const amf_hw_configs[]
Definition: amfdec.c:54
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:96
amf_decode_class
static const AVClass amf_decode_class
Definition: amfdec.c:687
FF_CODEC_RECEIVE_FRAME_CB
#define FF_CODEC_RECEIVE_FRAME_CB(func)
Definition: codec_internal.h:317
copy_output
static int copy_output(SANMVideoContext *ctx, SANMFrameHeader *hdr)
Definition: sanm.c:1696
amf_decode_close
static int amf_decode_close(AVCodecContext *avctx)
Definition: amfdec.c:220
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:568
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_CODEC_CAP_AVOID_PROBING
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: codec.h:138
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
options
static const AVOption options[]
Definition: amfdec.c:662