| @@ -53,14 +53,10 @@ static const struct profile_names avc_profiles[] = { · 52 unmodified lines |
| 53 | { MFX_PROFILE_AVC_MAIN, "avc main" }, | 53 | { MFX_PROFILE_AVC_MAIN, "avc main" }, |
| 54 | { MFX_PROFILE_AVC_EXTENDED, "avc extended" }, | 54 | { MFX_PROFILE_AVC_EXTENDED, "avc extended" }, |
| 55 | { MFX_PROFILE_AVC_HIGH, "avc high" }, | 55 | { MFX_PROFILE_AVC_HIGH, "avc high" }, |
| 56 | #if QSV_VERSION_ATLEAST(1, 15) | | |
| 57 | { MFX_PROFILE_AVC_HIGH_422, "avc high 422" }, | 56 | { MFX_PROFILE_AVC_HIGH_422, "avc high 422" }, |
| 58 | #endif | | |
| 59 | #if QSV_VERSION_ATLEAST(1, 4) | | |
| 60 | { MFX_PROFILE_AVC_CONSTRAINED_BASELINE, "avc constrained baseline" }, | 57 | { MFX_PROFILE_AVC_CONSTRAINED_BASELINE, "avc constrained baseline" }, |
| 61 | { MFX_PROFILE_AVC_CONSTRAINED_HIGH, "avc constrained high" }, | 58 | { MFX_PROFILE_AVC_CONSTRAINED_HIGH, "avc constrained high" }, |
| 62 | { MFX_PROFILE_AVC_PROGRESSIVE_HIGH, "avc progressive high" }, | 59 | { MFX_PROFILE_AVC_PROGRESSIVE_HIGH, "avc progressive high" }, |
| 63 | #endif | | |
| 64 | }; | 60 | }; |
| 65 | | 61 | |
| 66 | static const struct profile_names mpeg2_profiles[] = { | 62 | static const struct profile_names mpeg2_profiles[] = { |
| @@ -70,24 +66,20 @@ static const struct profile_names mpeg2_profiles[] = { · 3 unmodified lines |
| 70 | }; | 66 | }; |
| 71 | | 67 | |
| 72 | static const struct profile_names hevc_profiles[] = { | 68 | static const struct profile_names hevc_profiles[] = { |
| 73 | #if QSV_VERSION_ATLEAST(1, 8) | | |
| 74 | { MFX_PROFILE_HEVC_MAIN, "hevc main" }, | 69 | { MFX_PROFILE_HEVC_MAIN, "hevc main" }, |
| 75 | { MFX_PROFILE_HEVC_MAIN10, "hevc main10" }, | 70 | { MFX_PROFILE_HEVC_MAIN10, "hevc main10" }, |
| 76 | { MFX_PROFILE_HEVC_MAINSP, "hevc mainsp" }, | 71 | { MFX_PROFILE_HEVC_MAINSP, "hevc mainsp" }, |
| 77 | { MFX_PROFILE_HEVC_REXT, "hevc rext" }, | 72 | { MFX_PROFILE_HEVC_REXT, "hevc rext" }, |
| 78 | #endif | | |
| 79 | #if QSV_VERSION_ATLEAST(1, 32) | 73 | #if QSV_VERSION_ATLEAST(1, 32) |
| 80 | { MFX_PROFILE_HEVC_SCC, "hevc scc" }, | 74 | { MFX_PROFILE_HEVC_SCC, "hevc scc" }, |
| 81 | #endif | 75 | #endif |
| 82 | }; | 76 | }; |
| 83 | | 77 | |
| 84 | static const struct profile_names vp9_profiles[] = { | 78 | static const struct profile_names vp9_profiles[] = { |
| 85 | #if QSV_VERSION_ATLEAST(1, 19) | | |
| 86 | { MFX_PROFILE_VP9_0, "vp9 0" }, | 79 | { MFX_PROFILE_VP9_0, "vp9 0" }, |
| 87 | { MFX_PROFILE_VP9_1, "vp9 1" }, | 80 | { MFX_PROFILE_VP9_1, "vp9 1" }, |
| 88 | { MFX_PROFILE_VP9_2, "vp9 2" }, | 81 | { MFX_PROFILE_VP9_2, "vp9 2" }, |
| 89 | { MFX_PROFILE_VP9_3, "vp9 3" }, | 82 | { MFX_PROFILE_VP9_3, "vp9 3" }, |
| 90 | #endif | | |
| 91 | }; | 83 | }; |
| 92 | | 84 | |
| 93 | typedef struct QSVPacket { | 85 | typedef struct QSVPacket { |
| @@ -143,25 +135,15 @@ static const struct { · 49 unmodified lines |
| 143 | #if QSV_HAVE_AVBR | 135 | #if QSV_HAVE_AVBR |
| 144 | { MFX_RATECONTROL_AVBR, "AVBR" }, | 136 | { MFX_RATECONTROL_AVBR, "AVBR" }, |
| 145 | #endif | 137 | #endif |
| 146 | #if QSV_HAVE_LA | | |
| 147 | { MFX_RATECONTROL_LA, "LA" }, | 138 | { MFX_RATECONTROL_LA, "LA" }, |
| 148 | #endif | | |
| 149 | #if QSV_HAVE_ICQ | | |
| 150 | { MFX_RATECONTROL_ICQ, "ICQ" }, | 139 | { MFX_RATECONTROL_ICQ, "ICQ" }, |
| 151 | { MFX_RATECONTROL_LA_ICQ, "LA_ICQ" }, | 140 | { MFX_RATECONTROL_LA_ICQ, "LA_ICQ" }, |
| 152 | #endif | | |
| 153 | #if QSV_HAVE_VCM | 141 | #if QSV_HAVE_VCM |
| 154 | { MFX_RATECONTROL_VCM, "VCM" }, | 142 | { MFX_RATECONTROL_VCM, "VCM" }, |
| 155 | #endif | 143 | #endif |
| 156 | #if QSV_VERSION_ATLEAST(1, 10) | | |
| 157 | { MFX_RATECONTROL_LA_EXT, "LA_EXT" }, | 144 | { MFX_RATECONTROL_LA_EXT, "LA_EXT" }, |
| 158 | #endif | | |
| 159 | #if QSV_HAVE_LA_HRD | | |
| 160 | { MFX_RATECONTROL_LA_HRD, "LA_HRD" }, | 145 | { MFX_RATECONTROL_LA_HRD, "LA_HRD" }, |
| 161 | #endif | | |
| 162 | #if QSV_HAVE_QVBR | | |
| 163 | { MFX_RATECONTROL_QVBR, "QVBR" }, | 146 | { MFX_RATECONTROL_QVBR, "QVBR" }, |
| 164 | #endif | | |
| 165 | }; | 147 | }; |
| 166 | | 148 | |
| 167 | static const char *print_ratecontrol(mfxU16 rc_mode) | 149 | static const char *print_ratecontrol(mfxU16 rc_mode) |
| @@ -187,16 +169,20 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, · 19 unmodified lines |
| 187 | { | 169 | { |
| 188 | mfxInfoMFX *info = &q->param.mfx; | 170 | mfxInfoMFX *info = &q->param.mfx; |
| 189 | | 171 | |
| 190 | mfxExtCodingOption *co = (mfxExtCodingOption*)coding_opts[0]; | 172 | // co is always at index 1 |
| 191 | #if QSV_HAVE_CO2 | 173 | mfxExtCodingOption *co = (mfxExtCodingOption*)coding_opts[1]; |
| 192 | mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1]; | 174 | mfxExtCodingOption2 *co2 = NULL; |
| 193 | #endif | 175 | mfxExtCodingOption3 *co3 = NULL; |
| 194 | #if QSV_HAVE_CO3 | 176 | mfxExtHEVCTiles *exthevctiles = NULL; |
| 195 | mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2]; | 177 | |
| 196 | #endif | 178 | if (q->co2_idx > 0) |
| 197 | #if QSV_HAVE_EXT_HEVC_TILES | 179 | co2 = (mfxExtCodingOption2*)coding_opts[q->co2_idx]; |
| 198 | mfxExtHEVCTiles *exthevctiles = (mfxExtHEVCTiles *)coding_opts[3 + QSV_HAVE_CO_VPS]; | 180 | |
| 199 | #endif | 181 | if (q->co3_idx > 0) |
| | 182 | co3 = (mfxExtCodingOption3*)coding_opts[q->co3_idx]; |
| | 183 | |
| | 184 | if (q->exthevctiles_idx > 0) |
| | 185 | exthevctiles = (mfxExtHEVCTiles *)coding_opts[q->exthevctiles_idx]; |
| 200 | | 186 | |
| 201 | av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", | 187 | av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", |
| 202 | print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); | 188 | print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); |
| @@ -221,11 +207,6 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, · 18 unmodified lines |
| 221 | av_log(avctx, AV_LOG_VERBOSE, | 207 | av_log(avctx, AV_LOG_VERBOSE, |
| 222 | "BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"; BRCParamMultiplier: %"PRIu16"\n", | 208 | "BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"; BRCParamMultiplier: %"PRIu16"\n", |
| 223 | info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, info->MaxKbps, info->BRCParamMultiplier); | 209 | info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, info->MaxKbps, info->BRCParamMultiplier); |
| 224 | #if QSV_HAVE_LA | | |
| 225 | if (info->RateControlMethod == MFX_RATECONTROL_VBR && q->extbrc && q->look_ahead_depth > 0 ) { | | |
| 226 | av_log(avctx, AV_LOG_VERBOSE, "LookAheadDepth: %"PRIu16"\n",co2->LookAheadDepth); | | |
| 227 | } | | |
| 228 | #endif | | |
| 229 | } else if (info->RateControlMethod == MFX_RATECONTROL_CQP) { | 210 | } else if (info->RateControlMethod == MFX_RATECONTROL_CQP) { |
| 230 | av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n", | 211 | av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n", |
| 231 | info->QPI, info->QPP, info->QPB); | 212 | info->QPI, info->QPP, info->QPB); |
| @@ -237,117 +218,22 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, · 5 unmodified lines |
| 237 | info->TargetKbps, info->Accuracy, info->Convergence, info->BRCParamMultiplier); | 218 | info->TargetKbps, info->Accuracy, info->Convergence, info->BRCParamMultiplier); |
| 238 | } | 219 | } |
| 239 | #endif | 220 | #endif |
| 240 | #if QSV_HAVE_LA | | |
| 241 | else if (info->RateControlMethod == MFX_RATECONTROL_LA | 221 | else if (info->RateControlMethod == MFX_RATECONTROL_LA |
| 242 | #if QSV_HAVE_LA_HRD | | |
| 243 | || info->RateControlMethod == MFX_RATECONTROL_LA_HRD | 222 | || info->RateControlMethod == MFX_RATECONTROL_LA_HRD |
| 244 | #endif | | |
| 245 | ) { | 223 | ) { |
| 246 | av_log(avctx, AV_LOG_VERBOSE, | 224 | av_log(avctx, AV_LOG_VERBOSE, |
| 247 | "TargetKbps: %"PRIu16"; LookAheadDepth: %"PRIu16"; BRCParamMultiplier: %"PRIu16"\n", | 225 | "TargetKbps: %"PRIu16"; BRCParamMultiplier: %"PRIu16"\n", |
| 248 | info->TargetKbps, co2->LookAheadDepth, info->BRCParamMultiplier); | 226 | info->TargetKbps, info->BRCParamMultiplier); |
| 249 | } | 227 | } else if (info->RateControlMethod == MFX_RATECONTROL_ICQ || |
| 250 | #endif | 228 | info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) |
| 251 | #if QSV_HAVE_ICQ | | |
| 252 | else if (info->RateControlMethod == MFX_RATECONTROL_ICQ) { | | |
| 253 | av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"\n", info->ICQQuality); | 229 | av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"\n", info->ICQQuality); |
| 254 | } else if (info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) { | | |
| 255 | av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"; LookAheadDepth: %"PRIu16"\n", | | |
| 256 | info->ICQQuality, co2->LookAheadDepth); | | |
| 257 | } | | |
| 258 | #endif | | |
| 259 | #if QSV_HAVE_QVBR | | |
| 260 | else if (info->RateControlMethod == MFX_RATECONTROL_QVBR) { | | |
| 261 | av_log(avctx, AV_LOG_VERBOSE, "QVBRQuality: %"PRIu16"\n", | | |
| 262 | co3->QVBRQuality); | | |
| 263 | } | | |
| 264 | #endif | | |
| 265 | av_log(avctx, AV_LOG_VERBOSE, "NumSlice: %"PRIu16"; NumRefFrame: %"PRIu16"\n", | 230 | av_log(avctx, AV_LOG_VERBOSE, "NumSlice: %"PRIu16"; NumRefFrame: %"PRIu16"\n", |
| 266 | info->NumSlice, info->NumRefFrame); | 231 | info->NumSlice, info->NumRefFrame); |
| 267 | av_log(avctx, AV_LOG_VERBOSE, "RateDistortionOpt: %s\n", | 232 | av_log(avctx, AV_LOG_VERBOSE, "RateDistortionOpt: %s\n", |
| 268 | print_threestate(co->RateDistortionOpt)); | 233 | print_threestate(co->RateDistortionOpt)); |
| 269 | | 234 | |
| 270 | #if QSV_HAVE_EXT_HEVC_TILES | 235 | av_log(avctx, AV_LOG_VERBOSE, "RecoveryPointSEI: %s\n", print_threestate(co->RecoveryPointSEI)); |
| 271 | if (avctx->codec_id == AV_CODEC_ID_HEVC) | | |
| 272 | av_log(avctx, AV_LOG_VERBOSE, "NumTileColumns: %"PRIu16"; NumTileRows: %"PRIu16"\n", | | |
| 273 | exthevctiles->NumTileColumns, exthevctiles->NumTileRows); | | |
| 274 | #endif | | |
| 275 | | | |
| 276 | #if QSV_HAVE_CO2 | | |
| 277 | av_log(avctx, AV_LOG_VERBOSE, | | |
| 278 | "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n", | | |
| 279 | print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); | | |
| 280 | | | |
| 281 | av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize); | | |
| 282 | #if QSV_HAVE_MAX_SLICE_SIZE | | |
| 283 | av_log(avctx, AV_LOG_VERBOSE, "MaxSliceSize: %d; ", co2->MaxSliceSize); | | |
| 284 | #endif | | |
| 285 | av_log(avctx, AV_LOG_VERBOSE, "\n"); | | |
| 286 | | | |
| 287 | av_log(avctx, AV_LOG_VERBOSE, | | |
| 288 | "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n", | | |
| 289 | print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC), | | |
| 290 | print_threestate(co2->ExtBRC)); | | |
| 291 | | | |
| 292 | #if QSV_HAVE_TRELLIS | | |
| 293 | av_log(avctx, AV_LOG_VERBOSE, "Trellis: "); | | |
| 294 | if (co2->Trellis & MFX_TRELLIS_OFF) { | | |
| 295 | av_log(avctx, AV_LOG_VERBOSE, "off"); | | |
| 296 | } else if (!co2->Trellis) { | | |
| 297 | av_log(avctx, AV_LOG_VERBOSE, "auto"); | | |
| 298 | } else { | | |
| 299 | if (co2->Trellis & MFX_TRELLIS_I) av_log(avctx, AV_LOG_VERBOSE, "I"); | | |
| 300 | if (co2->Trellis & MFX_TRELLIS_P) av_log(avctx, AV_LOG_VERBOSE, "P"); | | |
| 301 | if (co2->Trellis & MFX_TRELLIS_B) av_log(avctx, AV_LOG_VERBOSE, "B"); | | |
| 302 | } | | |
| 303 | av_log(avctx, AV_LOG_VERBOSE, "\n"); | | |
| 304 | #endif | | |
| 305 | | | |
| 306 | #if QSV_HAVE_VDENC | | |
| 307 | av_log(avctx, AV_LOG_VERBOSE, "VDENC: %s\n", print_threestate(info->LowPower)); | 236 | av_log(avctx, AV_LOG_VERBOSE, "VDENC: %s\n", print_threestate(info->LowPower)); |
| 308 | #endif | | |
| 309 | | | |
| 310 | #if QSV_VERSION_ATLEAST(1, 8) | | |
| 311 | av_log(avctx, AV_LOG_VERBOSE, | | |
| 312 | "RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ", | | |
| 313 | print_threestate(co2->RepeatPPS), co2->NumMbPerSlice); | | |
| 314 | switch (co2->LookAheadDS) { | | |
| 315 | case MFX_LOOKAHEAD_DS_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break; | | |
| 316 | case MFX_LOOKAHEAD_DS_2x: av_log(avctx, AV_LOG_VERBOSE, "2x"); break; | | |
| 317 | case MFX_LOOKAHEAD_DS_4x: av_log(avctx, AV_LOG_VERBOSE, "4x"); break; | | |
| 318 | default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break; | | |
| 319 | } | | |
| 320 | av_log(avctx, AV_LOG_VERBOSE, "\n"); | | |
| 321 | | | |
| 322 | av_log(avctx, AV_LOG_VERBOSE, "AdaptiveI: %s; AdaptiveB: %s; BRefType: ", | | |
| 323 | print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB)); | | |
| 324 | switch (co2->BRefType) { | | |
| 325 | case MFX_B_REF_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break; | | |
| 326 | case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; | | |
| 327 | default: av_log(avctx, AV_LOG_VERBOSE, "auto"); break; | | |
| 328 | } | | |
| 329 | | | |
| 330 | av_log(avctx, AV_LOG_VERBOSE, "; PRefType: "); | | |
| 331 | switch (co3->PRefType) { | | |
| 332 | case MFX_P_REF_DEFAULT: av_log(avctx, AV_LOG_VERBOSE, "default"); break; | | |
| 333 | case MFX_P_REF_SIMPLE: av_log(avctx, AV_LOG_VERBOSE, "simple"); break; | | |
| 334 | case MFX_P_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; | | |
| 335 | default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break; | | |
| 336 | } | | |
| 337 | av_log(avctx, AV_LOG_VERBOSE, "\n"); | | |
| 338 | #endif | | |
| 339 | | | |
| 340 | #if QSV_VERSION_ATLEAST(1, 9) | | |
| 341 | av_log(avctx, AV_LOG_VERBOSE, | | |
| 342 | "MinQPI: %"PRIu8"; MaxQPI: %"PRIu8"; MinQPP: %"PRIu8"; MaxQPP: %"PRIu8"; MinQPB: %"PRIu8"; MaxQPB: %"PRIu8"\n", | | |
| 343 | co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB); | | |
| 344 | #endif | | |
| 345 | #endif | | |
| 346 | | | |
| 347 | #if QSV_HAVE_GPB | | |
| 348 | if (avctx->codec_id == AV_CODEC_ID_HEVC) | | |
| 349 | av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB)); | | |
| 350 | #endif | | |
| 351 | | 237 | |
| 352 | if (avctx->codec_id == AV_CODEC_ID_H264) { | 238 | if (avctx->codec_id == AV_CODEC_ID_H264) { |
| 353 | av_log(avctx, AV_LOG_VERBOSE, "Entropy coding: %s; MaxDecFrameBuffering: %"PRIu16"\n", | 239 | av_log(avctx, AV_LOG_VERBOSE, "Entropy coding: %s; MaxDecFrameBuffering: %"PRIu16"\n", |
| @@ -365,36 +251,103 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, · 11 unmodified lines |
| 365 | av_log(avctx, AV_LOG_VERBOSE, "FrameRateExtD: %"PRIu32"; FrameRateExtN: %"PRIu32" \n", | 251 | av_log(avctx, AV_LOG_VERBOSE, "FrameRateExtD: %"PRIu32"; FrameRateExtN: %"PRIu32" \n", |
| 366 | info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN); | 252 | info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN); |
| 367 | | 253 | |
| 368 | #if QSV_HAVE_DISABLEDEBLOCKIDC | 254 | if (co2) { |
| 369 | av_log(avctx, AV_LOG_VERBOSE, "DisableDeblockingIdc: %"PRIu32" \n", co2->DisableDeblockingIdc); | 255 | if ((info->RateControlMethod == MFX_RATECONTROL_VBR && q->extbrc && q->look_ahead_depth > 0) || |
| 370 | #endif | 256 | (info->RateControlMethod == MFX_RATECONTROL_LA) || |
| | 257 | (info->RateControlMethod == MFX_RATECONTROL_LA_HRD) || |
| | 258 | (info->RateControlMethod == MFX_RATECONTROL_LA_ICQ)) |
| | 259 | av_log(avctx, AV_LOG_VERBOSE, "LookAheadDepth: %"PRIu16"\n", co2->LookAheadDepth); |
| 371 | | 260 | |
| 372 | #if QSV_VERSION_ATLEAST(1, 26) | 261 | av_log(avctx, AV_LOG_VERBOSE, "IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n", |
| 373 | av_log(avctx, AV_LOG_VERBOSE, "TransformSkip: %s \n", print_threestate(co3->TransformSkip)); | 262 | co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); |
| 374 | #endif | | |
| 375 | | 263 | |
| 376 | #if QSV_VERSION_ATLEAST(1, 16) | 264 | av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize); |
| 377 | av_log(avctx, AV_LOG_VERBOSE, "IntRefCycleDist: %"PRId16"\n", co3->IntRefCycleDist); | 265 | av_log(avctx, AV_LOG_VERBOSE, "MaxSliceSize: %d; ", co2->MaxSliceSize); |
| 378 | #endif | 266 | av_log(avctx, AV_LOG_VERBOSE, "\n"); |
| 379 | #if QSV_VERSION_ATLEAST(1, 23) | 267 | |
| 380 | av_log(avctx, AV_LOG_VERBOSE, "LowDelayBRC: %s\n", print_threestate(co3->LowDelayBRC)); | 268 | av_log(avctx, AV_LOG_VERBOSE, |
| 381 | #endif | 269 | "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n", |
| 382 | #if QSV_VERSION_ATLEAST(1, 19) | 270 | print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC), |
| 383 | av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSizeI: %d; ", co3->MaxFrameSizeI); | 271 | print_threestate(co2->ExtBRC)); |
| 384 | av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSizeP: %d\n", co3->MaxFrameSizeP); | 272 | |
| 385 | #endif | 273 | av_log(avctx, AV_LOG_VERBOSE, "Trellis: "); |
| | 274 | if (co2->Trellis & MFX_TRELLIS_OFF) { |
| | 275 | av_log(avctx, AV_LOG_VERBOSE, "off"); |
| | 276 | } else if (!co2->Trellis) { |
| | 277 | av_log(avctx, AV_LOG_VERBOSE, "auto"); |
| | 278 | } else { |
| | 279 | if (co2->Trellis & MFX_TRELLIS_I) av_log(avctx, AV_LOG_VERBOSE, "I"); |
| | 280 | if (co2->Trellis & MFX_TRELLIS_P) av_log(avctx, AV_LOG_VERBOSE, "P"); |
| | 281 | if (co2->Trellis & MFX_TRELLIS_B) av_log(avctx, AV_LOG_VERBOSE, "B"); |
| | 282 | } |
| | 283 | av_log(avctx, AV_LOG_VERBOSE, "\n"); |
| | 284 | |
| | 285 | av_log(avctx, AV_LOG_VERBOSE, |
| | 286 | "RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ", |
| | 287 | print_threestate(co2->RepeatPPS), co2->NumMbPerSlice); |
| | 288 | switch (co2->LookAheadDS) { |
| | 289 | case MFX_LOOKAHEAD_DS_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break; |
| | 290 | case MFX_LOOKAHEAD_DS_2x: av_log(avctx, AV_LOG_VERBOSE, "2x"); break; |
| | 291 | case MFX_LOOKAHEAD_DS_4x: av_log(avctx, AV_LOG_VERBOSE, "4x"); break; |
| | 292 | default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break; |
| | 293 | } |
| | 294 | av_log(avctx, AV_LOG_VERBOSE, "\n"); |
| | 295 | |
| | 296 | av_log(avctx, AV_LOG_VERBOSE, "AdaptiveI: %s; AdaptiveB: %s; BRefType: ", |
| | 297 | print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB)); |
| | 298 | switch (co2->BRefType) { |
| | 299 | case MFX_B_REF_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break; |
| | 300 | case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; |
| | 301 | default: av_log(avctx, AV_LOG_VERBOSE, "auto"); break; |
| | 302 | } |
| | 303 | |
| | 304 | av_log(avctx, AV_LOG_VERBOSE, |
| | 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); |
| | 307 | av_log(avctx, AV_LOG_VERBOSE, "DisableDeblockingIdc: %"PRIu32" \n", co2->DisableDeblockingIdc); |
| | 308 | } |
| | 309 | |
| | 310 | if (co3) { |
| | 311 | if (info->RateControlMethod == MFX_RATECONTROL_QVBR) |
| | 312 | av_log(avctx, AV_LOG_VERBOSE, "QVBRQuality: %"PRIu16"\n", co3->QVBRQuality); |
| | 313 | |
| | 314 | av_log(avctx, AV_LOG_VERBOSE, "PRefType: "); |
| | 315 | switch (co3->PRefType) { |
| | 316 | case MFX_P_REF_DEFAULT: av_log(avctx, AV_LOG_VERBOSE, "default"); break; |
| | 317 | case MFX_P_REF_SIMPLE: av_log(avctx, AV_LOG_VERBOSE, "simple"); break; |
| | 318 | case MFX_P_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; |
| | 319 | default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break; |
| | 320 | } |
| | 321 | av_log(avctx, AV_LOG_VERBOSE, "\n"); |
| | 322 | |
| | 323 | if (avctx->codec_id == AV_CODEC_ID_HEVC) |
| | 324 | av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB)); |
| | 325 | |
| | 326 | av_log(avctx, AV_LOG_VERBOSE, "TransformSkip: %s \n", print_threestate(co3->TransformSkip)); |
| | 327 | av_log(avctx, AV_LOG_VERBOSE, "IntRefCycleDist: %"PRId16"\n", co3->IntRefCycleDist); |
| | 328 | av_log(avctx, AV_LOG_VERBOSE, "LowDelayBRC: %s\n", print_threestate(co3->LowDelayBRC)); |
| | 329 | av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSizeI: %d; ", co3->MaxFrameSizeI); |
| | 330 | av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSizeP: %d\n", co3->MaxFrameSizeP); |
| | 331 | } |
| | 332 | |
| | 333 | if (exthevctiles) { |
| | 334 | av_log(avctx, AV_LOG_VERBOSE, "NumTileColumns: %"PRIu16"; NumTileRows: %"PRIu16"\n", |
| | 335 | exthevctiles->NumTileColumns, exthevctiles->NumTileRows); |
| | 336 | } |
| 386 | } | 337 | } |
| 387 | | 338 | |
| 388 | static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, | 339 | static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, |
| 389 | mfxExtBuffer **coding_opts) | 340 | mfxExtBuffer **coding_opts) |
| 390 | { | 341 | { |
| 391 | mfxInfoMFX *info = &q->param.mfx; | 342 | mfxInfoMFX *info = &q->param.mfx; |
| 392 | #if QSV_HAVE_EXT_VP9_PARAM | 343 | mfxExtVP9Param *vp9_param = NULL; |
| 393 | mfxExtVP9Param *vp9_param = (mfxExtVP9Param *)coding_opts[0]; | 344 | mfxExtCodingOption2 *co2 = NULL; |
| 394 | #endif | 345 | |
| 395 | #if QSV_HAVE_CO2 | 346 | if (q->vp9_idx >= 0) |
| 396 | mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1]; | 347 | vp9_param = (mfxExtVP9Param *)coding_opts[q->vp9_idx]; |
| 397 | #endif | 348 | |
| | 349 | if (q->co2_idx >= 0) |
| | 350 | co2 = (mfxExtCodingOption2*)coding_opts[q->co2_idx]; |
| 398 | | 351 | |
| 399 | av_log(avctx, AV_LOG_VERBOSE, "profile: %s \n", | 352 | av_log(avctx, AV_LOG_VERBOSE, "profile: %s \n", |
| 400 | print_profile(avctx->codec_id, info->CodecProfile)); | 353 | print_profile(avctx->codec_id, info->CodecProfile)); |
| @@ -419,48 +372,41 @@ static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, · 18 unmodified lines |
| 419 | av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n", | 372 | av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n", |
| 420 | info->QPI, info->QPP, info->QPB); | 373 | info->QPI, info->QPP, info->QPB); |
| 421 | } | 374 | } |
| 422 | #if QSV_HAVE_ICQ | | |
| 423 | else if (info->RateControlMethod == MFX_RATECONTROL_ICQ) { | 375 | else if (info->RateControlMethod == MFX_RATECONTROL_ICQ) { |
| 424 | av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"\n", info->ICQQuality); | 376 | av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"\n", info->ICQQuality); |
| 425 | } | 377 | } |
| 426 | #endif | | |
| 427 | else { | 378 | else { |
| 428 | av_log(avctx, AV_LOG_VERBOSE, "Unsupported ratecontrol method: %d \n", info->RateControlMethod); | 379 | av_log(avctx, AV_LOG_VERBOSE, "Unsupported ratecontrol method: %d \n", info->RateControlMethod); |
| 429 | } | 380 | } |
| 430 | | 381 | |
| 431 | av_log(avctx, AV_LOG_VERBOSE, "NumRefFrame: %"PRIu16"\n", info->NumRefFrame); | 382 | av_log(avctx, AV_LOG_VERBOSE, "NumRefFrame: %"PRIu16"\n", info->NumRefFrame); |
| | 383 | av_log(avctx, AV_LOG_VERBOSE, "FrameRateExtD: %"PRIu32"; FrameRateExtN: %"PRIu32" \n", |
| | 384 | info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN); |
| 432 | | 385 | |
| 433 | #if QSV_HAVE_CO2 | 386 | if (co2) { |
| 434 | av_log(avctx, AV_LOG_VERBOSE, | 387 | av_log(avctx, AV_LOG_VERBOSE, |
| 435 | "IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n", | 388 | "IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n", |
| 436 | co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); | 389 | co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); |
| 437 | | 390 | |
| 438 | av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize); | 391 | av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize); |
| 439 | av_log(avctx, AV_LOG_VERBOSE, "\n"); | 392 | av_log(avctx, AV_LOG_VERBOSE, "\n"); |
| 440 | | 393 | |
| 441 | av_log(avctx, AV_LOG_VERBOSE, | 394 | av_log(avctx, AV_LOG_VERBOSE, |
| 442 | "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n", | 395 | "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n", |
| 443 | print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC), | 396 | print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC), |
| 444 | print_threestate(co2->ExtBRC)); | 397 | print_threestate(co2->ExtBRC)); |
| 445 | | 398 | |
| 446 | #if QSV_HAVE_VDENC | 399 | av_log(avctx, AV_LOG_VERBOSE, "VDENC: %s\n", print_threestate(info->LowPower)); |
| 447 | av_log(avctx, AV_LOG_VERBOSE, "VDENC: %s\n", print_threestate(info->LowPower)); | | |
| 448 | #endif | | |
| 449 | | 400 | |
| 450 | #if QSV_VERSION_ATLEAST(1, 9) | 401 | av_log(avctx, AV_LOG_VERBOSE, |
| 451 | av_log(avctx, AV_LOG_VERBOSE, | 402 | "MinQPI: %"PRIu8"; MaxQPI: %"PRIu8"; MinQPP: %"PRIu8"; MaxQPP: %"PRIu8"; MinQPB: %"PRIu8"; MaxQPB: %"PRIu8"\n", |
| 452 | "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); |
| 453 | co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB); | 404 | } |
| 454 | #endif | | |
| 455 | #endif | | |
| 456 | | | |
| 457 | av_log(avctx, AV_LOG_VERBOSE, "FrameRateExtD: %"PRIu32"; FrameRateExtN: %"PRIu32" \n", | | |
| 458 | info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN); | | |
| 459 | | 405 | |
| 460 | #if QSV_HAVE_EXT_VP9_PARAM | 406 | if (vp9_param) { |
| 461 | av_log(avctx, AV_LOG_VERBOSE, "WriteIVFHeaders: %s \n", | 407 | av_log(avctx, AV_LOG_VERBOSE, "WriteIVFHeaders: %s \n", |
| 462 | print_threestate(vp9_param->WriteIVFHeaders)); | 408 | print_threestate(vp9_param->WriteIVFHeaders)); |
| 463 | #endif | 409 | } |
| 464 | } | 410 | } |
| 465 | | 411 | |
| 466 | static void dump_video_mjpeg_param(AVCodecContext *avctx, QSVEncContext *q) | 412 | static void dump_video_mjpeg_param(AVCodecContext *avctx, QSVEncContext *q) |
| @@ -484,11 +430,6 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q) · 17 unmodified lines |
| 484 | int want_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE); | 430 | int want_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE); |
| 485 | int want_vcm = q->vcm; | 431 | int want_vcm = q->vcm; |
| 486 | | 432 | |
| 487 | if (want_la && !QSV_HAVE_LA) { | | |
| 488 | av_log(avctx, AV_LOG_ERROR, | | |
| 489 | "Lookahead ratecontrol mode requested, but is not supported by this SDK version\n"); | | |
| 490 | return AVERROR(ENOSYS); | | |
| 491 | } | | |
| 492 | if (want_vcm && !QSV_HAVE_VCM) { | 433 | if (want_vcm && !QSV_HAVE_VCM) { |
| 493 | av_log(avctx, AV_LOG_ERROR, | 434 | av_log(avctx, AV_LOG_ERROR, |
| 494 | "VCM ratecontrol mode requested, but is not supported by this SDK version\n"); | 435 | "VCM ratecontrol mode requested, but is not supported by this SDK version\n"); |
| @@ -502,12 +443,6 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q) · 7 unmodified lines |
| 502 | return AVERROR(EINVAL); | 443 | return AVERROR(EINVAL); |
| 503 | } | 444 | } |
| 504 | | 445 | |
| 505 | if (!want_qscale && avctx->global_quality > 0 && !QSV_HAVE_ICQ){ | | |
| 506 | av_log(avctx, AV_LOG_ERROR, | | |
| 507 | "ICQ ratecontrol mode requested, but is not supported by this SDK version\n"); | | |
| 508 | return AVERROR(ENOSYS); | | |
| 509 | } | | |
| 510 | | | |
| 511 | if (want_qscale) { | 446 | if (want_qscale) { |
| 512 | rc_mode = MFX_RATECONTROL_CQP; | 447 | rc_mode = MFX_RATECONTROL_CQP; |
| 513 | rc_desc = "constant quantization parameter (CQP)"; | 448 | rc_desc = "constant quantization parameter (CQP)"; |
| @@ -518,25 +453,19 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q) · 4 unmodified lines |
| 518 | rc_desc = "video conferencing mode (VCM)"; | 453 | rc_desc = "video conferencing mode (VCM)"; |
| 519 | } | 454 | } |
| 520 | #endif | 455 | #endif |
| 521 | #if QSV_HAVE_LA | | |
| 522 | else if (want_la) { | 456 | else if (want_la) { |
| 523 | rc_mode = MFX_RATECONTROL_LA; | 457 | rc_mode = MFX_RATECONTROL_LA; |
| 524 | rc_desc = "VBR with lookahead (LA)"; | 458 | rc_desc = "VBR with lookahead (LA)"; |
| 525 | | 459 | |
| 526 | #if QSV_HAVE_ICQ | | |
| 527 | if (avctx->global_quality > 0) { | 460 | if (avctx->global_quality > 0) { |
| 528 | rc_mode = MFX_RATECONTROL_LA_ICQ; | 461 | rc_mode = MFX_RATECONTROL_LA_ICQ; |
| 529 | rc_desc = "intelligent constant quality with lookahead (LA_ICQ)"; | 462 | rc_desc = "intelligent constant quality with lookahead (LA_ICQ)"; |
| 530 | } | 463 | } |
| 531 | #endif | | |
| 532 | } | 464 | } |
| 533 | #endif | | |
| 534 | #if QSV_HAVE_ICQ | | |
| 535 | else if (avctx->global_quality > 0 && !avctx->rc_max_rate) { | 465 | else if (avctx->global_quality > 0 && !avctx->rc_max_rate) { |
| 536 | rc_mode = MFX_RATECONTROL_ICQ; | 466 | rc_mode = MFX_RATECONTROL_ICQ; |
| 537 | rc_desc = "intelligent constant quality (ICQ)"; | 467 | rc_desc = "intelligent constant quality (ICQ)"; |
| 538 | } | 468 | } |
| 539 | #endif | | |
| 540 | else if (avctx->rc_max_rate == avctx->bit_rate) { | 469 | else if (avctx->rc_max_rate == avctx->bit_rate) { |
| 541 | rc_mode = MFX_RATECONTROL_CBR; | 470 | rc_mode = MFX_RATECONTROL_CBR; |
| 542 | rc_desc = "constant bitrate (CBR)"; | 471 | rc_desc = "constant bitrate (CBR)"; |
| @@ -547,12 +476,10 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q) · 4 unmodified lines |
| 547 | rc_desc = "average variable bitrate (AVBR)"; | 476 | rc_desc = "average variable bitrate (AVBR)"; |
| 548 | } | 477 | } |
| 549 | #endif | 478 | #endif |
| 550 | #if QSV_HAVE_QVBR | | |
| 551 | else if (avctx->global_quality > 0) { | 479 | else if (avctx->global_quality > 0) { |
| 552 | rc_mode = MFX_RATECONTROL_QVBR; | 480 | rc_mode = MFX_RATECONTROL_QVBR; |
| 553 | rc_desc = "constant quality with VBR algorithm (QVBR)"; | 481 | rc_desc = "constant quality with VBR algorithm (QVBR)"; |
| 554 | } | 482 | } |
| 555 | #endif | | |
| 556 | else { | 483 | else { |
| 557 | rc_mode = MFX_RATECONTROL_VBR; | 484 | rc_mode = MFX_RATECONTROL_VBR; |
| 558 | rc_desc = "variable bitrate (VBR)"; | 485 | rc_desc = "variable bitrate (VBR)"; |
| @@ -692,14 +619,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 133 unmodified lines |
| 692 | } | 619 | } |
| 693 | | 620 | |
| 694 | if (q->low_power == 1) { | 621 | if (q->low_power == 1) { |
| 695 | #if QSV_HAVE_VDENC | | |
| 696 | q->param.mfx.LowPower = MFX_CODINGOPTION_ON; | 622 | q->param.mfx.LowPower = MFX_CODINGOPTION_ON; |
| 697 | #else | | |
| 698 | av_log(avctx, AV_LOG_WARNING, "The low_power option is " | | |
| 699 | "not supported with this MSDK version.\n"); | | |
| 700 | q->low_power = 0; | | |
| 701 | q->param.mfx.LowPower = MFX_CODINGOPTION_OFF; | | |
| 702 | #endif | | |
| 703 | } else if (q->low_power == -1) | 623 | } else if (q->low_power == -1) |
| 704 | q->param.mfx.LowPower = MFX_CODINGOPTION_UNKNOWN; | 624 | q->param.mfx.LowPower = MFX_CODINGOPTION_UNKNOWN; |
| 705 | else | 625 | else |
| @@ -789,26 +709,20 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 83 unmodified lines |
| 789 | switch (q->param.mfx.RateControlMethod) { | 709 | switch (q->param.mfx.RateControlMethod) { |
| 790 | case MFX_RATECONTROL_CBR: | 710 | case MFX_RATECONTROL_CBR: |
| 791 | case MFX_RATECONTROL_VBR: | 711 | case MFX_RATECONTROL_VBR: |
| 792 | #if QSV_HAVE_LA | | |
| 793 | if (q->extbrc) { | 712 | if (q->extbrc) { |
| 794 | q->extco2.LookAheadDepth = q->look_ahead_depth; | 713 | q->extco2.LookAheadDepth = q->look_ahead_depth; |
| 795 | } | 714 | } |
| 796 | #endif | | |
| 797 | #if QSV_HAVE_VCM | 715 | #if QSV_HAVE_VCM |
| 798 | case MFX_RATECONTROL_VCM: | 716 | case MFX_RATECONTROL_VCM: |
| 799 | #endif | 717 | #endif |
| 800 | #if QSV_HAVE_QVBR | | |
| 801 | case MFX_RATECONTROL_QVBR: | 718 | case MFX_RATECONTROL_QVBR: |
| 802 | #endif | | |
| 803 | q->param.mfx.BufferSizeInKB = buffer_size_in_kilobytes / brc_param_multiplier; | 719 | q->param.mfx.BufferSizeInKB = buffer_size_in_kilobytes / brc_param_multiplier; |
| 804 | q->param.mfx.InitialDelayInKB = initial_delay_in_kilobytes / brc_param_multiplier; | 720 | q->param.mfx.InitialDelayInKB = initial_delay_in_kilobytes / brc_param_multiplier; |
| 805 | q->param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier; | 721 | q->param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier; |
| 806 | q->param.mfx.MaxKbps = max_bitrate_kbps / brc_param_multiplier; | 722 | q->param.mfx.MaxKbps = max_bitrate_kbps / brc_param_multiplier; |
| 807 | q->param.mfx.BRCParamMultiplier = brc_param_multiplier; | 723 | q->param.mfx.BRCParamMultiplier = brc_param_multiplier; |
| 808 | #if QSV_HAVE_QVBR | | |
| 809 | if (q->param.mfx.RateControlMethod == MFX_RATECONTROL_QVBR) | 724 | if (q->param.mfx.RateControlMethod == MFX_RATECONTROL_QVBR) |
| 810 | q->extco3.QVBRQuality = av_clip(avctx->global_quality, 0, 51); | 725 | q->extco3.QVBRQuality = av_clip(avctx->global_quality, 0, 51); |
| 811 | #endif | | |
| 812 | break; | 726 | break; |
| 813 | case MFX_RATECONTROL_CQP: | 727 | case MFX_RATECONTROL_CQP: |
| 814 | quant = avctx->global_quality / FF_QP2LAMBDA; | 728 | quant = avctx->global_quality / FF_QP2LAMBDA; |
| @@ -826,20 +740,16 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 11 unmodified lines |
| 826 | q->param.mfx.BRCParamMultiplier = brc_param_multiplier; | 740 | q->param.mfx.BRCParamMultiplier = brc_param_multiplier; |
| 827 | break; | 741 | break; |
| 828 | #endif | 742 | #endif |
| 829 | #if QSV_HAVE_LA | | |
| 830 | case MFX_RATECONTROL_LA: | 743 | case MFX_RATECONTROL_LA: |
| 831 | q->param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier; | 744 | q->param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier; |
| 832 | q->extco2.LookAheadDepth = q->look_ahead_depth; | 745 | q->extco2.LookAheadDepth = q->look_ahead_depth; |
| 833 | q->param.mfx.BRCParamMultiplier = brc_param_multiplier; | 746 | q->param.mfx.BRCParamMultiplier = brc_param_multiplier; |
| 834 | break; | 747 | break; |
| 835 | #if QSV_HAVE_ICQ | | |
| 836 | case MFX_RATECONTROL_LA_ICQ: | 748 | case MFX_RATECONTROL_LA_ICQ: |
| 837 | q->extco2.LookAheadDepth = q->look_ahead_depth; | 749 | q->extco2.LookAheadDepth = q->look_ahead_depth; |
| 838 | case MFX_RATECONTROL_ICQ: | 750 | case MFX_RATECONTROL_ICQ: |
| 839 | q->param.mfx.ICQQuality = av_clip(avctx->global_quality, 1, 51); | 751 | q->param.mfx.ICQQuality = av_clip(avctx->global_quality, 1, 51); |
| 840 | break; | 752 | break; |
| 841 | #endif | | |
| 842 | #endif | | |
| 843 | } | 753 | } |
| 844 | | 754 | |
| 845 | // The HEVC encoder plugin currently fails with some old libmfx version if coding options | 755 | // The HEVC encoder plugin currently fails with some old libmfx version if coding options |
| @@ -883,19 +793,15 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 37 unmodified lines |
| 883 | | 793 | |
| 884 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco; | 794 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco; |
| 885 | | 795 | |
| 886 | #if QSV_HAVE_CO2 | | |
| 887 | if (avctx->codec_id == AV_CODEC_ID_H264) { | 796 | if (avctx->codec_id == AV_CODEC_ID_H264) { |
| 888 | if (q->bitrate_limit >= 0) | 797 | if (q->bitrate_limit >= 0) |
| 889 | q->extco2.BitrateLimit = q->bitrate_limit ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; | 798 | q->extco2.BitrateLimit = q->bitrate_limit ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; |
| 890 | | 799 | |
| 891 | #if QSV_HAVE_TRELLIS | | |
| 892 | if (avctx->trellis >= 0) | 800 | if (avctx->trellis >= 0) |
| 893 | q->extco2.Trellis = (avctx->trellis == 0) ? MFX_TRELLIS_OFF : (MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B); | 801 | q->extco2.Trellis = (avctx->trellis == 0) ? MFX_TRELLIS_OFF : (MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B); |
| 894 | else | 802 | else |
| 895 | q->extco2.Trellis = MFX_TRELLIS_UNKNOWN; | 803 | q->extco2.Trellis = MFX_TRELLIS_UNKNOWN; |
| 896 | #endif | | |
| 897 | | 804 | |
| 898 | #if QSV_VERSION_ATLEAST(1, 8) | | |
| 899 | q->extco2.LookAheadDS = q->look_ahead_downsampling; | 805 | q->extco2.LookAheadDS = q->look_ahead_downsampling; |
| 900 | q->extco2.RepeatPPS = q->repeat_pps ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; | 806 | q->extco2.RepeatPPS = q->repeat_pps ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; |
| 901 | | 807 | |
| @@ -903,7 +809,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 1 unmodified line |
| 903 | q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; | 809 | q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; |
| 904 | if (q->adaptive_b >= 0) | 810 | if (q->adaptive_b >= 0) |
| 905 | q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; | 811 | q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; |
| 906 | #endif | | |
| 907 | } | 812 | } |
| 908 | | 813 | |
| 909 | if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) { | 814 | if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) { |
| @@ -917,19 +822,12 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 7 unmodified lines |
| 917 | q->extco2.IntRefCycleSize = q->int_ref_cycle_size; | 822 | q->extco2.IntRefCycleSize = q->int_ref_cycle_size; |
| 918 | if (q->int_ref_qp_delta != INT16_MIN) | 823 | if (q->int_ref_qp_delta != INT16_MIN) |
| 919 | q->extco2.IntRefQPDelta = q->int_ref_qp_delta; | 824 | q->extco2.IntRefQPDelta = q->int_ref_qp_delta; |
| 920 | #if QSV_HAVE_MAX_SLICE_SIZE | | |
| 921 | if (q->max_slice_size >= 0) | 825 | if (q->max_slice_size >= 0) |
| 922 | q->extco2.MaxSliceSize = q->max_slice_size; | 826 | q->extco2.MaxSliceSize = q->max_slice_size; |
| 923 | #endif | | |
| 924 | #if QSV_HAVE_DISABLEDEBLOCKIDC | | |
| 925 | q->extco2.DisableDeblockingIdc = q->dblk_idc; | 827 | q->extco2.DisableDeblockingIdc = q->dblk_idc; |
| 926 | #endif | | |
| 927 | | 828 | |
| 928 | #if QSV_VERSION_ATLEAST(1, 8) | | |
| 929 | if (q->b_strategy >= 0) | 829 | if (q->b_strategy >= 0) |
| 930 | q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF; | 830 | q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF; |
| 931 | #endif | | |
| 932 | #if QSV_VERSION_ATLEAST(1, 9) | | |
| 933 | if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) { | 831 | if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) { |
| 934 | av_log(avctx, AV_LOG_ERROR, "qmin and or qmax are set but invalid, please make sure min <= max\n"); | 832 | av_log(avctx, AV_LOG_ERROR, "qmin and or qmax are set but invalid, please make sure min <= max\n"); |
| 935 | return AVERROR(EINVAL); | 833 | return AVERROR(EINVAL); |
| @@ -942,7 +840,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 6 unmodified lines |
| 942 | q->extco2.MaxQPI = avctx->qmax > 51 ? 51 : avctx->qmax; | 840 | q->extco2.MaxQPI = avctx->qmax > 51 ? 51 : avctx->qmax; |
| 943 | q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; | 841 | q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; |
| 944 | } | 842 | } |
| 945 | #endif | | |
| 946 | if (q->mbbrc >= 0) | 843 | if (q->mbbrc >= 0) |
| 947 | q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; | 844 | q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; |
| 948 | | 845 | |
| @@ -951,7 +848,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 2 unmodified lines |
| 951 | | 848 | |
| 952 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco2; | 849 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco2; |
| 953 | } | 850 | } |
| 954 | #endif | | |
| 955 | | 851 | |
| 956 | if (avctx->codec_id == AV_CODEC_ID_H264) { | 852 | if (avctx->codec_id == AV_CODEC_ID_H264) { |
| 957 | #if QSV_HAVE_MF | 853 | #if QSV_HAVE_MF |
| @@ -965,13 +861,11 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 7 unmodified lines |
| 965 | } | 861 | } |
| 966 | #endif | 862 | #endif |
| 967 | } | 863 | } |
| 968 | #if QSV_HAVE_CO3 | | |
| 969 | q->extco3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3; | 864 | q->extco3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3; |
| 970 | q->extco3.Header.BufferSz = sizeof(q->extco3); | 865 | q->extco3.Header.BufferSz = sizeof(q->extco3); |
| 971 | | 866 | |
| 972 | if (avctx->codec_id == AV_CODEC_ID_HEVC || | 867 | if (avctx->codec_id == AV_CODEC_ID_HEVC || |
| 973 | avctx->codec_id == AV_CODEC_ID_H264) { | 868 | avctx->codec_id == AV_CODEC_ID_H264) { |
| 974 | #if QSV_HAVE_PREF | | |
| 975 | switch (q->p_strategy) { | 869 | switch (q->p_strategy) { |
| 976 | case 0: | 870 | case 0: |
| 977 | q->extco3.PRefType = MFX_P_REF_DEFAULT; | 871 | q->extco3.PRefType = MFX_P_REF_DEFAULT; |
| @@ -993,40 +887,27 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 15 unmodified lines |
| 993 | av_log(avctx, AV_LOG_WARNING, | 887 | av_log(avctx, AV_LOG_WARNING, |
| 994 | "Please set max_b_frames(-bf) to 0 to enable P-pyramid\n"); | 888 | "Please set max_b_frames(-bf) to 0 to enable P-pyramid\n"); |
| 995 | } | 889 | } |
| 996 | #endif | | |
| 997 | #if QSV_VERSION_ATLEAST(1, 16) | | |
| 998 | if (q->int_ref_cycle_dist >= 0) | 890 | if (q->int_ref_cycle_dist >= 0) |
| 999 | q->extco3.IntRefCycleDist = q->int_ref_cycle_dist; | 891 | q->extco3.IntRefCycleDist = q->int_ref_cycle_dist; |
| 1000 | #endif | | |
| 1001 | #if QSV_VERSION_ATLEAST(1, 23) | | |
| 1002 | if (q->low_delay_brc >= 0) | 892 | if (q->low_delay_brc >= 0) |
| 1003 | q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; | 893 | q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; |
| 1004 | #endif | | |
| 1005 | #if QSV_VERSION_ATLEAST(1, 19) | | |
| 1006 | if (q->max_frame_size_i >= 0) | 894 | if (q->max_frame_size_i >= 0) |
| 1007 | q->extco3.MaxFrameSizeI = q->max_frame_size_i; | 895 | q->extco3.MaxFrameSizeI = q->max_frame_size_i; |
| 1008 | if (q->max_frame_size_p >= 0) | 896 | if (q->max_frame_size_p >= 0) |
| 1009 | q->extco3.MaxFrameSizeP = q->max_frame_size_p; | 897 | q->extco3.MaxFrameSizeP = q->max_frame_size_p; |
| 1010 | #endif | | |
| 1011 | } | 898 | } |
| 1012 | | 899 | |
| 1013 | if (avctx->codec_id == AV_CODEC_ID_HEVC) { | 900 | if (avctx->codec_id == AV_CODEC_ID_HEVC) { |
| 1014 | #if QSV_VERSION_ATLEAST(1, 26) | | |
| 1015 | if (q->transform_skip >= 0) | 901 | if (q->transform_skip >= 0) |
| 1016 | q->extco3.TransformSkip = q->transform_skip ? MFX_CODINGOPTION_ON : | 902 | q->extco3.TransformSkip = q->transform_skip ? MFX_CODINGOPTION_ON : |
| 1017 | MFX_CODINGOPTION_OFF; | 903 | MFX_CODINGOPTION_OFF; |
| 1018 | else | 904 | else |
| 1019 | q->extco3.TransformSkip = MFX_CODINGOPTION_UNKNOWN; | 905 | q->extco3.TransformSkip = MFX_CODINGOPTION_UNKNOWN; |
| 1020 | #endif | | |
| 1021 | #if QSV_HAVE_GPB | | |
| 1022 | q->extco3.GPB = q->gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; | 906 | q->extco3.GPB = q->gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; |
| 1023 | #endif | | |
| 1024 | } | 907 | } |
| 1025 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco3; | 908 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco3; |
| 1026 | #endif | | |
| 1027 | } | 909 | } |
| 1028 | | 910 | |
| 1029 | #if QSV_HAVE_EXT_VP9_PARAM | | |
| 1030 | if (avctx->codec_id == AV_CODEC_ID_VP9) { | 911 | if (avctx->codec_id == AV_CODEC_ID_VP9) { |
| 1031 | q->extvp9param.Header.BufferId = MFX_EXTBUFF_VP9_PARAM; | 912 | q->extvp9param.Header.BufferId = MFX_EXTBUFF_VP9_PARAM; |
| 1032 | q->extvp9param.Header.BufferSz = sizeof(q->extvp9param); | 913 | q->extvp9param.Header.BufferSz = sizeof(q->extvp9param); |
| @@ -1037,9 +918,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 4 unmodified lines |
| 1037 | #endif | 918 | #endif |
| 1038 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extvp9param; | 919 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extvp9param; |
| 1039 | } | 920 | } |
| 1040 | #endif | | |
| 1041 | | 921 | |
| 1042 | #if QSV_HAVE_EXT_HEVC_TILES | | |
| 1043 | if (avctx->codec_id == AV_CODEC_ID_HEVC) { | 922 | if (avctx->codec_id == AV_CODEC_ID_HEVC) { |
| 1044 | q->exthevctiles.Header.BufferId = MFX_EXTBUFF_HEVC_TILES; | 923 | q->exthevctiles.Header.BufferId = MFX_EXTBUFF_HEVC_TILES; |
| 1045 | q->exthevctiles.Header.BufferSz = sizeof(q->exthevctiles); | 924 | q->exthevctiles.Header.BufferSz = sizeof(q->exthevctiles); |
| @@ -1047,7 +926,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) · 1 unmodified line |
| 1047 | q->exthevctiles.NumTileRows = q->tile_rows; | 926 | q->exthevctiles.NumTileRows = q->tile_rows; |
| 1048 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->exthevctiles; | 927 | q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->exthevctiles; |
| 1049 | } | 928 | } |
| 1050 | #endif | | |
| 1051 | | 929 | |
| 1052 | q->extvsi.VideoFullRange = (avctx->color_range == AVCOL_RANGE_JPEG); | 930 | q->extvsi.VideoFullRange = (avctx->color_range == AVCOL_RANGE_JPEG); |
| 1053 | q->extvsi.ColourDescriptionPresent = 0; | 931 | q->extvsi.ColourDescriptionPresent = 0; |
| @@ -1100,41 +978,44 @@ static int qsv_retrieve_enc_jpeg_params(AVCodecContext *avctx, QSVEncContext *q) · 46 unmodified lines |
| 1100 | static int qsv_retrieve_enc_vp9_params(AVCodecContext *avctx, QSVEncContext *q) | 978 | static int qsv_retrieve_enc_vp9_params(AVCodecContext *avctx, QSVEncContext *q) |
| 1101 | { | 979 | { |
| 1102 | int ret = 0; | 980 | int ret = 0; |
| 1103 | #if QSV_HAVE_EXT_VP9_PARAM | | |
| 1104 | mfxExtVP9Param vp9_extend_buf = { | 981 | mfxExtVP9Param vp9_extend_buf = { |
| 1105 | .Header.BufferId = MFX_EXTBUFF_VP9_PARAM, | 982 | .Header.BufferId = MFX_EXTBUFF_VP9_PARAM, |
| 1106 | .Header.BufferSz = sizeof(vp9_extend_buf), | 983 | .Header.BufferSz = sizeof(vp9_extend_buf), |
| 1107 | }; | 984 | }; |
| 1108 | #endif | | |
| 1109 | | 985 | |
| 1110 | #if QSV_HAVE_CO2 | | |
| 1111 | mfxExtCodingOption2 co2 = { | 986 | mfxExtCodingOption2 co2 = { |
| 1112 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2, | 987 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2, |
| 1113 | .Header.BufferSz = sizeof(co2), | 988 | .Header.BufferSz = sizeof(co2), |
| 1114 | }; | 989 | }; |
| 1115 | #endif | | |
| 1116 | | 990 | |
| 1117 | #if QSV_HAVE_CO3 | | |
| 1118 | mfxExtCodingOption3 co3 = { | 991 | mfxExtCodingOption3 co3 = { |
| 1119 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION3, | 992 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION3, |
| 1120 | .Header.BufferSz = sizeof(co3), | 993 | .Header.BufferSz = sizeof(co3), |
| 1121 | }; | 994 | }; |
| 1122 | #endif | | |
| 1123 | | 995 | |
| 1124 | mfxExtBuffer *ext_buffers[] = { | 996 | mfxExtBuffer *ext_buffers[3]; |
| 1125 | #if QSV_HAVE_EXT_VP9_PARAM | 997 | int ext_buf_num = 0; |
| 1126 | (mfxExtBuffer*)&vp9_extend_buf, | 998 | |
| 1127 | #endif | 999 | q->co2_idx = q->co3_idx = q->vp9_idx = -1; |
| 1128 | #if QSV_HAVE_CO2 | 1000 | |
| 1129 | (mfxExtBuffer*)&co2, | 1001 | // It is possible the runtime doesn't support the given ext buffer |
| 1130 | #endif | 1002 | if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 6)) { |
| 1131 | #if QSV_HAVE_CO3 | 1003 | q->co2_idx = ext_buf_num; |
| 1132 | (mfxExtBuffer*)&co3, | 1004 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co2; |
| 1133 | #endif | 1005 | } |
| 1134 | }; | 1006 | |
| | 1007 | if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11)) { |
| | 1008 | q->co3_idx = ext_buf_num; |
| | 1009 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co3; |
| | 1010 | } |
| | 1011 | |
| | 1012 | if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 26)) { |
| | 1013 | q->vp9_idx = ext_buf_num; |
| | 1014 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&vp9_extend_buf; |
| | 1015 | } |
| 1135 | | 1016 | |
| 1136 | q->param.ExtParam = ext_buffers; | 1017 | q->param.ExtParam = ext_buffers; |
| 1137 | q->param.NumExtParam = FF_ARRAY_ELEMS(ext_buffers); | 1018 | q->param.NumExtParam = ext_buf_num; |
| 1138 | | 1019 | |
| 1139 | ret = MFXVideoENCODE_GetVideoParam(q->session, &q->param); | 1020 | ret = MFXVideoENCODE_GetVideoParam(q->session, &q->param); |
| 1140 | if (ret < 0) | 1021 | if (ret < 0) |
| @@ -1166,20 +1047,15 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) · 25 unmodified lines |
| 1166 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION, | 1047 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION, |
| 1167 | .Header.BufferSz = sizeof(co), | 1048 | .Header.BufferSz = sizeof(co), |
| 1168 | }; | 1049 | }; |
| 1169 | #if QSV_HAVE_CO2 | | |
| 1170 | mfxExtCodingOption2 co2 = { | 1050 | mfxExtCodingOption2 co2 = { |
| 1171 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2, | 1051 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2, |
| 1172 | .Header.BufferSz = sizeof(co2), | 1052 | .Header.BufferSz = sizeof(co2), |
| 1173 | }; | 1053 | }; |
| 1174 | #endif | | |
| 1175 | #if QSV_HAVE_CO3 | | |
| 1176 | mfxExtCodingOption3 co3 = { | 1054 | mfxExtCodingOption3 co3 = { |
| 1177 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION3, | 1055 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION3, |
| 1178 | .Header.BufferSz = sizeof(co3), | 1056 | .Header.BufferSz = sizeof(co3), |
| 1179 | }; | 1057 | }; |
| 1180 | #endif | | |
| 1181 | | 1058 | |
| 1182 | #if QSV_HAVE_CO_VPS | | |
| 1183 | uint8_t vps_buf[128]; | 1059 | uint8_t vps_buf[128]; |
| 1184 | mfxExtCodingOptionVPS extradata_vps = { | 1060 | mfxExtCodingOptionVPS extradata_vps = { |
| 1185 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION_VPS, | 1061 | .Header.BufferId = MFX_EXTBUFF_CODING_OPTION_VPS, |
| @@ -1187,37 +1063,39 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) · 1 unmodified line |
| 1187 | .VPSBuffer = vps_buf, | 1063 | .VPSBuffer = vps_buf, |
| 1188 | .VPSBufSize = sizeof(vps_buf), | 1064 | .VPSBufSize = sizeof(vps_buf), |
| 1189 | }; | 1065 | }; |
| 1190 | #endif | | |
| 1191 | | 1066 | |
| 1192 | #if QSV_HAVE_EXT_HEVC_TILES | | |
| 1193 | mfxExtHEVCTiles hevc_tile_buf = { | 1067 | mfxExtHEVCTiles hevc_tile_buf = { |
| 1194 | .Header.BufferId = MFX_EXTBUFF_HEVC_TILES, | 1068 | .Header.BufferId = MFX_EXTBUFF_HEVC_TILES, |
| 1195 | .Header.BufferSz = sizeof(hevc_tile_buf), | 1069 | .Header.BufferSz = sizeof(hevc_tile_buf), |
| 1196 | }; | 1070 | }; |
| 1197 | #endif | | |
| 1198 | | 1071 | |
| 1199 | mfxExtBuffer *ext_buffers[2 + QSV_HAVE_CO2 + QSV_HAVE_CO3 + QSV_HAVE_CO_VPS + QSV_HAVE_EXT_HEVC_TILES]; | 1072 | mfxExtBuffer *ext_buffers[6]; |
| 1200 | | 1073 | |
| 1201 | int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO; | 1074 | int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO; |
| 1202 | int ret, ext_buf_num = 0, extradata_offset = 0; | 1075 | int ret, ext_buf_num = 0, extradata_offset = 0; |
| 1203 | | 1076 | |
| | 1077 | q->co2_idx = q->co3_idx = q->exthevctiles_idx = -1; |
| 1204 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata; | 1078 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata; |
| 1205 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co; | 1079 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co; |
| 1206 | #if QSV_HAVE_CO2 | 1080 | |
| 1207 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co2; | 1081 | // It is possible the runtime doesn't support the given ext buffer |
| 1208 | #endif | 1082 | if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 6)) { |
| 1209 | #if QSV_HAVE_CO3 | 1083 | q->co2_idx = ext_buf_num; |
| 1210 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co3; | 1084 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co2; |
| 1211 | #endif | 1085 | } |
| 1212 | #if QSV_HAVE_CO_VPS | 1086 | |
| | 1087 | if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11)) { |
| | 1088 | q->co3_idx = ext_buf_num; |
| | 1089 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co3; |
| | 1090 | } |
| | 1091 | |
| 1213 | q->hevc_vps = ((avctx->codec_id == AV_CODEC_ID_HEVC) && QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 17)); | 1092 | q->hevc_vps = ((avctx->codec_id == AV_CODEC_ID_HEVC) && QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 17)); |
| 1214 | if (q->hevc_vps) | 1093 | if (q->hevc_vps) |
| 1215 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata_vps; | 1094 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata_vps; |
| 1216 | #endif | 1095 | if (avctx->codec_id == AV_CODEC_ID_HEVC && QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 13)) { |
| 1217 | #if QSV_HAVE_EXT_HEVC_TILES | 1096 | q->exthevctiles_idx = ext_buf_num; |
| 1218 | if (avctx->codec_id == AV_CODEC_ID_HEVC) | | |
| 1219 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&hevc_tile_buf; | 1097 | ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&hevc_tile_buf; |
| 1220 | #endif | 1098 | } |
| 1221 | | 1099 | |
| 1222 | q->param.ExtParam = ext_buffers; | 1100 | q->param.ExtParam = ext_buffers; |
| 1223 | q->param.NumExtParam = ext_buf_num; | 1101 | q->param.NumExtParam = ext_buf_num; |
| @@ -1230,29 +1108,23 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) · 6 unmodified lines |
| 1230 | q->packet_size = q->param.mfx.BufferSizeInKB * q->param.mfx.BRCParamMultiplier * 1000; | 1108 | q->packet_size = q->param.mfx.BufferSizeInKB * q->param.mfx.BRCParamMultiplier * 1000; |
| 1231 | | 1109 | |
| 1232 | if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize) | 1110 | if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize) |
| 1233 | #if QSV_HAVE_CO_VPS | | |
| 1234 | || (q->hevc_vps && !extradata_vps.VPSBufSize) | 1111 | || (q->hevc_vps && !extradata_vps.VPSBufSize) |
| 1235 | #endif | | |
| 1236 | ) { | 1112 | ) { |
| 1237 | av_log(avctx, AV_LOG_ERROR, "No extradata returned from libmfx.\n"); | 1113 | av_log(avctx, AV_LOG_ERROR, "No extradata returned from libmfx.\n"); |
| 1238 | return AVERROR_UNKNOWN; | 1114 | return AVERROR_UNKNOWN; |
| 1239 | } | 1115 | } |
| 1240 | | 1116 | |
| 1241 | avctx->extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize; | 1117 | avctx->extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize; |
| 1242 | #if QSV_HAVE_CO_VPS | | |
| 1243 | avctx->extradata_size += q->hevc_vps * extradata_vps.VPSBufSize; | 1118 | avctx->extradata_size += q->hevc_vps * extradata_vps.VPSBufSize; |
| 1244 | #endif | | |
| 1245 | | 1119 | |
| 1246 | avctx->extradata = av_malloc(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); | 1120 | avctx->extradata = av_malloc(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); |
| 1247 | if (!avctx->extradata) | 1121 | if (!avctx->extradata) |
| 1248 | return AVERROR(ENOMEM); | 1122 | return AVERROR(ENOMEM); |
| 1249 | | 1123 | |
| 1250 | #if QSV_HAVE_CO_VPS | | |
| 1251 | if (q->hevc_vps) { | 1124 | if (q->hevc_vps) { |
| 1252 | memcpy(avctx->extradata, vps_buf, extradata_vps.VPSBufSize); | 1125 | memcpy(avctx->extradata, vps_buf, extradata_vps.VPSBufSize); |
| 1253 | extradata_offset += extradata_vps.VPSBufSize; | 1126 | extradata_offset += extradata_vps.VPSBufSize; |
| 1254 | } | 1127 | } |
| 1255 | #endif | | |
| 1256 | | 1128 | |
| 1257 | memcpy(avctx->extradata + extradata_offset, sps_buf, extradata.SPSBufSize); | 1129 | memcpy(avctx->extradata + extradata_offset, sps_buf, extradata.SPSBufSize); |
| 1258 | extradata_offset += extradata.SPSBufSize; | 1130 | extradata_offset += extradata.SPSBufSize; |
| @@ -1270,7 +1142,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) · 11 unmodified lines |
| 1270 | cpb_props->avg_bitrate = avctx->bit_rate; | 1142 | cpb_props->avg_bitrate = avctx->bit_rate; |
| 1271 | cpb_props->buffer_size = avctx->rc_buffer_size; | 1143 | cpb_props->buffer_size = avctx->rc_buffer_size; |
| 1272 | | 1144 | |
| 1273 | dump_video_param(avctx, q, ext_buffers + 1); | 1145 | dump_video_param(avctx, q, ext_buffers); |
| 1274 | | 1146 | |
| 1275 | return 0; | 1147 | return 0; |
| 1276 | } | 1148 | } |
| @@ -1652,10 +1524,8 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, · 375 unmodified lines |
| 1652 | const AVFrame *frame) | 1524 | const AVFrame *frame) |
| 1653 | { | 1525 | { |
| 1654 | QSVPacket pkt = { { 0 } }; | 1526 | QSVPacket pkt = { { 0 } }; |
| 1655 | #if QSV_VERSION_ATLEAST(1, 26) | | |
| 1656 | mfxExtAVCEncodedFrameInfo *enc_info = NULL; | 1527 | mfxExtAVCEncodedFrameInfo *enc_info = NULL; |
| 1657 | mfxExtBuffer **enc_buf = NULL; | 1528 | mfxExtBuffer **enc_buf = NULL; |
| 1658 | #endif | | |
| 1659 | | 1529 | |
| 1660 | mfxFrameSurface1 *surf = NULL; | 1530 | mfxFrameSurface1 *surf = NULL; |
| 1661 | QSVFrame *qsv_frame = NULL; | 1531 | QSVFrame *qsv_frame = NULL; |
| @@ -1692,7 +1562,6 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, · 30 unmodified lines |
| 1692 | pkt.bs->Data = pkt.pkt.data; | 1562 | pkt.bs->Data = pkt.pkt.data; |
| 1693 | pkt.bs->MaxLength = pkt.pkt.size; | 1563 | pkt.bs->MaxLength = pkt.pkt.size; |
| 1694 | | 1564 | |
| 1695 | #if QSV_VERSION_ATLEAST(1, 26) | | |
| 1696 | if (avctx->codec_id == AV_CODEC_ID_H264) { | 1565 | if (avctx->codec_id == AV_CODEC_ID_H264) { |
| 1697 | enc_info = av_mallocz(sizeof(*enc_info)); | 1566 | enc_info = av_mallocz(sizeof(*enc_info)); |
| 1698 | if (!enc_info) | 1567 | if (!enc_info) |
| @@ -1708,7 +1577,6 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, · 9 unmodified lines |
| 1708 | | 1577 | |
| 1709 | pkt.bs->ExtParam = enc_buf; | 1578 | pkt.bs->ExtParam = enc_buf; |
| 1710 | } | 1579 | } |
| 1711 | #endif | | |
| 1712 | | 1580 | |
| 1713 | if (q->set_encode_ctrl_cb) { | 1581 | if (q->set_encode_ctrl_cb) { |
| 1714 | q->set_encode_ctrl_cb(avctx, frame, &qsv_frame->enc_ctrl); | 1582 | q->set_encode_ctrl_cb(avctx, frame, &qsv_frame->enc_ctrl); |
| @@ -1745,12 +1613,10 @@ free: · 30 unmodified lines |
| 1745 | av_freep(&pkt.sync); | 1613 | av_freep(&pkt.sync); |
| 1746 | av_packet_unref(&pkt.pkt); | 1614 | av_packet_unref(&pkt.pkt); |
| 1747 | av_freep(&pkt.bs); | 1615 | av_freep(&pkt.bs); |
| 1748 | #if QSV_VERSION_ATLEAST(1, 26) | | |
| 1749 | if (avctx->codec_id == AV_CODEC_ID_H264) { | 1616 | if (avctx->codec_id == AV_CODEC_ID_H264) { |
| 1750 | av_freep(&enc_info); | 1617 | av_freep(&enc_info); |
| 1751 | av_freep(&enc_buf); | 1618 | av_freep(&enc_buf); |
| 1752 | } | 1619 | } |
| 1753 | #endif | | |
| 1754 | } | 1620 | } |
| 1755 | | 1621 | |
| 1756 | return ret; | 1622 | return ret; |
| @@ -1771,10 +1637,8 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, · 14 unmodified lines |
| 1771 | if ((av_fifo_can_read(q->async_fifo) >= q->async_depth) || | 1637 | if ((av_fifo_can_read(q->async_fifo) >= q->async_depth) || |
| 1772 | (!frame && av_fifo_can_read(q->async_fifo))) { | 1638 | (!frame && av_fifo_can_read(q->async_fifo))) { |
| 1773 | QSVPacket qpkt; | 1639 | QSVPacket qpkt; |
| 1774 | #if QSV_VERSION_ATLEAST(1, 26) | | |
| 1775 | mfxExtAVCEncodedFrameInfo *enc_info; | 1640 | mfxExtAVCEncodedFrameInfo *enc_info; |
| 1776 | mfxExtBuffer **enc_buf; | 1641 | mfxExtBuffer **enc_buf; |
| 1777 | #endif | | |
| 1778 | enum AVPictureType pict_type; | 1642 | enum AVPictureType pict_type; |
| 1779 | | 1643 | |
| 1780 | av_fifo_read(q->async_fifo, &qpkt, 1); | 1644 | av_fifo_read(q->async_fifo, &qpkt, 1); |
| @@ -1804,7 +1668,6 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, · 23 unmodified lines |
| 1804 | return AVERROR_INVALIDDATA; | 1668 | return AVERROR_INVALIDDATA; |
| 1805 | } | 1669 | } |
| 1806 | | 1670 | |
| 1807 | #if QSV_VERSION_ATLEAST(1, 26) | | |
| 1808 | if (avctx->codec_id == AV_CODEC_ID_H264) { | 1671 | if (avctx->codec_id == AV_CODEC_ID_H264) { |
| 1809 | enc_buf = qpkt.bs->ExtParam; | 1672 | enc_buf = qpkt.bs->ExtParam; |
| 1810 | enc_info = (mfxExtAVCEncodedFrameInfo *)(*enc_buf); | 1673 | enc_info = (mfxExtAVCEncodedFrameInfo *)(*enc_buf); |
| @@ -1813,7 +1676,6 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, · 2 unmodified lines |
| 1813 | av_freep(&enc_info); | 1676 | av_freep(&enc_info); |
| 1814 | av_freep(&enc_buf); | 1677 | av_freep(&enc_buf); |
| 1815 | } | 1678 | } |
| 1816 | #endif | | |
| 1817 | av_freep(&qpkt.bs); | 1679 | av_freep(&qpkt.bs); |
| 1818 | av_freep(&qpkt.sync); | 1680 | av_freep(&qpkt.sync); |
| 1819 | | 1681 | |
| @@ -1850,14 +1712,12 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) · 30 unmodified lines |
| 1850 | if (q->async_fifo) { | 1712 | if (q->async_fifo) { |
| 1851 | QSVPacket pkt; | 1713 | QSVPacket pkt; |
| 1852 | while (av_fifo_read(q->async_fifo, &pkt, 1) >= 0) { | 1714 | while (av_fifo_read(q->async_fifo, &pkt, 1) >= 0) { |
| 1853 | #if QSV_VERSION_ATLEAST(1, 26) | | |
| 1854 | if (avctx->codec_id == AV_CODEC_ID_H264) { | 1715 | if (avctx->codec_id == AV_CODEC_ID_H264) { |
| 1855 | mfxExtBuffer **enc_buf = pkt.bs->ExtParam; | 1716 | mfxExtBuffer **enc_buf = pkt.bs->ExtParam; |
| 1856 | mfxExtAVCEncodedFrameInfo *enc_info = (mfxExtAVCEncodedFrameInfo *)(*enc_buf); | 1717 | mfxExtAVCEncodedFrameInfo *enc_info = (mfxExtAVCEncodedFrameInfo *)(*enc_buf); |
| 1857 | av_freep(&enc_info); | 1718 | av_freep(&enc_info); |
| 1858 | av_freep(&enc_buf); | 1719 | av_freep(&enc_buf); |
| 1859 | } | 1720 | } |
| 1860 | #endif | | |
| 1861 | av_freep(&pkt.sync); | 1721 | av_freep(&pkt.sync); |
| 1862 | av_freep(&pkt.bs); | 1722 | av_freep(&pkt.bs); |
| 1863 | av_packet_unref(&pkt.pkt); | 1723 | av_packet_unref(&pkt.pkt); |