static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, DCTELEM *block,

                                    int n, int qscale, int *overflow)

{

    const uint8_t *scantable= ctx->intra_scantable.scantable;

    const int *qmat = ctx->q_intra_matrix[qscale];

    int last_non_zero = 0;



    ctx->dsp.fdct(block);



    // Divide by 4 with rounding, to compensate scaling of DCT coefficients

    block[0] = (block[0] + 2) >> 2;



    for (int i = 1; i < 64; ++i) {

        int j = scantable[i];

        int sign = block[j] >> 31;

        int level = (block[j] ^ sign) - sign;

        level = level * qmat[j] >> DNX10BIT_QMAT_SHIFT;

        block[j] = (level ^ sign) - sign;

        if (level)

            last_non_zero = i;

    }



    return last_non_zero;

}

static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, DCTELEM *block,

                                    int n, int qscale, int *overflow)

{

    const uint8_t *scantable= ctx->intra_scantable.scantable;

    const int *qmat = ctx->q_intra_matrix[qscale];

    int last_non_zero = 0;



    ctx->dsp.fdct(block);



    

    block[0] = (block[0] + 2) >> 2;



    for (int i = 1; i < 64; ++i) {

        int j = scantable[i];

        int sign = block[j] >> 31;

        int level = (block[j] ^ sign) - sign;

        level = level * qmat[j] >> DNX10BIT_QMAT_SHIFT;

        block[j] = (level ^ sign) - sign;

        if (level)

            last_non_zero = i;

    }



    return last_non_zero;

}

static int FUNC_0(MpegEncContext *VAR_0, DCTELEM *VAR_1,

                                    int VAR_2, int VAR_3, int *VAR_4)

{

    const uint8_t *VAR_5= VAR_0->intra_scantable.VAR_5;

    const int *VAR_6 = VAR_0->q_intra_matrix[VAR_3];

    int VAR_7 = 0;



    VAR_0->dsp.fdct(VAR_1);



    

    VAR_1[0] = (VAR_1[0] + 2) >> 2;



    for (int VAR_8 = 1; VAR_8 < 64; ++VAR_8) {

        int VAR_9 = VAR_5[VAR_8];

        int VAR_10 = VAR_1[VAR_9] >> 31;

        int VAR_11 = (VAR_1[VAR_9] ^ VAR_10) - VAR_10;

        VAR_11 = VAR_11 * VAR_6[VAR_9] >> DNX10BIT_QMAT_SHIFT;

        VAR_1[VAR_9] = (VAR_11 ^ VAR_10) - VAR_10;

        if (VAR_11)

            VAR_7 = VAR_8;

    }



    return VAR_7;

}

static int FUNC_0(MpegEncContext *VAR_0, DCTELEM *VAR_1,
int VAR_2, int VAR_3, int *VAR_4)
{ const uint8_t *VAR_5= VAR_0->intra_scantable.VAR_5; const int *VAR_6 = VAR_0->q_intra_matrix[VAR_3]; int VAR_7 = 0; VAR_0->dsp.fdct(VAR_1); VAR_1[0] = (VAR_1[0] + 2) >> 2; for (int VAR_8 = 1; VAR_8 < 64; ++VAR_8) { int VAR_9 = VAR_5[VAR_8]; int VAR_10 = VAR_1[VAR_9] >> 31; int VAR_11 = (VAR_1[VAR_9] ^ VAR_10) - VAR_10; VAR_11 = VAR_11 * VAR_6[VAR_9] >> DNX10BIT_QMAT_SHIFT; VAR_1[VAR_9] = (VAR_11 ^ VAR_10) - VAR_10; if (VAR_11)
VAR_7 = VAR_8; } return VAR_7; }