| 359 | } |
| 360 | |
| 361 | static int vaapi_encode_av1_init_sequence_params(AVCodecContext *avctx) |
| 362 | { |
| 363 | FFHWBaseEncodeContext *base_ctx = avctx->priv_data; |
| 364 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 365 | VAAPIEncodeAV1Context *priv = avctx->priv_data; |
| 366 | AV1RawOBU *sh_obu = &priv->sh; |
| 367 | AV1RawSequenceHeader *sh = &sh_obu->obu.sequence_header; |
| 368 | VAEncSequenceParameterBufferAV1 *vseq = ctx->codec_sequence_params; |
| 369 | CodedBitstreamFragment *obu = &priv->current_obu; |
| 370 | const AVPixFmtDescriptor *desc; |
| 371 | int ret; |
| 372 | |
| 373 | memset(sh_obu, 0, sizeof(*sh_obu)); |
| 374 | sh_obu->header.obu_type = AV1_OBU_SEQUENCE_HEADER; |
| 375 | |
| 376 | desc = av_pix_fmt_desc_get(base_ctx->input_frames->sw_format); |
| 377 | av_assert0(desc); |
| 378 | |
| 379 | sh->seq_profile = avctx->profile; |
| 380 | if (!sh->seq_force_screen_content_tools) |
| 381 | sh->seq_force_integer_mv = AV1_SELECT_INTEGER_MV; |
| 382 | sh->frame_width_bits_minus_1 = av_log2(avctx->width); |
| 383 | sh->frame_height_bits_minus_1 = av_log2(avctx->height); |
| 384 | sh->max_frame_width_minus_1 = avctx->width - 1; |
| 385 | sh->max_frame_height_minus_1 = avctx->height - 1; |
| 386 | sh->seq_tier[0] = priv->tier; |
| 387 | /** enable order hint and reserve maximum 8 bits for it by default. */ |
| 388 | sh->enable_order_hint = 1; |
| 389 | sh->order_hint_bits_minus_1 = 7; |
| 390 | |
| 391 | sh->color_config = (AV1RawColorConfig) { |
| 392 | .high_bitdepth = desc->comp[0].depth == 8 ? 0 : 1, |
| 393 | .color_primaries = avctx->color_primaries, |
| 394 | .transfer_characteristics = avctx->color_trc, |
| 395 | .matrix_coefficients = avctx->colorspace, |
| 396 | .color_description_present_flag = (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || |
| 397 | avctx->color_trc != AVCOL_TRC_UNSPECIFIED || |
| 398 | avctx->colorspace != AVCOL_SPC_UNSPECIFIED), |
| 399 | .color_range = avctx->color_range == AVCOL_RANGE_JPEG, |
| 400 | .subsampling_x = desc->log2_chroma_w, |
| 401 | .subsampling_y = desc->log2_chroma_h, |
| 402 | }; |
| 403 | |
| 404 | switch (avctx->chroma_sample_location) { |
| 405 | case AVCHROMA_LOC_LEFT: |
| 406 | sh->color_config.chroma_sample_position = AV1_CSP_VERTICAL; |
| 407 | break; |
| 408 | case AVCHROMA_LOC_TOPLEFT: |
| 409 | sh->color_config.chroma_sample_position = AV1_CSP_COLOCATED; |
| 410 | break; |
| 411 | default: |
| 412 | sh->color_config.chroma_sample_position = AV1_CSP_UNKNOWN; |
| 413 | break; |
| 414 | } |
| 415 | |
| 416 | if (avctx->level != AV_LEVEL_UNKNOWN) { |
| 417 | sh->seq_level_idx[0] = avctx->level; |
| 418 | } else { |
nothing calls this directly
no test coverage detected