static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, const HEVCContext *h,

                                    DXVA_PicParams_HEVC *pp)

{

    const HEVCFrame *current_picture = h->ref;

    int i, j, k;



    memset(pp, 0, sizeof(*pp));



    pp->PicWidthInMinCbsY  = h->sps->min_cb_width;

    pp->PicHeightInMinCbsY = h->sps->min_cb_height;



    pp->wFormatAndSequenceInfoFlags = (h->sps->chroma_format_idc          <<  0) |

                                      (h->sps->separate_colour_plane_flag <<  2) |

                                      ((h->sps->bit_depth - 8)            <<  3) |

                                      ((h->sps->bit_depth - 8)            <<  6) |

                                      ((h->sps->log2_max_poc_lsb - 4)     <<  9) |

                                      (0                                  << 13) |

                                      (0                                  << 14) |

                                      (0                                  << 15);



    fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture->frame), 0);



    pp->sps_max_dec_pic_buffering_minus1         = h->sps->temporal_layer[h->sps->max_sub_layers - 1].max_dec_pic_buffering - 1;

    pp->log2_min_luma_coding_block_size_minus3   = h->sps->log2_min_cb_size - 3;

    pp->log2_diff_max_min_luma_coding_block_size = h->sps->log2_diff_max_min_coding_block_size;

    pp->log2_min_transform_block_size_minus2     = h->sps->log2_min_tb_size - 2;

    pp->log2_diff_max_min_transform_block_size   = h->sps->log2_max_trafo_size  - h->sps->log2_min_tb_size;

    pp->max_transform_hierarchy_depth_inter      = h->sps->max_transform_hierarchy_depth_inter;

    pp->max_transform_hierarchy_depth_intra      = h->sps->max_transform_hierarchy_depth_intra;

    pp->num_short_term_ref_pic_sets              = h->sps->nb_st_rps;

    pp->num_long_term_ref_pics_sps               = h->sps->num_long_term_ref_pics_sps;



    pp->num_ref_idx_l0_default_active_minus1     = h->pps->num_ref_idx_l0_default_active - 1;

    pp->num_ref_idx_l1_default_active_minus1     = h->pps->num_ref_idx_l1_default_active - 1;

    pp->init_qp_minus26                          = h->pps->pic_init_qp_minus26;



    if (h->sh.short_term_ref_pic_set_sps_flag == 0 && h->sh.short_term_rps) {

        pp->ucNumDeltaPocsOfRefRpsIdx            = h->sh.short_term_rps->num_delta_pocs;

        pp->wNumBitsForShortTermRPSInSlice       = h->sh.short_term_ref_pic_set_size;

    }



    pp->dwCodingParamToolFlags = (h->sps->scaling_list_enable_flag               <<  0) |

                                 (h->sps->amp_enabled_flag                       <<  1) |

                                 (h->sps->sao_enabled                            <<  2) |

                                 (h->sps->pcm_enabled_flag                       <<  3) |

                                 ((h->sps->pcm_enabled_flag ? (h->sps->pcm.bit_depth - 1) : 0)            <<  4) |

                                 ((h->sps->pcm_enabled_flag ? (h->sps->pcm.bit_depth_chroma - 1) : 0)     <<  8) |

                                 ((h->sps->pcm_enabled_flag ? (h->sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) |

                                 ((h->sps->pcm_enabled_flag ? (h->sps->pcm.log2_max_pcm_cb_size - h->sps->pcm.log2_min_pcm_cb_size) : 0) << 14) |

                                 (h->sps->pcm.loop_filter_disable_flag           << 16) |

                                 (h->sps->long_term_ref_pics_present_flag        << 17) |

                                 (h->sps->sps_temporal_mvp_enabled_flag          << 18) |

                                 (h->sps->sps_strong_intra_smoothing_enable_flag << 19) |

                                 (h->pps->dependent_slice_segments_enabled_flag  << 20) |

                                 (h->pps->output_flag_present_flag               << 21) |

                                 (h->pps->num_extra_slice_header_bits            << 22) |

                                 (h->pps->sign_data_hiding_flag                  << 25) |

                                 (h->pps->cabac_init_present_flag                << 26) |

                                 (0                                              << 27);



    pp->dwCodingSettingPicturePropertyFlags = (h->pps->constrained_intra_pred_flag                <<  0) |

                                              (h->pps->transform_skip_enabled_flag                <<  1) |

                                              (h->pps->cu_qp_delta_enabled_flag                   <<  2) |

                                              (h->pps->pic_slice_level_chroma_qp_offsets_present_flag <<  3) |

                                              (h->pps->weighted_pred_flag                         <<  4) |

                                              (h->pps->weighted_bipred_flag                       <<  5) |

                                              (h->pps->transquant_bypass_enable_flag              <<  6) |

                                              (h->pps->tiles_enabled_flag                         <<  7) |

                                              (h->pps->entropy_coding_sync_enabled_flag           <<  8) |

                                              (h->pps->uniform_spacing_flag                       <<  9) |

                                              ((h->pps->tiles_enabled_flag ? h->pps->loop_filter_across_tiles_enabled_flag : 0) << 10) |

                                              (h->pps->seq_loop_filter_across_slices_enabled_flag << 11) |

                                              (h->pps->deblocking_filter_override_enabled_flag    << 12) |

                                              (h->pps->disable_dbf                                << 13) |

                                              (h->pps->lists_modification_present_flag            << 14) |

                                              (h->pps->slice_header_extension_present_flag        << 15) |

                                              (IS_IRAP(h)                                         << 16) |

                                              (IS_IDR(h)                                          << 17) |

                                              /* IntraPicFlag */

                                              (IS_IRAP(h)                                         << 18) |

                                              (0                                                  << 19);

    pp->pps_cb_qp_offset            = h->pps->cb_qp_offset;

    pp->pps_cr_qp_offset            = h->pps->cr_qp_offset;

    if (h->pps->tiles_enabled_flag) {

        pp->num_tile_columns_minus1 = h->pps->num_tile_columns - 1;

        pp->num_tile_rows_minus1    = h->pps->num_tile_rows - 1;



        if (!h->pps->uniform_spacing_flag) {

            for (i = 0; i < h->pps->num_tile_columns; i++)

                pp->column_width_minus1[i] = h->pps->column_width[i] - 1;



            for (i = 0; i < h->pps->num_tile_rows; i++)

                pp->row_height_minus1[i] = h->pps->row_height[i] - 1;

        }

    }



    pp->diff_cu_qp_delta_depth           = h->pps->diff_cu_qp_delta_depth;

    pp->pps_beta_offset_div2             = h->pps->beta_offset / 2;

    pp->pps_tc_offset_div2               = h->pps->tc_offset / 2;

    pp->log2_parallel_merge_level_minus2 = h->pps->log2_parallel_merge_level - 2;

    pp->CurrPicOrderCntVal               = h->poc;



    // empty the lists

    memset(&pp->RefPicList, 0xff, sizeof(pp->RefPicList));

    memset(&pp->RefPicSetStCurrBefore, 0xff, sizeof(pp->RefPicSetStCurrBefore));

    memset(&pp->RefPicSetStCurrAfter, 0xff, sizeof(pp->RefPicSetStCurrAfter));

    memset(&pp->RefPicSetLtCurr, 0xff, sizeof(pp->RefPicSetLtCurr));



    // fill RefPicList from the DPB

    for (i = 0, j = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) {

        const HEVCFrame *frame = &h->DPB[i];

        if (frame != current_picture && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) {

            fill_picture_entry(&pp->RefPicList[j], ff_dxva2_get_surface_index(avctx, ctx, frame->frame), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));

            pp->PicOrderCntValList[j] = frame->poc;

            j++;

        }

    }



    #define DO_REF_LIST(ref_idx, ref_list) { \

        const RefPicList *rpl = &h->rps[ref_idx]; \

        av_assert0(rpl->nb_refs <= FF_ARRAY_ELEMS(pp->ref_list)); \

        for (j = 0, k = 0; j < rpl->nb_refs; j++) { \

            if (rpl->ref[j]) { \

                pp->ref_list[k] = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, rpl->ref[j]->frame)); \

                k++; \

            } \

        } \

    }



    // Fill short term and long term lists

    DO_REF_LIST(ST_CURR_BEF, RefPicSetStCurrBefore);

    DO_REF_LIST(ST_CURR_AFT, RefPicSetStCurrAfter);

    DO_REF_LIST(LT_CURR, RefPicSetLtCurr);



    pp->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(avctx, ctx)++;

}

