Go to the documentation of this file.
22 #include <mfx/mfxvideo.h>
47 #define QSV_VERSION_ATLEAST(MAJOR, MINOR) \
48 (MFX_VERSION_MAJOR > (MAJOR) || \
49 MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
102 static const struct {
113 #if QSV_VERSION_ATLEAST(1, 27)
141 if (err == MFX_ERR_NONE) {
150 "from the session\n");
153 err = MFXQueryIMPL(hwctx->
session, &
s->impl);
154 if (err == MFX_ERR_NONE)
155 err = MFXQueryVersion(hwctx->
session, &
s->ver);
156 if (err != MFX_ERR_NONE) {
168 if (
s->session_download) {
169 MFXVideoVPP_Close(
s->session_download);
170 MFXClose(
s->session_download);
172 s->session_download =
NULL;
173 s->session_download_init = 0;
175 if (
s->session_upload) {
176 MFXVideoVPP_Close(
s->session_upload);
177 MFXClose(
s->session_upload);
179 s->session_upload =
NULL;
180 s->session_upload_init = 0;
204 s->nb_surfaces_used++;
226 if (!device_priv->
handle) {
228 "Cannot create a non-opaque internal surface pool without "
229 "a hardware handle\n");
234 if (!child_device_ref)
241 child_device_hwctx->
display = (VADisplay)device_priv->
handle;
247 child_device_hwctx->
devmgr = (IDirect3DDeviceManager9*)device_priv->
handle;
258 if (!child_frames_ref) {
273 if (hwctx->
frame_type & MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET)
274 child_frames_hwctx->
surface_type = DXVA2_VideoProcessorRenderTarget;
276 child_frames_hwctx->
surface_type = DXVA2_VideoDecoderRenderTarget;
289 for (
i = 0;
i <
ctx->initial_pool_size;
i++)
290 s->surfaces_internal[
i].Data.MemId = child_frames_hwctx->
surface_ids +
i;
291 hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
297 for (
i = 0;
i <
ctx->initial_pool_size;
i++)
298 s->surfaces_internal[
i].Data.MemId = (mfxMemId)child_frames_hwctx->
surfaces[
i];
299 if (child_frames_hwctx->
surface_type == DXVA2_VideoProcessorRenderTarget)
300 hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET;
302 hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
306 s->child_frames_ref = child_frames_ref;
307 child_frames_ref =
NULL;
328 surf->Info.BitDepthLuma =
desc->comp[0].depth;
329 surf->Info.BitDepthChroma =
desc->comp[0].depth;
330 surf->Info.Shift =
desc->comp[0].depth > 8;
332 if (
desc->log2_chroma_w &&
desc->log2_chroma_h)
333 surf->Info.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
334 else if (
desc->log2_chroma_w)
335 surf->Info.ChromaFormat = MFX_CHROMAFORMAT_YUV422;
337 surf->Info.ChromaFormat = MFX_CHROMAFORMAT_YUV444;
339 surf->Info.FourCC =
fourcc;
341 surf->Info.CropW =
ctx->width;
343 surf->Info.CropH =
ctx->height;
344 surf->Info.FrameRateExtN = 25;
345 surf->Info.FrameRateExtD = 1;
346 surf->Info.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
358 if (
ctx->initial_pool_size <= 0) {
364 sizeof(*
s->surfaces_internal));
365 if (!
s->surfaces_internal)
368 for (
i = 0;
i <
ctx->initial_pool_size;
i++) {
374 if (!(frames_hwctx->
frame_type & MFX_MEMTYPE_OPAQUE_FRAME)) {
385 frames_hwctx->
surfaces =
s->surfaces_internal;
391 static mfxStatus
frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
392 mfxFrameAllocResponse *resp)
397 mfxFrameInfo *
i = &req->Info;
398 mfxFrameInfo *i1 = &hwctx->
surfaces[0].Info;
400 if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET) ||
401 !(req->Type & (MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_FROM_VPPOUT)) ||
402 !(req->Type & MFX_MEMTYPE_EXTERNAL_FRAME))
403 return MFX_ERR_UNSUPPORTED;
404 if (
i->Width > i1->Width ||
i->Height > i1->Height ||
405 i->FourCC != i1->FourCC ||
i->ChromaFormat != i1->ChromaFormat) {
407 "allocation request: %dx%d %d %d vs %dx%d %d %d\n",
408 i->Width,
i->Height,
i->FourCC,
i->ChromaFormat,
409 i1->Width, i1->Height, i1->FourCC, i1->ChromaFormat);
410 return MFX_ERR_UNSUPPORTED;
413 resp->mids =
s->mem_ids;
419 static mfxStatus
frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
424 static mfxStatus
frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
426 return MFX_ERR_UNSUPPORTED;
429 static mfxStatus
frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
431 return MFX_ERR_UNSUPPORTED;
441 mfxSession *session,
int upload)
446 int opaque = !!(frames_hwctx->
frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
448 mfxFrameAllocator frame_allocator = {
460 err = MFXInit(device_priv->
impl, &device_priv->
ver, session);
461 if (err != MFX_ERR_NONE) {
466 if (device_priv->
handle) {
467 err = MFXVideoCORE_SetHandle(*session, device_priv->
handle_type,
469 if (err != MFX_ERR_NONE)
474 err = MFXVideoCORE_SetFrameAllocator(*session, &frame_allocator);
475 if (err != MFX_ERR_NONE)
479 memset(&par, 0,
sizeof(par));
482 par.ExtParam =
s->ext_buffers;
484 par.IOPattern = upload ? MFX_IOPATTERN_OUT_OPAQUE_MEMORY :
485 MFX_IOPATTERN_IN_OPAQUE_MEMORY;
487 par.IOPattern = upload ? MFX_IOPATTERN_OUT_VIDEO_MEMORY :
488 MFX_IOPATTERN_IN_VIDEO_MEMORY;
491 par.IOPattern |= upload ? MFX_IOPATTERN_IN_SYSTEM_MEMORY :
492 MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
495 par.vpp.In = frames_hwctx->
surfaces[0].Info;
501 par.vpp.In.FrameRateExtN = 25;
502 par.vpp.In.FrameRateExtD = 1;
503 par.vpp.Out = par.vpp.In;
505 err = MFXVideoVPP_Init(*session, &par);
506 if (err != MFX_ERR_NONE) {
508 "Surface upload/download will not be possible\n");
521 int opaque = !!(frames_hwctx->
frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
542 sizeof(*
s->surface_ptrs));
543 if (!
s->surface_ptrs)
549 s->opaque_alloc.In.Surfaces =
s->surface_ptrs;
550 s->opaque_alloc.In.NumSurface = frames_hwctx->
nb_surfaces;
551 s->opaque_alloc.In.Type = frames_hwctx->
frame_type;
553 s->opaque_alloc.Out =
s->opaque_alloc.In;
555 s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
556 s->opaque_alloc.Header.BufferSz =
sizeof(
s->opaque_alloc);
558 s->ext_buffers[0] = (mfxExtBuffer*)&
s->opaque_alloc;
565 s->mem_ids[
i] = frames_hwctx->
surfaces[
i].Data.MemId;
568 s->session_download =
NULL;
569 s->session_upload =
NULL;
571 s->session_download_init = 0;
572 s->session_upload_init = 0;
606 fmts[0] =
ctx->sw_format;
631 *(VASurfaceID*)src_hwctx->
surfaces[
i].Data.MemId;
646 (IDirect3DSurface9*)src_hwctx->
surfaces[
i].Data.MemId;
648 if (src_hwctx->
frame_type == MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
649 dst_hwctx->
surface_type = DXVA2_VideoDecoderRenderTarget;
651 dst_hwctx->
surface_type = DXVA2_VideoProcessorRenderTarget;
666 mfxFrameSurface1 *surf = (mfxFrameSurface1*)
src->data[3];
673 if (!
s->child_frames_ref)
677 switch (child_frames_ctx->device_ctx->type) {
680 child_data = (
uint8_t*)(intptr_t)*(VASurfaceID*)surf->Data.MemId;
685 child_data = surf->Data.MemId;
692 if (dst->
format == child_frames_ctx->format) {
700 dst->
data[3] = child_data;
720 dummy->format = child_frames_ctx->format;
723 dummy->data[3] = child_data;
738 int download = !!
src->hw_frames_ctx;
739 mfxFrameSurface1 *surf = (mfxFrameSurface1*)(download ?
src->data[3] : dst->
data[3]);
751 dummy->buf[0] = download ?
src->buf[0] : dst->
buf[0];
752 dummy->data[3] = surf->Data.MemId;
753 dummy->hw_frames_ctx =
s->child_frames_ref;
769 switch (
frame->format) {
772 surface->Data.Y =
frame->data[0];
773 surface->Data.UV =
frame->data[1];
777 surface->Data.Y =
frame->data[0];
778 surface->Data.U =
frame->data[1];
779 surface->Data.V =
frame->data[2];
783 surface->Data.B =
frame->data[0];
784 surface->Data.G =
frame->data[0] + 1;
785 surface->Data.R =
frame->data[0] + 2;
786 surface->Data.A =
frame->data[0] + 3;
790 surface->Data.Y =
frame->data[0];
791 surface->Data.U =
frame->data[0] + 1;
792 surface->Data.V =
frame->data[0] + 3;
796 surface->Data.Y16 = (mfxU16 *)
frame->data[0];
797 surface->Data.U16 = (mfxU16 *)
frame->data[0] + 1;
798 surface->Data.V16 = (mfxU16 *)
frame->data[0] + 3;
802 return MFX_ERR_UNSUPPORTED;
804 surface->Data.Pitch =
frame->linesize[0];
805 surface->Data.TimeStamp =
frame->pts;
814 mfxFrameSurface1
out = {{ 0 }};
815 mfxFrameSurface1 *
in = (mfxFrameSurface1*)
src->data[3];
817 mfxSyncPoint sync =
NULL;
821 while (!
s->session_download_init && !
s->session_download && !
ret) {
823 if (pthread_mutex_trylock(&
s->session_lock) == 0) {
825 if (!
s->session_download_init) {
827 if (
s->session_download)
828 s->session_download_init = 1;
835 while (!
s->session_download_init && !
s->session_download) {
846 if (!
s->session_download) {
847 if (
s->child_frames_ref)
858 err = MFXVideoVPP_RunFrameVPPAsync(
s->session_download,
in, &
out,
NULL, &sync);
859 if (err == MFX_WRN_DEVICE_BUSY)
861 }
while (err == MFX_WRN_DEVICE_BUSY);
863 if (err < 0 || !sync) {
869 err = MFXVideoCORE_SyncOperation(
s->session_download, sync, 1000);
870 }
while (err == MFX_WRN_IN_EXECUTION);
883 mfxFrameSurface1
in = {{ 0 }};
884 mfxFrameSurface1 *
out = (mfxFrameSurface1*)dst->
data[3];
886 mfxSyncPoint sync =
NULL;
895 while (!
s->session_upload_init && !
s->session_upload && !
ret) {
897 if (pthread_mutex_trylock(&
s->session_lock) == 0) {
899 if (!
s->session_upload_init) {
901 if (
s->session_upload)
902 s->session_upload_init = 1;
909 while (!
s->session_upload_init && !
s->session_upload) {
919 if (
src->height & 15 ||
src->linesize[0] & 15) {
921 memset(&tmp_frame, 0,
sizeof(tmp_frame));
922 tmp_frame.format =
src->format;
936 src_frame = realigned ? &tmp_frame :
src;
938 if (!
s->session_upload) {
939 if (
s->child_frames_ref)
950 err = MFXVideoVPP_RunFrameVPPAsync(
s->session_upload, &
in,
out,
NULL, &sync);
951 if (err == MFX_WRN_DEVICE_BUSY)
953 }
while (err == MFX_WRN_DEVICE_BUSY);
955 if (err < 0 || !sync) {
961 err = MFXVideoCORE_SyncOperation(
s->session_upload, sync, 1000);
962 }
while (err == MFX_WRN_IN_EXECUTION);
987 sizeof(*
s->surfaces_internal));
988 if (!
s->surfaces_internal)
995 dst_hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
1004 sizeof(*
s->surfaces_internal));
1005 if (!
s->surfaces_internal)
1009 s->surfaces_internal[
i].Data.MemId = (mfxMemId)src_hwctx->
surfaces[
i];
1012 if (src_hwctx->
surface_type == DXVA2_VideoProcessorRenderTarget)
1013 dst_hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET;
1015 dst_hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
1023 dst_hwctx->
surfaces =
s->surfaces_internal;
1036 if (*(VASurfaceID*)hwctx->
surfaces[
i].Data.MemId ==
1037 (VASurfaceID)(uintptr_t)
src->data[3])
1041 if ((IDirect3DSurface9*)hwctx->
surfaces[
i].Data.MemId ==
1042 (IDirect3DSurface9*)(uintptr_t)
src->data[3])
1048 "is not in the mapped frames context.\n");
1065 const void *hwconfig,
1103 static const struct {
1107 {
"auto", MFX_IMPL_AUTO },
1108 {
"sw", MFX_IMPL_SOFTWARE },
1109 {
"hw", MFX_IMPL_HARDWARE },
1110 {
"auto_any", MFX_IMPL_AUTO_ANY },
1111 {
"hw_any", MFX_IMPL_HARDWARE_ANY },
1112 {
"hw2", MFX_IMPL_HARDWARE2 },
1113 {
"hw3", MFX_IMPL_HARDWARE3 },
1114 {
"hw4", MFX_IMPL_HARDWARE4 },
1117 mfxIMPL impl = MFX_IMPL_AUTO_ANY;
1122 if (!strcmp(device, impl_map[
i].
name)) {
1123 impl = impl_map[
i].impl;
1127 impl = strtol(device,
NULL, 0);
1134 mfxIMPL implementation,
1140 mfxVersion ver = { { 3, 1 } };
1146 switch (child_device_ctx->
type) {
1152 handle = (mfxHDL)child_device_hwctx->
display;
1161 handle = (mfxHDL)child_device_hwctx->
devmgr;
1170 err = MFXInit(implementation, &ver, &hwctx->
session);
1171 if (err != MFX_ERR_NONE) {
1178 err = MFXQueryVersion(hwctx->
session, &ver);
1179 if (err != MFX_ERR_NONE) {
1186 "Initialize MFX session: API version is %d.%d, implementation version is %d.%d\n",
1187 MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor);
1191 err = MFXInit(implementation, &ver, &hwctx->
session);
1192 if (err != MFX_ERR_NONE) {
1194 "Error initializing an MFX session: %d.\n", err);
1200 if (err != MFX_ERR_NONE) {
1220 child_device_ctx,
flags);
1239 ctx->user_opaque = priv;
1244 child_device_opts =
NULL;
1252 av_dict_set(&child_device_opts,
"kernel_driver",
"i915", 0);
1253 av_dict_set(&child_device_opts,
"driver",
"iHD", 0);
1254 }
else if (CONFIG_DXVA2)
1262 e ? e->
value :
NULL, child_device_opts, 0);
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
static int qsv_transfer_data_child(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
int frame_type
A combination of MFX_MEMTYPE_* describing the frame pool.
AVPixelFormat
Pixel format.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
AVBufferRef * child_frames_ref
static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t * data
The data buffer.
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
static int qsv_map_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
static uint32_t qsv_fourcc_from_pix_fmt(enum AVPixelFormat pix_fmt)
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
static const struct @305 supported_pixel_formats[]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
This structure describes decoded (raw) audio or video data.
This struct is allocated as AVHWDeviceContext.hwctx.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
static int qsv_device_derive(AVHWDeviceContext *ctx, AVHWDeviceContext *child_device_ctx, AVDictionary *opts, int flags)
This struct is allocated as AVHWFramesContext.hwctx.
static int qsv_frames_derive_from(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
Map a hardware frame.
static int qsv_init_surface(AVHWFramesContext *ctx, mfxFrameSurface1 *surf)
void * av_mallocz_array(size_t nmemb, size_t size)
IDirect3DDeviceManager9 * devmgr
#define AV_LOG_VERBOSE
Detailed information.
VADisplay display
The VADisplay handle, to be filled by the user.
AVBufferRef * av_buffer_create(uint8_t *data, buffer_size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
AVHWFramesInternal * internal
Private data used internally by libavutil.
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int width
The allocated dimensions of the frames in this pool.
int av_hwdevice_ctx_init(AVBufferRef *ref)
Finalize the device context before use.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
mfxHandleType handle_type
static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
static const struct @304 supported_handle_types[]
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
enum AVHWDeviceType child_device_type
static int qsv_init_child_ctx(AVHWFramesContext *ctx)
static AVBufferRef * qsv_pool_alloc(void *opaque, buffer_size_t size)
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
static int qsv_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
mfxHandleType handle_type
static int qsv_frames_derive_to(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
AVBufferRef * av_hwdevice_ctx_alloc(enum AVHWDeviceType type)
Allocate an AVHWDeviceContext for a given hardware type.
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
mfxExtBuffer * ext_buffers[1]
static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req, mfxFrameAllocResponse *resp)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
AVBufferRef * child_device_ctx
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int av_usleep(unsigned usec)
Sleep for a period of time.
const HWContextType ff_hwcontext_type_qsv
mfxFrameSurface1 * surfaces
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
static void qsv_frames_uninit(AVHWFramesContext *ctx)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
static int qsv_frames_init(AVHWFramesContext *ctx)
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface)
static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
#define pthread_mutex_unlock(a)
static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxSession *session, int upload)
mfxExtOpaqueSurfaceAlloc opaque_alloc
static int qsv_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
DWORD surface_type
The surface type (e.g.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
int session_download_init
enum AVHWDeviceType device_type
static void qsv_device_free(AVHWDeviceContext *ctx)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
static int qsv_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, mfxIMPL implementation, AVHWDeviceContext *child_device_ctx, int flags)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static int qsv_device_init(AVHWDeviceContext *ctx)
This struct is allocated as AVHWDeviceContext.hwctx.
#define av_malloc_array(a, b)
mfxFrameSurface1 ** surface_ptrs
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
mfxSession session_download
IDirect3DSurface9 ** surfaces
The surface pool.
AVBufferPool * av_buffer_pool_init2(buffer_size_t size, void *opaque, AVBufferRef *(*alloc)(void *opaque, buffer_size_t size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
AVHWFrameTransferDirection
This struct describes a set or pool of "hardware" frames (i.e.
static int qsv_map_to(AVHWFramesContext *dst_ctx, AVFrame *dst, const AVFrame *src, int flags)
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
enum AVPixelFormat pix_fmt
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
@ 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...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags)
Open a device of the specified type and create an AVHWDeviceContext for it.
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
static void qsv_pool_release_dummy(void *opaque, uint8_t *data)
enum AVPixelFormat child_pix_fmt
mfxSession session_upload
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
This struct is allocated as AVHWFramesContext.hwctx.
int initial_pool_size
Initial size of the frame pool.
A reference to a data buffer.
static mfxIMPL choose_implementation(const char *device)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
VAAPI-specific data associated with a frame pool.
mfxFrameSurface1 * surfaces_internal
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define flags(name, subs,...)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
VAAPI connection details.
static int qsv_init_pool(AVHWFramesContext *ctx, uint32_t fourcc)
#define pthread_mutex_lock(a)