List Info

Thread: CR-Client: handle duplicated entries in MP4 Sample-To-Chunk table




CR-Client: handle duplicated entries in MP4 Sample-To-Chunk table
country flaguser name
United States
2008-04-23 14:18:45
Description
-------------------------------------------------
In mp4 files, samples can be stored in chunks, which
are contiguous blocks on media data. In order to tell
which samples belong to which chunks, there's a 
sample-to-chunk table which tells how many samples
are in each chunk:

  Chunk     NumberOfSamples
    1             31
    2             31
    3             31
    4             32
    5             32
    6             31
   ...

Since lots of times consecutive chunks have the same
number of samples, then this table is stored in compact
fashion,
and only the first chunk is stored in the table for 
a run of chunks with the same number of samples.
For the example above, the table above would be stored
like this:

FirstChunk     NumberOfSamples
    1             31
    4             32
    6             31
   ...

which means that chunks 1-3 have 31 samples each,
chunks 4-5 have 32 samples each, etc. Therefore, in almost
all files I have seen up until now, the FirstChunk field
in the table is STRICTLY INCREASING. However, the mp4 file
format spec does not specifically prohibit duplicated
entries
in the table. I have attached an image of a
"normal"
sample-to-chunk table (normal_stsc.png).

However, in hc.org bug 7975, Intel discovered some content
where there are duplicated entries in the sample-to-chunk
table (see attached image odd_stsc.png). This duplicated
entry
uncovered a bug in the CQT_SampleToChunk_Manager class in
the mp4 file format plugin. These duplicated entries were
causing
us to produce a packet of the correct size but from the
wrong
offset in the file. This was resulting in garbage packets
being handed to the AAC decoder.

This changes enables the CQT_SampleToChunk_Manager class to
handle duplicated entries in the sample-to-chunk table. It
does this by not assuming that the next entry in the table
will be valid, but rather introduces two new functions to
search for valid entries: GetNextFirstChunk() and
GetPrevFirstChunk().
It also cleans up some code which was duplicated in several
places by centralizing these code in three new functions:
GetFirstChunk(), GetSamplesPerChunk(), and
GetSampleDescID().

Files Modified
-------------------------------------------------
datatype/mp4/fileformat/qtatmmgs.cpp
datatype/mp4/fileformat/pub/qtatmmgs.h

Branches
-------------------------------------------------
HEAD and hxclient_3_1_0_atlas

Testing
-------------------------------------------------
I tested playback and seeking on files with duplicated
sample-to-chunk entries (the repro content) as well as
files with no duplicated sample-to-chunk entries.

=============================================
Eric Hyche (ehychereal.com)
Technical Lead
RealNetworks, Inc. 

_______________________________________________
Datatype-dev mailing list
Datatype-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/da
tatype-dev

View Original Image
View Original Image
  
CN-Client: handle duplicated entries in MP4Sample-To-Chunk table
country flaguser name
United States
2008-04-29 07:31:09
This is now checked into HEAD and 310Atlas.

=============================================
Eric Hyche (ehychereal.com)
Technical Lead
RealNetworks, Inc.  

> -----Original Message-----
> From: datatype-dev-bounceshelixcommunity.org 
> [mailto:datatype-dev-bounceshelixcommunity.org] On
Behalf Of 
> Eric Hyche
> Sent: Wednesday, April 23, 2008 3:19 PM
> To: datatype-devlists.helixcommunity.org
> Subject: [datatype-dev] CR-Client: handle duplicated
entries 
> in MP4Sample-To-Chunk table
> 
> 
> Description
> -------------------------------------------------
> In mp4 files, samples can be stored in chunks, which
> are contiguous blocks on media data. In order to tell
> which samples belong to which chunks, there's a 
> sample-to-chunk table which tells how many samples
> are in each chunk:
> 
>   Chunk     NumberOfSamples
>     1             31
>     2             31
>     3             31
>     4             32
>     5             32
>     6             31
>    ...
> 
> Since lots of times consecutive chunks have the same
> number of samples, then this table is stored in compact
fashion,
> and only the first chunk is stored in the table for 
> a run of chunks with the same number of samples.
> For the example above, the table above would be stored
> like this:
> 
> FirstChunk     NumberOfSamples
>     1             31
>     4             32
>     6             31
>    ...
> 
> which means that chunks 1-3 have 31 samples each,
> chunks 4-5 have 32 samples each, etc. Therefore, in
almost
> all files I have seen up until now, the FirstChunk
field
> in the table is STRICTLY INCREASING. However, the mp4
file
> format spec does not specifically prohibit duplicated
entries
> in the table. I have attached an image of a
"normal"
> sample-to-chunk table (normal_stsc.png).
> 
> However, in hc.org bug 7975, Intel discovered some
content
> where there are duplicated entries in the
sample-to-chunk
> table (see attached image odd_stsc.png). This
duplicated entry
> uncovered a bug in the CQT_SampleToChunk_Manager class
in
> the mp4 file format plugin. These duplicated entries
were causing
> us to produce a packet of the correct size but from the
wrong
> offset in the file. This was resulting in garbage
packets
> being handed to the AAC decoder.
> 
> This changes enables the CQT_SampleToChunk_Manager
class to
> handle duplicated entries in the sample-to-chunk table.
It
> does this by not assuming that the next entry in the
table
> will be valid, but rather introduces two new functions
to
> search for valid entries: GetNextFirstChunk() and
GetPrevFirstChunk().
> It also cleans up some code which was duplicated in
several
> places by centralizing these code in three new
functions:
> GetFirstChunk(), GetSamplesPerChunk(), and
GetSampleDescID().
> 
> Files Modified
> -------------------------------------------------
> datatype/mp4/fileformat/qtatmmgs.cpp
> datatype/mp4/fileformat/pub/qtatmmgs.h
> 
> Branches
> -------------------------------------------------
> HEAD and hxclient_3_1_0_atlas
> 
> Testing
> -------------------------------------------------
> I tested playback and seeking on files with duplicated
> sample-to-chunk entries (the repro content) as well as
> files with no duplicated sample-to-chunk entries.
> 
> =============================================
> Eric Hyche (ehychereal.com)
> Technical Lead
> RealNetworks, Inc. 
> 


_______________________________________________
Datatype-dev mailing list
Datatype-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/da
tatype-dev

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )