comparison mov.c @ 3956:8bdecea89071 libavformat

support negative ctts in some way, unset wrong dts
author bcoudurier
date Tue, 30 Sep 2008 02:44:57 +0000
parents d30c8469093d
children 4fd67f05bad9
comparison
equal deleted inserted replaced
3955:874534fb6d0f 3956:8bdecea89071
131 int pseudo_stream_id; ///< -1 means demux all ids 131 int pseudo_stream_id; ///< -1 means demux all ids
132 int16_t audio_cid; ///< stsd audio compression id 132 int16_t audio_cid; ///< stsd audio compression id
133 unsigned drefs_count; 133 unsigned drefs_count;
134 MOV_dref_t *drefs; 134 MOV_dref_t *drefs;
135 int dref_id; 135 int dref_id;
136 int wrong_dts; ///< dts are wrong due to negative ctts
136 } MOVStreamContext; 137 } MOVStreamContext;
137 138
138 typedef struct MOVContext { 139 typedef struct MOVContext {
139 AVFormatContext *fc; 140 AVFormatContext *fc;
140 int time_scale; 141 int time_scale;
1164 for(i=0; i<entries; i++) { 1165 for(i=0; i<entries; i++) {
1165 int count =get_be32(pb); 1166 int count =get_be32(pb);
1166 int duration =get_be32(pb); 1167 int duration =get_be32(pb);
1167 1168
1168 if (duration < 0) { 1169 if (duration < 0) {
1169 av_log(c->fc, AV_LOG_WARNING, "negative ctts, ignoring\n"); 1170 sc->wrong_dts = 1;
1170 sc->ctts_count = 0; 1171 st->codec->has_b_frames = 1;
1171 url_fskip(pb, 8 * (entries - i - 1));
1172 break;
1173 } 1172 }
1174 sc->ctts_data[i].count = count; 1173 sc->ctts_data[i].count = count;
1175 sc->ctts_data[i].duration= duration; 1174 sc->ctts_data[i].duration= duration;
1176 1175
1177 sc->time_rate= ff_gcd(sc->time_rate, duration); 1176 sc->time_rate= ff_gcd(sc->time_rate, FFABS(duration));
1178 } 1177 }
1179 return 0; 1178 return 0;
1180 } 1179 }
1181 1180
1182 static void mov_build_index(MOVContext *mov, AVStream *st) 1181 static void mov_build_index(MOVContext *mov, AVStream *st)
1880 if (sc->sample_to_ctime_index < sc->ctts_count && 1879 if (sc->sample_to_ctime_index < sc->ctts_count &&
1881 sc->ctts_data[sc->sample_to_ctime_index].count == sc->sample_to_ctime_sample) { 1880 sc->ctts_data[sc->sample_to_ctime_index].count == sc->sample_to_ctime_sample) {
1882 sc->sample_to_ctime_index++; 1881 sc->sample_to_ctime_index++;
1883 sc->sample_to_ctime_sample = 0; 1882 sc->sample_to_ctime_sample = 0;
1884 } 1883 }
1884 if (sc->wrong_dts)
1885 pkt->dts = AV_NOPTS_VALUE;
1885 } else { 1886 } else {
1886 AVStream *st = s->streams[sc->ffindex]; 1887 AVStream *st = s->streams[sc->ffindex];
1887 int64_t next_dts = (sc->current_sample < sc->sample_count) ? 1888 int64_t next_dts = (sc->current_sample < sc->sample_count) ?
1888 st->index_entries[sc->current_sample].timestamp : st->duration; 1889 st->index_entries[sc->current_sample].timestamp : st->duration;
1889 pkt->duration = next_dts - pkt->dts; 1890 pkt->duration = next_dts - pkt->dts;