static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, const HEVCContext *h,

                                    DXVA_PicParams_HEVC *pp)

{

    const HEVCFrame *current_picture = h->ref;

    int i, j, k;



    memset(pp, 0, sizeof(*pp));



    pp->PicWidthInMinCbsY  = h->sps->min_cb_width;

    pp->PicHeightInMinCbsY = h->sps->min_cb_height;



    pp->wFormatAndSequenceInfoFlags = (h->sps->chroma_format_idc          <<  0) |

                                      (h->sps->separate_colour_plane_flag <<  2) |

                                      ((h->sps->bit_depth - 8)            <<  3) |

                                      ((h->sps->bit_depth - 8)            <<  6) |

                                      ((h->sps->log2_max_poc_lsb - 4)     <<  9) |

                                      (0                                  << 13) |

                                      (0                                  << 14) |

                                      (0                                  << 15);



    fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture->frame), 0);



    pp->sps_max_dec_pic_buffering_minus1         = h->sps->temporal_layer[h->sps->max_sub_layers - 1].max_dec_pic_buffering - 1;

    pp->log2_min_luma_coding_block_size_minus3   = h->sps->log2_min_cb_size - 3;

    pp->log2_diff_max_min_luma_coding_block_size = h->sps->log2_diff_max_min_coding_block_size;

    pp->log2_min_transform_block_size_minus2     = h->sps->log2_min_tb_size - 2;

    pp->log2_diff_max_min_transform_block_size   = h->sps->log2_max_trafo_size  - h->sps->log2_min_tb_size;

    pp->max_transform_hierarchy_depth_inter      = h->sps->max_transform_hierarchy_depth_inter;

    pp->max_transform_hierarchy_depth_intra      = h->sps->max_transform_hierarchy_depth_intra;

    pp->num_short_term_ref_pic_sets              = h->sps->nb_st_rps;

    pp->num_long_term_ref_pics_sps               = h->sps->num_long_term_ref_pics_sps;



    pp->num_ref_idx_l0_default_active_minus1     = h->pps->num_ref_idx_l0_default_active - 1;

    pp->num_ref_idx_l1_default_active_minus1     = h->pps->num_ref_idx_l1_default_active - 1;

    pp->init_qp_minus26                          = h->pps->pic_init_qp_minus26;



    if (h->sh.short_term_ref_pic_set_sps_flag == 0 && h->sh.short_term_rps) {

        pp->ucNumDeltaPocsOfRefRpsIdx            = h->sh.short_term_rps->num_delta_pocs;

        pp->wNumBitsForShortTermRPSInSlice       = h->sh.short_term_ref_pic_set_size;

    }



    pp->dwCodingParamToolFlags = (h->sps->scaling_list_enable_flag               <<  0) |

                                 (h->sps->amp_enabled_flag                       <<  1) |

                                 (h->sps->sao_enabled                            <<  2) |

                                 (h->sps->pcm_enabled_flag                       <<  3) |

                                 ((h->sps->pcm_enabled_flag ? (h->sps->pcm.bit_depth - 1) : 0)            <<  4) |

                                 ((h->sps->pcm_enabled_flag ? (h->sps->pcm.bit_depth_chroma - 1) : 0)     <<  8) |

                                 ((h->sps->pcm_enabled_flag ? (h->sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) |

                                 ((h->sps->pcm_enabled_flag ? (h->sps->pcm.log2_max_pcm_cb_size - h->sps->pcm.log2_min_pcm_cb_size) : 0) << 14) |

                                 (h->sps->pcm.loop_filter_disable_flag           << 16) |

                                 (h->sps->long_term_ref_pics_present_flag        << 17) |

                                 (h->sps->sps_temporal_mvp_enabled_flag          << 18) |

                                 (h->sps->sps_strong_intra_smoothing_enable_flag << 19) |

                                 (h->pps->dependent_slice_segments_enabled_flag  << 20) |

                                 (h->pps->output_flag_present_flag               << 21) |

                                 (h->pps->num_extra_slice_header_bits            << 22) |

                                 (h->pps->sign_data_hiding_flag                  << 25) |

                                 (h->pps->cabac_init_present_flag                << 26) |

                                 (0                                              << 27);



    pp->dwCodingSettingPicturePropertyFlags = (h->pps->constrained_intra_pred_flag                <<  0) |

                                              (h->pps->transform_skip_enabled_flag                <<  1) |

                                              (h->pps->cu_qp_delta_enabled_flag                   <<  2) |

                                              (h->pps->pic_slice_level_chroma_qp_offsets_present_flag <<  3) |

                                              (h->pps->weighted_pred_flag                         <<  4) |

                                              (h->pps->weighted_bipred_flag                       <<  5) |

                                              (h->pps->transquant_bypass_enable_flag              <<  6) |

                                              (h->pps->tiles_enabled_flag                         <<  7) |

                                              (h->pps->entropy_coding_sync_enabled_flag           <<  8) |

                                              (h->pps->uniform_spacing_flag                       <<  9) |

                                              ((h->pps->tiles_enabled_flag ? h->pps->loop_filter_across_tiles_enabled_flag : 0) << 10) |

                                              (h->pps->seq_loop_filter_across_slices_enabled_flag << 11) |

                                              (h->pps->deblocking_filter_override_enabled_flag    << 12) |

                                              (h->pps->disable_dbf                                << 13) |

                                              (h->pps->lists_modification_present_flag            << 14) |

                                              (h->pps->slice_header_extension_present_flag        << 15) |

                                              (IS_IRAP(h)                                         << 16) |

                                              (IS_IDR(h)                                          << 17) |

                                              

                                              (IS_IRAP(h)                                         << 18) |

                                              (0                                                  << 19);

    pp->pps_cb_qp_offset            = h->pps->cb_qp_offset;

    pp->pps_cr_qp_offset            = h->pps->cr_qp_offset;

    if (h->pps->tiles_enabled_flag) {

        pp->num_tile_columns_minus1 = h->pps->num_tile_columns - 1;

        pp->num_tile_rows_minus1    = h->pps->num_tile_rows - 1;



        if (!h->pps->uniform_spacing_flag) {

            for (i = 0; i < h->pps->num_tile_columns; i++)

                pp->column_width_minus1[i] = h->pps->column_width[i] - 1;



            for (i = 0; i < h->pps->num_tile_rows; i++)

                pp->row_height_minus1[i] = h->pps->row_height[i] - 1;

        }

    }



    pp->diff_cu_qp_delta_depth           = h->pps->diff_cu_qp_delta_depth;

    pp->pps_beta_offset_div2             = h->pps->beta_offset / 2;

    pp->pps_tc_offset_div2               = h->pps->tc_offset / 2;

    pp->log2_parallel_merge_level_minus2 = h->pps->log2_parallel_merge_level - 2;

    pp->CurrPicOrderCntVal               = h->poc;



    

    memset(&pp->RefPicList, 0xff, sizeof(pp->RefPicList));

    memset(&pp->RefPicSetStCurrBefore, 0xff, sizeof(pp->RefPicSetStCurrBefore));

    memset(&pp->RefPicSetStCurrAfter, 0xff, sizeof(pp->RefPicSetStCurrAfter));

    memset(&pp->RefPicSetLtCurr, 0xff, sizeof(pp->RefPicSetLtCurr));



    

    for (i = 0, j = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) {

        const HEVCFrame *frame = &h->DPB[i];

        if (frame != current_picture && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) {

            fill_picture_entry(&pp->RefPicList[j], ff_dxva2_get_surface_index(avctx, ctx, frame->frame), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));

            pp->PicOrderCntValList[j] = frame->poc;

            j++;

        }

    }



    #define DO_REF_LIST(ref_idx, ref_list) { \

        const RefPicList *rpl = &h->rps[ref_idx]; \

        av_assert0(rpl->nb_refs <= FF_ARRAY_ELEMS(pp->ref_list)); \

        for (j = 0, k = 0; j < rpl->nb_refs; j++) { \

            if (rpl->ref[j]) { \

                pp->ref_list[k] = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, rpl->ref[j]->frame)); \

                k++; \

            } \

        } \

    }



    

    DO_REF_LIST(ST_CURR_BEF, RefPicSetStCurrBefore);

    DO_REF_LIST(ST_CURR_AFT, RefPicSetStCurrAfter);

    DO_REF_LIST(LT_CURR, RefPicSetLtCurr);



    pp->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(avctx, ctx)++;

}

    int i, j, k;     memset(&pp->RefPicList, 0xff, sizeof(pp->RefPicList));     memset(&pp->RefPicSetStCurrBefore, 0xff, sizeof(pp->RefPicSetStCurrBefore));     memset(&pp->RefPicSetStCurrAfter, 0xff, sizeof(pp->RefPicSetStCurrAfter));     memset(&pp->RefPicSetLtCurr, 0xff, sizeof(pp->RefPicSetLtCurr));     for (i = 0, j = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) {         const HEVCFrame *frame = &h->DPB[i];         if (frame != current_picture && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) {             fill_picture_entry(&pp->RefPicList[j], ff_dxva2_get_surface_index(avctx, ctx, frame->frame), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));             pp->PicOrderCntValList[j] = frame->poc;         av_assert0(rpl->nb_refs <= FF_ARRAY_ELEMS(pp->ref_list)); \         for (j = 0, k = 0; j < rpl->nb_refs; j++) { \             if (rpl->ref[j]) { \                 pp->ref_list[k] = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, rpl->ref[j]->frame)); \                 k++; \             } \
