static int decode_frame(AVCodecContext *avctx, void *data,
                        int *got_frame_ptr, AVPacket *avpkt)
{
    BinkAudioContext *s = avctx->priv_data;
    GetBitContext *gb = &s->gb;
    int ret, consumed = 0;
    if (!get_bits_left(gb)) {
        uint8_t *buf;
        if (!avpkt->size) {
            *got_frame_ptr = 0;
            return 0;
        }
        if (avpkt->size < 4) {
            av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
            return AVERROR_INVALIDDATA;
        }
        buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
        if (!buf)
            return AVERROR(ENOMEM);
        s->packet_buffer = buf;
        memcpy(s->packet_buffer, avpkt->data, avpkt->size);
        init_get_bits(gb, s->packet_buffer, avpkt->size * 8);
        consumed = avpkt->size;
        skip_bits_long(gb, 32);
    }
    s->frame.nb_samples = s->frame_len;
    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
        return ret;
    }
    if (decode_block(s, (float **)s->frame.extended_data,
                     avctx->codec->id == AV_CODEC_ID_BINKAUDIO_DCT)) {
        av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n");
        return AVERROR_INVALIDDATA;
    }
    get_bits_align32(gb);
    s->frame.nb_samples = s->block_size / avctx->channels;
    *got_frame_ptr   = 1;
    *(AVFrame *)data = s->frame;
    return consumed;
}
['static int decode_frame(AVCodecContext *avctx, void *data,\n                        int *got_frame_ptr, AVPacket *avpkt)\n{\n    BinkAudioContext *s = avctx->priv_data;\n    GetBitContext *gb = &s->gb;\n    int ret, consumed = 0;\n    if (!get_bits_left(gb)) {\n        uint8_t *buf;\n        if (!avpkt->size) {\n            *got_frame_ptr = 0;\n            return 0;\n        }\n        if (avpkt->size < 4) {\n            av_log(avctx, AV_LOG_ERROR, "Packet is too small\\n");\n            return AVERROR_INVALIDDATA;\n        }\n        buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);\n        if (!buf)\n            return AVERROR(ENOMEM);\n        s->packet_buffer = buf;\n        memcpy(s->packet_buffer, avpkt->data, avpkt->size);\n        init_get_bits(gb, s->packet_buffer, avpkt->size * 8);\n        consumed = avpkt->size;\n        skip_bits_long(gb, 32);\n    }\n    s->frame.nb_samples = s->frame_len;\n    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return ret;\n    }\n    if (decode_block(s, (float **)s->frame.extended_data,\n                     avctx->codec->id == AV_CODEC_ID_BINKAUDIO_DCT)) {\n        av_log(avctx, AV_LOG_ERROR, "Incomplete packet\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    get_bits_align32(gb);\n    s->frame.nb_samples = s->block_size / avctx->channels;\n    *got_frame_ptr   = 1;\n    *(AVFrame *)data = s->frame;\n    return consumed;\n}', 'static inline int get_bits_left(GetBitContext *gb)\n{\n    return gb->size_in_bits - get_bits_count(gb);\n}', 'static inline int get_bits_count(const GetBitContext *s)\n{\n    return s->index;\n}', 'void *av_realloc(void *ptr, size_t size)\n{\n#if CONFIG_MEMALIGN_HACK\n    int diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    if(!ptr) return av_malloc(size);\n    diff= ((char*)ptr)[-1];\n    return (char*)realloc((char*)ptr - diff, size + diff) + diff;\n#elif HAVE_ALIGNED_MALLOC\n    return _aligned_realloc(ptr, size, 32);\n#else\n    return realloc(ptr, size);\n#endif\n}', 'static inline void init_get_bits(GetBitContext *s, const uint8_t *buffer,\n                                 int bit_size)\n{\n    int buffer_size = (bit_size+7)>>3;\n    if (buffer_size < 0 || bit_size < 0) {\n        buffer_size = bit_size = 0;\n        buffer = NULL;\n    }\n    s->buffer       = buffer;\n    s->size_in_bits = bit_size;\n#if !UNCHECKED_BITSTREAM_READER\n    s->size_in_bits_plus8 = bit_size + 8;\n#endif\n    s->buffer_end   = buffer + buffer_size;\n    s->index        = 0;\n}', 'static inline void skip_bits_long(GetBitContext *s, int n){\n#if UNCHECKED_BITSTREAM_READER\n    s->index += n;\n#else\n    s->index += av_clip(n, -s->index, s->size_in_bits_plus8 - s->index);\n#endif\n}']