static int avi_read_idx1(AVFormatContext *s, int size)
{
    AVIContext *avi = s->priv_data;
    ByteIOContext *pb = s->pb;
    int nb_index_entries, i;
    AVStream *st;
    AVIStream *ast;
    unsigned int index, tag, flags, pos, len;
    unsigned last_pos= -1;
    nb_index_entries = size / 16;
    if (nb_index_entries <= 0)
        return -1;
    for(i = 0; i < nb_index_entries; i++) {
        tag = get_le32(pb);
        flags = get_le32(pb);
        pos = get_le32(pb);
        len = get_le32(pb);
#if defined(DEBUG_SEEK)
        av_log(NULL, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
               i, tag, flags, pos, len);
#endif
        if(i==0 && pos > avi->movi_list)
            avi->movi_list= 0;
        pos += avi->movi_list;
        index = ((tag & 0xff) - '0') * 10;
        index += ((tag >> 8) & 0xff) - '0';
        if (index >= s->nb_streams)
            continue;
        st = s->streams[index];
        ast = st->priv_data;
#if defined(DEBUG_SEEK)
        av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%"PRId64"\n", len, ast->cum_len);
#endif
        if(last_pos == pos)
            avi->non_interleaved= 1;
        else
            av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
        if(ast->sample_size)
            ast->cum_len += len;
        else
            ast->cum_len ++;
        last_pos= pos;
    }
    return 0;
}
['static int avi_read_idx1(AVFormatContext *s, int size)\n{\n    AVIContext *avi = s->priv_data;\n    ByteIOContext *pb = s->pb;\n    int nb_index_entries, i;\n    AVStream *st;\n    AVIStream *ast;\n    unsigned int index, tag, flags, pos, len;\n    unsigned last_pos= -1;\n    nb_index_entries = size / 16;\n    if (nb_index_entries <= 0)\n        return -1;\n    for(i = 0; i < nb_index_entries; i++) {\n        tag = get_le32(pb);\n        flags = get_le32(pb);\n        pos = get_le32(pb);\n        len = get_le32(pb);\n#if defined(DEBUG_SEEK)\n        av_log(NULL, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",\n               i, tag, flags, pos, len);\n#endif\n        if(i==0 && pos > avi->movi_list)\n            avi->movi_list= 0;\n        pos += avi->movi_list;\n        index = ((tag & 0xff) - \'0\') * 10;\n        index += ((tag >> 8) & 0xff) - \'0\';\n        if (index >= s->nb_streams)\n            continue;\n        st = s->streams[index];\n        ast = st->priv_data;\n#if defined(DEBUG_SEEK)\n        av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%"PRId64"\\n", len, ast->cum_len);\n#endif\n        if(last_pos == pos)\n            avi->non_interleaved= 1;\n        else\n            av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);\n        if(ast->sample_size)\n            ast->cum_len += len;\n        else\n            ast->cum_len ++;\n        last_pos= pos;\n    }\n    return 0;\n}', 'unsigned int get_le32(ByteIOContext *s)\n{\n    unsigned int val;\n    val = get_le16(s);\n    val |= get_le16(s) << 16;\n    return val;\n}', 'unsigned int get_le16(ByteIOContext *s)\n{\n    unsigned int val;\n    val = get_byte(s);\n    val |= get_byte(s) << 8;\n    return val;\n}', 'int get_byte(ByteIOContext *s)\n{\n    if (s->buf_ptr < s->buf_end) {\n        return *s->buf_ptr++;\n    } else {\n        fill_buffer(s);\n        if (s->buf_ptr < s->buf_end)\n            return *s->buf_ptr++;\n        else\n            return 0;\n    }\n}']