static void FUNC_0(const AVCodecContext *VAR_0, AVDXVAContext *VAR_1, const HEVCContext *VAR_2,

                                    DXVA_PicParams_HEVC *VAR_3)

{

    const HEVCFrame *VAR_4 = VAR_2->ref;

    int VAR_5, VAR_6, VAR_7;



    memset(VAR_3, 0, sizeof(*VAR_3));



    VAR_3->PicWidthInMinCbsY  = VAR_2->sps->min_cb_width;

    VAR_3->PicHeightInMinCbsY = VAR_2->sps->min_cb_height;



    VAR_3->wFormatAndSequenceInfoFlags = (VAR_2->sps->chroma_format_idc          <<  0) |

                                      (VAR_2->sps->separate_colour_plane_flag <<  2) |

                                      ((VAR_2->sps->bit_depth - 8)            <<  3) |

                                      ((VAR_2->sps->bit_depth - 8)            <<  6) |

                                      ((VAR_2->sps->log2_max_poc_lsb - 4)     <<  9) |

                                      (0                                  << 13) |

                                      (0                                  << 14) |

                                      (0                                  << 15);



    fill_picture_entry(&VAR_3->CurrPic, ff_dxva2_get_surface_index(VAR_0, VAR_1, VAR_4->frame), 0);



    VAR_3->sps_max_dec_pic_buffering_minus1         = VAR_2->sps->temporal_layer[VAR_2->sps->max_sub_layers - 1].max_dec_pic_buffering - 1;

    VAR_3->log2_min_luma_coding_block_size_minus3   = VAR_2->sps->log2_min_cb_size - 3;

    VAR_3->log2_diff_max_min_luma_coding_block_size = VAR_2->sps->log2_diff_max_min_coding_block_size;

    VAR_3->log2_min_transform_block_size_minus2     = VAR_2->sps->log2_min_tb_size - 2;

    VAR_3->log2_diff_max_min_transform_block_size   = VAR_2->sps->log2_max_trafo_size  - VAR_2->sps->log2_min_tb_size;

    VAR_3->max_transform_hierarchy_depth_inter      = VAR_2->sps->max_transform_hierarchy_depth_inter;

    VAR_3->max_transform_hierarchy_depth_intra      = VAR_2->sps->max_transform_hierarchy_depth_intra;

    VAR_3->num_short_term_ref_pic_sets              = VAR_2->sps->nb_st_rps;

    VAR_3->num_long_term_ref_pics_sps               = VAR_2->sps->num_long_term_ref_pics_sps;



    VAR_3->num_ref_idx_l0_default_active_minus1     = VAR_2->pps->num_ref_idx_l0_default_active - 1;

    VAR_3->num_ref_idx_l1_default_active_minus1     = VAR_2->pps->num_ref_idx_l1_default_active - 1;

    VAR_3->init_qp_minus26                          = VAR_2->pps->pic_init_qp_minus26;



    if (VAR_2->sh.short_term_ref_pic_set_sps_flag == 0 && VAR_2->sh.short_term_rps) {

        VAR_3->ucNumDeltaPocsOfRefRpsIdx            = VAR_2->sh.short_term_rps->num_delta_pocs;

        VAR_3->wNumBitsForShortTermRPSInSlice       = VAR_2->sh.short_term_ref_pic_set_size;

    }



    VAR_3->dwCodingParamToolFlags = (VAR_2->sps->scaling_list_enable_flag               <<  0) |

                                 (VAR_2->sps->amp_enabled_flag                       <<  1) |

                                 (VAR_2->sps->sao_enabled                            <<  2) |

                                 (VAR_2->sps->pcm_enabled_flag                       <<  3) |

                                 ((VAR_2->sps->pcm_enabled_flag ? (VAR_2->sps->pcm.bit_depth - 1) : 0)            <<  4) |

                                 ((VAR_2->sps->pcm_enabled_flag ? (VAR_2->sps->pcm.bit_depth_chroma - 1) : 0)     <<  8) |

                                 ((VAR_2->sps->pcm_enabled_flag ? (VAR_2->sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) |

                                 ((VAR_2->sps->pcm_enabled_flag ? (VAR_2->sps->pcm.log2_max_pcm_cb_size - VAR_2->sps->pcm.log2_min_pcm_cb_size) : 0) << 14) |

                                 (VAR_2->sps->pcm.loop_filter_disable_flag           << 16) |

                                 (VAR_2->sps->long_term_ref_pics_present_flag        << 17) |

                                 (VAR_2->sps->sps_temporal_mvp_enabled_flag          << 18) |

                                 (VAR_2->sps->sps_strong_intra_smoothing_enable_flag << 19) |

                                 (VAR_2->pps->dependent_slice_segments_enabled_flag  << 20) |

                                 (VAR_2->pps->output_flag_present_flag               << 21) |

                                 (VAR_2->pps->num_extra_slice_header_bits            << 22) |

                                 (VAR_2->pps->sign_data_hiding_flag                  << 25) |

                                 (VAR_2->pps->cabac_init_present_flag                << 26) |

                                 (0                                              << 27);



    VAR_3->dwCodingSettingPicturePropertyFlags = (VAR_2->pps->constrained_intra_pred_flag                <<  0) |

                                              (VAR_2->pps->transform_skip_enabled_flag                <<  1) |

                                              (VAR_2->pps->cu_qp_delta_enabled_flag                   <<  2) |

                                              (VAR_2->pps->pic_slice_level_chroma_qp_offsets_present_flag <<  3) |

                                              (VAR_2->pps->weighted_pred_flag                         <<  4) |

                                              (VAR_2->pps->weighted_bipred_flag                       <<  5) |

                                              (VAR_2->pps->transquant_bypass_enable_flag              <<  6) |

                                              (VAR_2->pps->tiles_enabled_flag                         <<  7) |

                                              (VAR_2->pps->entropy_coding_sync_enabled_flag           <<  8) |

                                              (VAR_2->pps->uniform_spacing_flag                       <<  9) |

                                              ((VAR_2->pps->tiles_enabled_flag ? VAR_2->pps->loop_filter_across_tiles_enabled_flag : 0) << 10) |

                                              (VAR_2->pps->seq_loop_filter_across_slices_enabled_flag << 11) |

                                              (VAR_2->pps->deblocking_filter_override_enabled_flag    << 12) |

                                              (VAR_2->pps->disable_dbf                                << 13) |

                                              (VAR_2->pps->lists_modification_present_flag            << 14) |

                                              (VAR_2->pps->slice_header_extension_present_flag        << 15) |

                                              (IS_IRAP(VAR_2)                                         << 16) |

                                              (IS_IDR(VAR_2)                                          << 17) |

                                              

                                              (IS_IRAP(VAR_2)                                         << 18) |

                                              (0                                                  << 19);

    VAR_3->pps_cb_qp_offset            = VAR_2->pps->cb_qp_offset;

    VAR_3->pps_cr_qp_offset            = VAR_2->pps->cr_qp_offset;

    if (VAR_2->pps->tiles_enabled_flag) {

        VAR_3->num_tile_columns_minus1 = VAR_2->pps->num_tile_columns - 1;

        VAR_3->num_tile_rows_minus1    = VAR_2->pps->num_tile_rows - 1;



        if (!VAR_2->pps->uniform_spacing_flag) {

            for (VAR_5 = 0; VAR_5 < VAR_2->pps->num_tile_columns; VAR_5++)

                VAR_3->column_width_minus1[VAR_5] = VAR_2->pps->column_width[VAR_5] - 1;



            for (VAR_5 = 0; VAR_5 < VAR_2->pps->num_tile_rows; VAR_5++)

                VAR_3->row_height_minus1[VAR_5] = VAR_2->pps->row_height[VAR_5] - 1;

        }

    }



    VAR_3->diff_cu_qp_delta_depth           = VAR_2->pps->diff_cu_qp_delta_depth;

    VAR_3->pps_beta_offset_div2             = VAR_2->pps->beta_offset / 2;

    VAR_3->pps_tc_offset_div2               = VAR_2->pps->tc_offset / 2;

    VAR_3->log2_parallel_merge_level_minus2 = VAR_2->pps->log2_parallel_merge_level - 2;

    VAR_3->CurrPicOrderCntVal               = VAR_2->poc;



    

    memset(&VAR_3->RefPicList, 0xff, sizeof(VAR_3->RefPicList));

    memset(&VAR_3->RefPicSetStCurrBefore, 0xff, sizeof(VAR_3->RefPicSetStCurrBefore));

    memset(&VAR_3->RefPicSetStCurrAfter, 0xff, sizeof(VAR_3->RefPicSetStCurrAfter));

    memset(&VAR_3->RefPicSetLtCurr, 0xff, sizeof(VAR_3->RefPicSetLtCurr));



    

    for (VAR_5 = 0, VAR_6 = 0; VAR_5 < FF_ARRAY_ELEMS(VAR_2->DPB); VAR_5++) {

        const HEVCFrame *frame = &VAR_2->DPB[VAR_5];

        if (frame != VAR_4 && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) {

            fill_picture_entry(&VAR_3->RefPicList[VAR_6], ff_dxva2_get_surface_index(VAR_0, VAR_1, frame->frame), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));

            VAR_3->PicOrderCntValList[VAR_6] = frame->poc;

            VAR_6++;

        }

    }



    #define DO_REF_LIST(ref_idx, ref_list) { \

        const RefPicList *VAR_8 = &VAR_2->rps[ref_idx]; \

        av_assert0(VAR_8->nb_refs <= FF_ARRAY_ELEMS(VAR_3->ref_list)); \

        for (VAR_6 = 0, VAR_7 = 0; VAR_6 < VAR_8->nb_refs; VAR_6++) { \

            if (VAR_8->ref[VAR_6]) { \

                VAR_3->ref_list[VAR_7] = get_refpic_index(VAR_3, ff_dxva2_get_surface_index(VAR_0, VAR_1, VAR_8->ref[VAR_6]->frame)); \

                VAR_7++; \

            } \

        } \

    }



    

    DO_REF_LIST(ST_CURR_BEF, RefPicSetStCurrBefore);

    DO_REF_LIST(ST_CURR_AFT, RefPicSetStCurrAfter);

    DO_REF_LIST(LT_CURR, RefPicSetLtCurr);



    VAR_3->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(VAR_0, VAR_1)++;

}

