static int
flac_header (AVFormatContext * s, int idx)
{
    ogg_t *ogg = s->priv_data;
    ogg_stream_t *os = ogg->streams + idx;
    AVStream *st = s->streams[idx];
    GetBitContext gb;
    int mdt;
    if (os->buf[os->pstart] == 0xff)
        return 0;
    init_get_bits(&gb, os->buf + os->pstart, os->psize*8);
    get_bits(&gb, 1);
    mdt = get_bits(&gb, 7);
    if (mdt == 0x7f) {
        skip_bits(&gb, 4*8);
        if(get_bits(&gb, 8) != 1)
            return -1;
        skip_bits(&gb, 8 + 16);
        skip_bits(&gb, 4*8);
        if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE)
            return -1;
        skip_bits(&gb, 16*2+24*2);
        st->codec->sample_rate = get_bits_long(&gb, 20);
        st->codec->channels = get_bits(&gb, 3) + 1;
        st->codec->codec_type = CODEC_TYPE_AUDIO;
        st->codec->codec_id = CODEC_ID_FLAC;
        st->codec->extradata =
            av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
        memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4,
                FLAC_STREAMINFO_SIZE);
        st->codec->extradata_size = FLAC_STREAMINFO_SIZE;
        st->time_base.num = 1;
        st->time_base.den = st->codec->sample_rate;
    } else if (mdt == 4) {
        vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4);
    }
    return 1;
}
['static int\nflac_header (AVFormatContext * s, int idx)\n{\n    ogg_t *ogg = s->priv_data;\n    ogg_stream_t *os = ogg->streams + idx;\n    AVStream *st = s->streams[idx];\n    GetBitContext gb;\n    int mdt;\n    if (os->buf[os->pstart] == 0xff)\n        return 0;\n    init_get_bits(&gb, os->buf + os->pstart, os->psize*8);\n    get_bits(&gb, 1);\n    mdt = get_bits(&gb, 7);\n    if (mdt == 0x7f) {\n        skip_bits(&gb, 4*8);\n        if(get_bits(&gb, 8) != 1)\n            return -1;\n        skip_bits(&gb, 8 + 16);\n        skip_bits(&gb, 4*8);\n        if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE)\n            return -1;\n        skip_bits(&gb, 16*2+24*2);\n        st->codec->sample_rate = get_bits_long(&gb, 20);\n        st->codec->channels = get_bits(&gb, 3) + 1;\n        st->codec->codec_type = CODEC_TYPE_AUDIO;\n        st->codec->codec_id = CODEC_ID_FLAC;\n        st->codec->extradata =\n            av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);\n        memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4,\n                FLAC_STREAMINFO_SIZE);\n        st->codec->extradata_size = FLAC_STREAMINFO_SIZE;\n        st->time_base.num = 1;\n        st->time_base.den = st->codec->sample_rate;\n    } else if (mdt == 4) {\n        vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4);\n    }\n    return 1;\n}', 'static inline unsigned int get_bits(GetBitContext *s, int n){\n    register int tmp;\n    OPEN_READER(re, s)\n    UPDATE_CACHE(re, s)\n    tmp= SHOW_UBITS(re, s, n);\n    LAST_SKIP_BITS(re, s, n)\n    CLOSE_READER(re, s)\n    return tmp;\n}']