Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
08941cc
Use AESNI for AES-CTR if available
aguinet Feb 24, 2019
ade2f40
Add Dolby Vision for DASH signaling support.
Dec 6, 2022
3c67a8e
Fix Level and BitDepth in AV1 Codec String
Jan 11, 2024
8cdd099
Add build option BUILD_SHARED_LIBRARY
dguglielmi May 9, 2024
84d2c72
Add pkg-config file
dguglielmi May 9, 2024
4c5b67f
add gh LICENSE file
barbibulle Jun 17, 2024
3fcc8e8
Merge branch 'master' of https://github.com/axiomatic-systems/Bento4
barbibulle Jun 17, 2024
7493cd2
update license file
barbibulle Jun 17, 2024
874c264
Merge pull request #918 from saisrirammortha/master
barbibulle Jun 17, 2024
57a992e
fix edit list duration typo for AC3, EC3 and AC4.
Jul 18, 2024
324c571
fix #975
barbibulle Aug 4, 2024
3b809bd
Merge pull request #973 from DolbyLaboratories/dolby/mp4mux_edts_dura…
barbibulle Aug 4, 2024
4cb5f23
Check `__PPC__` and `__PPC`
capitalistspz Aug 6, 2024
df13e92
fix upmix object number for AC4 level 4.
Sep 3, 2024
725caa5
Merge pull request #979 from capitalistspz/ppcdef
barbibulle Sep 9, 2024
928e9ed
Merge pull request #978 from DolbyLaboratories/dolby/ac4_level_4
barbibulle Sep 16, 2024
f8ce9a9
Update ci.yml
barbibulle Sep 16, 2024
26bfad3
Remove deprecated Algorithm field 1 which should not be used conjunct…
ftyp Nov 13, 2024
3bdc891
Merge pull request #986 from ftyp/fix-widevine-pssh
barbibulle Nov 15, 2024
ac0f173
fix ac4 edit list duration.
Jan 20, 2025
7adf3bb
convert duration to AP4_UI64
Jan 20, 2025
c2cdaf8
Fix quote import in python 3.13
acrilique Feb 18, 2025
5ce6198
Fix single-quote issue on windows shells
acrilique Feb 18, 2025
29e3faf
Fix two sample description boxes when ClearLeadFragments=0
MingxinChen Jun 13, 2025
0d86d53
Merge pull request #1007 from DolbyLaboratories/fix_clearlead
barbibulle Jun 25, 2025
52f5569
Recognise s390 and s390x as big-endian platforms
neuschaefer Jun 30, 2025
7439c54
Update Ap4MdhdAtom.cpp
Sisyphus-wang Jul 18, 2025
a54a1eb
Update Ap4TfraAtom.cpp
Sisyphus-wang Jul 18, 2025
7af2177
Update Ap4TfraAtom.cpp
Sisyphus-wang Jul 18, 2025
419349c
Update Ap4TfraAtom.cpp
Sisyphus-wang Jul 18, 2025
96a8193
Update Ap4MdhdAtom.cpp
Sisyphus-wang Jul 18, 2025
6b51738
Update Mp4Fragment.cpp
Sisyphus-wang Jul 18, 2025
e136463
Update Ap4StsdAtom.cpp
Sisyphus-wang Jul 18, 2025
8af7564
Update Ap4CommonEncryption.cpp
Sisyphus-wang Jul 18, 2025
0229234
Update Mp42Ts.cpp
Sisyphus-wang Jul 20, 2025
63c1191
Update Ap4LinearReader.cpp
Sisyphus-wang Jul 20, 2025
d08b571
Adding FairPlay ContentProtection element with --fairplay option
ftyp Sep 22, 2025
8f51d55
Fix CodeQL "Unused local variable" warning
ftyp Sep 22, 2025
becafe8
Merge pull request #1040 from ftyp/dash-fairplay-signaling
barbibulle Sep 22, 2025
ad52c07
support ac4 subsample encryption
Nov 7, 2025
89ed5ce
Merge pull request #1046 from DolbyLaboratories/dolby/ac4_subsample
barbibulle Nov 15, 2025
b7ef459
Merge pull request #1035 from Sisyphus-wang/patch-5-Mp42Ts-fix-heap-u…
barbibulle Nov 15, 2025
e9c27de
Merge pull request #1036 from Sisyphus-wang/patch-6-fix-Ap4LinearRead…
barbibulle Nov 15, 2025
f104ec0
Merge pull request #1033 from Sisyphus-wang/patch-3-fix-Ap4StsdAtom-npd
barbibulle Nov 15, 2025
860ed7b
Merge pull request #1032 from Sisyphus-wang/patch-2-fix-Ap4TfraAtom.c…
barbibulle Nov 15, 2025
522b6a1
Merge pull request #1031 from Sisyphus-wang/patch-1-fix-Ap4MdhdAtom-npd
barbibulle Nov 15, 2025
b0df739
Merge pull request #1034 from Sisyphus-wang/patch-4-fix-heap-overflow…
barbibulle Nov 15, 2025
9ed40bc
Merge pull request #997 from acrilique/patch-2
barbibulle Nov 15, 2025
2219802
Merge pull request #996 from acrilique/patch-1
barbibulle Nov 15, 2025
b4b6cac
Merge pull request #1008 from neuschaefer/s390x
barbibulle Nov 15, 2025
8365144
Merge pull request #992 from DolbyLaboratories/dolby/fix_ac4_edit_lis…
barbibulle Nov 15, 2025
2cfda62
Merge pull request #959 from dguglielmi/pkgconfig-support
barbibulle Nov 15, 2025
b4c3d98
Merge branch 'master' into dolby/dovi_dash
Nov 17, 2025
a57da11
fix dangling pointer for subtream object.
Oct 30, 2024
dbb217a
Merge branch 'master' into dolby/fix_ac4_memory_leak
faushine1 Nov 17, 2025
3d8c30b
fix dangling pointer issue for AC4.
Sep 13, 2024
8ec865d
Merge pull request #820 from DolbyLaboratories/dolby/dovi_dash
barbibulle Nov 17, 2025
601b30b
Merge pull request #1047 from DolbyLaboratories/dolby/fix_ac4_memory_…
barbibulle Nov 17, 2025
eb6e369
Enable artifact overwrite in CI workflow
barbibulle Nov 17, 2025
5d40406
fix #1045
barbibulle Nov 25, 2025
0010f4f
Merge pull request #1049 from axiomatic-systems/gbg/1045
barbibulle Nov 25, 2025
f2b676d
Merge pull request #371 from aguinet/feature/aesni
barbibulle Dec 2, 2025
a13fcb9
Should be OCR tag here
fnordware Dec 4, 2025
2898b7a
Merge pull request #1052 from fnordware/esds_ocr
barbibulle Dec 6, 2025
a68215d
make static c runtime library optional
roamic Jan 27, 2026
8f641b0
cmake: set osx flags only for builds on macos
roamic Jan 29, 2026
9840a9a
Merge pull request #1056 from roamic/cmake-cond-osx-flags
barbibulle Jan 30, 2026
80924b9
fix video/audio only encryption packaging failure
faushine1 Apr 27, 2026
b53e138
fix ac3 heap overflow in issue https://github.com/axiomatic-systems/B…
faushine1 May 13, 2026
48dccc2
update HE-AAC sample rate in DASH to match the audio decoder config
faushine1 May 13, 2026
af249d7
Merge pull request #1067 from DolbyLaboratories/dolby/fix_ac3_heap_ov…
barbibulle May 13, 2026
402c957
Merge pull request #1068 from DolbyLaboratories/dolby/fix_he_aac_samp…
barbibulle May 13, 2026
add46ff
Merge pull request #1063 from DolbyLaboratories/dolby/vo_ao_enc
barbibulle May 13, 2026
deb4707
Merge pull request #1 from axiomatic-systems/master
faushine1 May 28, 2026
64448ee
Fix incorrect VIDEO-RANGE value in HLS packaging
faushine1 May 28, 2026
5387bc7
Fix SampleBuffer leak in AP4_LinearReader::Tracker destructor
dobo90 May 20, 2026
1dc8093
Fix heap buffer overflow in AP4_BitReader::ReadCache (issue #1066)
SAY-5 Jun 6, 2026
17c79a9
[Ap4CommonEncryption] Treat aux info of exactly iv_size bytes as "IV …
CastagnaIT Jun 19, 2026
8315d67
Merge pull request #1073 from SAY-5/fix-hevc-bitreader-overflow
barbibulle Jun 22, 2026
d0eb559
Merge pull request #1055 from roamic/static-library-option
barbibulle Jun 22, 2026
e3c0a6d
Merge pull request #1070 from DolbyLaboratories/dolby/fix-video-range
barbibulle Jun 22, 2026
e22a9fe
Merge pull request #1074 from CastagnaIT/common_enc_fix
barbibulle Jun 22, 2026
ad45bcd
Merge pull request #1069 from dobo90/fix_samplebuffer_leak_in_tracker…
barbibulle Jun 22, 2026
e2383d3
add missing file to make/build files
barbibulle Jun 22, 2026
5643218
Merge pull request #1078 from axiomatic-systems/gbg/fix-makefiles
barbibulle Jun 22, 2026
b8d3ca7
add dolby truehd support
barbibulle Nov 26, 2025
8a8e5d8
windows fixes
barbibulle Dec 2, 2025
b00f814
Merge pull request #1050 from axiomatic-systems/gbg/1048
barbibulle Jun 22, 2026
6285b6a
add missing dynamic cast anchor
barbibulle Jun 27, 2026
b8c50a0
Merge pull request #1079 from axiomatic-systems/gbg/fix-dynamic-cast
barbibulle Jun 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
289 changes: 289 additions & 0 deletions .github/LICENSE

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
# Upload the SDK
- name: Upload SDK
if: github.event_name == 'push'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
path: SDK/*.zip
overwrite: true

2 changes: 2 additions & 0 deletions Build/Makefiles/Lib.mak
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CORE_SOURCES = \
Ap4Av1cAtom.cpp \
Ap4ByteStream.cpp \
Ap4Co64Atom.cpp \
Ap4ColrAtom.cpp \
Ap4ContainerAtom.cpp \
Ap4CttsAtom.cpp \
Ap4DataBuffer.cpp \
Expand All @@ -25,6 +26,7 @@ CORE_SOURCES = \
Ap4DecoderSpecificInfoDescriptor.cpp \
Ap4Descriptor.cpp \
Ap4DescriptorFactory.cpp \
Ap4DmlpAtom.cpp \
Ap4DrefAtom.cpp \
Ap4EsDescriptor.cpp \
Ap4EsdsAtom.cpp \
Expand Down
250 changes: 134 additions & 116 deletions Build/Targets/universal-apple-macosx/Bento4.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<ClCompile Include="..\..\..\..\Source\C++\Codecs\Ap4BitStream.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ByteStream.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Co64Atom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ColrAtom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Command.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4CommandFactory.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ContainerAtom.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Co64Atom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ColrAtom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Command.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<ClCompile Include="..\..\..\..\Source\C++\Codecs\Ap4BitStream.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ByteStream.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Co64Atom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ColrAtom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Command.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4CommandFactory.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ContainerAtom.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Co64Atom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ColrAtom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Command.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Dac3Atom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Dac4Atom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Dec3Atom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4DmlpAtom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4DvccAtom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4HvccAtom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4PsshAtom.cpp" />
Expand All @@ -190,6 +191,7 @@
<ClCompile Include="..\..\..\..\Source\C++\Codecs\Ap4BitStream.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ByteStream.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Co64Atom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ColrAtom.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Command.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4CommandFactory.cpp" />
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ContainerAtom.cpp" />
Expand Down Expand Up @@ -303,6 +305,7 @@
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4Dac3Atom.h" />
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4Dac4Atom.h" />
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4Dec3Atom.h" />
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4DmlpAtom.h" />
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4DvccAtom.h" />
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4PsshAtom.h" />
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4SaioAtom.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Co64Atom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4ColrAtom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4Command.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -411,6 +414,9 @@
<ClCompile Include="..\..\..\..\Source\C++\Codecs\Ap4Eac3Parser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\C++\Core\Ap4DmlpAtom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4.h">
Expand Down Expand Up @@ -833,5 +839,8 @@
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4Ac4Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\C++\Core\Ap4DmlpAtom.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions Build/pkgconfig/bento4.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prefix=@CMAKE_INSTALL_PREFIX@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@

Name: @PROJECT_NAME@
Description: Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
Version: @BENTO4_VERSION@
Libs: -L${libdir} -lap4
Cflags: -I${includedir}/bento4
32 changes: 26 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ function(get_bento4_version)
endfunction()

get_bento4_version()
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "")
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "")
endif()
project(bento4 VERSION "${BENTO4_VERSION}")

# Variables
Expand All @@ -34,7 +36,9 @@ if (EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-warn-absolute-paths")
endif()

set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)
endif()

if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
Expand Down Expand Up @@ -71,13 +75,18 @@ file(GLOB AP4_HEADERS
${SOURCE_METADATA}/*.h
)

add_library(ap4 STATIC ${AP4_SOURCES})
option(BUILD_SHARED_LIBRARY "Build as a shared library" OFF)
if(BUILD_SHARED_LIBRARY)
add_library(ap4 SHARED ${AP4_SOURCES})
else()
add_library(ap4 STATIC ${AP4_SOURCES})
endif()
target_include_directories(ap4 PUBLIC
${AP4_INCLUDE_DIRS}
)

# Use the statically linked C runtime library
if(MSVC)
option(MSVC_FORCE_STATIC_C_RUNTIME "Use the statically linked C runtime library when compiling with MSVC" ON)
if(MSVC AND MSVC_FORCE_STATIC_C_RUNTIME)
set_property(TARGET ap4 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_definitions(ap4 PRIVATE -D_LIB)
endif()
Expand All @@ -92,7 +101,7 @@ foreach(app ${BENTO4_APPS})
add_executable(${binary_name} ${SOURCE_ROOT}/Apps/${app}/${app}.cpp)
target_link_libraries(${binary_name} ap4)

if(MSVC)
if(MSVC AND MSVC_FORCE_STATIC_C_RUNTIME)
set_property(TARGET ${binary_name} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_definitions(${binary_name} PRIVATE -D_CONSOLE)
endif()
Expand All @@ -119,6 +128,12 @@ configure_package_config_file(
INSTALL_DESTINATION "${config_install_dir}"
)

configure_file(
"Build/pkgconfig/bento4.pc.in"
"${generated_dir}/bento4.pc"
@ONLY
)

install(
TARGETS ap4 ${BENTO4_APPS_LOWERCASE}
EXPORT "${TARGETS_EXPORT_NAME}"
Expand All @@ -138,6 +153,11 @@ install(
DESTINATION "${config_install_dir}"
)

install(
FILES "${generated_dir}/bento4.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)

install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
Expand Down
16 changes: 8 additions & 8 deletions Source/C++/Apps/Mp42Ts/Mp42Ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,21 +301,21 @@ WriteSamples(AP4_Mpeg2TsWriter& writer,
audio_track->GetSampleDescription(audio_sample.GetDescriptionIndex()),
video_track==NULL,
*output);
if (AP4_FAILED(result)) return result;
if (AP4_FAILED(result)) goto end;

result = ReadSample(*audio_reader, *audio_track, audio_sample, audio_sample_data, audio_ts, audio_eos);
if (AP4_FAILED(result)) return result;
if (AP4_FAILED(result)) goto end;
++audio_sample_count;
} else if (chosen_track == video_track) {
result = video_stream->WriteSample(video_sample,
video_sample_data,
video_track->GetSampleDescription(video_sample.GetDescriptionIndex()),
true,
*output);
if (AP4_FAILED(result)) return result;
if (AP4_FAILED(result)) goto end;

result = ReadSample(*video_reader, *video_track, video_sample, video_sample_data, video_ts, video_eos);
if (AP4_FAILED(result)) return result;
if (AP4_FAILED(result)) goto end;
++video_sample_count;
} else {
break;
Expand Down Expand Up @@ -347,7 +347,7 @@ WriteSamples(AP4_Mpeg2TsWriter& writer,
// create the playlist file if needed
if (Options.playlist) {
playlist = OpenOutput(Options.playlist, 0);
if (playlist == NULL) return AP4_ERROR_CANNOT_OPEN_FILE;
if (playlist == NULL) goto end;

unsigned int target_duration = 0;
for (unsigned int i=0; i<segment_durations.ItemCount(); i++) {
Expand Down Expand Up @@ -515,8 +515,8 @@ main(int argc, char** argv)
AP4_Movie* movie = input_file->GetMovie();
if (movie == NULL) {
fprintf(stderr, "ERROR: no movie in file\n");
delete input;
delete input_file;
input->Release();
return 1;
}

Expand Down Expand Up @@ -581,7 +581,7 @@ main(int argc, char** argv)
stream_id = AP4_MPEG2_TS_STREAM_ID_PRIVATE_STREAM_1;
} else {
fprintf(stderr, "ERROR: audio codec not supported\n");
return 1;
goto end;
}

result = writer.SetAudioStream(audio_track->GetMediaTimeScale(),
Expand Down Expand Up @@ -622,7 +622,7 @@ main(int argc, char** argv)
stream_type = AP4_MPEG2_STREAM_TYPE_HEVC;
} else {
fprintf(stderr, "ERROR: video codec not supported\n");
return 1;
goto end;
}
result = writer.SetVideoStream(video_track->GetMediaTimeScale(),
stream_type,
Expand Down
2 changes: 1 addition & 1 deletion Source/C++/Apps/Mp4Fragment/Mp4Fragment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ Fragment(AP4_File& input_file,
AP4_UI32 sync_sample_flags = 0;
AP4_UI32 non_sync_sample_flags = 0x10000; // 0x10000 -> sample_is_non_sync
if (cursor->m_Track->GetType() == AP4_Track::TYPE_VIDEO ||
(cursor->m_Track->GetSampleDescriptionCount() > 0 &&
(cursor->m_Track->GetSampleDescriptionCount() > 0 && cursor->m_Track->GetSampleDescription(0) &&
cursor->m_Track->GetSampleDescription(0)->GetFormat() == AP4_SAMPLE_FORMAT_AC_4)) {
non_sync_sample_flags |= 0x1000000; // sample_depends_on=1 (not I frame)
sync_sample_flags |= 0x2000000; // sample_depends_on=2 (I frame)
Expand Down
26 changes: 26 additions & 0 deletions Source/C++/Apps/Mp4Info/Mp4Info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,16 @@ ShowSampleDescription_Text(AP4_SampleDescription& description, bool verbose)
break;
}

case AP4_SAMPLE_FORMAT_MLPA: {
// Dolby TrueHD specifics
AP4_DmlpAtom* dmlp = AP4_DYNAMIC_CAST(AP4_DmlpAtom, desc->GetDetails().GetChild(AP4_ATOM_TYPE_DMLP));
if (dmlp) {
printf(" Format Info: %d\n", dmlp->m_FormatInfo);
printf(" Peak Data Rate: %d\n", dmlp->m_PeakDataRate);
}
break;
}

// VPx Specifics
case AP4_SAMPLE_FORMAT_VP8:
case AP4_SAMPLE_FORMAT_VP9:
Expand Down Expand Up @@ -1081,6 +1091,22 @@ ShowSampleDescription_Json(AP4_SampleDescription& description, bool verbose)
printf("}");
}

// Color information from colr atom for non-VPx tracks
if (desc->GetFormat() != AP4_SAMPLE_FORMAT_VP8 &&
desc->GetFormat() != AP4_SAMPLE_FORMAT_VP9 &&
desc->GetFormat() != AP4_SAMPLE_FORMAT_VP10) {
AP4_ColrAtom* colr = AP4_DYNAMIC_CAST(AP4_ColrAtom, desc->GetDetails().GetChild(AP4_ATOM_TYPE_COLR));
if (colr && colr->GetColourParameterType() == AP4_SAMPLE_COLOR_TYPE_NCLX) {
printf(",\n");
printf("\"color_info\": {\n");
printf(" \"colour_primaries\":%d,\n", colr->GetPrimariesIndex());
printf(" \"transfer_characteristics\":%d,\n", colr->GetTransferFunctionIndex());
printf(" \"matrix_coefficients\":%d,\n", colr->GetMatrixIndex());
printf(" \"video_full_range_flag\":%s\n", colr->GetFullRangeFlag() ? "true" : "false");
printf("}");
}
}

printf("\n}");
}

Expand Down
6 changes: 3 additions & 3 deletions Source/C++/Apps/Mp4Mux/Mp4Mux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ AddAc3Track(AP4_Movie& movie,
if (!movie.GetTimeScale()) {
duration = sample_count * 1536;
} else {
duration = AP4_ConvertTime(1000*sample_table->GetSampleCount(), sample_rate, movie.GetTimeScale());
duration = AP4_ConvertTime(1536*sample_table->GetSampleCount(), sample_rate, movie.GetTimeScale());
}
AP4_ElstEntry new_elst_entry = AP4_ElstEntry(duration, 0, 1);
new_elst->AddEntry(new_elst_entry);
Expand Down Expand Up @@ -814,7 +814,7 @@ AddEac3Track(AP4_Movie& movie,
if (!movie.GetTimeScale()) {
duration = sample_count * 1536;
} else {
duration = AP4_ConvertTime(1000*sample_table->GetSampleCount(), sample_rate, movie.GetTimeScale());
duration = AP4_ConvertTime(1536*sample_table->GetSampleCount(), sample_rate, movie.GetTimeScale());
}
AP4_ElstEntry new_elst_entry = AP4_ElstEntry(duration, 0, 1);
new_elst->AddEntry(new_elst_entry);
Expand Down Expand Up @@ -962,7 +962,7 @@ AddAc4Track(AP4_Movie& movie,
if (!movie.GetTimeScale()) {
duration = AP4_UI64(sample_count) * sample_duration;
} else {
duration = AP4_ConvertTime(1000*sample_table->GetSampleCount(), media_time_scale, movie.GetTimeScale());
duration = AP4_ConvertTime(AP4_UI64(sample_duration)*sample_table->GetSampleCount(), media_time_scale, movie.GetTimeScale());
}
AP4_ElstEntry new_elst_entry = AP4_ElstEntry(duration, 0, 1);
new_elst->AddEntry(new_elst_entry);
Expand Down
12 changes: 12 additions & 0 deletions Source/C++/Codecs/Ap4Ac3Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ AP4_Ac3Header::AP4_Ac3Header(const AP4_UI08* bytes)
bits.SkipBits(16); // crc1
m_Fscod = bits.ReadBits(2);
m_Frmsizecod = bits.ReadBits(6); // frmsizecod
if (m_Fscod >= sizeof(FRAME_SIZE_CODE_ARY_AC3)/sizeof(FRAME_SIZE_CODE_ARY_AC3[0]) ||
m_Frmsizecod >= sizeof(FRAME_SIZE_CODE_ARY_AC3[0])/sizeof(FRAME_SIZE_CODE_ARY_AC3[0][0])) {
m_FrameSize = 0;
// invalid frame size code, set bsid to an invalid value to make sure the header check will fail
m_Bsid = 0xFF;
return;
}
m_FrameSize = FRAME_SIZE_CODE_ARY_AC3[m_Fscod][m_Frmsizecod] * 2;

m_Bsid = bits.ReadBits(5);
Expand All @@ -58,6 +65,11 @@ AP4_Ac3Header::AP4_Ac3Header(const AP4_UI08* bytes)
bits.SkipBits(2); //dsurmod
}
m_Lfeon = bits.ReadBit();
if (m_Acmod >= sizeof(GLOBAL_CHANNEL_ARY)/sizeof(GLOBAL_CHANNEL_ARY[0])) {
// invalid acmod, set bsid to an invalid value to make sure the header check will fail
m_Bsid = 0xFF;
return;
}
m_ChannelCount = GLOBAL_CHANNEL_ARY[m_Acmod] + m_Lfeon;
bits.SkipBits(5); // dialnorm
if(bits.ReadBit()){ // compre
Expand Down
Loading