static int cbs_read_se_golomb(CodedBitstreamContext *ctx, BitstreamContext *bc,

                              const char *name, int32_t *write_to,

                              int32_t range_min, int32_t range_max)

{

    int32_t value;

    int position;



    if (ctx->trace_enable) {

        char bits[65];

        uint32_t v;

        unsigned int k;

        int i, j;



        position = bitstream_tell(bc);



        for (i = 0; i < 32; i++) {

            k = bitstream_read_bit(bc);

            bits[i] = k ? '1' : '0';

            if (k)

                break;

        }

        if (i >= 32) {

            av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid se-golomb "

                   "code found while reading %s: "

                   "more than 31 zeroes.\n", name);

            return AVERROR_INVALIDDATA;

        }

        v = 1;

        for (j = 0; j < i; j++) {

            k = bitstream_read_bit(bc);

            bits[i + j + 1] = k ? '1' : '0';

            v = v << 1 | k;

        }

        bits[i + j + 1] = 0;

        if (v & 1)

            value = -(int32_t)(v / 2);

        else

            value = v / 2;



        ff_cbs_trace_syntax_element(ctx, position, name, bits, value);

    } else {

        value = get_se_golomb_long(bc);

    }



    if (value < range_min || value > range_max) {

        av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "

               "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",

               name, value, range_min, range_max);

        return AVERROR_INVALIDDATA;

    }



    *write_to = value;

    return 0;

}

static int cbs_read_se_golomb(CodedBitstreamContext *ctx, BitstreamContext *bc,

                              const char *name, int32_t *write_to,

                              int32_t range_min, int32_t range_max)

{

    int32_t value;

    int position;



    if (ctx->trace_enable) {

        char bits[65];

        uint32_t v;

        unsigned int k;

        int i, j;



        position = bitstream_tell(bc);



        for (i = 0; i < 32; i++) {

            k = bitstream_read_bit(bc);

            bits[i] = k ? '1' : '0';

            if (k)

                break;

        }

        if (i >= 32) {

            av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid se-golomb "

                   "code found while reading %s: "

                   "more than 31 zeroes.\n", name);

            return AVERROR_INVALIDDATA;

        }

        v = 1;

        for (j = 0; j < i; j++) {

            k = bitstream_read_bit(bc);

            bits[i + j + 1] = k ? '1' : '0';

            v = v << 1 | k;

        }

        bits[i + j + 1] = 0;

        if (v & 1)

            value = -(int32_t)(v / 2);

        else

            value = v / 2;



        ff_cbs_trace_syntax_element(ctx, position, name, bits, value);

    } else {

        value = get_se_golomb_long(bc);

    }



    if (value < range_min || value > range_max) {

        av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "

               "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",

               name, value, range_min, range_max);

        return AVERROR_INVALIDDATA;

    }



    *write_to = value;

    return 0;

}

static int FUNC_0(CodedBitstreamContext *VAR_0, BitstreamContext *VAR_1,

                              const char *VAR_2, int32_t *VAR_3,

                              int32_t VAR_4, int32_t VAR_5)

{

    int32_t value;

    int VAR_6;



    if (VAR_0->trace_enable) {

        char VAR_7[65];

        uint32_t v;

        unsigned int VAR_8;

        int VAR_9, VAR_10;



        VAR_6 = bitstream_tell(VAR_1);



        for (VAR_9 = 0; VAR_9 < 32; VAR_9++) {

            VAR_8 = bitstream_read_bit(VAR_1);

            VAR_7[VAR_9] = VAR_8 ? '1' : '0';

            if (VAR_8)

                break;

        }

        if (VAR_9 >= 32) {

            av_log(VAR_0->log_ctx, AV_LOG_ERROR, "Invalid se-golomb "

                   "code found while reading %s: "

                   "more than 31 zeroes.\n", VAR_2);

            return AVERROR_INVALIDDATA;

        }

        v = 1;

        for (VAR_10 = 0; VAR_10 < VAR_9; VAR_10++) {

            VAR_8 = bitstream_read_bit(VAR_1);

            VAR_7[VAR_9 + VAR_10 + 1] = VAR_8 ? '1' : '0';

            v = v << 1 | VAR_8;

        }

        VAR_7[VAR_9 + VAR_10 + 1] = 0;

        if (v & 1)

            value = -(int32_t)(v / 2);

        else

            value = v / 2;



        ff_cbs_trace_syntax_element(VAR_0, VAR_6, VAR_2, VAR_7, value);

    } else {

        value = get_se_golomb_long(VAR_1);

    }



    if (value < VAR_4 || value > VAR_5) {

        av_log(VAR_0->log_ctx, AV_LOG_ERROR, "%s out of range: "

               "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",

               VAR_2, value, VAR_4, VAR_5);

        return AVERROR_INVALIDDATA;

    }



    *VAR_3 = value;

    return 0;

}

static int FUNC_0(CodedBitstreamContext *VAR_0, BitstreamContext *VAR_1,
const char *VAR_2, int32_t *VAR_3,
int32_t VAR_4, int32_t VAR_5)
{ int32_t value; int VAR_6; if (VAR_0->trace_enable) { char VAR_7[65]; uint32_t v; unsigned int VAR_8; int VAR_9, VAR_10; VAR_6 = bitstream_tell(VAR_1); for (VAR_9 = 0; VAR_9 < 32; VAR_9++) { VAR_8 = bitstream_read_bit(VAR_1); VAR_7[VAR_9] = VAR_8 ? '1' : '0'; if (VAR_8)
break; } if (VAR_9 >= 32) { av_log(VAR_0->log_ctx, AV_LOG_ERROR, "Invalid se-golomb "
"code found while reading %s: "
"more than 31 zeroes.\n", VAR_2); return AVERROR_INVALIDDATA; } v = 1; for (VAR_10 = 0; VAR_10 < VAR_9; VAR_10++) { VAR_8 = bitstream_read_bit(VAR_1); VAR_7[VAR_9 + VAR_10 + 1] = VAR_8 ? '1' : '0'; v = v << 1 | VAR_8; } VAR_7[VAR_9 + VAR_10 + 1] = 0; if (v & 1)
value = -(int32_t)(v / 2); else
value = v / 2; ff_cbs_trace_syntax_element(VAR_0, VAR_6, VAR_2, VAR_7, value); } else { value = get_se_golomb_long(VAR_1); } if (value < VAR_4 || value > VAR_5) { av_log(VAR_0->log_ctx, AV_LOG_ERROR, "%s out of range: "
"%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
VAR_2, value, VAR_4, VAR_5); return AVERROR_INVALIDDATA; } *VAR_3 = value; return 0; }