24 #include "config_components.h"
27 #include <sys/types.h>
28 #include <mfx/mfxvideo.h>
52 { MFX_PROFILE_AVC_BASELINE,
"avc baseline" },
53 { MFX_PROFILE_AVC_MAIN,
"avc main" },
54 { MFX_PROFILE_AVC_EXTENDED,
"avc extended" },
55 { MFX_PROFILE_AVC_HIGH,
"avc high" },
56 { MFX_PROFILE_AVC_HIGH_422,
"avc high 422" },
57 { MFX_PROFILE_AVC_CONSTRAINED_BASELINE,
"avc constrained baseline" },
58 { MFX_PROFILE_AVC_CONSTRAINED_HIGH,
"avc constrained high" },
59 { MFX_PROFILE_AVC_PROGRESSIVE_HIGH,
"avc progressive high" },
63 { MFX_PROFILE_MPEG2_SIMPLE,
"mpeg2 simple" },
64 { MFX_PROFILE_MPEG2_MAIN,
"mpeg2 main" },
65 { MFX_PROFILE_MPEG2_HIGH,
"mpeg2 high" },
69 { MFX_PROFILE_HEVC_MAIN,
"hevc main" },
70 { MFX_PROFILE_HEVC_MAIN10,
"hevc main10" },
71 { MFX_PROFILE_HEVC_MAINSP,
"hevc mainsp" },
72 { MFX_PROFILE_HEVC_REXT,
"hevc rext" },
73 #if QSV_VERSION_ATLEAST(1, 32)
74 { MFX_PROFILE_HEVC_SCC,
"hevc scc" },
79 { MFX_PROFILE_VP9_0,
"vp9 0" },
80 { MFX_PROFILE_VP9_1,
"vp9 1" },
81 { MFX_PROFILE_VP9_2,
"vp9 2" },
82 { MFX_PROFILE_VP9_3,
"vp9 3" },
121 for (
i = 0;
i < num_profiles;
i++)
128 static const struct {
132 { MFX_RATECONTROL_CBR,
"CBR" },
133 { MFX_RATECONTROL_VBR,
"VBR" },
134 { MFX_RATECONTROL_CQP,
"CQP" },
136 { MFX_RATECONTROL_AVBR,
"AVBR" },
138 { MFX_RATECONTROL_LA,
"LA" },
139 { MFX_RATECONTROL_ICQ,
"ICQ" },
140 { MFX_RATECONTROL_LA_ICQ,
"LA_ICQ" },
142 { MFX_RATECONTROL_VCM,
"VCM" },
144 { MFX_RATECONTROL_LA_EXT,
"LA_EXT" },
145 { MFX_RATECONTROL_LA_HRD,
"LA_HRD" },
146 { MFX_RATECONTROL_QVBR,
"QVBR" },
160 if (
val == MFX_CODINGOPTION_ON)
162 else if (
val == MFX_CODINGOPTION_OFF)
168 mfxExtBuffer **coding_opts)
173 mfxExtCodingOption *co = (mfxExtCodingOption*)coding_opts[1];
174 mfxExtCodingOption2 *co2 =
NULL;
175 mfxExtCodingOption3 *co3 =
NULL;
176 mfxExtHEVCTiles *exthevctiles =
NULL;
179 co2 = (mfxExtCodingOption2*)coding_opts[q->
co2_idx];
182 co3 = (mfxExtCodingOption3*)coding_opts[q->
co3_idx];
191 info->GopPicSize,
info->GopRefDist);
192 if (
info->GopOptFlag & MFX_GOP_CLOSED)
194 if (
info->GopOptFlag & MFX_GOP_STRICT)
201 if (
info->RateControlMethod == MFX_RATECONTROL_CBR ||
202 info->RateControlMethod == MFX_RATECONTROL_VBR
204 ||
info->RateControlMethod == MFX_RATECONTROL_VCM
208 "BufferSizeInKB: %"PRIu16
"; InitialDelayInKB: %"PRIu16
"; TargetKbps: %"PRIu16
"; MaxKbps: %"PRIu16
"; BRCParamMultiplier: %"PRIu16
"\n",
209 info->BufferSizeInKB,
info->InitialDelayInKB,
info->TargetKbps,
info->MaxKbps,
info->BRCParamMultiplier);
210 }
else if (
info->RateControlMethod == MFX_RATECONTROL_CQP) {
215 else if (
info->RateControlMethod == MFX_RATECONTROL_AVBR) {
217 "TargetKbps: %"PRIu16
"; Accuracy: %"PRIu16
"; Convergence: %"PRIu16
"; BRCParamMultiplier: %"PRIu16
"\n",
218 info->TargetKbps,
info->Accuracy,
info->Convergence,
info->BRCParamMultiplier);
221 else if (
info->RateControlMethod == MFX_RATECONTROL_LA
222 ||
info->RateControlMethod == MFX_RATECONTROL_LA_HRD
225 "TargetKbps: %"PRIu16
"; BRCParamMultiplier: %"PRIu16
"\n",
226 info->TargetKbps,
info->BRCParamMultiplier);
227 }
else if (
info->RateControlMethod == MFX_RATECONTROL_ICQ ||
228 info->RateControlMethod == MFX_RATECONTROL_LA_ICQ)
240 co->CAVLC == MFX_CODINGOPTION_ON ?
"CAVLC" :
"CABAC", co->MaxDecFrameBuffering);
242 "NalHrdConformance: %s; SingleSeiNalUnit: %s; VuiVclHrdParameters: %s VuiNalHrdParameters: %s\n",
247 "NalHrdConformance: %s; VuiNalHrdParameters: %s\n",
252 info->FrameInfo.FrameRateExtD,
info->FrameInfo.FrameRateExtN);
256 (
info->RateControlMethod == MFX_RATECONTROL_LA) ||
257 (
info->RateControlMethod == MFX_RATECONTROL_LA_HRD) ||
258 (
info->RateControlMethod == MFX_RATECONTROL_LA_ICQ))
261 av_log(avctx,
AV_LOG_VERBOSE,
"IntRefType: %"PRIu16
"; IntRefCycleSize: %"PRIu16
"; IntRefQPDelta: %"PRId16
"\n",
262 co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);
269 "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n",
274 if (co2->Trellis & MFX_TRELLIS_OFF) {
276 }
else if (!co2->Trellis) {
286 "RepeatPPS: %s; NumMbPerSlice: %"PRIu16
"; LookAheadDS: ",
288 switch (co2->LookAheadDS) {
298 switch (co2->BRefType) {
305 "MinQPI: %"PRIu8
"; MaxQPI: %"PRIu8
"; MinQPP: %"PRIu8
"; MaxQPP: %"PRIu8
"; MinQPB: %"PRIu8
"; MaxQPB: %"PRIu8
"\n",
306 co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB);
311 if (
info->RateControlMethod == MFX_RATECONTROL_QVBR)
315 switch (co3->PRefType) {
335 exthevctiles->NumTileColumns, exthevctiles->NumTileRows);
340 mfxExtBuffer **coding_opts)
343 mfxExtVP9Param *vp9_param =
NULL;
344 mfxExtCodingOption2 *co2 =
NULL;
347 vp9_param = (mfxExtVP9Param *)coding_opts[q->
vp9_idx];
350 co2 = (mfxExtCodingOption2*)coding_opts[q->
co2_idx];
356 info->GopPicSize,
info->GopRefDist);
357 if (
info->GopOptFlag & MFX_GOP_CLOSED)
359 if (
info->GopOptFlag & MFX_GOP_STRICT)
366 if (
info->RateControlMethod == MFX_RATECONTROL_CBR ||
367 info->RateControlMethod == MFX_RATECONTROL_VBR) {
369 "BufferSizeInKB: %"PRIu16
"; InitialDelayInKB: %"PRIu16
"; TargetKbps: %"PRIu16
"; MaxKbps: %"PRIu16
"; BRCParamMultiplier: %"PRIu16
"\n",
370 info->BufferSizeInKB,
info->InitialDelayInKB,
info->TargetKbps,
info->MaxKbps,
info->BRCParamMultiplier);
371 }
else if (
info->RateControlMethod == MFX_RATECONTROL_CQP) {
375 else if (
info->RateControlMethod == MFX_RATECONTROL_ICQ) {
384 info->FrameInfo.FrameRateExtD,
info->FrameInfo.FrameRateExtN);
388 "IntRefType: %"PRIu16
"; IntRefCycleSize: %"PRIu16
"; IntRefQPDelta: %"PRId16
"\n",
389 co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);
395 "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n",
402 "MinQPI: %"PRIu8
"; MaxQPI: %"PRIu8
"; MinQPP: %"PRIu8
"; MaxQPP: %"PRIu8
"; MinQPB: %"PRIu8
"; MaxQPB: %"PRIu8
"\n",
403 co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB);
421 info->FrameInfo.FrameRateExtD,
info->FrameInfo.FrameRateExtN);
431 int want_vcm = q->
vcm;
435 "VCM ratecontrol mode requested, but is not supported by this SDK version\n");
439 if (want_la + want_qscale + want_vcm > 1) {
441 "More than one of: { constant qscale, lookahead, VCM } requested, "
442 "only one of them can be used at a time.\n");
448 rc_desc =
"constant quantization parameter (CQP)";
453 rc_desc =
"video conferencing mode (VCM)";
458 rc_desc =
"VBR with lookahead (LA)";
461 rc_mode = MFX_RATECONTROL_LA_ICQ;
462 rc_desc =
"intelligent constant quality with lookahead (LA_ICQ)";
467 rc_desc =
"intelligent constant quality (ICQ)";
471 rc_desc =
"constant bitrate (CBR)";
475 rc_mode = MFX_RATECONTROL_AVBR;
476 rc_desc =
"average variable bitrate (AVBR)";
480 rc_mode = MFX_RATECONTROL_QVBR;
481 rc_desc =
"constant quality with VBR algorithm (QVBR)";
485 rc_desc =
"variable bitrate (VBR)";
496 mfxVideoParam param_out = { .mfx.CodecId = q->
param.mfx.CodecId };
499 #define UNMATCH(x) (param_out.mfx.x != q->param.mfx.x)
508 if (
UNMATCH(RateControlMethod))
537 if (avctx->
level > 0)
549 q->
param.mfx.FrameInfo.CropX = 0;
550 q->
param.mfx.FrameInfo.CropY = 0;
555 q->
param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420 +
556 !
desc->log2_chroma_w + !
desc->log2_chroma_h;
557 q->
param.mfx.FrameInfo.BitDepthLuma =
desc->comp[0].depth;
558 q->
param.mfx.FrameInfo.BitDepthChroma =
desc->comp[0].depth;
559 q->
param.mfx.FrameInfo.Shift =
desc->comp[0].depth > 8;
567 q->
param.mfx.FrameInfo.Width = frames_hwctx->surfaces[0].Info.Width;
568 q->
param.mfx.FrameInfo.Height = frames_hwctx->surfaces[0].Info.Height;
579 q->
param.mfx.Interleaved = 1;
581 q->
param.mfx.RestartInterval = 0;
598 int target_bitrate_kbps, max_bitrate_kbps, brc_param_multiplier;
599 int buffer_size_in_kilobytes, initial_delay_in_kilobytes;
607 if (avctx->
level > 0)
615 "valid range is 0-%d, using %d instead\n",
616 MFX_TARGETUSAGE_BEST_SPEED, MFX_TARGETUSAGE_BEST_SPEED);
622 q->
param.mfx.LowPower = MFX_CODINGOPTION_ON;
624 q->
param.mfx.LowPower = MFX_CODINGOPTION_UNKNOWN;
626 q->
param.mfx.LowPower = MFX_CODINGOPTION_OFF;
633 MFX_GOP_CLOSED : MFX_GOP_STRICT;
637 q->
param.mfx.EncodedOrder = 0;
638 q->
param.mfx.BufferSizeInKB = 0;
648 q->
param.mfx.FrameInfo.CropX = 0;
649 q->
param.mfx.FrameInfo.CropY = 0;
654 q->
param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420 +
655 !
desc->log2_chroma_w + !
desc->log2_chroma_h;
656 q->
param.mfx.FrameInfo.BitDepthLuma =
desc->comp[0].depth;
657 q->
param.mfx.FrameInfo.BitDepthChroma =
desc->comp[0].depth;
658 q->
param.mfx.FrameInfo.Shift =
desc->comp[0].depth > 8;
670 q->
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
674 q->
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
685 q->
param.mfx.FrameInfo.Width = frames_hwctx->surfaces[0].Info.Width;
686 q->
param.mfx.FrameInfo.Height = frames_hwctx->surfaces[0].Info.Height;
704 target_bitrate_kbps = avctx->
bit_rate / 1000;
706 brc_param_multiplier = (
FFMAX(
FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes),
707 initial_delay_in_kilobytes) + 0x10000) / 0x10000;
709 switch (q->
param.mfx.RateControlMethod) {
710 case MFX_RATECONTROL_CBR:
711 case MFX_RATECONTROL_VBR:
716 case MFX_RATECONTROL_VCM:
718 case MFX_RATECONTROL_QVBR:
719 q->
param.mfx.BufferSizeInKB = buffer_size_in_kilobytes / brc_param_multiplier;
720 q->
param.mfx.InitialDelayInKB = initial_delay_in_kilobytes / brc_param_multiplier;
721 q->
param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier;
722 q->
param.mfx.MaxKbps = max_bitrate_kbps / brc_param_multiplier;
723 q->
param.mfx.BRCParamMultiplier = brc_param_multiplier;
724 if (q->
param.mfx.RateControlMethod == MFX_RATECONTROL_QVBR)
727 case MFX_RATECONTROL_CQP:
736 case MFX_RATECONTROL_AVBR:
737 q->
param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier;
740 q->
param.mfx.BRCParamMultiplier = brc_param_multiplier;
743 case MFX_RATECONTROL_LA:
744 q->
param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier;
746 q->
param.mfx.BRCParamMultiplier = brc_param_multiplier;
748 case MFX_RATECONTROL_LA_ICQ:
750 case MFX_RATECONTROL_ICQ:
760 q->
extco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
764 MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
767 q->
extco.RateDistortionOpt = q->
rdo > 0 ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
770 q->
extco.CAVLC = q->
cavlc ? MFX_CODINGOPTION_ON
771 : MFX_CODINGOPTION_UNKNOWN;
775 MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
782 q->
extco.AUDelimiter = q->
aud ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
786 MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
791 q->
extco.AUDelimiter = q->
aud ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
801 q->
extco2.Trellis = (avctx->
trellis == 0) ? MFX_TRELLIS_OFF : (MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B);
803 q->
extco2.Trellis = MFX_TRELLIS_UNKNOWN;
806 q->
extco2.RepeatPPS = q->
repeat_pps ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
809 q->
extco2.AdaptiveI = q->
adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
811 q->
extco2.AdaptiveB = q->
adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
816 q->
extco2.ExtBRC = q->
extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
832 av_log(avctx,
AV_LOG_ERROR,
"qmin and or qmax are set but invalid, please make sure min <= max\n");
835 if (avctx->
qmin >= 0) {
839 if (avctx->
qmax >= 0) {
844 q->
extco2.MBBRC = q->
mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
846 q->
extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
855 q->
extmfp.Header.BufferId = MFX_EXTBUFF_MULTI_FRAME_PARAM;
864 q->
extco3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3;
871 q->
extco3.PRefType = MFX_P_REF_DEFAULT;
874 q->
extco3.PRefType = MFX_P_REF_SIMPLE;
877 q->
extco3.PRefType = MFX_P_REF_PYRAMID;
880 q->
extco3.PRefType = MFX_P_REF_DEFAULT;
882 "invalid p_strategy, set to default\n");
885 if (q->
extco3.PRefType == MFX_P_REF_PYRAMID &&
888 "Please set max_b_frames(-bf) to 0 to enable P-pyramid\n");
903 MFX_CODINGOPTION_OFF;
905 q->
extco3.TransformSkip = MFX_CODINGOPTION_UNKNOWN;
906 q->
extco3.GPB = q->
gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
912 q->
extvp9param.Header.BufferId = MFX_EXTBUFF_VP9_PARAM;
914 q->
extvp9param.WriteIVFHeaders = MFX_CODINGOPTION_OFF;
915 #if QSV_HAVE_EXT_VP9_TILES
923 q->
exthevctiles.Header.BufferId = MFX_EXTBUFF_HEVC_TILES;
931 q->
extvsi.ColourDescriptionPresent = 0;
936 q->
extvsi.ColourDescriptionPresent = 1;
942 if (q->
extvsi.VideoFullRange || q->
extvsi.ColourDescriptionPresent) {
943 q->
extvsi.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO;
950 "some encoding parameters are not supported by the QSV "
951 "runtime. Please double check the input parameters.\n");
965 "Error calling GetVideoParam");
981 mfxExtVP9Param vp9_extend_buf = {
982 .Header.BufferId = MFX_EXTBUFF_VP9_PARAM,
983 .Header.BufferSz =
sizeof(vp9_extend_buf),
986 mfxExtCodingOption2 co2 = {
987 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2,
988 .Header.BufferSz =
sizeof(co2),
991 mfxExtCodingOption3 co3 = {
992 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION3,
993 .Header.BufferSz =
sizeof(co3),
996 mfxExtBuffer *ext_buffers[3];
1004 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co2;
1009 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co3;
1014 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&vp9_extend_buf;
1017 q->
param.ExtParam = ext_buffers;
1018 q->
param.NumExtParam = ext_buf_num;
1023 "Error calling GetVideoParam");
1036 uint8_t sps_buf[128];
1037 uint8_t pps_buf[128];
1039 mfxExtCodingOptionSPSPPS extradata = {
1040 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION_SPSPPS,
1041 .Header.BufferSz =
sizeof(extradata),
1042 .SPSBuffer = sps_buf, .SPSBufSize =
sizeof(sps_buf),
1043 .PPSBuffer = pps_buf, .PPSBufSize =
sizeof(pps_buf)
1046 mfxExtCodingOption co = {
1047 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION,
1048 .Header.BufferSz =
sizeof(co),
1050 mfxExtCodingOption2 co2 = {
1051 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2,
1052 .Header.BufferSz =
sizeof(co2),
1054 mfxExtCodingOption3 co3 = {
1055 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION3,
1056 .Header.BufferSz =
sizeof(co3),
1059 uint8_t vps_buf[128];
1060 mfxExtCodingOptionVPS extradata_vps = {
1061 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION_VPS,
1062 .Header.BufferSz =
sizeof(extradata_vps),
1063 .VPSBuffer = vps_buf,
1064 .VPSBufSize =
sizeof(vps_buf),
1067 mfxExtHEVCTiles hevc_tile_buf = {
1068 .Header.BufferId = MFX_EXTBUFF_HEVC_TILES,
1069 .Header.BufferSz =
sizeof(hevc_tile_buf),
1072 mfxExtBuffer *ext_buffers[6];
1075 int ret, ext_buf_num = 0, extradata_offset = 0;
1078 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata;
1079 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co;
1084 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co2;
1089 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co3;
1094 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata_vps;
1097 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&hevc_tile_buf;
1100 q->
param.ExtParam = ext_buffers;
1101 q->
param.NumExtParam = ext_buf_num;
1106 "Error calling GetVideoParam");
1110 if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize)
1111 || (q->
hevc_vps && !extradata_vps.VPSBufSize)
1117 avctx->
extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize;
1125 memcpy(avctx->
extradata, vps_buf, extradata_vps.VPSBufSize);
1126 extradata_offset += extradata_vps.VPSBufSize;
1129 memcpy(avctx->
extradata + extradata_offset, sps_buf, extradata.SPSBufSize);
1130 extradata_offset += extradata.SPSBufSize;
1132 memcpy(avctx->
extradata + extradata_offset, pps_buf, extradata.PPSBufSize);
1133 extradata_offset += extradata.PPSBufSize;
1153 mfxFrameSurface1 *surfaces;
1167 for (
i = 0;
i < nb_surfaces;
i++) {
1168 surfaces[
i].Info = q->
req.Info;
1172 q->
opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
1201 q->
param.IOPattern == MFX_IOPATTERN_IN_OPAQUE_MEMORY,
1232 int opaque_alloc = 0;
1253 if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
1254 iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;
1255 else if (frames_hwctx->frame_type &
1256 (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
1257 iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY;
1262 iopattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
1263 q->
param.IOPattern = iopattern;
1273 "Error querying mfx version");
1307 if (j < qsv->nb_ext_buffers)
1318 if (
ret == MFX_WRN_PARTIAL_ACCELERATION) {
1320 }
else if (
ret < 0) {
1322 "Error querying encoder params");
1328 "Error querying (IOSurf) the encoding parameters");
1339 "Error initializing the encoder");
1342 "Warning in encoder initialization");
1372 enc_ctrl->NumPayload = 0;
1409 last = &
frame->next;
1417 if (!
frame->frame) {
1488 !
frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
1489 frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
1490 MFX_PICSTRUCT_FIELD_BFF;
1491 if (
frame->repeat_pict == 1)
1492 qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
1493 else if (
frame->repeat_pict == 2)
1494 qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
1495 else if (
frame->repeat_pict == 4)
1496 qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
1513 if (q->
param.mfx.CodecId == MFX_CODEC_AVC) {
1514 if (q->
param.mfx.CodecProfile == MFX_PROFILE_AVC_BASELINE ||
1515 q->
param.mfx.CodecLevel < MFX_LEVEL_AVC_21 ||
1516 q->
param.mfx.CodecLevel > MFX_LEVEL_AVC_41)
1518 "Interlaced coding is supported"
1519 " at Main/High Profile Level 2.2-4.0\n");
1527 mfxExtAVCEncodedFrameInfo *enc_info =
NULL;
1528 mfxExtBuffer **enc_buf =
NULL;
1530 mfxFrameSurface1 *surf =
NULL;
1532 mfxEncodeCtrl* enc_ctrl =
NULL;
1547 enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
1549 enc_ctrl->FrameType |= MFX_FRAMETYPE_IDR;
1570 enc_info->Header.BufferId = MFX_EXTBUFF_ENCODED_FRAME_INFO;
1571 enc_info->Header.BufferSz =
sizeof (*enc_info);
1572 pkt.bs->NumExtParam = 1;
1573 enc_buf =
av_mallocz(
sizeof(mfxExtBuffer *));
1576 enc_buf[0] = (mfxExtBuffer *)enc_info;
1578 pkt.bs->ExtParam = enc_buf;
1590 ret = MFXVideoENCODE_EncodeFrameAsync(q->
session, enc_ctrl, surf,
pkt.bs,
pkt.sync);
1591 if (
ret == MFX_WRN_DEVICE_BUSY)
1593 }
while (
ret == MFX_WRN_DEVICE_BUSY ||
ret == MFX_WRN_IN_EXECUTION);
1599 ret = (
ret == MFX_ERR_MORE_DATA) ?
1604 if (
ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM &&
frame &&
frame->interlaced_frame)
1640 mfxExtAVCEncodedFrameInfo *enc_info;
1641 mfxExtBuffer **enc_buf;
1648 }
while (
ret == MFX_WRN_IN_EXECUTION);
1654 if (qpkt.
bs->FrameType & MFX_FRAMETYPE_IDR || qpkt.
bs->FrameType & MFX_FRAMETYPE_xIDR) {
1657 }
else if (qpkt.
bs->FrameType & MFX_FRAMETYPE_I || qpkt.
bs->FrameType & MFX_FRAMETYPE_xI)
1659 else if (qpkt.
bs->FrameType & MFX_FRAMETYPE_P || qpkt.
bs->FrameType & MFX_FRAMETYPE_xP)
1661 else if (qpkt.
bs->FrameType & MFX_FRAMETYPE_B || qpkt.
bs->FrameType & MFX_FRAMETYPE_xB)
1663 else if (qpkt.
bs->FrameType == MFX_FRAMETYPE_UNKNOWN) {
1672 enc_buf = qpkt.
bs->ExtParam;
1673 enc_info = (mfxExtAVCEncodedFrameInfo *)(*enc_buf);
1695 MFXVideoENCODE_Close(q->
session);
1716 mfxExtBuffer **enc_buf =
pkt.bs->ExtParam;
1717 mfxExtAVCEncodedFrameInfo *enc_info = (mfxExtAVCEncodedFrameInfo *)(*enc_buf);