comparison mov.c @ 4399:530e55405feb libavformat

offset dts according to edit list, hackish but works, based on patch by Reimar
author bcoudurier
date Sun, 08 Feb 2009 04:27:07 +0000
parents 329080adea79
children 146d6083662b
comparison
equal deleted inserted replaced
4398:043d314bb216 4399:530e55405feb
123 int *sample_sizes; 123 int *sample_sizes;
124 unsigned int keyframe_count; 124 unsigned int keyframe_count;
125 int *keyframes; 125 int *keyframes;
126 int time_scale; 126 int time_scale;
127 int time_rate; 127 int time_rate;
128 int time_offset; /// time offset of the first edit list entry
128 int current_sample; 129 int current_sample;
129 unsigned int bytes_per_frame; 130 unsigned int bytes_per_frame;
130 unsigned int samples_per_frame; 131 unsigned int samples_per_frame;
131 int dv_audio_container; 132 int dv_audio_container;
132 int pseudo_stream_id; ///< -1 means demux all ids 133 int pseudo_stream_id; ///< -1 means demux all ids
1228 int64_t current_dts = 0; 1229 int64_t current_dts = 0;
1229 unsigned int stts_index = 0; 1230 unsigned int stts_index = 0;
1230 unsigned int stsc_index = 0; 1231 unsigned int stsc_index = 0;
1231 unsigned int stss_index = 0; 1232 unsigned int stss_index = 0;
1232 unsigned int i, j; 1233 unsigned int i, j;
1234
1235 /* adjust first dts according to edit list */
1236 if (sc->time_offset) {
1237 assert(sc->time_offset % sc->time_rate == 0);
1238 current_dts = - (sc->time_offset / sc->time_rate);
1239 }
1233 1240
1234 /* only use old uncompressed audio chunk demuxing when stts specifies it */ 1241 /* only use old uncompressed audio chunk demuxing when stts specifies it */
1235 if (!(st->codec->codec_type == CODEC_TYPE_AUDIO && 1242 if (!(st->codec->codec_type == CODEC_TYPE_AUDIO &&
1236 sc->stts_count == 1 && sc->stts_data[0].duration == 1)) { 1243 sc->stts_count == 1 && sc->stts_data[0].duration == 1)) {
1237 unsigned int current_sample = 0; 1244 unsigned int current_sample = 0;
1760 for(i=0; i<edit_count; i++){ 1767 for(i=0; i<edit_count; i++){
1761 int time; 1768 int time;
1762 get_be32(pb); /* Track duration */ 1769 get_be32(pb); /* Track duration */
1763 time = get_be32(pb); /* Media time */ 1770 time = get_be32(pb); /* Media time */
1764 get_be32(pb); /* Media rate */ 1771 get_be32(pb); /* Media rate */
1765 if (time != 0) 1772 if (i == 0 && time != -1)
1766 av_log(c->fc, AV_LOG_WARNING, "edit list not starting at 0, " 1773 sc->time_offset = time;
1767 "a/v desync might occur, patch welcome\n"); 1774 }
1768 } 1775
1776 if(edit_count > 1)
1777 av_log(c->fc, AV_LOG_WARNING, "multiple edit list entries, "
1778 "a/v desync might occur, patch welcome\n");
1779
1769 dprintf(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, sc->edit_count); 1780 dprintf(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, sc->edit_count);
1770 return 0; 1781 return 0;
1771 } 1782 }
1772 1783
1773 static const MOVParseTableEntry mov_default_parse_table[] = { 1784 static const MOVParseTableEntry mov_default_parse_table[] = {