Revision 30a43f2d

View differences:

libavformat/asf.c
813 813
            assert((asf_st->packet_pos - s->data_offset) % asf->packet_size == 0);
814 814
            pos= asf_st->packet_pos;
815 815

  
816
            av_add_index_entry(s->streams[i], pos, pts, pos - start_pos[i] + 1, AVINDEX_KEYFRAME);
816
            av_add_index_entry(s->streams[i], pos, pkt->size, pts, pos - start_pos[i] + 1, AVINDEX_KEYFRAME);
817 817
            start_pos[i]= asf_st->packet_pos + 1;
818 818

  
819 819
            if(pkt->stream_index == stream_index)
libavformat/avformat.h
208 208
    int64_t pos;
209 209
    int64_t timestamp;
210 210
#define AVINDEX_KEYFRAME 0x0001
211
/* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */
212
    int flags;
211
    int flags:2;
212
    int size:30; //yeah trying to keep the size of this small to reduce memory requirements (its 24 vs 32 byte due to possible 8byte align)
213 213
    int min_distance;         /* min distance between this and the previous keyframe, used to avoid unneeded searching */
214 214
} AVIndexEntry;
215 215

  
......
641 641
int av_find_default_stream_index(AVFormatContext *s);
642 642
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
643 643
int av_add_index_entry(AVStream *st,
644
                       int64_t pos, int64_t timestamp, int distance, int flags);
644
                       int64_t pos, int64_t timestamp, int size, int distance, int flags);
645 645
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
646 646

  
647 647
/* media file output */
libavformat/avidec.c
55 55
} AVIContext;
56 56

  
57 57
static int avi_load_index(AVFormatContext *s);
58
static int guess_ni_flag(AVFormatContext *s);
58 59

  
59 60
#ifdef DEBUG
60 61
static void print_tag(const char *str, unsigned int tag, int size)
......
118 119

  
119 120
    for(i=0; i<entries_in_use; i++){
120 121
        if(index_type){
121
            int64_t pos= get_le32(pb) + base;
122
            int64_t pos= get_le32(pb) + base - 8;
122 123
            int len    = get_le32(pb);
123

  
124
            av_add_index_entry(st, pos, ast->cum_len, 0, (len<0) ? 0 : AVINDEX_KEYFRAME);
124
            int key= len >= 0;
125 125
            len &= 0x7FFFFFFF;
126 126

  
127
//av_log(s, AV_LOG_ERROR, "pos:%Ld, len:%X\n", pos, len);
128
            av_add_index_entry(st, pos, ast->cum_len, len, 0, key ? AVINDEX_KEYFRAME : 0);
129

  
127 130
            if(ast->sample_size)
128 131
                ast->cum_len += len / ast->sample_size;
129 132
            else
......
412 415
    if(!avi->index_loaded)
413 416
        avi_load_index(s);
414 417
    avi->index_loaded = 1;
418
    avi->non_interleaved |= guess_ni_flag(s);
415 419

  
416 420
    return 0;
417 421
}
......
699 703
        if(last_pos == pos)
700 704
            avi->non_interleaved= 1;
701 705
        else
702
            av_add_index_entry(st, pos, ast->cum_len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
706
            av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
703 707
        if(ast->sample_size)
704 708
            ast->cum_len += len / ast->sample_size;
705 709
        else
......
768 772
        }
769 773
    }
770 774
 the_end:
771
    avi->non_interleaved |= guess_ni_flag(s);
772 775
    url_fseek(pb, pos, SEEK_SET);
773 776
    return 0;
774 777
}
libavformat/mpeg.c
1541 1541
        int i;
1542 1542
        for(i=0; i<s->nb_streams; i++){
1543 1543
            if(startcode == s->streams[i]->id) {
1544
                av_add_index_entry(s->streams[i], *ppos, dts, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
1544
                av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
1545 1545
            }
1546 1546
        }
1547 1547
    }
libavformat/nut.c
1192 1192
            s->streams[stream_id],
1193 1193
            frame_start,
1194 1194
            pts,
1195
            0,
1195 1196
            frame_start - nut->stream[stream_id].last_sync_pos,
1196 1197
            AVINDEX_KEYFRAME);
1197 1198
        nut->stream[stream_id].last_sync_pos= frame_start;
libavformat/rm.c
982 982
        if(flags&2){
983 983
            pkt->flags |= PKT_FLAG_KEY;
984 984
            if((seq&0x7F) == 1)
985
                av_add_index_entry(st, pos, timestamp, 0, AVINDEX_KEYFRAME);
985
                av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
986 986
        }
987 987
    }
988 988

  
......
1054 1054

  
1055 1055
        if((flags&2) && (seq&0x7F) == 1){
1056 1056
//            av_log(s, AV_LOG_DEBUG, "%d %d-%d %Ld %d\n", flags, stream_index2, stream_index, dts, seq);
1057
            av_add_index_entry(st, pos, dts, 0, AVINDEX_KEYFRAME);
1057
            av_add_index_entry(st, pos, dts, 0, 0, AVINDEX_KEYFRAME);
1058 1058
            if(stream_index2 == stream_index)
1059 1059
                break;
1060 1060
        }
libavformat/utils.c
1131 1131
 * @param timestamp timestamp in the timebase of the given stream
1132 1132
 */
1133 1133
int av_add_index_entry(AVStream *st,
1134
                            int64_t pos, int64_t timestamp, int distance, int flags)
1134
                            int64_t pos, int64_t timestamp, int size, int distance, int flags)
1135 1135
{
1136 1136
    AVIndexEntry *entries, *ie;
1137 1137
    int index;
......
1168 1168
    ie->pos = pos;
1169 1169
    ie->timestamp = timestamp;
1170 1170
    ie->min_distance= distance;
1171
    ie->size= size;
1171 1172
    ie->flags = flags;
1172 1173

  
1173 1174
    return index;
......
1193 1194
        if (pkt->stream_index == 0 && st->parser &&
1194 1195
            (pkt->flags & PKT_FLAG_KEY)) {
1195 1196
            av_add_index_entry(st, st->parser->frame_offset, pkt->dts,
1196
                            0, AVINDEX_KEYFRAME);
1197
                            0, 0, AVINDEX_KEYFRAME);
1197 1198
        }
1198 1199
        av_free_packet(pkt);
1199 1200
    }

Also available in: Unified diff