-
Notifications
You must be signed in to change notification settings - Fork 64
add support for zero-length boxes #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chemag
wants to merge
76
commits into
DigiDNA:main
Choose a base branch
from
chemag:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In order to end a list of sub-boxes, some ISOBMFF multiplexers prefer to end a box list with a length=0 entry, instead of a non-existent length field. Patch adds support for this behavior.
Contributor
Author
|
ping |
Contributor
Author
|
added CTSS parser |
Contributor
Author
|
did you manage to take a look at these 2 patches? |
Only adding 32-bit BE, as it is the one needed for now.
Standard defines offsets (sample_offset) to be unsigned or signed
int depending on the version field. More concretely,
ISO/IEC 14496-12:2022 modifies the behavior of CTTS so that
makes sample_offset is a 32-bit signed int when version is 1.
Section 8.6.1.3.2:
```
aligned(8) class CompositionOffsetBox
extends FullBox('ctts', version, 0) {
unsigned int(32) entry_count;
int i;
if (version==0) {
for (i=0; i < entry_count; i++) {
unsigned int(32) sample_count;
unsigned int(32) sample_offset;
}
}
else if (version == 1) {
for (i=0; i < entry_count; i++) {
unsigned int(32) sample_count;
signed int(32) sample_offset;
}
}
}
```
Apple MOV muxers are known to use negative CTTS offsets even
without setting the version field to 1. It typically makes no
sense to have a sensor offset larger than 0x7fff,ffff, so we
will force signed int always.
|
yo the homie @chemag is trying to help y'all @DDNA-BuildAgent help them out, robot |
Add unit test for ISOBMFF Parser using static binary stream input. The binary stream was dumped from a mp4 video file.
Add fuzzing support to ISOBMFF with libfuzzer. Add fuzzing to Parser
Add exception catch to Parser unit test and fuzzer to prevent crashing during fuzzing
Add unit test to META atom parser
Add fuzzing to META atom parser
If wrong box size is given the box->ReadData may fail, resulting memory leak as content is nor properly deleted. Fix it by try-catch to delete content if box->ReadData failed.
Tested: linux ``` $ CC=gcc CXX=g++ cmake .. -- The CXX compiler identification is GNU 15.1.1 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /bin/g++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (0.3s) -- Generating done (0.0s) -- Build files have been written to: isobmff/build $ make -j [ 1%] Building CXX object CMakeFiles/ISOBMFF.dir/ISOBMFF/source/AV01.cpp.o ... [ 98%] Building CXX object CMakeFiles/ISOBMFF.dir/ISOBMFF/source/URN.cpp.o [100%] Linking CXX shared library libISOBMFF.so [100%] Built target ISOBMFF ``` ``` $ CC=clang CXX=clang++ cmake .. -- The CXX compiler identification is Clang 20.1.3 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (0.4s) -- Generating done (0.0s) -- Build files have been written to: isobmff/build $ make -j [ 3%] Building CXX object CMakeFiles/ISOBMFF.dir/ISOBMFF/source/AVC1.cpp.o ... [100%] Linking CXX shared library libISOBMFF.so [100%] Built target ISOBMFF ``` Tested: MacOS ``` % CC=gcc CXX=g++ cmake .. -- The CXX compiler identification is AppleClang 17.0.0.17000013 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/g++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (0.8s) -- Generating done (0.0s) -- Build files have been written to: isobmff/build % make -j [ 3%] Building CXX object CMakeFiles/ISOBMFF.dir/ISOBMFF/source/AVC1.cpp.o ... [ 98%] Building CXX object CMakeFiles/ISOBMFF.dir/ISOBMFF/source/Matrix.cpp.o [100%] Linking CXX shared library libISOBMFF.dylib [100%] Built target ISOBMFF ``` ``` % CC=clang CXX=clang++ cmake .. -- The CXX compiler identification is AppleClang 17.0.0.17000013 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (0.7s) -- Generating done (0.0s) -- Build files have been written to: isobmff/build % make -j [ 1%] Building CXX object CMakeFiles/ISOBMFF.dir/ISOBMFF/source/AV01.cpp.o ... [ 98%] Building CXX object CMakeFiles/ISOBMFF.dir/ISOBMFF/source/HDLR.cpp.o [100%] Linking CXX shared library libISOBMFF.dylib [100%] Built target ISOBMFF ```
abs() is defined only for int in <cstdlib>. std::streamoff is typically a long or even long long, so using abs(int) may lead to truncation, overflow, or undefined behavior when dealing with large offsets.
Tested:
```
$ tools/isobmff --no-analyze-flag in.mp4
$ tools/isobmff --analyze-flag in.mp4
[ ISOBMFF::File ]
{
[ ftyp ]
{
- Major brand: isom
...
$ tools/isobmff in.mp4
[ ISOBMFF::File ]
{
[ ftyp ]
{
- Major brand: isom
...
```
Tested:
default case:
```
$ valgrind --tool=massif --detailed-freq=1 ./tools/isobmff in.mp4
$ grep mem_heap_B massif.out.default | awk -F= '{if($2 > max) max=$2} END{print max}'
691167
```
donotskipmdat:
Added the following patch
```
diff --git a/tools/main.cpp b/tools/main.cpp
index def1861..5552cb7 100644
--- a/tools/main.cpp
+++ b/tools/main.cpp
@@ -223,6 +223,7 @@ int main( int argc, char *const * argv )
try
{
+ parser.AddOption( ISOBMFF::Parser::Options::DoNotSkipMDATData );
parser.Parse( path );
}
catch( const std::runtime_error & e )
```
And then:
```
$ valgrind --tool=massif --detailed-freq=1 ./tools/isobmff in.mp4
$ grep mem_heap_B massif.out.donotskipmdat | awk -F= '{if($2 > max) max=$2} END{print max}'
682524151
```
Tested:
```
$ make test
Running tests...
/usr/local/lib64/python3.13/site-packages/cmake/data/bin/ctest
Test project isobmff/build
Start 1: DREF_unittest
1/8 Test #1: DREF_unittest .................... Passed 0.00 sec
Start 2: FTYP_unittest
2/8 Test #2: FTYP_unittest .................... Passed 0.00 sec
Start 3: HDLR_unittest
3/8 Test #3: HDLR_unittest .................... Passed 0.00 sec
Start 4: MDHD_unittest
4/8 Test #4: MDHD_unittest .................... Passed 0.00 sec
Start 5: META_unittest
5/8 Test #5: META_unittest .................... Passed 0.00 sec
Start 6: MVHD_unittest
6/8 Test #6: MVHD_unittest .................... Passed 0.00 sec
Start 7: Parser_unittest
7/8 Test #7: Parser_unittest .................. Passed 0.00 sec
Start 8: TKHD_unittest
8/8 Test #8: TKHD_unittest .................... Passed 0.00 sec
100% tests passed, 0 tests failed out of 8
Total Test time (real) = 0.03 sec
```
Tested: ``` $ cd fuzz $ RUNS=10000000 make -j -Oline fuzz ... ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In order to end a list of sub-boxes, some ISOBMFF multiplexers prefer to end a box list with a length=0 entry, instead of a non-existent length field. Patch adds support for this behavior.