| 466 | } |
| 467 | |
| 468 | static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx, |
| 469 | FFHWBaseEncodePicture *pic) |
| 470 | { |
| 471 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 472 | VAAPIEncodeAV1Context *priv = avctx->priv_data; |
| 473 | VAAPIEncodePicture *vaapi_pic = pic->priv; |
| 474 | VAAPIEncodeAV1Picture *hpic = pic->codec_priv; |
| 475 | AV1RawOBU *fh_obu = &priv->fh; |
| 476 | AV1RawFrameHeader *fh = &fh_obu->obu.frame.header; |
| 477 | VAEncPictureParameterBufferAV1 *vpic = vaapi_pic->codec_picture_params; |
| 478 | CodedBitstreamFragment *obu = &priv->current_obu; |
| 479 | CodedBitstreamAV1Context *cbctx = priv->cbc->priv_data; |
| 480 | FFHWBaseEncodePicture *ref; |
| 481 | VAAPIEncodeAV1Picture *href; |
| 482 | int slot, i; |
| 483 | int ret; |
| 484 | static const int8_t default_loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME] = |
| 485 | { 1, 0, 0, 0, -1, 0, -1, -1 }; |
| 486 | |
| 487 | memset(fh_obu, 0, sizeof(*fh_obu)); |
| 488 | vaapi_pic->nb_slices = priv->tile_groups; |
| 489 | vaapi_pic->non_independent_frame = pic->encode_order < pic->display_order; |
| 490 | fh_obu->header.obu_type = AV1_OBU_FRAME_HEADER; |
| 491 | fh_obu->header.obu_has_size_field = 1; |
| 492 | |
| 493 | switch (pic->type) { |
| 494 | case FF_HW_PICTURE_TYPE_IDR: |
| 495 | av_assert0(pic->nb_refs[0] == 0 || pic->nb_refs[1]); |
| 496 | fh->frame_type = AV1_FRAME_KEY; |
| 497 | fh->refresh_frame_flags = 0xFF; |
| 498 | fh->base_q_idx = priv->q_idx_idr; |
| 499 | hpic->slot = 0; |
| 500 | hpic->last_idr_frame = pic->display_order; |
| 501 | break; |
| 502 | case FF_HW_PICTURE_TYPE_P: |
| 503 | av_assert0(pic->nb_refs[0]); |
| 504 | fh->frame_type = AV1_FRAME_INTER; |
| 505 | fh->base_q_idx = priv->q_idx_p; |
| 506 | ref = pic->refs[0][pic->nb_refs[0] - 1]; |
| 507 | href = ref->codec_priv; |
| 508 | hpic->slot = !href->slot; |
| 509 | hpic->last_idr_frame = href->last_idr_frame; |
| 510 | fh->refresh_frame_flags = 1 << hpic->slot; |
| 511 | |
| 512 | /** set the nearest frame in L0 as all reference frame. */ |
| 513 | for (i = 0; i < AV1_REFS_PER_FRAME; i++) { |
| 514 | fh->ref_frame_idx[i] = href->slot; |
| 515 | } |
| 516 | fh->primary_ref_frame = href->slot; |
| 517 | fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame; |
| 518 | vpic->ref_frame_ctrl_l0.fields.search_idx0 = AV1_REF_FRAME_LAST; |
| 519 | |
| 520 | /** set the 2nd nearest frame in L0 as Golden frame. */ |
| 521 | if (pic->nb_refs[0] > 1) { |
| 522 | ref = pic->refs[0][pic->nb_refs[0] - 2]; |
| 523 | href = ref->codec_priv; |
| 524 | fh->ref_frame_idx[3] = href->slot; |
| 525 | fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame; |
nothing calls this directly
no test coverage detected