25 #include <sys/types.h>
26 #include <mfx/mfxvideo.h>
48 { MFX_PROFILE_AVC_BASELINE,
"baseline" },
49 { MFX_PROFILE_AVC_MAIN,
"main" },
50 { MFX_PROFILE_AVC_EXTENDED,
"extended" },
51 { MFX_PROFILE_AVC_HIGH,
"high" },
52 #if QSV_VERSION_ATLEAST(1, 15)
53 { MFX_PROFILE_AVC_HIGH_422,
"high 422" },
55 #if QSV_VERSION_ATLEAST(1, 4)
56 { MFX_PROFILE_AVC_CONSTRAINED_BASELINE,
"constrained baseline" },
57 { MFX_PROFILE_AVC_CONSTRAINED_HIGH,
"constrained high" },
58 { MFX_PROFILE_AVC_PROGRESSIVE_HIGH,
"progressive high" },
60 { MFX_PROFILE_MPEG2_SIMPLE,
"simple" },
61 { MFX_PROFILE_MPEG2_MAIN,
"main" },
62 { MFX_PROFILE_MPEG2_HIGH,
"high" },
63 { MFX_PROFILE_VC1_SIMPLE,
"simple" },
64 { MFX_PROFILE_VC1_MAIN,
"main" },
65 { MFX_PROFILE_VC1_ADVANCED,
"advanced" },
66 #if QSV_VERSION_ATLEAST(1, 8)
67 { MFX_PROFILE_HEVC_MAIN,
"main" },
68 { MFX_PROFILE_HEVC_MAIN10,
"main10" },
69 { MFX_PROFILE_HEVC_MAINSP,
"mainsp" },
70 { MFX_PROFILE_HEVC_REXT,
"rext" },
87 { MFX_RATECONTROL_CBR,
"CBR" },
88 { MFX_RATECONTROL_VBR,
"VBR" },
89 { MFX_RATECONTROL_CQP,
"CQP" },
91 { MFX_RATECONTROL_AVBR,
"AVBR" },
94 { MFX_RATECONTROL_LA,
"LA" },
97 { MFX_RATECONTROL_ICQ,
"ICQ" },
98 { MFX_RATECONTROL_LA_ICQ,
"LA_ICQ" },
101 { MFX_RATECONTROL_VCM,
"VCM" },
103 #if QSV_VERSION_ATLEAST(1, 10)
104 { MFX_RATECONTROL_LA_EXT,
"LA_EXT" },
107 { MFX_RATECONTROL_LA_HRD,
"LA_HRD" },
110 { MFX_RATECONTROL_QVBR,
"QVBR" },
125 if (
val == MFX_CODINGOPTION_ON)
127 else if (
val == MFX_CODINGOPTION_OFF)
133 mfxExtBuffer **coding_opts)
137 mfxExtCodingOption *co = (mfxExtCodingOption*)coding_opts[0];
139 mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
142 mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
144 #if QSV_HAVE_EXT_HEVC_TILES
145 mfxExtHEVCTiles *exthevctiles = (mfxExtHEVCTiles *)coding_opts[3 +
QSV_HAVE_CO_VPS];
152 info->GopPicSize,
info->GopRefDist);
153 if (
info->GopOptFlag & MFX_GOP_CLOSED)
155 if (
info->GopOptFlag & MFX_GOP_STRICT)
162 if (
info->RateControlMethod == MFX_RATECONTROL_CBR ||
163 info->RateControlMethod == MFX_RATECONTROL_VBR
165 ||
info->RateControlMethod == MFX_RATECONTROL_VCM
169 "BufferSizeInKB: %"PRIu16
"; InitialDelayInKB: %"PRIu16
"; TargetKbps: %"PRIu16
"; MaxKbps: %"PRIu16
"; BRCParamMultiplier: %"PRIu16
"\n",
170 info->BufferSizeInKB,
info->InitialDelayInKB,
info->TargetKbps,
info->MaxKbps,
info->BRCParamMultiplier);
171 }
else if (
info->RateControlMethod == MFX_RATECONTROL_CQP) {
176 else if (
info->RateControlMethod == MFX_RATECONTROL_AVBR) {
178 "TargetKbps: %"PRIu16
"; Accuracy: %"PRIu16
"; Convergence: %"PRIu16
"; BRCParamMultiplier: %"PRIu16
"\n",
179 info->TargetKbps,
info->Accuracy,
info->Convergence,
info->BRCParamMultiplier);
183 else if (
info->RateControlMethod == MFX_RATECONTROL_LA
185 ||
info->RateControlMethod == MFX_RATECONTROL_LA_HRD
189 "TargetKbps: %"PRIu16
"; LookAheadDepth: %"PRIu16
"; BRCParamMultiplier: %"PRIu16
"\n",
190 info->TargetKbps, co2->LookAheadDepth,
info->BRCParamMultiplier);
194 else if (
info->RateControlMethod == MFX_RATECONTROL_ICQ) {
196 }
else if (
info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) {
198 info->ICQQuality, co2->LookAheadDepth);
202 else if (
info->RateControlMethod == MFX_RATECONTROL_QVBR) {
212 #if QSV_HAVE_EXT_HEVC_TILES
215 exthevctiles->NumTileColumns, exthevctiles->NumTileRows);
220 "RecoveryPointSEI: %s IntRefType: %"PRIu16
"; IntRefCycleSize: %"PRIu16
"; IntRefQPDelta: %"PRId16
"\n",
221 print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);
224 #if QSV_HAVE_MAX_SLICE_SIZE
230 "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n",
236 if (co2->Trellis & MFX_TRELLIS_OFF) {
238 }
else if (!co2->Trellis) {
252 #if QSV_VERSION_ATLEAST(1, 8)
254 "RepeatPPS: %s; NumMbPerSlice: %"PRIu16
"; LookAheadDS: ",
256 switch (co2->LookAheadDS) {
266 switch (co2->BRefType) {
274 #if QSV_VERSION_ATLEAST(1, 9)
276 "MinQPI: %"PRIu8
"; MaxQPI: %"PRIu8
"; MinQPP: %"PRIu8
"; MaxQPP: %"PRIu8
"; MinQPB: %"PRIu8
"; MaxQPB: %"PRIu8
"\n",
277 co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB);
288 co->CAVLC == MFX_CODINGOPTION_ON ?
"CAVLC" :
"CABAC", co->MaxDecFrameBuffering);
290 "NalHrdConformance: %s; SingleSeiNalUnit: %s; VuiVclHrdParameters: %s VuiNalHrdParameters: %s\n",
296 info->FrameInfo.FrameRateExtD,
info->FrameInfo.FrameRateExtN);
307 int want_vcm = q->
vcm;
311 "Lookahead ratecontrol mode requested, but is not supported by this SDK version\n");
316 "VCM ratecontrol mode requested, but is not supported by this SDK version\n");
320 if (want_la + want_qscale + want_vcm > 1) {
322 "More than one of: { constant qscale, lookahead, VCM } requested, "
323 "only one of them can be used at a time.\n");
329 "ICQ ratecontrol mode requested, but is not supported by this SDK version\n");
335 rc_desc =
"constant quantization parameter (CQP)";
340 rc_desc =
"video conferencing mode (VCM)";
346 rc_desc =
"VBR with lookahead (LA)";
350 rc_mode = MFX_RATECONTROL_LA_ICQ;
351 rc_desc =
"intelligent constant quality with lookahead (LA_ICQ)";
359 rc_desc =
"intelligent constant quality (ICQ)";
364 rc_desc =
"constant bitrate (CBR)";
368 rc_mode = MFX_RATECONTROL_AVBR;
369 rc_desc =
"average variable bitrate (AVBR)";
374 rc_mode = MFX_RATECONTROL_QVBR;
375 rc_desc =
"constant quality with VBR algorithm (QVBR)";
380 rc_desc =
"variable bitrate (VBR)";
391 mfxVideoParam param_out = { .mfx.CodecId = q->
param.mfx.CodecId };
394 #define UNMATCH(x) (param_out.mfx.x != q->param.mfx.x)
403 if (
UNMATCH(RateControlMethod))
432 if (avctx->
level > 0)
442 q->
param.mfx.FrameInfo.CropX = 0;
443 q->
param.mfx.FrameInfo.CropY = 0;
448 q->
param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
449 q->
param.mfx.FrameInfo.BitDepthLuma =
desc->comp[0].depth;
450 q->
param.mfx.FrameInfo.BitDepthChroma =
desc->comp[0].depth;
451 q->
param.mfx.FrameInfo.Shift =
desc->comp[0].depth > 8;
459 q->
param.mfx.FrameInfo.Width = frames_hwctx->surfaces[0].Info.Width;
460 q->
param.mfx.FrameInfo.Height = frames_hwctx->surfaces[0].Info.Height;
471 q->
param.mfx.Interleaved = 1;
473 q->
param.mfx.RestartInterval = 0;
490 int target_bitrate_kbps, max_bitrate_kbps, brc_param_multiplier;
491 int buffer_size_in_kilobytes, initial_delay_in_kilobytes;
499 if (avctx->
level > 0)
507 "valid range is 0-%d, using %d instead\n",
508 MFX_TARGETUSAGE_BEST_SPEED, MFX_TARGETUSAGE_BEST_SPEED);
515 q->
param.mfx.LowPower = MFX_CODINGOPTION_ON;
518 "not supported with this MSDK version.\n");
520 q->
param.mfx.LowPower = MFX_CODINGOPTION_OFF;
523 q->
param.mfx.LowPower = MFX_CODINGOPTION_OFF;
534 q->
param.mfx.EncodedOrder = 0;
535 q->
param.mfx.BufferSizeInKB = 0;
543 q->
param.mfx.FrameInfo.CropX = 0;
544 q->
param.mfx.FrameInfo.CropY = 0;
549 q->
param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420 +
550 !
desc->log2_chroma_w + !
desc->log2_chroma_h;
551 q->
param.mfx.FrameInfo.BitDepthLuma =
desc->comp[0].depth;
552 q->
param.mfx.FrameInfo.BitDepthChroma =
desc->comp[0].depth;
553 q->
param.mfx.FrameInfo.Shift =
desc->comp[0].depth > 8;
565 q->
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
569 q->
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
580 q->
param.mfx.FrameInfo.Width = frames_hwctx->surfaces[0].Info.Width;
581 q->
param.mfx.FrameInfo.Height = frames_hwctx->surfaces[0].Info.Height;
599 target_bitrate_kbps = avctx->
bit_rate / 1000;
601 brc_param_multiplier = (
FFMAX(
FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes),
602 initial_delay_in_kilobytes) + 0x10000) / 0x10000;
604 switch (q->
param.mfx.RateControlMethod) {
605 case MFX_RATECONTROL_CBR:
606 case MFX_RATECONTROL_VBR:
608 case MFX_RATECONTROL_VCM:
611 case MFX_RATECONTROL_QVBR:
613 q->
param.mfx.BufferSizeInKB = buffer_size_in_kilobytes / brc_param_multiplier;
614 q->
param.mfx.InitialDelayInKB = initial_delay_in_kilobytes / brc_param_multiplier;
615 q->
param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier;
616 q->
param.mfx.MaxKbps = max_bitrate_kbps / brc_param_multiplier;
617 q->
param.mfx.BRCParamMultiplier = brc_param_multiplier;
619 if (q->
param.mfx.RateControlMethod == MFX_RATECONTROL_QVBR)
623 case MFX_RATECONTROL_CQP:
632 case MFX_RATECONTROL_AVBR:
633 q->
param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier;
636 q->
param.mfx.BRCParamMultiplier = brc_param_multiplier;
640 case MFX_RATECONTROL_LA:
641 q->
param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier;
643 q->
param.mfx.BRCParamMultiplier = brc_param_multiplier;
646 case MFX_RATECONTROL_LA_ICQ:
648 case MFX_RATECONTROL_ICQ:
660 q->
extco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
664 MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
667 q->
extco.RateDistortionOpt = q->
rdo > 0 ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
670 #if FF_API_CODER_TYPE
676 q->
extco.CAVLC = q->
cavlc ? MFX_CODINGOPTION_ON
677 : MFX_CODINGOPTION_UNKNOWN;
681 MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
688 q->
extco.AUDelimiter = q->
aud ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
703 q->extco2.BitrateLimit = q->
bitrate_limit ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
705 q->extco2.MBBRC = q->
mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
709 #if QSV_HAVE_MAX_SLICE_SIZE
716 q->extco2.Trellis = (avctx->
trellis == 0) ? MFX_TRELLIS_OFF : (MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B);
718 q->extco2.Trellis = MFX_TRELLIS_UNKNOWN;
721 #if QSV_VERSION_ATLEAST(1, 8)
723 q->extco2.RepeatPPS = q->
repeat_pps ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
725 #if FF_API_PRIVATE_OPT
732 q->extco2.BRefType = q->
b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
734 q->extco2.AdaptiveI = q->
adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
736 q->extco2.AdaptiveB = q->
adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
742 q->extco2.ExtBRC = q->
extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
744 #if QSV_VERSION_ATLEAST(1, 9)
746 av_log(avctx,
AV_LOG_ERROR,
"qmin and or qmax are set but invalid, please make sure min <= max\n");
749 if (avctx->
qmin >= 0) {
750 q->extco2.MinQPI = avctx->
qmin > 51 ? 51 : avctx->
qmin;
751 q->extco2.MinQPP = q->extco2.MinQPB = q->extco2.MinQPI;
753 if (avctx->
qmax >= 0) {
754 q->extco2.MaxQPI = avctx->
qmax > 51 ? 51 : avctx->
qmax;
755 q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI;
758 q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
759 q->extco2.Header.BufferSz =
sizeof(q->extco2);
768 q->extmfp.Header.BufferId = MFX_EXTBUFF_MULTI_FRAME_PARAM;
769 q->extmfp.Header.BufferSz =
sizeof(q->extmfp);
771 q->extmfp.MFMode = q->mfmode;
778 q->extco3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3;
779 q->extco3.Header.BufferSz =
sizeof(q->extco3);
782 q->extco3.GPB = q->
gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
788 #if QSV_HAVE_EXT_VP9_PARAM
790 q->extvp9param.Header.BufferId = MFX_EXTBUFF_VP9_PARAM;
791 q->extvp9param.Header.BufferSz =
sizeof(q->extvp9param);
792 q->extvp9param.WriteIVFHeaders = MFX_CODINGOPTION_OFF;
797 #if QSV_HAVE_EXT_HEVC_TILES
799 q->exthevctiles.Header.BufferId = MFX_EXTBUFF_HEVC_TILES;
800 q->exthevctiles.Header.BufferSz =
sizeof(q->exthevctiles);
801 q->exthevctiles.NumTileColumns = q->
tile_cols;
802 q->exthevctiles.NumTileRows = q->
tile_rows;
809 "some encoding parameters are not supported by the QSV "
810 "runtime. Please double check the input parameters.\n");
824 "Error calling GetVideoParam");
838 #if QSV_HAVE_EXT_VP9_PARAM
839 mfxExtVP9Param vp9_extend_buf = {
840 .Header.BufferId = MFX_EXTBUFF_VP9_PARAM,
841 .Header.BufferSz =
sizeof(vp9_extend_buf),
846 mfxExtCodingOption2 co2 = {
847 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2,
848 .Header.BufferSz =
sizeof(co2),
853 mfxExtCodingOption3 co3 = {
854 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION3,
855 .Header.BufferSz =
sizeof(co3),
859 mfxExtBuffer *ext_buffers[] = {
860 #if QSV_HAVE_EXT_VP9_PARAM
861 (mfxExtBuffer*)&vp9_extend_buf,
871 q->
param.ExtParam = ext_buffers;
877 "Error calling GetVideoParam");
891 mfxExtCodingOptionSPSPPS extradata = {
892 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION_SPSPPS,
893 .Header.BufferSz =
sizeof(extradata),
894 .SPSBuffer = sps_buf, .SPSBufSize =
sizeof(sps_buf),
895 .PPSBuffer = pps_buf, .PPSBufSize =
sizeof(pps_buf)
898 mfxExtCodingOption co = {
899 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION,
900 .Header.BufferSz =
sizeof(co),
903 mfxExtCodingOption2 co2 = {
904 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2,
905 .Header.BufferSz =
sizeof(co2),
909 mfxExtCodingOption3 co3 = {
910 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION3,
911 .Header.BufferSz =
sizeof(co3),
917 mfxExtCodingOptionVPS extradata_vps = {
918 .Header.BufferId = MFX_EXTBUFF_CODING_OPTION_VPS,
919 .Header.BufferSz =
sizeof(extradata_vps),
920 .VPSBuffer = vps_buf,
921 .VPSBufSize =
sizeof(vps_buf),
925 #if QSV_HAVE_EXT_HEVC_TILES
926 mfxExtHEVCTiles hevc_tile_buf = {
927 .Header.BufferId = MFX_EXTBUFF_HEVC_TILES,
928 .Header.BufferSz =
sizeof(hevc_tile_buf),
935 int ret, ext_buf_num = 0, extradata_offset = 0;
937 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata;
938 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co;
940 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co2;
943 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co3;
948 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata_vps;
950 #if QSV_HAVE_EXT_HEVC_TILES
952 ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&hevc_tile_buf;
955 q->
param.ExtParam = ext_buffers;
956 q->
param.NumExtParam = ext_buf_num;
961 "Error calling GetVideoParam");
965 if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize)
967 || (q->
hevc_vps && !extradata_vps.VPSBufSize)
974 avctx->
extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize;
985 memcpy(avctx->
extradata, vps_buf, extradata_vps.VPSBufSize);
986 extradata_offset += extradata_vps.VPSBufSize;
990 memcpy(avctx->
extradata + extradata_offset, sps_buf, extradata.SPSBufSize);
991 extradata_offset += extradata.SPSBufSize;
993 memcpy(avctx->
extradata + extradata_offset, pps_buf, extradata.PPSBufSize);
994 extradata_offset += extradata.PPSBufSize;
1014 mfxFrameSurface1 *surfaces;
1028 for (
i = 0;
i < nb_surfaces;
i++) {
1029 surfaces[
i].Info = q->
req.Info;
1033 q->
opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
1062 q->
param.IOPattern == MFX_IOPATTERN_IN_OPAQUE_MEMORY,
1092 return sizeof(
AVPacket) +
sizeof(mfxSyncPoint*) +
sizeof(mfxBitstream*);
1103 int opaque_alloc = 0;
1124 if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
1125 iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;
1126 else if (frames_hwctx->frame_type &
1127 (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
1128 iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY;
1133 iopattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
1134 q->
param.IOPattern = iopattern;
1144 "Error querying mfx version");
1178 if (j < qsv->nb_ext_buffers)
1189 if (
ret == MFX_WRN_PARTIAL_ACCELERATION) {
1191 }
else if (
ret < 0) {
1193 "Error querying encoder params");
1199 "Error querying (IOSurf) the encoding parameters");
1210 "Error initializing the encoder");
1213 "Warning in encoder initialization");
1243 enc_ctrl->NumPayload = 0;
1277 last = &
frame->next;
1285 if (!
frame->frame) {
1290 if (!
frame->enc_ctrl.Payload) {
1359 !
frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
1360 frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
1361 MFX_PICSTRUCT_FIELD_BFF;
1362 if (
frame->repeat_pict == 1)
1363 qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
1364 else if (
frame->repeat_pict == 2)
1365 qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
1366 else if (
frame->repeat_pict == 4)
1367 qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
1383 if (q->
param.mfx.CodecId == MFX_CODEC_AVC) {
1384 if (q->
param.mfx.CodecProfile == MFX_PROFILE_AVC_BASELINE ||
1385 q->
param.mfx.CodecLevel < MFX_LEVEL_AVC_21 ||
1386 q->
param.mfx.CodecLevel > MFX_LEVEL_AVC_41)
1388 "Interlaced coding is supported"
1389 " at Main/High Profile Level 2.2-4.0\n");
1398 #if QSV_VERSION_ATLEAST(1, 26)
1399 mfxExtAVCEncodedFrameInfo *enc_info;
1400 mfxExtBuffer **enc_buf;
1403 mfxFrameSurface1 *surf =
NULL;
1404 mfxSyncPoint *sync =
NULL;
1406 mfxEncodeCtrl* enc_ctrl =
NULL;
1421 enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
1423 enc_ctrl->FrameType |= MFX_FRAMETYPE_IDR;
1438 bs->Data = new_pkt.
data;
1439 bs->MaxLength = new_pkt.
size;
1441 #if QSV_VERSION_ATLEAST(1, 26)
1447 enc_info->Header.BufferId = MFX_EXTBUFF_ENCODED_FRAME_INFO;
1448 enc_info->Header.BufferSz =
sizeof (*enc_info);
1449 bs->NumExtParam = 1;
1450 enc_buf =
av_mallocz(
sizeof(mfxExtBuffer *));
1453 enc_buf[0] = (mfxExtBuffer *)enc_info;
1455 bs->ExtParam = enc_buf;
1466 #if QSV_VERSION_ATLEAST(1, 26)
1477 ret = MFXVideoENCODE_EncodeFrameAsync(q->
session, enc_ctrl, surf, bs, sync);
1478 if (
ret == MFX_WRN_DEVICE_BUSY)
1480 }
while (
ret == MFX_WRN_DEVICE_BUSY ||
ret == MFX_WRN_IN_EXECUTION);
1488 #if QSV_VERSION_ATLEAST(1, 26)
1495 return (
ret == MFX_ERR_MORE_DATA) ?
1499 if (
ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM &&
frame->interlaced_frame)
1510 #if QSV_VERSION_ATLEAST(1, 26)
1535 #if QSV_VERSION_ATLEAST(1, 26)
1536 mfxExtAVCEncodedFrameInfo *enc_info;
1537 mfxExtBuffer **enc_buf;
1546 ret = MFXVideoCORE_SyncOperation(q->
session, *sync, 1000);
1547 }
while (
ret == MFX_WRN_IN_EXECUTION);
1551 new_pkt.
size = bs->DataLength;
1553 if (bs->FrameType & MFX_FRAMETYPE_IDR || bs->FrameType & MFX_FRAMETYPE_xIDR) {
1556 }
else if (bs->FrameType & MFX_FRAMETYPE_I || bs->FrameType & MFX_FRAMETYPE_xI)
1558 else if (bs->FrameType & MFX_FRAMETYPE_P || bs->FrameType & MFX_FRAMETYPE_xP)
1560 else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & MFX_FRAMETYPE_xB)
1562 else if (bs->FrameType == MFX_FRAMETYPE_UNKNOWN) {
1570 #if FF_API_CODED_FRAME
1576 #if QSV_VERSION_ATLEAST(1, 26)
1578 enc_buf = bs->ExtParam;
1579 enc_info = (mfxExtAVCEncodedFrameInfo *)(*bs->ExtParam);
1618 MFXVideoENCODE_Close(q->
session);