24#include "config_components.h"
57#include <mfxdispatcher.h>
59#define MFXUnload(a) do { } while(0)
64#define PTS_TO_MFX_PTS(pts, pts_tb) ((pts) == AV_NOPTS_VALUE ? \
65 MFX_TIMESTAMP_UNKNOWN : pts_tb.num ? \
66 av_rescale_q(pts, pts_tb, mfx_tb) : pts)
68#define MFX_PTS_TO_PTS(mfx_pts, pts_tb) ((mfx_pts) == MFX_TIMESTAMP_UNKNOWN ? \
69 AV_NOPTS_VALUE : pts_tb.num ? \
70 av_rescale_q(mfx_pts, mfx_tb, pts_tb) : mfx_pts)
72#define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))
192 if (q->
gpu_copy == MFX_GPUCOPY_ON &&
193 !(q->
iopattern & MFX_IOPATTERN_OUT_SYSTEM_MEMORY)) {
195 "only works in system memory mode.\n");
200 }
else if (hw_frames_ref) {
215 q->
iopattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY,
226 }
else if (hw_device_ref) {
249 if (MFXQueryIMPL(q->
session, &impl) == MFX_ERR_NONE) {
251 case MFX_IMPL_VIA_VAAPI:
255 case MFX_IMPL_VIA_D3D11:
259 case MFX_IMPL_VIA_D3D9:
271 if (MFXQueryVersion(q->
session, &q->
ver) != MFX_ERR_NONE) {
277 MFXVideoDECODE_Close(q->
session);
299 mfxSession session =
NULL;
339 frames_hwctx = hwframes_ctx->
hwctx;
348 frames_hwctx->
frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
365 if (frames_hwctx->
frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
366 iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
367 else if (frames_hwctx->
frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
368 iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
370 if (frames_hwctx->
frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
371 iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
377 iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
400 avctx->
width = param->mfx.FrameInfo.CropW;
401 avctx->
height = param->mfx.FrameInfo.CropH;
404 avctx->
level = param->mfx.CodecLevel;
405 avctx->
profile = param->mfx.CodecProfile;
409 ret = MFXVideoDECODE_Init(q->
session, param);
412 "Error initializing the MFX video decoder");
427 mfxVideoParam *param)
430 mfxExtVideoSignalInfo video_signal_info = { 0 };
431 mfxExtBuffer *header_ext_params[1] = { (mfxExtBuffer *)&video_signal_info };
432 mfxBitstream bs = { 0 };
435 bs.Data = avpkt->
data;
436 bs.DataLength = avpkt->
size;
437 bs.MaxLength = bs.DataLength;
440 bs.DataFlag |= MFX_BITSTREAM_COMPLETE_FRAME;
455 param->mfx.CodecId = ret;
456 video_signal_info.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO;
457 video_signal_info.Header.BufferSz =
sizeof(video_signal_info);
460 param->ExtParam = header_ext_params;
461 param->NumExtParam = 1;
462 ret = MFXVideoDECODE_DecodeHeader(q->
session, &bs, param);
463 if (MFX_ERR_MORE_DATA == ret) {
468 "Error decoding stream header");
472 if (video_signal_info.ColourDescriptionPresent) {
474 avctx->
color_trc = video_signal_info.TransferCharacteristics;
475 avctx->
colorspace = video_signal_info.MatrixCoefficients;
481 if (param->mfx.FrameInfo.FrameRateExtN == 0 || param->mfx.FrameInfo.FrameRateExtD == 0) {
482 param->mfx.FrameInfo.FrameRateExtN = 25;
483 param->mfx.FrameInfo.FrameRateExtD = 1;
486#if QSV_VERSION_ATLEAST(1, 34)
507 frame->surface = *(mfxFrameSurface1*)
frame->frame->data[3];
526 frame->surface.Data.ExtParam =
frame->ext_param;
527 frame->surface.Data.NumExtParam = 0;
528 frame->num_ext_params = 0;
529 frame->dec_info.Header.BufferId = MFX_EXTBUFF_DECODED_FRAME_INFO;
530 frame->dec_info.Header.BufferSz =
sizeof(
frame->dec_info);
532#if QSV_VERSION_ATLEAST(1, 34)
534 frame->av1_film_grain_param.Header.BufferId = MFX_EXTBUFF_AV1_FILM_GRAIN_PARAM;
535 frame->av1_film_grain_param.Header.BufferSz =
sizeof(
frame->av1_film_grain_param);
536 frame->av1_film_grain_param.FilmGrainFlags = 0;
541#if QSV_VERSION_ATLEAST(1, 35)
544 frame->mdcv.Header.BufferId = MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME;
545 frame->mdcv.Header.BufferSz =
sizeof(
frame->mdcv);
547 frame->mdcv.InsertPayloadToggle = 0;
550 frame->clli.Header.BufferId = MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO;
551 frame->clli.Header.BufferSz =
sizeof(
frame->clli);
553 frame->clli.InsertPayloadToggle = 0;
589 *surf = &
frame->surface;
611 *surf = &
frame->surface;
627#if QSV_VERSION_ATLEAST(1, 34)
634 if (!(ext_param->FilmGrainFlags & MFX_FILM_GRAIN_APPLY))
643 fgp->
seed = ext_param->GrainSeed;
651 aom->
overlap_flag = !!(ext_param->FilmGrainFlags & MFX_FILM_GRAIN_OVERLAP);
652 aom->
limit_output_range = !!(ext_param->FilmGrainFlags & MFX_FILM_GRAIN_CLIP_TO_RESTRICTED_RANGE);
657 aom->
y_points[
i][0] = ext_param->PointY[
i].Value;
658 aom->
y_points[
i][1] = ext_param->PointY[
i].Scaling;
664 aom->
uv_points[0][
i][0] = ext_param->PointCb[
i].Value;
665 aom->
uv_points[0][
i][1] = ext_param->PointCb[
i].Scaling;
671 aom->
uv_points[1][
i][0] = ext_param->PointCr[
i].Value;
672 aom->
uv_points[1][
i][1] = ext_param->PointCr[
i].Scaling;
675 for (
i = 0;
i < 24;
i++)
678 for (
i = 0;
i < 25;
i++) {
683 aom->
uv_mult[0] = ext_param->CbMult;
684 aom->
uv_mult[1] = ext_param->CrMult;
694#if QSV_VERSION_ATLEAST(1, 35)
695static int qsv_export_hdr_side_data(
AVCodecContext *avctx, mfxExtMasteringDisplayColourVolume *mdcv,
701 if (mdcv->InsertPayloadToggle) {
703 const int mapping[3] = {2, 0, 1};
704 const int chroma_den = 50000;
705 const int luma_den = 10000;
713 for (
i = 0;
i < 3;
i++) {
714 const int j = mapping[
i];
731 if (clli->InsertPayloadToggle) {
739 light->
MaxCLL = clli->MaxContentLightLevel;
740 light->
MaxFALL = clli->MaxPicAverageLightLevel;
747static int qsv_export_hdr_side_data_av1(
AVCodecContext *avctx, mfxExtMasteringDisplayColourVolume *mdcv,
750 if (mdcv->InsertPayloadToggle) {
752 const int chroma_den = 1 << 16;
753 const int max_luma_den = 1 << 8;
754 const int min_luma_den = 1 << 14;
759 for (
int i = 0;
i < 3;
i++) {
774 if (clli->InsertPayloadToggle) {
779 light->
MaxCLL = clli->MaxContentLightLevel;
780 light->
MaxFALL = clli->MaxPicAverageLightLevel;
792 mfxFrameSurface1 *insurf;
793 mfxFrameSurface1 *outsurf;
795 mfxBitstream bs = { { { 0 } } };
799 bs.Data = avpkt->
data;
800 bs.DataLength = avpkt->
size;
801 bs.MaxLength = bs.DataLength;
804 bs.DataFlag |= MFX_BITSTREAM_COMPLETE_FRAME;
820 ret = MFXVideoDECODE_DecodeFrameAsync(q->
session, avpkt->
size ? &bs :
NULL,
821 insurf, &outsurf, sync);
822 if (ret == MFX_WRN_DEVICE_BUSY)
825 }
while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE);
827 if (ret == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) {
834 if (ret != MFX_ERR_NONE &&
835 ret != MFX_ERR_MORE_DATA &&
836 ret != MFX_WRN_VIDEO_PARAM_CHANGED &&
837 ret != MFX_ERR_MORE_SURFACE) {
840 "Error during QSV decoding.");
845 if (!*sync && !bs.DataOffset) {
846 bs.DataOffset = avpkt->
size;
850 ret != MFX_ERR_MORE_DATA))
862 "The returned surface does not correspond to any frame\n");
885 ret = MFXVideoCORE_SyncOperation(q->
session, *aframe.
sync, 1000);
886 }
while (ret == MFX_WRN_IN_EXECUTION);
900#if QSV_VERSION_ATLEAST(1, 34)
904 ret = qsv_export_film_grain(avctx, &aframe.
frame->av1_film_grain_param,
frame);
911#if QSV_VERSION_ATLEAST(1, 35)
913 ret = qsv_export_hdr_side_data(avctx, &aframe.
frame->mdcv, &aframe.
frame->clli,
frame);
920 ret = qsv_export_hdr_side_data_av1(avctx, &aframe.
frame->mdcv, &aframe.
frame->clli,
frame);
927 outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_TRIPLING ? 4 :
928 outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_DOUBLING ? 2 :
929 outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_REPEATED ? 1 : 0;
931 !!(outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF);
933 !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
949 frame->crop_left = outsurf->Info.CropX;
950 frame->crop_top = outsurf->Info.CropY;
951 frame->crop_right = outsurf->Info.Width - (outsurf->Info.CropX + outsurf->Info.CropW);
952 frame->crop_bottom = outsurf->Info.Height - (outsurf->Info.CropY + outsurf->Info.CropH);
956 ((mfxFrameSurface1*)
frame->data[3])->Info = outsurf->Info;
961 return bs.DataOffset;
969 MFXVideoDECODE_Close(q->
session);
996 mfxVideoParam param = { 0 };
1018 if (ret < 0 || *got_frame)
1023 mfxFrameAllocRequest request;
1024 memset(&request, 0,
sizeof(request));
1042 ret = MFXVideoDECODE_QueryIOSurf(q->
session, ¶m, &request);
1114 uid =
"f622394d8d87452f878c51f2fc9b4131";
1116 uid =
"a922394d8d87452f878c51f2fc9b4131";
1119 static const char *
const uid_hevcdec_sw =
"15dd936825ad475ea34e35f3f54217a6";
1120 static const char *
const uid_hevcdec_hw =
"33a61c0b4c27454ca8d85dde757c6f8e";
1122 if (
s->qsv.load_plugins[0]) {
1124 "load_plugins is not empty, but load_plugin is not set to 'none'."
1125 "The load_plugin value will be ignored.\n");
1128 uid = uid_hevcdec_sw;
1130 uid = uid_hevcdec_hw;
1136 if (!
s->qsv.load_plugins)
1143 if (!
s->packet_fifo) {
1174 while (!*got_frame) {
1176 if (
s->buffer_pkt.size <= 0) {
1181 if (!
s->qsv.reinit_flag) {
1197 if (
s->qsv.reinit_flag)
1200 s->buffer_pkt.size -= ret;
1201 s->buffer_pkt.data += ret;
1214 s->qsv.initialized = 0;
1217#define OFFSET(x) offsetof(QSVDecContext, x)
1218#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1220#define DEFINE_QSV_DECODER_WITH_OPTION(x, X, bsf_name, opt) \
1221static const AVClass x##_qsv_class = { \
1222 .class_name = #x "_qsv", \
1223 .item_name = av_default_item_name, \
1225 .version = LIBAVUTIL_VERSION_INT, \
1227const FFCodec ff_##x##_qsv_decoder = { \
1228 .p.name = #x "_qsv", \
1229 CODEC_LONG_NAME(#X " video (Intel Quick Sync Video acceleration)"), \
1230 .priv_data_size = sizeof(QSVDecContext), \
1231 .p.type = AVMEDIA_TYPE_VIDEO, \
1232 .p.id = AV_CODEC_ID_##X, \
1233 .init = qsv_decode_init, \
1234 FF_CODEC_DECODE_CB(qsv_decode_frame), \
1235 .flush = qsv_decode_flush, \
1236 .close = qsv_decode_close, \
1238 .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
1239 .p.priv_class = &x##_qsv_class, \
1240 .hw_configs = qsv_hw_configs, \
1241 .p.wrapper_name = "qsv", \
1242 .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING, \
1245#define DEFINE_QSV_DECODER(x, X, bsf_name) DEFINE_QSV_DECODER_WITH_OPTION(x, X, bsf_name, options)
1247#if CONFIG_HEVC_QSV_DECODER
1256 {
"load_plugins",
"A :-separate list of hexadecimal plugin UIDs to load in an internal session",
1259 {
"gpu_copy",
"A GPU-accelerated copy between video and system memory",
OFFSET(qsv.gpu_copy),
AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF,
VD, .unit =
"gpu_copy"},
1271 {
"gpu_copy",
"A GPU-accelerated copy between video and system memory",
OFFSET(qsv.gpu_copy),
AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF,
VD, .unit =
"gpu_copy"},
1278#if CONFIG_H264_QSV_DECODER
1282#if CONFIG_MPEG2_QSV_DECODER
1286#if CONFIG_VC1_QSV_DECODER
1290#if CONFIG_MJPEG_QSV_DECODER
1294#if CONFIG_VP8_QSV_DECODER
1298#if CONFIG_VP9_QSV_DECODER
1302#if CONFIG_AV1_QSV_DECODER
1306#if CONFIG_VVC_QSV_DECODER
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
int ff_attach_decode_data(AVCodecContext *avctx, AVFrame *frame)
int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, AVContentLightMetadata **clm)
Wrapper around av_content_light_metadata_create_side_data(), which rejects side data overridden by th...
int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, AVMasteringDisplayMetadata **mdm)
Wrapper around av_mastering_display_metadata_create_side_data(), which rejects side data overridden b...
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
static enum AVPixelFormat pix_fmt
AVFilmGrainParams * av_film_grain_params_create_side_data(AVFrame *frame)
Allocate a complete AVFilmGrainParams and add it to the frame.
@ AV_FILM_GRAIN_PARAMS_AV1
The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
reference-counted frame API
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
@ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
The codec supports this format via the hw_frames_ctx interface.
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
AVBufferPool * av_buffer_pool_init(size_t size, AVBufferRef *(*alloc)(size_t size))
Allocate and initialize a buffer pool.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
size_t av_fifo_can_read(const AVFifo *f)
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
An API-specific header for AV_HWDEVICE_TYPE_QSV.
common internal api header.
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
@ 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...
@ AV_PIX_FMT_VUYX
packed VUYX 4:4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface)
int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
enum AVFieldOrder ff_qsv_map_picstruct(int mfx_pic_struct)
int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, const char *load_plugins, int gpu_copy)
int ff_qsv_print_error(void *log_ctx, mfxStatus err, const char *error_string)
int ff_qsv_close_internal_session(QSVSession *qs)
int ff_qsv_init_session_frames(AVCodecContext *avctx, mfxSession *psession, QSVFramesContext *qsv_frames_ctx, const char *load_plugins, int opaque, int gpu_copy)
int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern, const char *extra_string)
void ff_qsv_frame_add_ext_param(AVCodecContext *avctx, QSVFrame *frame, mfxExtBuffer *param)
int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, AVBufferRef *device_ref, const char *load_plugins, int gpu_copy)
enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame)
int ff_qsv_print_warning(void *log_ctx, mfxStatus err, const char *warning_string)
#define ASYNC_DEPTH_DEFAULT
#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR)
static int qsv_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
static int qsv_process_data(AVCodecContext *avctx, QSVContext *q, AVFrame *frame, int *got_frame, const AVPacket *pkt)
static int qsv_decode(AVCodecContext *avctx, QSVContext *q, AVFrame *frame, int *got_frame, const AVPacket *avpkt)
static void qsv_clear_unused_frames(QSVContext *q)
#define DEFINE_QSV_DECODER_WITH_OPTION(x, X, bsf_name, opt)
static QSVFrame * find_frame(QSVContext *q, mfxFrameSurface1 *surf)
static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, const AVPacket *avpkt, enum AVPixelFormat pix_fmt, mfxVideoParam *param)
static const AVRational mfx_tb
#define PTS_TO_MFX_PTS(pts, pts_tb)
static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q, enum AVPixelFormat pix_fmt, mfxVideoParam *param)
static int qsv_decode_init_context(AVCodecContext *avctx, QSVContext *q, mfxVideoParam *param)
static int get_surface(AVCodecContext *avctx, QSVContext *q, mfxFrameSurface1 **surf)
static void qsv_decode_flush(AVCodecContext *avctx)
#define DEFINE_QSV_DECODER(x, X, bsf_name)
static void qsv_decode_close_qsvcontext(QSVContext *q)
static const AVCodecHWConfigInternal *const qsv_hw_configs[]
static void qsv_clear_buffers(QSVDecContext *s)
static av_cold int qsv_decode_init(AVCodecContext *avctx)
#define MFX_PTS_TO_PTS(mfx_pts, pts_tb)
static av_cold int qsv_decode_close(AVCodecContext *avctx)
static int alloc_frame(AVCodecContext *avctx, QSVContext *q, QSVFrame *frame)
#define MFX_IMPL_VIA_MASK(impl)
static int qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame, AVBufferPool *pool)
static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession session, AVBufferRef *hw_frames_ref, AVBufferRef *hw_device_ref)
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
A reference to a data buffer.
uint8_t * data
The data buffer.
Describe the class of an AVClass context structure.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
enum AVFieldOrder field_order
Field order.
int level
Encoding level descriptor.
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
enum AVColorSpace colorspace
YUV colorspace type.
void * hwaccel_context
Legacy hardware accelerator context.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
int extra_hw_frames
Video decoding only.
int coded_width
Bitstream width / height, may be different from width/height e.g.
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
This structure describes how to handle film grain synthesis for AOM codecs.
int chroma_scaling_from_luma
Signals whether to derive the chroma scaling function from the luma.
int limit_output_range
Signals to clip to limited color levels after film grain application.
int scaling_shift
Specifies the shift applied to the chroma components.
int grain_scale_shift
Signals the down shift applied to the generated gaussian numbers during synthesis.
int num_uv_points[2]
If chroma_scaling_from_luma is set to 0, signals the chroma scaling function parameters.
int overlap_flag
Signals whether to overlap film grain blocks.
int ar_coeff_lag
Specifies the auto-regression lag.
int uv_offset[2]
Offset used for component scaling function.
int ar_coeff_shift
Specifies the range of the auto-regressive coefficients.
uint8_t uv_points[2][10][2]
int8_t ar_coeffs_uv[2][25]
Chroma auto-regression coefficients.
int uv_mult[2]
Specifies the luma/chroma multipliers for the index to the component scaling function.
int8_t ar_coeffs_y[24]
Luma auto-regression coefficients.
int num_y_points
Number of points, and the scale and value for each point of the piecewise linear scaling function for...
This structure describes how to handle film grain synthesis in video for specific codecs.
union AVFilmGrainParams::@177057277273004265167152242113040056044005264354 codec
Additional fields may be added both here and in any structure included.
enum AVFilmGrainParamsType type
Specifies the codec for which this structure is valid.
uint64_t seed
Seed to use for the synthesis process, if the codec allows for it.
This structure describes decoded (raw) audio or video data.
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int initial_pool_size
Initial size of the frame pool.
int width
The allocated dimensions of the frames in this pool.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
This struct is used for communicating QSV parameters between libavcodec and the caller.
mfxExtBuffer ** ext_buffers
Extra buffers to pass to encoder or decoder initialization.
int iopattern
The IO pattern to use.
mfxSession session
If non-NULL, the session to use for encoding or decoding.
This struct is allocated as AVHWFramesContext.hwctx.
int frame_type
A combination of MFX_MEMTYPE_* describing the frame pool.
Rational number (pair of numerator and denominator).
mfxExtBuffer ** ext_buffers
enum AVPixelFormat orig_pix_fmt
QSVFramesContext frames_ctx
mfxHandleType handle_type
QSVFrame * work_frames
a linked list of frames currently being used by QSV
mfxExtDecodedFrameInfo dec_info
QSVMid * mids
The memory ids for the external frames.
AVBufferRef * hw_frames_ctx
int av_usleep(unsigned usec)
Sleep for a period of time.