Skip to content

Conversation

@chemag
Copy link
Contributor

@chemag chemag commented Nov 26, 2024

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.

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.
@chemag
Copy link
Contributor Author

chemag commented Dec 3, 2024

ping

@chemag
Copy link
Contributor Author

chemag commented Dec 5, 2024

added CTSS parser

@chemag
Copy link
Contributor Author

chemag commented Dec 10, 2024

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.
@hwknsj
Copy link

hwknsj commented Dec 19, 2024

yo the homie @chemag is trying to help y'all

@DDNA-BuildAgent help them out, robot

chemag and others added 4 commits May 1, 2025 09:14
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
ChenDu-Meta and others added 6 commits May 5, 2025 12:27
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.
chemag and others added 7 commits May 23, 2025 12:00
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.
chemag added 3 commits July 7, 2025 18:01
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
```
chemag added 2 commits July 10, 2025 17:16
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
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants