static void fill_picture_parameters(AVCodecContext *avctx,

                                    struct dxva_context *ctx,

                                    const struct MpegEncContext *s,

                                    DXVA_PictureParameters *pp)

{

    const Picture *current_picture = s->current_picture_ptr;

    int is_field = s->picture_structure != PICT_FRAME;



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

    pp->wDecodedPictureIndex         = ff_dxva2_get_surface_index(ctx, &current_picture->f);

    pp->wDeblockedPictureIndex       = 0;

    if (s->pict_type != AV_PICTURE_TYPE_I)

        pp->wForwardRefPictureIndex  = ff_dxva2_get_surface_index(ctx, &s->last_picture.f);

    else

        pp->wForwardRefPictureIndex  = 0xffff;

    if (s->pict_type == AV_PICTURE_TYPE_B)

        pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);

    else

        pp->wBackwardRefPictureIndex = 0xffff;

    pp->wPicWidthInMBminus1          = s->mb_width  - 1;

    pp->wPicHeightInMBminus1         = (s->mb_height >> is_field) - 1;

    pp->bMacroblockWidthMinus1       = 15;

    pp->bMacroblockHeightMinus1      = 15;

    pp->bBlockWidthMinus1            = 7;

    pp->bBlockHeightMinus1           = 7;

    pp->bBPPminus1                   = 7;

    pp->bPicStructure                = s->picture_structure;

    pp->bSecondField                 = is_field && !s->first_field;

    pp->bPicIntra                    = s->pict_type == AV_PICTURE_TYPE_I;

    pp->bPicBackwardPrediction       = s->pict_type == AV_PICTURE_TYPE_B;

    pp->bBidirectionalAveragingMode  = 0;

    pp->bMVprecisionAndChromaRelation= 0; /* FIXME */

    pp->bChromaFormat                = s->chroma_format;

    pp->bPicScanFixed                = 1;

    pp->bPicScanMethod               = s->alternate_scan ? 1 : 0;

    pp->bPicReadbackRequests         = 0;

    pp->bRcontrol                    = 0;

    pp->bPicSpatialResid8            = 0;

    pp->bPicOverflowBlocks           = 0;

    pp->bPicExtrapolation            = 0;

    pp->bPicDeblocked                = 0;

    pp->bPicDeblockConfined          = 0;

    pp->bPic4MVallowed               = 0;

    pp->bPicOBMC                     = 0;

    pp->bPicBinPB                    = 0;

    pp->bMV_RPS                      = 0;

    pp->bReservedBits                = 0;

    pp->wBitstreamFcodes             = (s->mpeg_f_code[0][0] << 12) |

                                       (s->mpeg_f_code[0][1] <<  8) |

                                       (s->mpeg_f_code[1][0] <<  4) |

                                       (s->mpeg_f_code[1][1]      );

    pp->wBitstreamPCEelements        = (s->intra_dc_precision         << 14) |

                                       (s->picture_structure          << 12) |

                                       (s->top_field_first            << 11) |

                                       (s->frame_pred_frame_dct       << 10) |

                                       (s->concealment_motion_vectors <<  9) |

                                       (s->q_scale_type               <<  8) |

                                       (s->intra_vlc_format           <<  7) |

                                       (s->alternate_scan             <<  6) |

                                       (s->repeat_first_field         <<  5) |

                                       (s->chroma_420_type            <<  4) |

                                       (s->progressive_frame          <<  3);

    pp->bBitstreamConcealmentNeed    = 0;

    pp->bBitstreamConcealmentMethod  = 0;

}

static void fill_picture_parameters(AVCodecContext *avctx,

                                    struct dxva_context *ctx,

                                    const struct MpegEncContext *s,

                                    DXVA_PictureParameters *pp)

