comparison avidec.c @ 979:d2e5dfdf4def libavformat

add size to AVIndex
author michael
date Wed, 01 Mar 2006 11:29:55 +0000
parents 8bb9cea3c2d3
children da4296d3bc39
comparison
equal deleted inserted replaced
978:c168be36dbba 979:d2e5dfdf4def
53 int stream_index; 53 int stream_index;
54 DVDemuxContext* dv_demux; 54 DVDemuxContext* dv_demux;
55 } AVIContext; 55 } AVIContext;
56 56
57 static int avi_load_index(AVFormatContext *s); 57 static int avi_load_index(AVFormatContext *s);
58 static int guess_ni_flag(AVFormatContext *s);
58 59
59 #ifdef DEBUG 60 #ifdef DEBUG
60 static void print_tag(const char *str, unsigned int tag, int size) 61 static void print_tag(const char *str, unsigned int tag, int size)
61 { 62 {
62 printf("%s: tag=%c%c%c%c size=0x%x\n", 63 printf("%s: tag=%c%c%c%c size=0x%x\n",
116 if(index_type>1) 117 if(index_type>1)
117 return -1; 118 return -1;
118 119
119 for(i=0; i<entries_in_use; i++){ 120 for(i=0; i<entries_in_use; i++){
120 if(index_type){ 121 if(index_type){
121 int64_t pos= get_le32(pb) + base; 122 int64_t pos= get_le32(pb) + base - 8;
122 int len = get_le32(pb); 123 int len = get_le32(pb);
123 124 int key= len >= 0;
124 av_add_index_entry(st, pos, ast->cum_len, 0, (len<0) ? 0 : AVINDEX_KEYFRAME);
125 len &= 0x7FFFFFFF; 125 len &= 0x7FFFFFFF;
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);
126 129
127 if(ast->sample_size) 130 if(ast->sample_size)
128 ast->cum_len += len / ast->sample_size; 131 ast->cum_len += len / ast->sample_size;
129 else 132 else
130 ast->cum_len ++; 133 ast->cum_len ++;
410 } 413 }
411 414
412 if(!avi->index_loaded) 415 if(!avi->index_loaded)
413 avi_load_index(s); 416 avi_load_index(s);
414 avi->index_loaded = 1; 417 avi->index_loaded = 1;
418 avi->non_interleaved |= guess_ni_flag(s);
415 419
416 return 0; 420 return 0;
417 } 421 }
418 422
419 static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) 423 static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
697 av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%d\n", len, ast->cum_len); 701 av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%d\n", len, ast->cum_len);
698 #endif 702 #endif
699 if(last_pos == pos) 703 if(last_pos == pos)
700 avi->non_interleaved= 1; 704 avi->non_interleaved= 1;
701 else 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 if(ast->sample_size) 707 if(ast->sample_size)
704 ast->cum_len += len / ast->sample_size; 708 ast->cum_len += len / ast->sample_size;
705 else 709 else
706 ast->cum_len ++; 710 ast->cum_len ++;
707 last_pos= pos; 711 last_pos= pos;
766 url_fskip(pb, size); 770 url_fskip(pb, size);
767 break; 771 break;
768 } 772 }
769 } 773 }
770 the_end: 774 the_end:
771 avi->non_interleaved |= guess_ni_flag(s);
772 url_fseek(pb, pos, SEEK_SET); 775 url_fseek(pb, pos, SEEK_SET);
773 return 0; 776 return 0;
774 } 777 }
775 778
776 static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) 779 static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)