1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

add size to AVIndex

Originally committed as revision 5083 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2006-03-01 11:29:55 +00:00
parent 26d6d03270
commit 30a43f2d09
7 changed files with 19 additions and 14 deletions

View File

@ -813,7 +813,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos,
assert((asf_st->packet_pos - s->data_offset) % asf->packet_size == 0); assert((asf_st->packet_pos - s->data_offset) % asf->packet_size == 0);
pos= asf_st->packet_pos; pos= asf_st->packet_pos;
av_add_index_entry(s->streams[i], pos, pts, pos - start_pos[i] + 1, AVINDEX_KEYFRAME); av_add_index_entry(s->streams[i], pos, pkt->size, pts, pos - start_pos[i] + 1, AVINDEX_KEYFRAME);
start_pos[i]= asf_st->packet_pos + 1; start_pos[i]= asf_st->packet_pos + 1;
if(pkt->stream_index == stream_index) if(pkt->stream_index == stream_index)

View File

@ -208,8 +208,8 @@ typedef struct AVIndexEntry {
int64_t pos; int64_t pos;
int64_t timestamp; int64_t timestamp;
#define AVINDEX_KEYFRAME 0x0001 #define AVINDEX_KEYFRAME 0x0001
/* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */ int flags:2;
int flags; 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)
int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */ int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */
} AVIndexEntry; } AVIndexEntry;
@ -641,7 +641,7 @@ void av_set_pts_info(AVStream *s, int pts_wrap_bits,
int av_find_default_stream_index(AVFormatContext *s); int av_find_default_stream_index(AVFormatContext *s);
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
int av_add_index_entry(AVStream *st, int av_add_index_entry(AVStream *st,
int64_t pos, int64_t timestamp, int distance, int flags); int64_t pos, int64_t timestamp, int size, int distance, int flags);
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags); int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
/* media file output */ /* media file output */

View File

@ -55,6 +55,7 @@ typedef struct {
} AVIContext; } AVIContext;
static int avi_load_index(AVFormatContext *s); static int avi_load_index(AVFormatContext *s);
static int guess_ni_flag(AVFormatContext *s);
#ifdef DEBUG #ifdef DEBUG
static void print_tag(const char *str, unsigned int tag, int size) static void print_tag(const char *str, unsigned int tag, int size)
@ -118,12 +119,14 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
for(i=0; i<entries_in_use; i++){ for(i=0; i<entries_in_use; i++){
if(index_type){ if(index_type){
int64_t pos= get_le32(pb) + base; int64_t pos= get_le32(pb) + base - 8;
int len = get_le32(pb); int len = get_le32(pb);
int key= len >= 0;
av_add_index_entry(st, pos, ast->cum_len, 0, (len<0) ? 0 : AVINDEX_KEYFRAME);
len &= 0x7FFFFFFF; len &= 0x7FFFFFFF;
//av_log(s, AV_LOG_ERROR, "pos:%Ld, len:%X\n", pos, len);
av_add_index_entry(st, pos, ast->cum_len, len, 0, key ? AVINDEX_KEYFRAME : 0);
if(ast->sample_size) if(ast->sample_size)
ast->cum_len += len / ast->sample_size; ast->cum_len += len / ast->sample_size;
else else
@ -412,6 +415,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
if(!avi->index_loaded) if(!avi->index_loaded)
avi_load_index(s); avi_load_index(s);
avi->index_loaded = 1; avi->index_loaded = 1;
avi->non_interleaved |= guess_ni_flag(s);
return 0; return 0;
} }
@ -699,7 +703,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
if(last_pos == pos) if(last_pos == pos)
avi->non_interleaved= 1; avi->non_interleaved= 1;
else else
av_add_index_entry(st, pos, ast->cum_len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0); av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
if(ast->sample_size) if(ast->sample_size)
ast->cum_len += len / ast->sample_size; ast->cum_len += len / ast->sample_size;
else else
@ -768,7 +772,6 @@ static int avi_load_index(AVFormatContext *s)
} }
} }
the_end: the_end:
avi->non_interleaved |= guess_ni_flag(s);
url_fseek(pb, pos, SEEK_SET); url_fseek(pb, pos, SEEK_SET);
return 0; return 0;
} }

View File

@ -1541,7 +1541,7 @@ static int mpegps_read_pes_header(AVFormatContext *s,
int i; int i;
for(i=0; i<s->nb_streams; i++){ for(i=0; i<s->nb_streams; i++){
if(startcode == s->streams[i]->id) { if(startcode == s->streams[i]->id) {
av_add_index_entry(s->streams[i], *ppos, dts, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
} }
} }
} }

View File

@ -1192,6 +1192,7 @@ static int decode_frame_header(NUTContext *nut, int *key_frame_ret, int64_t *pts
s->streams[stream_id], s->streams[stream_id],
frame_start, frame_start,
pts, pts,
0,
frame_start - nut->stream[stream_id].last_sync_pos, frame_start - nut->stream[stream_id].last_sync_pos,
AVINDEX_KEYFRAME); AVINDEX_KEYFRAME);
nut->stream[stream_id].last_sync_pos= frame_start; nut->stream[stream_id].last_sync_pos= frame_start;

View File

@ -982,7 +982,7 @@ resync:
if(flags&2){ if(flags&2){
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
if((seq&0x7F) == 1) if((seq&0x7F) == 1)
av_add_index_entry(st, pos, timestamp, 0, AVINDEX_KEYFRAME); av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
} }
} }
@ -1054,7 +1054,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
if((flags&2) && (seq&0x7F) == 1){ if((flags&2) && (seq&0x7F) == 1){
// av_log(s, AV_LOG_DEBUG, "%d %d-%d %Ld %d\n", flags, stream_index2, stream_index, dts, seq); // av_log(s, AV_LOG_DEBUG, "%d %d-%d %Ld %d\n", flags, stream_index2, stream_index, dts, seq);
av_add_index_entry(st, pos, dts, 0, AVINDEX_KEYFRAME); av_add_index_entry(st, pos, dts, 0, 0, AVINDEX_KEYFRAME);
if(stream_index2 == stream_index) if(stream_index2 == stream_index)
break; break;
} }

View File

@ -1131,7 +1131,7 @@ static void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t time
* @param timestamp timestamp in the timebase of the given stream * @param timestamp timestamp in the timebase of the given stream
*/ */
int av_add_index_entry(AVStream *st, int av_add_index_entry(AVStream *st,
int64_t pos, int64_t timestamp, int distance, int flags) int64_t pos, int64_t timestamp, int size, int distance, int flags)
{ {
AVIndexEntry *entries, *ie; AVIndexEntry *entries, *ie;
int index; int index;
@ -1168,6 +1168,7 @@ int av_add_index_entry(AVStream *st,
ie->pos = pos; ie->pos = pos;
ie->timestamp = timestamp; ie->timestamp = timestamp;
ie->min_distance= distance; ie->min_distance= distance;
ie->size= size;
ie->flags = flags; ie->flags = flags;
return index; return index;
@ -1193,7 +1194,7 @@ static void av_build_index_raw(AVFormatContext *s)
if (pkt->stream_index == 0 && st->parser && if (pkt->stream_index == 0 && st->parser &&
(pkt->flags & PKT_FLAG_KEY)) { (pkt->flags & PKT_FLAG_KEY)) {
av_add_index_entry(st, st->parser->frame_offset, pkt->dts, av_add_index_entry(st, st->parser->frame_offset, pkt->dts,
0, AVINDEX_KEYFRAME); 0, 0, AVINDEX_KEYFRAME);
} }
av_free_packet(pkt); av_free_packet(pkt);
} }