Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: build
run: cmake --build build
- name: test
run: ./bin/unit_tests --wait-for-keypress never -d yes
run: ./build/test/unit_tests --wait-for-keypress never -d yes

macos:
runs-on: macOS-latest
Expand All @@ -26,7 +26,7 @@ jobs:
- name: build
run: cmake --build build
- name: test
run: ./bin/unit_tests --wait-for-keypress never -d yes exclude:large_files
run: ./build/test/unit_tests --wait-for-keypress never -d yes exclude:large_files

windows:
runs-on: windows-latest
Expand All @@ -37,4 +37,4 @@ jobs:
- name: build
run: cmake --build build --config Debug
- name: test
run: ./bin/Debug/unit_tests --wait-for-keypress never -d yes exclude:large_files
run: ./build/test/Debug/unit_tests --wait-for-keypress never -d yes exclude:large_files
77 changes: 45 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
cmake_minimum_required(VERSION 3.9.2)
cmake_minimum_required(VERSION 3.16)

project(IsoLib)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)

find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
option(SET_CUSTOM_OUTPUT_DIRS "Set custom output directories for artifacts" OFF)
option(ISOBMFF_BUILD_LIB_ONLY "Build only libisomediafile (skip examples/tools/tests)" OFF)

if(SET_CUSTOM_OUTPUT_DIRS)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
endif()

# Only check/update submodules if building tools
if(NOT ISOBMFF_BUILD_LIB_ONLY)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
endif()

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/IsoLib/HM/README")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/IsoLib/HM/README")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
endif()

# Build dependencies
add_subdirectory(external)

# Build isobmff tools
# Always build the library
add_subdirectory(IsoLib/libisomediafile)
add_subdirectory(IsoLib/audio_example)
add_subdirectory(IsoLib/drc_in_isom)
add_subdirectory(IsoLib/favs_example)
add_subdirectory(IsoLib/hevc_extractors)
add_subdirectory(IsoLib/ipmp_example)
add_subdirectory(IsoLib/isoiff_tool)
add_subdirectory(IsoLib/pcm_audio_example)
add_subdirectory(test)
add_subdirectory(IsoLib/vvc_base)

# Only build tools/examples/tests if requested
if(NOT ISOBMFF_BUILD_LIB_ONLY)
# Build dependencies
add_subdirectory(external)

# Build isobmff tools
add_subdirectory(IsoLib/audio_example)
add_subdirectory(IsoLib/drc_in_isom)
add_subdirectory(IsoLib/favs_example)
add_subdirectory(IsoLib/hevc_extractors)
add_subdirectory(IsoLib/ipmp_example)
add_subdirectory(IsoLib/isoiff_tool)
add_subdirectory(IsoLib/pcm_audio_example)
add_subdirectory(IsoLib/vvc_base)
add_subdirectory(test)
endif()
2 changes: 1 addition & 1 deletion IsoLib/audio_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9.2)
cmake_minimum_required(VERSION 3.16)

project(audio_example)

Expand Down
2 changes: 1 addition & 1 deletion IsoLib/drc_in_isom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9.2)
cmake_minimum_required(VERSION 3.16)

project(drc_in_isom)

