22 #include <mfx/mfxvideo.h>
129 if (err == MFX_ERR_NONE) {
138 "from the session\n");
142 if (err == MFX_ERR_NONE)
143 err = MFXQueryVersion(hwctx->
session, &s->
ver);
144 if (err != MFX_ERR_NONE) {
214 if (!device_priv->
handle) {
216 "Cannot create a non-opaque internal surface pool without "
217 "a hardware handle\n");
222 if (!child_device_ref)
229 child_device_hwctx->
display = (VADisplay)device_priv->
handle;
235 child_device_hwctx->
devmgr = (IDirect3DDeviceManager9*)device_priv->
handle;
246 if (!child_frames_ref) {
261 if (hwctx->
frame_type & MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET)
262 child_frames_hwctx->
surface_type = DXVA2_VideoProcessorRenderTarget;
264 child_frames_hwctx->
surface_type = DXVA2_VideoDecoderRenderTarget;
279 hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
287 if (child_frames_hwctx->
surface_type == DXVA2_VideoProcessorRenderTarget)
288 hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET;
290 hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
295 child_frames_ref =
NULL;
316 surf->Info.BitDepthLuma = desc->
comp[0].
depth;
317 surf->Info.BitDepthChroma = desc->
comp[0].
depth;
318 surf->Info.Shift = desc->
comp[0].
depth > 8;
321 surf->Info.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
323 surf->Info.ChromaFormat = MFX_CHROMAFORMAT_YUV422;
325 surf->Info.ChromaFormat = MFX_CHROMAFORMAT_YUV444;
327 surf->Info.FourCC =
fourcc;
329 surf->Info.CropW = ctx->
width;
331 surf->Info.CropH = ctx->
height;
332 surf->Info.FrameRateExtN = 25;
333 surf->Info.FrameRateExtD = 1;
334 surf->Info.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
362 if (!(frames_hwctx->
frame_type & MFX_MEMTYPE_OPAQUE_FRAME)) {
379 static mfxStatus
frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
380 mfxFrameAllocResponse *resp)
385 mfxFrameInfo *i = &req->Info;
386 mfxFrameInfo *i1 = &hwctx->
surfaces[0].Info;
388 if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET) ||
389 !(req->Type & (MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_FROM_VPPOUT)) ||
390 !(req->Type & MFX_MEMTYPE_EXTERNAL_FRAME))
391 return MFX_ERR_UNSUPPORTED;
392 if (i->Width != i1->Width || i->Height != i1->Height ||
393 i->FourCC != i1->FourCC || i->ChromaFormat != i1->ChromaFormat) {
395 "allocation request: %dx%d %d %d vs %dx%d %d %d\n",
396 i->Width, i->Height, i->FourCC, i->ChromaFormat,
397 i1->Width, i1->Height, i1->FourCC, i1->ChromaFormat);
398 return MFX_ERR_UNSUPPORTED;
407 static mfxStatus
frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
412 static mfxStatus
frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
414 return MFX_ERR_UNSUPPORTED;
417 static mfxStatus
frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
419 return MFX_ERR_UNSUPPORTED;
429 mfxSession *session,
int upload)
434 int opaque = !!(frames_hwctx->
frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
436 mfxFrameAllocator frame_allocator = {
448 err = MFXInit(device_priv->
impl, &device_priv->
ver, session);
449 if (err != MFX_ERR_NONE) {
454 if (device_priv->
handle) {
455 err = MFXVideoCORE_SetHandle(*session, device_priv->
handle_type,
457 if (err != MFX_ERR_NONE)
462 err = MFXVideoCORE_SetFrameAllocator(*session, &frame_allocator);
463 if (err != MFX_ERR_NONE)
467 memset(&par, 0,
sizeof(par));
472 par.IOPattern = upload ? MFX_IOPATTERN_OUT_OPAQUE_MEMORY :
473 MFX_IOPATTERN_IN_OPAQUE_MEMORY;
475 par.IOPattern = upload ? MFX_IOPATTERN_OUT_VIDEO_MEMORY :
476 MFX_IOPATTERN_IN_VIDEO_MEMORY;
479 par.IOPattern |= upload ? MFX_IOPATTERN_IN_SYSTEM_MEMORY :
480 MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
483 par.vpp.In = frames_hwctx->
surfaces[0].Info;
489 par.vpp.In.FrameRateExtN = 25;
490 par.vpp.In.FrameRateExtD = 1;
491 par.vpp.Out = par.vpp.In;
493 err = MFXVideoVPP_Init(*session, &par);
494 if (err != MFX_ERR_NONE) {
496 "Surface upload/download will not be possible\n");
509 int opaque = !!(frames_hwctx->
frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
543 s->
opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
619 *(VASurfaceID*)src_hwctx->
surfaces[i].Data.MemId;
634 (IDirect3DSurface9*)src_hwctx->
surfaces[i].Data.MemId;
636 if (src_hwctx->
frame_type == MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
637 dst_hwctx->
surface_type = DXVA2_VideoDecoderRenderTarget;
639 dst_hwctx->
surface_type = DXVA2_VideoProcessorRenderTarget;
654 mfxFrameSurface1 *surf = (mfxFrameSurface1*)src->
data[3];
665 switch (child_frames_ctx->device_ctx->type) {
668 child_data = (
uint8_t*)(intptr_t)*(VASurfaceID*)surf->Data.MemId;
673 child_data = surf->Data.MemId;
680 if (dst->
format == child_frames_ctx->format) {
688 dst->
data[3] = child_data;
708 dummy->format = child_frames_ctx->format;
711 dummy->data[3] = child_data;
727 mfxFrameSurface1 *surf = (mfxFrameSurface1*)(download ? src->
data[3] : dst->
data[3]);
739 dummy->
buf[0] = download ? src->
buf[0] : dst->
buf[0];
740 dummy->
data[3] = surf->Data.MemId;
760 surface->Data.Y = frame->
data[0];
761 surface->Data.UV = frame->
data[1];
765 surface->Data.Y = frame->
data[0];
766 surface->Data.U = frame->
data[1];
767 surface->Data.V = frame->
data[2];
771 surface->Data.B = frame->
data[0];
772 surface->Data.G = frame->
data[0] + 1;
773 surface->Data.R = frame->
data[0] + 2;
774 surface->Data.A = frame->
data[0] + 3;
778 return MFX_ERR_UNSUPPORTED;
780 surface->Data.Pitch = frame->
linesize[0];
781 surface->Data.TimeStamp = frame->
pts;
790 mfxFrameSurface1
out = {{ 0 }};
791 mfxFrameSurface1 *
in = (mfxFrameSurface1*)src->
data[3];
793 mfxSyncPoint sync =
NULL;
799 if (pthread_mutex_trylock(&s->session_lock) == 0) {
835 if (err == MFX_WRN_DEVICE_BUSY)
837 }
while (err == MFX_WRN_DEVICE_BUSY);
839 if (err < 0 || !sync) {
846 }
while (err == MFX_WRN_IN_EXECUTION);
859 mfxFrameSurface1
in = {{ 0 }};
860 mfxFrameSurface1 *
out = (mfxFrameSurface1*)dst->
data[3];
862 mfxSyncPoint sync =
NULL;
872 if (pthread_mutex_trylock(&s->session_lock) == 0) {
897 memset(&tmp_frame, 0,
sizeof(tmp_frame));
912 src_frame = realigned ? &tmp_frame :
src;
927 if (err == MFX_WRN_DEVICE_BUSY)
929 }
while (err == MFX_WRN_DEVICE_BUSY);
931 if (err < 0 || !sync) {
938 }
while (err == MFX_WRN_IN_EXECUTION);
971 dst_hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
988 if (src_hwctx->
surface_type == DXVA2_VideoProcessorRenderTarget)
989 dst_hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET;
991 dst_hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
1012 if (*(VASurfaceID*)hwctx->
surfaces[i].Data.MemId ==
1013 (VASurfaceID)(uintptr_t)src->
data[3])
1017 if ((IDirect3DSurface9*)hwctx->
surfaces[i].Data.MemId ==
1018 (IDirect3DSurface9*)(uintptr_t)src->
data[3])
1024 "is not in the mapped frames context.\n");
1041 const void *hwconfig,
1079 static const struct {
1083 {
"auto", MFX_IMPL_AUTO },
1084 {
"sw", MFX_IMPL_SOFTWARE },
1085 {
"hw", MFX_IMPL_HARDWARE },
1086 {
"auto_any", MFX_IMPL_AUTO_ANY },
1087 {
"hw_any", MFX_IMPL_HARDWARE_ANY },
1088 {
"hw2", MFX_IMPL_HARDWARE2 },
1089 {
"hw3", MFX_IMPL_HARDWARE3 },
1090 {
"hw4", MFX_IMPL_HARDWARE4 },
1093 mfxIMPL impl = MFX_IMPL_AUTO_ANY;
1098 if (!strcmp(device, impl_map[i].
name)) {
1099 impl = impl_map[i].impl;
1103 impl = strtol(device,
NULL, 0);
1110 mfxIMPL implementation,
1116 mfxVersion ver = { { 3, 1 } };
1122 switch (child_device_ctx->
type) {
1127 handle_type = MFX_HANDLE_VA_DISPLAY;
1128 handle = (mfxHDL)child_device_hwctx->
display;
1136 handle_type = MFX_HANDLE_D3D9_DEVICE_MANAGER;
1137 handle = (mfxHDL)child_device_hwctx->
devmgr;
1146 err = MFXInit(implementation, &ver, &hwctx->
session);
1147 if (err != MFX_ERR_NONE) {
1154 err = MFXQueryVersion(hwctx->
session, &ver);
1155 if (err != MFX_ERR_NONE) {
1162 "Initialize MFX session: API version is %d.%d, implementation version is %d.%d\n",
1163 MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor);
1167 err = MFXInit(implementation, &ver, &hwctx->
session);
1168 if (err != MFX_ERR_NONE) {
1170 "Error initializing an MFX session: %d.\n", err);
1175 err = MFXVideoCORE_SetHandle(hwctx->
session, handle_type, handle);
1176 if (err != MFX_ERR_NONE) {
1183 ret = MFXQueryVersion(hwctx->
session,&ver);
1184 if (ret == MFX_ERR_NONE) {
1186 MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor);
1200 child_device_ctx, flags);
1225 else if (CONFIG_DXVA2)
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
static int qsv_init_child_ctx(AVHWFramesContext *ctx)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
VAAPI-specific data associated with a frame pool.
This structure describes decoded (raw) audio or video data.
#define pthread_mutex_lock(a)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
ptrdiff_t const GLvoid * data
static int qsv_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
mfxFrameSurface1 * surfaces_internal
int frame_type
A combination of MFX_MEMTYPE_* describing the frame pool.
mfxExtBuffer * ext_buffers[1]
This struct is allocated as AVHWFramesContext.hwctx.
Memory handling functions.
mfxHandleType handle_type
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
This struct is allocated as AVHWFramesContext.hwctx.
An API-specific header for AV_HWDEVICE_TYPE_DXVA2.
int width
The allocated dimensions of the frames in this pool.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
mfxHandleType handle_type
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int av_usleep(unsigned usec)
Sleep for a period of time.
static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req, mfxFrameAllocResponse *resp)
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static int qsv_init_pool(AVHWFramesContext *ctx, uint32_t fourcc)
API-specific header for AV_HWDEVICE_TYPE_VAAPI.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
static int qsv_transfer_data_child(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
AVBufferPool * pool_internal
static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
8 bits with AV_PIX_FMT_RGB32 palette
DWORD surface_type
The surface type (e.g.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
enum AVHWDeviceType child_device_type
static int qsv_map_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
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.
#define AV_LOG_VERBOSE
Detailed information.
static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
static int qsv_frames_init(AVHWFramesContext *ctx)
int session_download_init
static int qsv_init_surface(AVHWFramesContext *ctx, mfxFrameSurface1 *surf)
This struct is allocated as AVHWDeviceContext.hwctx.
static int qsv_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void(* free)(struct AVHWDeviceContext *ctx)
This field may be set by the caller before calling av_hwdevice_ctx_init().
static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
enum AVHWDeviceType device_type
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
IDirect3DDeviceManager9 * devmgr
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
static int qsv_frames_derive_to(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
static int qsv_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
int initial_pool_size
Initial size of the frame pool.
static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
static const struct @288 supported_handle_types[]
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
mfxFrameSurface1 ** surface_ptrs
#define pthread_mutex_unlock(a)
mfxSession session_download
AVBufferPool * av_buffer_pool_init2(int size, void *opaque, AVBufferRef *(*alloc)(void *opaque, int size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
#define FF_ARRAY_ELEMS(a)
static const struct @289 supported_pixel_formats[]
VADisplay display
The VADisplay handle, to be filled by the user.
static void qsv_frames_uninit(AVHWFramesContext *ctx)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
AVBufferRef * av_hwdevice_ctx_alloc(enum AVHWDeviceType type)
Allocate an AVHWDeviceContext for a given hardware type.
static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
const HWContextType ff_hwcontext_type_qsv
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
mfxFrameSurface1 * surfaces
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t * data
The data buffer.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
int av_hwdevice_ctx_init(AVBufferRef *ref)
Finalize the device context before use.
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxSession *session, int upload)
This struct describes a set or pool of "hardware" frames (i.e.
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
static mfxIMPL choose_implementation(const char *device)
refcounted data buffer API
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
mfxExtOpaqueSurfaceAlloc opaque_alloc
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
AVHWFramesInternal * internal
Private data used internally by libavutil.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define flags(name, subs,...)
static AVBufferRef * qsv_pool_alloc(void *opaque, int size)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void * user_opaque
Arbitrary user data, to be used e.g.
static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, mfxIMPL implementation, AVHWDeviceContext *child_device_ctx, int flags)
A reference to a data buffer.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void qsv_device_free(AVHWDeviceContext *ctx)
common internal and external API header
int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
Map a hardware frame.
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, int flags)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
static int qsv_device_init(AVHWDeviceContext *ctx)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
enum AVPixelFormat child_pix_fmt
IDirect3DSurface9 ** surfaces
The surface pool.
AVHWFrameTransferDirection
AVBufferPool * pool
A pool from which the frames are allocated by av_hwframe_get_buffer().
This struct is allocated as AVHWDeviceContext.hwctx.
static uint32_t qsv_fourcc_from_pix_fmt(enum AVPixelFormat pix_fmt)
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
VAAPI connection details.
static int qsv_frames_derive_from(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
An API-specific header for AV_HWDEVICE_TYPE_QSV.
AVBufferRef * child_device_ctx
AVBufferRef * child_frames_ref
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define av_malloc_array(a, b)
AVHWDeviceInternal * internal
Private data used internally by libavutil.
int depth
Number of bits in the component.
static void qsv_pool_release_dummy(void *opaque, uint8_t *data)
static int qsv_map_to(AVHWFramesContext *dst_ctx, AVFrame *dst, const AVFrame *src, int flags)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.
enum AVPixelFormat pix_fmt
mfxSession session_upload
void * av_mallocz_array(size_t nmemb, size_t size)