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