{

    const Picture *current_picture = s->current_picture_ptr;

    int is_field = s->picture_structure != PICT_FRAME;



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

    pp->wDecodedPictureIndex         = ff_dxva2_get_surface_index(ctx, &current_picture->f);

    pp->wDeblockedPictureIndex       = 0;

    if (s->pict_type != AV_PICTURE_TYPE_I)

        pp->wForwardRefPictureIndex  = ff_dxva2_get_surface_index(ctx, &s->last_picture.f);

    else

        pp->wForwardRefPictureIndex  = 0xffff;

    if (s->pict_type == AV_PICTURE_TYPE_B)

        pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);

    else

        pp->wBackwardRefPictureIndex = 0xffff;

    pp->wPicWidthInMBminus1          = s->mb_width  - 1;

    pp->wPicHeightInMBminus1         = (s->mb_height >> is_field) - 1;

    pp->bMacroblockWidthMinus1       = 15;

    pp->bMacroblockHeightMinus1      = 15;

    pp->bBlockWidthMinus1            = 7;

    pp->bBlockHeightMinus1           = 7;

    pp->bBPPminus1                   = 7;

    pp->bPicStructure                = s->picture_structure;

    pp->bSecondField                 = is_field && !s->first_field;

    pp->bPicIntra                    = s->pict_type == AV_PICTURE_TYPE_I;

    pp->bPicBackwardPrediction       = s->pict_type == AV_PICTURE_TYPE_B;

    pp->bBidirectionalAveragingMode  = 0;

    pp->bMVprecisionAndChromaRelation= 0; 

    pp->bChromaFormat                = s->chroma_format;

    pp->bPicScanFixed                = 1;

    pp->bPicScanMethod               = s->alternate_scan ? 1 : 0;

    pp->bPicReadbackRequests         = 0;

    pp->bRcontrol                    = 0;

    pp->bPicSpatialResid8            = 0;

    pp->bPicOverflowBlocks           = 0;

    pp->bPicExtrapolation            = 0;

    pp->bPicDeblocked                = 0;

    pp->bPicDeblockConfined          = 0;

    pp->bPic4MVallowed               = 0;

    pp->bPicOBMC                     = 0;

    pp->bPicBinPB                    = 0;

    pp->bMV_RPS                      = 0;

    pp->bReservedBits                = 0;

    pp->wBitstreamFcodes             = (s->mpeg_f_code[0][0] << 12) |

                                       (s->mpeg_f_code[0][1] <<  8) |

                                       (s->mpeg_f_code[1][0] <<  4) |

                                       (s->mpeg_f_code[1][1]      );

    pp->wBitstreamPCEelements        = (s->intra_dc_precision         << 14) |

                                       (s->picture_structure          << 12) |

                                       (s->top_field_first            << 11) |

                                       (s->frame_pred_frame_dct       << 10) |

                                       (s->concealment_motion_vectors <<  9) |

                                       (s->q_scale_type               <<  8) |

                                       (s->intra_vlc_format           <<  7) |

                                       (s->alternate_scan             <<  6) |

                                       (s->repeat_first_field         <<  5) |

                                       (s->chroma_420_type            <<  4) |

                                       (s->progressive_frame          <<  3);

    pp->bBitstreamConcealmentNeed    = 0;

    pp->bBitstreamConcealmentMethod  = 0;

}

    pp->wDecodedPictureIndex         = ff_dxva2_get_surface_index(ctx, &current_picture->f);         pp->wForwardRefPictureIndex  = ff_dxva2_get_surface_index(ctx, &s->last_picture.f);         pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);         pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);
static void FUNC_0(AVCodecContext *VAR_0,

                                    struct dxva_context *VAR_1,

                                    const struct MpegEncContext *VAR_2,

                                    DXVA_PictureParameters *VAR_3)

{

    const Picture *VAR_4 = VAR_2->current_picture_ptr;

    int VAR_5 = VAR_2->picture_structure != PICT_FRAME;



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

    VAR_3->wDecodedPictureIndex         = ff_dxva2_get_surface_index(VAR_1, &VAR_4->f);

    VAR_3->wDeblockedPictureIndex       = 0;

    if (VAR_2->pict_type != AV_PICTURE_TYPE_I)

        VAR_3->wForwardRefPictureIndex  = ff_dxva2_get_surface_index(VAR_1, &VAR_2->last_picture.f);

    else

        VAR_3->wForwardRefPictureIndex  = 0xffff;

    if (VAR_2->pict_type == AV_PICTURE_TYPE_B)

        VAR_3->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(VAR_1, &VAR_2->next_picture.f);

    else

        VAR_3->wBackwardRefPictureIndex = 0xffff;

    VAR_3->wPicWidthInMBminus1          = VAR_2->mb_width  - 1;

    VAR_3->wPicHeightInMBminus1         = (VAR_2->mb_height >> VAR_5) - 1;

    VAR_3->bMacroblockWidthMinus1       = 15;

    VAR_3->bMacroblockHeightMinus1      = 15;

    VAR_3->bBlockWidthMinus1            = 7;

    VAR_3->bBlockHeightMinus1           = 7;

    VAR_3->bBPPminus1                   = 7;

    VAR_3->bPicStructure                = VAR_2->picture_structure;

    VAR_3->bSecondField                 = VAR_5 && !VAR_2->first_field;

    VAR_3->bPicIntra                    = VAR_2->pict_type == AV_PICTURE_TYPE_I;

    VAR_3->bPicBackwardPrediction       = VAR_2->pict_type == AV_PICTURE_TYPE_B;

    VAR_3->bBidirectionalAveragingMode  = 0;

    VAR_3->bMVprecisionAndChromaRelation= 0; 

    VAR_3->bChromaFormat                = VAR_2->chroma_format;

    VAR_3->bPicScanFixed                = 1;

    VAR_3->bPicScanMethod               = VAR_2->alternate_scan ? 1 : 0;

    VAR_3->bPicReadbackRequests         = 0;

    VAR_3->bRcontrol                    = 0;

    VAR_3->bPicSpatialResid8            = 0;

    VAR_3->bPicOverflowBlocks           = 0;

    VAR_3->bPicExtrapolation            = 0;

    VAR_3->bPicDeblocked                = 0;

    VAR_3->bPicDeblockConfined          = 0;

    VAR_3->bPic4MVallowed               = 0;

    VAR_3->bPicOBMC                     = 0;

    VAR_3->bPicBinPB                    = 0;

    VAR_3->bMV_RPS                      = 0;

    VAR_3->bReservedBits                = 0;

    VAR_3->wBitstreamFcodes             = (VAR_2->mpeg_f_code[0][0] << 12) |

                                       (VAR_2->mpeg_f_code[0][1] <<  8) |

                                       (VAR_2->mpeg_f_code[1][0] <<  4) |

                                       (VAR_2->mpeg_f_code[1][1]      );

    VAR_3->wBitstreamPCEelements        = (VAR_2->intra_dc_precision         << 14) |

                                       (VAR_2->picture_structure          << 12) |

                                       (VAR_2->top_field_first            << 11) |

                                       (VAR_2->frame_pred_frame_dct       << 10) |

                                       (VAR_2->concealment_motion_vectors <<  9) |

                                       (VAR_2->q_scale_type               <<  8) |

                                       (VAR_2->intra_vlc_format           <<  7) |

                                       (VAR_2->alternate_scan             <<  6) |

                                       (VAR_2->repeat_first_field         <<  5) |

                                       (VAR_2->chroma_420_type            <<  4) |

                                       (VAR_2->progressive_frame          <<  3);

    VAR_3->bBitstreamConcealmentNeed    = 0;

    VAR_3->bBitstreamConcealmentMethod  = 0;

}

