FFmpeg
Data Structures | Macros | Functions | Variables
hwcontext_amf.c File Reference
#include "buffer.h"
#include "common.h"
#include "hwcontext.h"
#include "hwcontext_amf.h"
#include "hwcontext_internal.h"
#include "hwcontext_amf_internal.h"
#include "mem.h"
#include "pixdesc.h"
#include "pixfmt.h"
#include "imgutils.h"
#include "libavutil/avassert.h"
#include <AMF/core/Surface.h>
#include <AMF/core/Trace.h>
#include <dlfcn.h>

Go to the source code of this file.

Data Structures

struct  AmfTraceWriter
 
struct  AMFFramesContext
 We still need AVHWFramesContext to utilize our hardware memory otherwise, we will receive the error "HW format requires hw_frames_ctx to be non-NULL". More...
 
struct  AVAMFFormatMap
 

Macros

#define FFMPEG_AMF_WRITER_ID   L"ffmpeg_amf"
 

Functions

static void AMF_CDECL_CALL AMFTraceWriter_Write (AMFTraceWriter *pThis, const wchar_t *scope, const wchar_t *message)
 
static void AMF_CDECL_CALL AMFTraceWriter_Flush (AMFTraceWriter *pThis)
 
static AmfTraceWriteramf_writer_alloc (void *avctx)
 
static void amf_writer_free (void *opaque)
 
enum AMF_SURFACE_FORMAT av_av_to_amf_format (enum AVPixelFormat fmt)
 
enum AVPixelFormat av_amf_to_av_format (enum AMF_SURFACE_FORMAT fmt)
 
