From: Torsten J. <t....@gm...> - 2014-02-11 13:09:43
|
# HG changeset patch # User Torsten Jager <t....@gm...> # Date 1392124155 -3600 # Node ID ab229a035d91862723f91d48de2c6eaefe5a81c6 # Branch default # Parent 155c153554bed5ee65bc02fa7f4b9bdf81b75739 demux_qt: add compact sample size table support. This is an ISO extension, and even they dont recommend breaking some players with it. In other words: I have no file for testing. diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c --- a/src/demuxers/demux_qt.c +++ b/src/demuxers/demux_qt.c @@ -83,6 +83,7 @@ /* atoms in a sample table */ #define STSD_ATOM QT_ATOM('s', 't', 's', 'd') #define STSZ_ATOM QT_ATOM('s', 't', 's', 'z') +#define STZ2_ATOM QT_ATOM('s', 't', 'z', '2') #define STSC_ATOM QT_ATOM('s', 't', 's', 'c') #define STCO_ATOM QT_ATOM('s', 't', 'c', 'o') #define STTS_ATOM QT_ATOM('s', 't', 't', 's') @@ -314,6 +315,7 @@ unsigned int samples; unsigned int sample_size; unsigned int sample_size_count; + unsigned int sample_size_bits; unsigned char *sample_size_table; /* sync samples, a.k.a., keyframes */ @@ -934,9 +936,9 @@ VMHD_ATOM, SMHD_ATOM, TKHD_ATOM, ELST_ATOM, MDHD_ATOM, STSD_ATOM, STSZ_ATOM, STSS_ATOM, STCO_ATOM, CO64_ATOM, STSC_ATOM, STTS_ATOM, - CTTS_ATOM, 0}; - unsigned int sizes[13]; - unsigned char *atoms[13]; + CTTS_ATOM, STZ2_ATOM, 0}; + unsigned int sizes[14]; + unsigned char *atoms[14]; /* initialize trak structure */ trak->id = -1; @@ -948,6 +950,7 @@ trak->samples = 0; trak->sample_size = 0; trak->sample_size_count = 0; + trak->sample_size_bits = 0; trak->sample_size_table = NULL; trak->sync_sample_count = 0; trak->sync_sample_table = NULL; @@ -1456,6 +1459,26 @@ /* there may be 0 items + moof fragments later */ if (trak->sample_size == 0) trak->sample_size_table = atom + 20; + trak->sample_size_bits = 32; + } else { + atom = atoms[13]; /* STZ2_ATOM */ + atomsize = sizes[13]; + if (atomsize >= 20) { + trak->sample_size_count = _X_BE_32 (&atom[16]); + trak->sample_size_bits = atom[15]; + trak->sample_size_table = atom + 20; + if (atom[15] == 16) { + if (trak->sample_size_count > (atomsize - 20) / 2) + trak->sample_size_count = (atomsize - 20) / 2; + } else if (atom[15] == 8) { + if (trak->sample_size_count > (atomsize - 20)) + trak->sample_size_count = atomsize - 20; + } else { + trak->sample_size_count = 0; + trak->sample_size_bits = 0; + trak->sample_size_table = NULL; + } + } } atom = atoms[7]; /* STSS_ATOM */ @@ -1823,7 +1846,12 @@ /* figure out the offset and size */ if (size_left) { - size_value = _X_BE_32 (s); s += 4; + if (trak->sample_size_bits == 32) + size_value = _X_BE_32 (s), s += 4; + else if (trak->sample_size_bits == 16) + size_value = _X_BE_16 (s), s += 2; + else + size_value = *s++; size_left--; } frame->offset = offset_value; |