static void FUNC_0(AVCodecContext *VAR_0,
struct dxva_context *VAR_1,
const struct MpegEncContext *VAR_2,
DXVA_PictureParameters *VAR_3)
{ const Picture *VAR_4 = VAR_2->current_picture_ptr; int VAR_5 = VAR_2->picture_structure != PICT_FRAME; memset(VAR_3, 0, sizeof(*VAR_3)); VAR_3->wDecodedPictureIndex         = ff_dxva2_get_surface_index(VAR_1, &VAR_4->f); VAR_3->wDeblockedPictureIndex       = 0; if (VAR_2->pict_type != AV_PICTURE_TYPE_I)
VAR_3->wForwardRefPictureIndex  = ff_dxva2_get_surface_index(VAR_1, &VAR_2->last_picture.f); else
VAR_3->wForwardRefPictureIndex  = 0xffff; if (VAR_2->pict_type == AV_PICTURE_TYPE_B)
VAR_3->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(VAR_1, &VAR_2->next_picture.f); else
VAR_3->wBackwardRefPictureIndex = 0xffff; VAR_3->wPicWidthInMBminus1          = VAR_2->mb_width  - 1; VAR_3->wPicHeightInMBminus1         = (VAR_2->mb_height >> VAR_5) - 1; VAR_3->bMacroblockWidthMinus1       = 15; VAR_3->bMacroblockHeightMinus1      = 15; VAR_3->bBlockWidthMinus1            = 7; VAR_3->bBlockHeightMinus1           = 7; VAR_3->bBPPminus1                   = 7; VAR_3->bPicStructure                = VAR_2->picture_structure; VAR_3->bSecondField                 = VAR_5 && !VAR_2->first_field; VAR_3->bPicIntra                    = VAR_2->pict_type == AV_PICTURE_TYPE_I; VAR_3->bPicBackwardPrediction       = VAR_2->pict_type == AV_PICTURE_TYPE_B; VAR_3->bBidirectionalAveragingMode  = 0; VAR_3->bMVprecisionAndChromaRelation= 0; VAR_3->bChromaFormat                = VAR_2->chroma_format; VAR_3->bPicScanFixed                = 1; VAR_3->bPicScanMethod               = VAR_2->alternate_scan ? 1 : 0; VAR_3->bPicReadbackRequests         = 0; VAR_3->bRcontrol                    = 0; VAR_3->bPicSpatialResid8            = 0; VAR_3->bPicOverflowBlocks           = 0; VAR_3->bPicExtrapolation            = 0; VAR_3->bPicDeblocked                = 0; VAR_3->bPicDeblockConfined          = 0; VAR_3->bPic4MVallowed               = 0; VAR_3->bPicOBMC                     = 0; VAR_3->bPicBinPB                    = 0; VAR_3->bMV_RPS                      = 0; VAR_3->bReservedBits                = 0; VAR_3->wBitstreamFcodes             = (VAR_2->mpeg_f_code[0][0] << 12) |
(VAR_2->mpeg_f_code[0][1] <<  8) |
(VAR_2->mpeg_f_code[1][0] <<  4) |
(VAR_2->mpeg_f_code[1][1]      ); VAR_3->wBitstreamPCEelements        = (VAR_2->intra_dc_precision         << 14) |
(VAR_2->picture_structure          << 12) |
(VAR_2->top_field_first            << 11) |
(VAR_2->frame_pred_frame_dct       << 10) |
(VAR_2->concealment_motion_vectors <<  9) |
(VAR_2->q_scale_type               <<  8) |
(VAR_2->intra_vlc_format           <<  7) |
(VAR_2->alternate_scan             <<  6) |
(VAR_2->repeat_first_field         <<  5) |
(VAR_2->chroma_420_type            <<  4) |
(VAR_2->progressive_frame          <<  3); VAR_3->bBitstreamConcealmentNeed    = 0; VAR_3->bBitstreamConcealmentMethod  = 0; }