Expand Down
61 changes: 37 additions & 24 deletions IsoLib/favs_example/src/demux_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ ISOErr playMyMovie(struct ParamStruct *parameters, char *filename) {
/* Loop all the tracks in the container, starting from 1 */
for (trackNumber = 1; trackNumber < trackCount + 1; trackNumber++) {
FILE *out;
ISOHandle spsHandle = NULL;
ISOHandle vpsHandle = NULL;
ISOHandle ppsHandle = NULL;
MP4Handle sampleEntryNALs = NULL;

MP4GenericAtom subs = NULL;
u32 sampleSize;
u32 alst_target = 0;
Expand Down Expand Up @@ -160,13 +159,39 @@ ISOErr playMyMovie(struct ParamStruct *parameters, char *filename) {

/* Get sample description from the trak */
err = MP4TrackReaderGetCurrentSampleDescription(reader, sampleEntryH); if (err) goto bail;
/* Allocate handles for parameter sets */
err = ISONewHandle(1, &vpsHandle); err = ISONewHandle(1, &spsHandle); err = ISONewHandle(1, &ppsHandle);
if (err) goto bail;
/* Grab parameter sets from the sample description */
err = ISOGetHEVCSampleDescriptionPS(sampleEntryH, vpsHandle, 32, 1); if (err) goto bail;
err = ISOGetHEVCSampleDescriptionPS(sampleEntryH, spsHandle, 33, 1); if (err) goto bail;
err = ISOGetHEVCSampleDescriptionPS(sampleEntryH, ppsHandle, 34, 1); if (err) goto bail;

switch (parameters->hevcExtractionMode)
{
case 0:
printf("Dump all NAL units from the sample entry\n");
break;

case 1:
printf("Only dump NAL units from the hvcC\n");
break;

case 2:
printf("Only dump NAL units from the lhvC\n");
break;

default:
printf("Unknown extraction mode. Dump all NAL units from the sample entry\n");
parameters->hevcExtractionMode = 0;
break;
}

/* Write Sample Entry NAL Units in the beginning of the trak output file */
MP4NewHandle(0, &sampleEntryNALs);
err = ISOGetHEVCNALUs(sampleEntryH, sampleEntryNALs, parameters->hevcExtractionMode);
if(err)
{
printf("Failed to extract NAL units with mode %u (err = %d)\n", parameters->hevcExtractionMode, err);
}
else
{
err = MP4GetHandleSize(sampleEntryNALs, &sampleSize); if (err) goto bail;
fwrite(*sampleEntryNALs, sampleSize, 1, out);
}

ISOGetMediaTimeScale(media, &mediaTimeScale);
ISOGetMediaSampleCount(media, &totalSamples);
Expand All @@ -187,16 +212,6 @@ ISOErr playMyMovie(struct ParamStruct *parameters, char *filename) {
ISOGetSampletoGroupMap(media, MP4_FOUR_CHAR_CODE('a', 'l', 's', 't'), i + 1, &((u32*)*alst_index)[i]);
}
}

/* Write parameter sets in the beginning of the trak output file */
err = ISOGetHandleSize(vpsHandle, &sampleSize); if (err) goto bail;
fwrite(&syncCode, 4, 1, out); fwrite(*vpsHandle, sampleSize, 1, out);

err = ISOGetHandleSize(spsHandle, &sampleSize); if (err) goto bail;
fwrite(&syncCode, 4, 1, out); fwrite(*spsHandle, sampleSize, 1, out);

err = ISOGetHandleSize(ppsHandle, &sampleSize); if (err) goto bail;
fwrite(&syncCode, 4, 1, out); fwrite(*ppsHandle, sampleSize, 1, out);

/* Handle the case when seek parameter is given and alst is present */
if (parameters->seek && alst) {
Expand Down Expand Up @@ -286,9 +301,7 @@ ISOErr playMyMovie(struct ParamStruct *parameters, char *filename) {
err = ISODisposeHandle(sampleH);
err = ISODisposeHandle(decoderConfigH);
err = ISODisposeTrackReader(reader);
err = ISODisposeHandle(spsHandle);
err = ISODisposeHandle(ppsHandle);
err = ISODisposeHandle(vpsHandle);
MP4DisposeHandle(sampleEntryNALs);
}
free(outSampleName);
err = ISODisposeMovie(moov);
Expand Down Expand Up @@ -340,5 +353,5 @@ int main(int argc, char* argv[])

cleanParameters(&parameters);

return 1;
return 0;
}
1 change: 1 addition & 0 deletions IsoLib/favs_example/src/structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ struct ParamStruct {

u32 subsample_information;
u32 compactSampleToGroup;
u32 hevcExtractionMode; /* 0 = all (default), 1 = hvcC only, 2 = lhvC only */
};


Expand Down
17 changes: 12 additions & 5 deletions IsoLib/favs_example/src/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,16 @@ int parseInput(int argc, char* argv[], struct ParamStruct *parameters) {
break;
/* Long parameter name */
case '-': {
#define LONG_PARAM_I(NAME, LEN, OUTPUT) if (strncmp(&argv[param][2], NAME, LEN) == 0) { \
if (argv[param][LEN+2] == '=') OUTPUT = atoi(&argv[param][LEN+3]); \
else { if (argc - 1 == param) break; param++; OUTPUT = atoi(argv[param + 1]); } \
}
#define LONG_PARAM_I(NAME, LEN, OUTPUT) \
if (strncmp(&argv[param][2], NAME, LEN) == 0) { \
if (argv[param][LEN+2] == '=') { \
OUTPUT = atoi(&argv[param][LEN+3]); \
} else { \
if (argc - 1 <= param) break; \
param++; \
OUTPUT = atoi(argv[param]); \
} \
}
#define LONG_PARAM_F(NAME, LEN, OUTPUT) if (strncmp(&argv[param][2], NAME, LEN) == 0) { \
if (argv[param][LEN+2] == '=') OUTPUT = atof(&argv[param][LEN+3]); \
else { if (argc - 1 == param) break; param++; OUTPUT = atof(argv[param + 1]); } \
Expand Down Expand Up @@ -278,7 +284,8 @@ int parseInput(int argc, char* argv[], struct ParamStruct *parameters) {
temp_string = NULL;
}
LONG_PARAM_S("output", 5, parameters->output);


LONG_PARAM_I("mode", 4, parameters->hevcExtractionMode);
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion IsoLib/hevc_extractors/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9.2)
cmake_minimum_required(VERSION 3.16)

project(hevc_extractors)

Expand Down
2 changes: 1 addition & 1 deletion IsoLib/hevc_extractors/macosx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.16)

# CPPFLAGS = -I. -I../src -I../../libisomediafile/linux -I../../libisomediafile/src -O -g -Wall
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O -g -Wall -UNDEBUG")
Expand Down
4 changes: 2 additions & 2 deletions IsoLib/hevc_extractors/src/HEVCExtractorReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

extern "C"
{
MP4_EXTERN(MP4Err) ISOGetRESVOriginalFormat(MP4Handle sampleEntryH,
MP4_EXTERN(MP4Err) ISOGetOriginalFormat(MP4Handle sampleEntryH,
u32* outOrigFmt);
MP4_EXTERN(MP4Err) ISOGetRESVSampleDescriptionPS(MP4Handle sampleEntryH,
MP4Handle ps,
Expand Down Expand Up @@ -175,7 +175,7 @@ std::string HEVCExtractorReader::getOriginalFormat(uint32_t uiTrackID) const
if(MP4NoErr==err)
{
uint32_t uiOrigFormat = 0;
err = ISOGetRESVOriginalFormat(sampleEntryH, &uiOrigFormat);
err = ISOGetOriginalFormat(sampleEntryH, &uiOrigFormat);
if(MP4NoErr==err)
{
if(uiOrigFormat==ISOHEVCSampleEntryAtomType) { strRet = "hvc1"; }
Expand Down
2 changes: 1 addition & 1 deletion IsoLib/ipmp_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9.2)
cmake_minimum_required(VERSION 3.16)

project(ipmp_example)

Expand Down
2 changes: 1 addition & 1 deletion IsoLib/isoiff_tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9.2)
cmake_minimum_required(VERSION 3.16)

project(isoiff)

Expand Down
37 changes: 15 additions & 22 deletions IsoLib/libisomediafile/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#---------------------------------------------------------------------------------------------------
# libisomediafile top-level list
#---------------------------------------------------------------------------------------------------
cmake_minimum_required (VERSION 3.9.2)
#---------------------------------------------------------------------------------------------------
cmake_minimum_required (VERSION 3.16)

project(libisomediafile)
#---------------------------------------------------------------------------------------------------

if (MSVC)
# warning level 4 and all warnings as errors
add_compile_options(/W4 /WX)
else()
# lots of warnings and all warnings as errors
add_compile_options(-Wall -Wextra -pedantic -Werror)

option(LIBISOMEDIAFILE_STRICT_WARNINGS "Enable strict compiler warnings in libisomediafile" ON)

if(LIBISOMEDIAFILE_STRICT_WARNINGS)
if (MSVC)
# warning level 4 and all warnings as errors
add_compile_options(/W4 /WX)
else()
# lots of warnings and all warnings as errors
add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()
endif()

add_library(
Expand Down Expand Up @@ -71,6 +71,7 @@ add_library(
src/H263SpecificInfoAtom.c
src/HandlerAtom.c
src/HEVCConfigAtom.c
src/LHEVCConfigAtom.c
src/VVCConfigAtom.c
src/VVCNALUConfigAtom.c
src/HintMediaHeaderAtom.c
Expand Down Expand Up @@ -248,8 +249,6 @@ add_library(
) # add_library


#---------------------------------------------------------------------------------------------------

target_include_directories(
${PROJECT_NAME}

Expand All @@ -268,23 +267,19 @@ target_include_directories(

)

#---------------------------------------------------------------------------------------------------

target_compile_options(
${PROJECT_NAME}

PRIVATE

# GNU compiler
$<$<C_COMPILER_ID:GNU>:-Wall -W -ansi -pedantic -Wno-long-long -Wmissing-prototypes>
$<$<AND:$<BOOL:${LIBISOMEDIAFILE_STRICT_WARNINGS}>,$<C_COMPILER_ID:GNU>>:-Wall -W -std=c99 -pedantic -Wno-long-long -Wmissing-prototypes>

# Visual Studio run time library
$<$<AND:$<C_COMPILER_ID:MSVC>,$<CONFIG:Debug>>:/MTd>
$<$<AND:$<C_COMPILER_ID:MSVC>,$<NOT:$<CONFIG:Debug>>>:/MT>
)

#---------------------------------------------------------------------------------------------------

target_compile_definitions(
${PROJECT_NAME}

Expand All @@ -297,5 +292,3 @@ target_compile_definitions(
$<$<PLATFORM_ID:Windows>:ISOMP4DLLAPI _CRT_SECURE_NO_WARNINGS>

)

#---------------------------------------------------------------------------------------------------
Loading