int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase)
{
    if (   s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < threshold
        && s->slice_context_count == 1
        && s->pb.buf == s->avctx->internal->byte_buffer) {
        int lastgob_pos = s->ptr_lastgob - s->pb.buf;
        int vbv_pos     = s->vbv_delay_ptr - s->pb.buf;
        uint8_t *new_buffer = NULL;
        int new_buffer_size = 0;
        av_fast_padded_malloc(&new_buffer, &new_buffer_size,
                              s->avctx->internal->byte_buffer_size + size_increase);
        if (!new_buffer)
        memcpy(new_buffer, s->avctx->internal->byte_buffer, s->avctx->internal->byte_buffer_size);
        av_free(s->avctx->internal->byte_buffer);
        s->avctx->internal->byte_buffer      = new_buffer;
        s->avctx->internal->byte_buffer_size = new_buffer_size;
        rebase_put_bits(&s->pb, new_buffer, new_buffer_size);
        s->ptr_lastgob   = s->pb.buf + lastgob_pos;
        s->vbv_delay_ptr = s->pb.buf + vbv_pos;
    if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < threshold)
        return AVERROR(EINVAL);
    return 0;
int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase)
{
    if (   s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < threshold
        && s->slice_context_count == 1
        && s->pb.buf == s->avctx->internal->byte_buffer) {
        int lastgob_pos = s->ptr_lastgob - s->pb.buf;
        int vbv_pos     = s->vbv_delay_ptr - s->pb.buf;
        uint8_t *new_buffer = NULL;
        int new_buffer_size = 0;
        av_fast_padded_malloc(&new_buffer, &new_buffer_size,
                              s->avctx->internal->byte_buffer_size + size_increase);
        if (!new_buffer)
        memcpy(new_buffer, s->avctx->internal->byte_buffer, s->avctx->internal->byte_buffer_size);
        av_free(s->avctx->internal->byte_buffer);
        s->avctx->internal->byte_buffer      = new_buffer;
        s->avctx->internal->byte_buffer_size = new_buffer_size;
        rebase_put_bits(&s->pb, new_buffer, new_buffer_size);
        s->ptr_lastgob   = s->pb.buf + lastgob_pos;
        s->vbv_delay_ptr = s->pb.buf + vbv_pos;
    if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < threshold)
        return AVERROR(EINVAL);
    return 0;
int FUNC_0(MpegEncContext *VAR_0, size_t VAR_1, size_t VAR_2)
{
    if (   VAR_0->pb.buf_end - VAR_0->pb.buf - (put_bits_count(&VAR_0->pb)>>3) < VAR_1
        && VAR_0->slice_context_count == 1
        && VAR_0->pb.buf == VAR_0->avctx->internal->byte_buffer) {
        int VAR_3 = VAR_0->ptr_lastgob - VAR_0->pb.buf;
        int VAR_4     = VAR_0->vbv_delay_ptr - VAR_0->pb.buf;
        uint8_t *new_buffer = NULL;
        int VAR_5 = 0;
        av_fast_padded_malloc(&new_buffer, &VAR_5,
                              VAR_0->avctx->internal->byte_buffer_size + VAR_2);
        if (!new_buffer)
        memcpy(new_buffer, VAR_0->avctx->internal->byte_buffer, VAR_0->avctx->internal->byte_buffer_size);
        av_free(VAR_0->avctx->internal->byte_buffer);
        VAR_0->avctx->internal->byte_buffer      = new_buffer;
        VAR_0->avctx->internal->byte_buffer_size = VAR_5;
        rebase_put_bits(&VAR_0->pb, new_buffer, VAR_5);
        VAR_0->ptr_lastgob   = VAR_0->pb.buf + VAR_3;
        VAR_0->vbv_delay_ptr = VAR_0->pb.buf + VAR_4;
    if (VAR_0->pb.buf_end - VAR_0->pb.buf - (put_bits_count(&VAR_0->pb)>>3) < VAR_1)
        return AVERROR(EINVAL);
    return 0;
int FUNC_0(MpegEncContext *VAR_0, size_t VAR_1, size_t VAR_2)
{ if (   VAR_0->pb.buf_end - VAR_0->pb.buf - (put_bits_count(&VAR_0->pb)>>3) < VAR_1
&& VAR_0->slice_context_count == 1
&& VAR_0->pb.buf == VAR_0->avctx->internal->byte_buffer) { int VAR_3 = VAR_0->ptr_lastgob - VAR_0->pb.buf; int VAR_4     = VAR_0->vbv_delay_ptr - VAR_0->pb.buf; uint8_t *new_buffer = NULL; int VAR_5 = 0; av_fast_padded_malloc(&new_buffer, &VAR_5,
VAR_0->avctx->internal->byte_buffer_size + VAR_2); if (!new_buffer)
memcpy(new_buffer, VAR_0->avctx->internal->byte_buffer, VAR_0->avctx->internal->byte_buffer_size); av_free(VAR_0->avctx->internal->byte_buffer); VAR_0->avctx->internal->byte_buffer      = new_buffer; VAR_0->avctx->internal->byte_buffer_size = VAR_5; rebase_put_bits(&VAR_0->pb, new_buffer, VAR_5); VAR_0->ptr_lastgob   = VAR_0->pb.buf + VAR_3; VAR_0->vbv_delay_ptr = VAR_0->pb.buf + VAR_4; if (VAR_0->pb.buf_end - VAR_0->pb.buf - (put_bits_count(&VAR_0->pb)>>3) < VAR_1)
return AVERROR(EINVAL); return 0;