static int amf_frames_get_constraints (AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
 
static void amf_dummy_free (void *opaque, uint8_t *data)
 
static AVBufferRefamf_pool_alloc (void *opaque, size_t size)
 
static int amf_frames_init (AVHWFramesContext *ctx)
 
static int amf_get_buffer (AVHWFramesContext *ctx, AVFrame *frame)
 
static int amf_transfer_get_formats (AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
 
static void amf_free_amfsurface (void *opaque, uint8_t *data)
 
static int amf_transfer_data_to (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
 
static int amf_transfer_data_from (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
 
static void amf_device_uninit (AVHWDeviceContext *device_ctx)
 
static int amf_device_init (AVHWDeviceContext *ctx)
 
static int amf_load_library (AVAMFDeviceContext *amf_ctx, void *avcl)
 
static int amf_device_create (AVHWDeviceContext *device_ctx, const char *device, AVDictionary *opts, int flags)
 
static int amf_device_derive (AVHWDeviceContext *device_ctx, AVHWDeviceContext *child_device_ctx, AVDictionary *opts, int flags)
 

Variables

const FormatMap format_map []
 
static enum AVPixelFormat supported_formats []
 
static enum AVPixelFormat supported_transfer_formats []
 
const HWContextType ff_hwcontext_type_amf
 

Macro Definition Documentation

◆ FFMPEG_AMF_WRITER_ID

#define FFMPEG_AMF_WRITER_ID   L"ffmpeg_amf"

Definition at line 47 of file hwcontext_amf.c.

Function Documentation

◆ AMFTraceWriter_Write()

static void AMF_CDECL_CALL AMFTraceWriter_Write ( AMFTraceWriter *  pThis,
const wchar_t *  scope,
const wchar_t *  message 
)
static

Definition at line 56 of file hwcontext_amf.c.

Referenced by amf_writer_alloc().

◆ AMFTraceWriter_Flush()

static void AMF_CDECL_CALL AMFTraceWriter_Flush ( AMFTraceWriter *  pThis)
static

Definition at line 63 of file hwcontext_amf.c.

Referenced by amf_writer_alloc().

◆ amf_writer_alloc()

static AmfTraceWriter* amf_writer_alloc ( void *  avctx)
static

Definition at line 67 of file hwcontext_amf.c.

Referenced by amf_device_create().

◆ amf_writer_free()

static void amf_writer_free ( void *  opaque)
static

Definition at line 81 of file hwcontext_amf.c.

Referenced by amf_device_uninit().

◆ av_av_to_amf_format()

enum AMF_SURFACE_FORMAT av_av_to_amf_format ( enum AVPixelFormat  fmt)

◆ av_amf_to_av_format()

enum AVPixelFormat av_amf_to_av_format ( enum AMF_SURFACE_FORMAT  fmt)

Definition at line 127 of file hwcontext_amf.c.

Referenced by amf_amfsurface_to_avframe(), amf_decode_frame(), and amf_decode_init().

◆ amf_frames_get_constraints()

static int amf_frames_get_constraints ( AVHWDeviceContext ctx,
const void *  hwconfig,
AVHWFramesConstraints constraints 
)
static

Definition at line 161 of file hwcontext_amf.c.

◆ amf_dummy_free()

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

Definition at line 186 of file hwcontext_amf.c.

Referenced by amf_pool_alloc().

◆ amf_pool_alloc()

static AVBufferRef* amf_pool_alloc ( void *  opaque,
size_t  size 
)
static

Definition at line 191 of file hwcontext_amf.c.

Referenced by amf_frames_init().

◆ amf_frames_init()

static int amf_frames_init ( AVHWFramesContext ctx)
static

Definition at line 204 of file hwcontext_amf.c.

◆ amf_get_buffer()

static int amf_get_buffer ( AVHWFramesContext ctx,
AVFrame frame 
)
static

Definition at line 226 of file hwcontext_amf.c.

◆ amf_transfer_get_formats()

static int amf_transfer_get_formats ( AVHWFramesContext ctx,
enum AVHWFrameTransferDirection  dir,
enum AVPixelFormat **  formats 
)
static

Definition at line 239 of file hwcontext_amf.c.

◆ amf_free_amfsurface()

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

Definition at line 257 of file hwcontext_amf.c.

Referenced by amf_transfer_data_to().

◆ amf_transfer_data_to()

static int amf_transfer_data_to ( AVHWFramesContext ctx,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 265 of file hwcontext_amf.c.

◆ amf_transfer_data_from()

static int amf_transfer_data_from ( AVHWFramesContext ctx,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 307 of file hwcontext_amf.c.

◆ amf_device_uninit()

static void amf_device_uninit ( AVHWDeviceContext device_ctx)
static

Definition at line 339 of file hwcontext_amf.c.

Referenced by amf_device_create().

◆ amf_device_init()

static int amf_device_init ( AVHWDeviceContext ctx)
static

Definition at line 369 of file hwcontext_amf.c.

◆ amf_load_library()

static int amf_load_library ( AVAMFDeviceContext amf_ctx,
void *  avcl 
)
static

Definition at line 406 of file hwcontext_amf.c.

Referenced by amf_device_create().

◆ amf_device_create()

static int amf_device_create ( AVHWDeviceContext device_ctx,
const char *  device,
AVDictionary opts,
int  flags 
)
static

Definition at line 429 of file hwcontext_amf.c.

Referenced by amf_device_derive().

◆ amf_device_derive()

static int amf_device_derive ( AVHWDeviceContext device_ctx,
AVHWDeviceContext child_device_ctx,
AVDictionary opts,
int  flags 
)
static

Definition at line 554 of file hwcontext_amf.c.

Variable Documentation

◆ format_map

const FormatMap format_map[]
Initial value:
=
{
{ AV_PIX_FMT_NONE, AMF_SURFACE_UNKNOWN },
{ AV_PIX_FMT_NV12, AMF_SURFACE_NV12 },
{ AV_PIX_FMT_BGR0, AMF_SURFACE_BGRA },
{ AV_PIX_FMT_RGB0, AMF_SURFACE_RGBA },
{ AV_PIX_FMT_BGRA, AMF_SURFACE_BGRA },
{ AV_PIX_FMT_ARGB, AMF_SURFACE_ARGB },
{ AV_PIX_FMT_RGBA, AMF_SURFACE_RGBA },
{ AV_PIX_FMT_GRAY8, AMF_SURFACE_GRAY8 },
{ AV_PIX_FMT_YUV420P, AMF_SURFACE_YUV420P },
{ AV_PIX_FMT_YUYV422, AMF_SURFACE_YUY2 },
{ AV_PIX_FMT_P010, AMF_SURFACE_P010 },
}

Definition at line 101 of file hwcontext_amf.c.

Referenced by av_amf_to_av_format(), and av_av_to_amf_format().

◆ supported_formats

enum AVPixelFormat supported_formats[]
static

◆ supported_transfer_formats

enum AVPixelFormat supported_transfer_formats[]
static

◆ ff_hwcontext_type_amf

const HWContextType ff_hwcontext_type_amf
Initial value:
= {
.name = "AMF",
.device_hwctx_size = sizeof(AVAMFDeviceContext),
.frames_hwctx_size = sizeof(AMFFramesContext),
.device_create = amf_device_create,
.device_derive = amf_device_derive,
.device_init = amf_device_init,
.device_uninit = amf_device_uninit,
.frames_get_constraints = amf_frames_get_constraints,
.frames_init = amf_frames_init,
.frames_get_buffer = amf_get_buffer,
.transfer_get_formats = amf_transfer_get_formats,
.transfer_data_to = amf_transfer_data_to,
.transfer_data_from = amf_transfer_data_from,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_AMF_SURFACE, AV_PIX_FMT_NONE },
}

Definition at line 593 of file hwcontext_amf.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
amf_device_create
static int amf_device_create(AVHWDeviceContext *device_ctx, const char *device, AVDictionary *opts, int flags)
Definition: hwcontext_amf.c:429
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
AV_PIX_FMT_AMF_SURFACE
@ AV_PIX_FMT_AMF_SURFACE
HW acceleration through AMF.
Definition: pixfmt.h:477
amf_transfer_get_formats
static int amf_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
Definition: hwcontext_amf.c:239
amf_frames_get_constraints
static int amf_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
Definition: hwcontext_amf.c:161
amf_device_init
static int amf_device_init(AVHWDeviceContext *ctx)
Definition: hwcontext_amf.c:369
AV_HWDEVICE_TYPE_AMF
@ AV_HWDEVICE_TYPE_AMF
Definition: hwcontext.h:41
amf_transfer_data_to
static int amf_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_amf.c:265
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
amf_get_buffer
static int amf_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
Definition: hwcontext_amf.c:226
AVAMFDeviceContext
This struct is allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_amf.h:33
amf_device_uninit
static void amf_device_uninit(AVHWDeviceContext *device_ctx)
Definition: hwcontext_amf.c:339
AMFFramesContext
We still need AVHWFramesContext to utilize our hardware memory otherwise, we will receive the error "...
Definition: hwcontext_amf.c:92
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
amf_frames_init
static int amf_frames_init(AVHWFramesContext *ctx)
Definition: hwcontext_amf.c:204
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
amf_transfer_data_from
static int amf_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_amf.c:307
amf_device_derive
static int amf_device_derive(AVHWDeviceContext *device_ctx, AVHWDeviceContext *child_device_ctx, AVDictionary *opts, int flags)
Definition: hwcontext_amf.c:554
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
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:568