diff options
author | Torsten Jager <t.jager@gmx.de> | 2014-02-11 14:09:15 +0100 |
---|---|---|
committer | Torsten Jager <t.jager@gmx.de> | 2014-02-11 14:09:15 +0100 |
commit | 0163b4daf1ce8392a7f277b94c90d26dc9e7b12c (patch) | |
tree | 8d2da33374c38034ba3ba8ca556b4ee160b11ec7 | |
parent | 3a971da000da1f4c6aea5cb95323c8b817db78fe (diff) | |
download | xine-lib-0163b4daf1ce8392a7f277b94c90d26dc9e7b12c.tar.gz xine-lib-0163b4daf1ce8392a7f277b94c90d26dc9e7b12c.tar.bz2 |
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.
-rw-r--r-- | src/demuxers/demux_qt.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c index ebb039daf..bdf366448 100644 --- a/src/demuxers/demux_qt.c +++ b/src/demuxers/demux_qt.c @@ -83,6 +83,7 @@ typedef unsigned int qt_atom; /* 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 @@ typedef struct { 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 @@ static qt_error parse_trak_atom (qt_trak *trak, 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 @@ static qt_error parse_trak_atom (qt_trak *trak, 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 @@ static qt_error parse_trak_atom (qt_trak *trak, /* 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 @@ static qt_error build_frame_table(qt_trak *trak, /* 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; |