static void FUNC_0(const AVCodecContext *VAR_0, AVDXVAContext *VAR_1, const HEVCContext *VAR_2,
DXVA_PicParams_HEVC *VAR_3)
{ const HEVCFrame *VAR_4 = VAR_2->ref; int VAR_5, VAR_6, VAR_7; memset(VAR_3, 0, sizeof(*VAR_3)); VAR_3->PicWidthInMinCbsY  = VAR_2->sps->min_cb_width; VAR_3->PicHeightInMinCbsY = VAR_2->sps->min_cb_height; VAR_3->wFormatAndSequenceInfoFlags = (VAR_2->sps->chroma_format_idc          <<  0) |
(VAR_2->sps->separate_colour_plane_flag <<  2) |
((VAR_2->sps->bit_depth - 8)            <<  3) |
((VAR_2->sps->bit_depth - 8)            <<  6) |
((VAR_2->sps->log2_max_poc_lsb - 4)     <<  9) |
(0                                  << 13) |
(0                                  << 14) |
(0                                  << 15); fill_picture_entry(&VAR_3->CurrPic, ff_dxva2_get_surface_index(VAR_0, VAR_1, VAR_4->frame), 0); VAR_3->sps_max_dec_pic_buffering_minus1         = VAR_2->sps->temporal_layer[VAR_2->sps->max_sub_layers - 1].max_dec_pic_buffering - 1; VAR_3->log2_min_luma_coding_block_size_minus3   = VAR_2->sps->log2_min_cb_size - 3; VAR_3->log2_diff_max_min_luma_coding_block_size = VAR_2->sps->log2_diff_max_min_coding_block_size; VAR_3->log2_min_transform_block_size_minus2     = VAR_2->sps->log2_min_tb_size - 2; VAR_3->log2_diff_max_min_transform_block_size   = VAR_2->sps->log2_max_trafo_size  - VAR_2->sps->log2_min_tb_size; VAR_3->max_transform_hierarchy_depth_inter      = VAR_2->sps->max_transform_hierarchy_depth_inter; VAR_3->max_transform_hierarchy_depth_intra      = VAR_2->sps->max_transform_hierarchy_depth_intra; VAR_3->num_short_term_ref_pic_sets              = VAR_2->sps->nb_st_rps; VAR_3->num_long_term_ref_pics_sps               = VAR_2->sps->num_long_term_ref_pics_sps; VAR_3->num_ref_idx_l0_default_active_minus1     = VAR_2->pps->num_ref_idx_l0_default_active - 1; VAR_3->num_ref_idx_l1_default_active_minus1     = VAR_2->pps->num_ref_idx_l1_default_active - 1; VAR_3->init_qp_minus26                          = VAR_2->pps->pic_init_qp_minus26; if (VAR_2->sh.short_term_ref_pic_set_sps_flag == 0 && VAR_2->sh.short_term_rps) { VAR_3->ucNumDeltaPocsOfRefRpsIdx            = VAR_2->sh.short_term_rps->num_delta_pocs; VAR_3->wNumBitsForShortTermRPSInSlice       = VAR_2->sh.short_term_ref_pic_set_size; } VAR_3->dwCodingParamToolFlags = (VAR_2->sps->scaling_list_enable_flag               <<  0) |
(VAR_2->sps->amp_enabled_flag                       <<  1) |
(VAR_2->sps->sao_enabled                            <<  2) |
(VAR_2->sps->pcm_enabled_flag                       <<  3) |
((VAR_2->sps->pcm_enabled_flag ? (VAR_2->sps->pcm.bit_depth - 1) : 0)            <<  4) |
((VAR_2->sps->pcm_enabled_flag ? (VAR_2->sps->pcm.bit_depth_chroma - 1) : 0)     <<  8) |
((VAR_2->sps->pcm_enabled_flag ? (VAR_2->sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) |
((VAR_2->sps->pcm_enabled_flag ? (VAR_2->sps->pcm.log2_max_pcm_cb_size - VAR_2->sps->pcm.log2_min_pcm_cb_size) : 0) << 14) |
(VAR_2->sps->pcm.loop_filter_disable_flag           << 16) |
(VAR_2->sps->long_term_ref_pics_present_flag        << 17) |
(VAR_2->sps->sps_temporal_mvp_enabled_flag          << 18) |
(VAR_2->sps->sps_strong_intra_smoothing_enable_flag << 19) |
(VAR_2->pps->dependent_slice_segments_enabled_flag  << 20) |
(VAR_2->pps->output_flag_present_flag               << 21) |
(VAR_2->pps->num_extra_slice_header_bits            << 22) |
(VAR_2->pps->sign_data_hiding_flag                  << 25) |
(VAR_2->pps->cabac_init_present_flag                << 26) |
(0                                              << 27); VAR_3->dwCodingSettingPicturePropertyFlags = (VAR_2->pps->constrained_intra_pred_flag                <<  0) |
(VAR_2->pps->transform_skip_enabled_flag                <<  1) |
(VAR_2->pps->cu_qp_delta_enabled_flag                   <<  2) |
(VAR_2->pps->pic_slice_level_chroma_qp_offsets_present_flag <<  3) |
(VAR_2->pps->weighted_pred_flag                         <<  4) |
(VAR_2->pps->weighted_bipred_flag                       <<  5) |
(VAR_2->pps->transquant_bypass_enable_flag              <<  6) |
(VAR_2->pps->tiles_enabled_flag                         <<  7) |
(VAR_2->pps->entropy_coding_sync_enabled_flag           <<  8) |
(VAR_2->pps->uniform_spacing_flag                       <<  9) |
((VAR_2->pps->tiles_enabled_flag ? VAR_2->pps->loop_filter_across_tiles_enabled_flag : 0) << 10) |
(VAR_2->pps->seq_loop_filter_across_slices_enabled_flag << 11) |
(VAR_2->pps->deblocking_filter_override_enabled_flag    << 12) |
(VAR_2->pps->disable_dbf                                << 13) |
(VAR_2->pps->lists_modification_present_flag            << 14) |
(VAR_2->pps->slice_header_extension_present_flag        << 15) |
(IS_IRAP(VAR_2)                                         << 16) |
(IS_IDR(VAR_2)                                          << 17) |
(IS_IRAP(VAR_2)                                         << 18) |
(0                                                  << 19); VAR_3->pps_cb_qp_offset            = VAR_2->pps->cb_qp_offset; VAR_3->pps_cr_qp_offset            = VAR_2->pps->cr_qp_offset; if (VAR_2->pps->tiles_enabled_flag) { VAR_3->num_tile_columns_minus1 = VAR_2->pps->num_tile_columns - 1; VAR_3->num_tile_rows_minus1    = VAR_2->pps->num_tile_rows - 1; if (!VAR_2->pps->uniform_spacing_flag) { for (VAR_5 = 0; VAR_5 < VAR_2->pps->num_tile_columns; VAR_5++) VAR_3->column_width_minus1[VAR_5] = VAR_2->pps->column_width[VAR_5] - 1; for (VAR_5 = 0; VAR_5 < VAR_2->pps->num_tile_rows; VAR_5++) VAR_3->row_height_minus1[VAR_5] = VAR_2->pps->row_height[VAR_5] - 1; } } VAR_3->diff_cu_qp_delta_depth           = VAR_2->pps->diff_cu_qp_delta_depth; VAR_3->pps_beta_offset_div2             = VAR_2->pps->beta_offset / 2; VAR_3->pps_tc_offset_div2               = VAR_2->pps->tc_offset / 2; VAR_3->log2_parallel_merge_level_minus2 = VAR_2->pps->log2_parallel_merge_level - 2; VAR_3->CurrPicOrderCntVal               = VAR_2->poc; memset(&VAR_3->RefPicList, 0xff, sizeof(VAR_3->RefPicList)); memset(&VAR_3->RefPicSetStCurrBefore, 0xff, sizeof(VAR_3->RefPicSetStCurrBefore)); memset(&VAR_3->RefPicSetStCurrAfter, 0xff, sizeof(VAR_3->RefPicSetStCurrAfter)); memset(&VAR_3->RefPicSetLtCurr, 0xff, sizeof(VAR_3->RefPicSetLtCurr)); for (VAR_5 = 0, VAR_6 = 0; VAR_5 < FF_ARRAY_ELEMS(VAR_2->DPB); VAR_5++) { const HEVCFrame *frame = &VAR_2->DPB[VAR_5]; if (frame != VAR_4 && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) { fill_picture_entry(&VAR_3->RefPicList[VAR_6], ff_dxva2_get_surface_index(VAR_0, VAR_1, frame->frame), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF)); VAR_3->PicOrderCntValList[VAR_6] = frame->poc; VAR_6++; } } #define DO_REF_LIST(ref_idx, ref_list) { \ const RefPicList *VAR_8 = &VAR_2->rps[ref_idx]; \ av_assert0(VAR_8->nb_refs <= FF_ARRAY_ELEMS(VAR_3->ref_list)); \ for (VAR_6 = 0, VAR_7 = 0; VAR_6 < VAR_8->nb_refs; VAR_6++) { \ if (VAR_8->ref[VAR_6]) { \ VAR_3->ref_list[VAR_7] = get_refpic_index(VAR_3, ff_dxva2_get_surface_index(VAR_0, VAR_1, VAR_8->ref[VAR_6]->frame)); \ VAR_7++; \ } \ } \ } DO_REF_LIST(ST_CURR_BEF, RefPicSetStCurrBefore); DO_REF_LIST(ST_CURR_AFT, RefPicSetStCurrAfter); DO_REF_LIST(LT_CURR, RefPicSetLtCurr); VAR_3->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(VAR_0, VAR_1)++; }