comparison mov.c @ 4742:0496cbd94374 libavformat

Extend mov edit list support to work for a first padding entry with time == -1 and duration. Complicated since time is relative to stream, duration relative to container time base.
author reimar
date Mon, 16 Mar 2009 20:49:52 +0000
parents 07ac6d6584a1
children a0e0086f7f52
comparison
equal deleted inserted replaced
4741:4f53f8346307 4742:0496cbd94374
1276 unsigned int stss_index = 0; 1276 unsigned int stss_index = 0;
1277 unsigned int i, j; 1277 unsigned int i, j;
1278 1278
1279 /* adjust first dts according to edit list */ 1279 /* adjust first dts according to edit list */
1280 if (sc->time_offset) { 1280 if (sc->time_offset) {
1281 int rescaled = sc->time_offset < 0 ? av_rescale(sc->time_offset, sc->time_scale, mov->time_scale) : sc->time_offset;
1281 assert(sc->time_offset % sc->time_rate == 0); 1282 assert(sc->time_offset % sc->time_rate == 0);
1282 current_dts = - (sc->time_offset / sc->time_rate); 1283 current_dts = - (rescaled / sc->time_rate);
1283 } 1284 }
1284 1285
1285 /* only use old uncompressed audio chunk demuxing when stts specifies it */ 1286 /* only use old uncompressed audio chunk demuxing when stts specifies it */
1286 if (!(st->codec->codec_type == CODEC_TYPE_AUDIO && 1287 if (!(st->codec->codec_type == CODEC_TYPE_AUDIO &&
1287 sc->stts_count == 1 && sc->stts_data[0].duration == 1)) { 1288 sc->stts_count == 1 && sc->stts_data[0].duration == 1)) {
1772 get_be24(pb); /* flags */ 1773 get_be24(pb); /* flags */
1773 edit_count = get_be32(pb); /* entries */ 1774 edit_count = get_be32(pb); /* entries */
1774 1775
1775 for(i=0; i<edit_count; i++){ 1776 for(i=0; i<edit_count; i++){
1776 int time; 1777 int time;
1777 get_be32(pb); /* Track duration */ 1778 int duration = get_be32(pb); /* Track duration */
1778 time = get_be32(pb); /* Media time */ 1779 time = get_be32(pb); /* Media time */
1779 get_be32(pb); /* Media rate */ 1780 get_be32(pb); /* Media rate */
1780 if (i == 0 && time != -1) { 1781 if (i == 0 && time >= -1) {
1781 sc->time_offset = time; 1782 sc->time_offset = time != -1 ? time : -duration;
1782 sc->time_rate = av_gcd(sc->time_rate, time); 1783 sc->time_rate = av_gcd(sc->time_rate, FFABS(sc->time_offset));
1783 } 1784 }
1784 } 1785 }
1785 1786
1786 if(edit_count > 1) 1787 if(edit_count > 1)
1787 av_log(c->fc, AV_LOG_WARNING, "multiple edit list entries, " 1788 av_log(c->fc, AV_LOG_WARNING, "multiple edit list entries, "