mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-02-26 08:22:31 +00:00
MP4: move constants to namespace mtx::m4p; use constexpr instead of #define
This commit is contained in:
parent
98fa7b5a45
commit
47ffd40bc2
@ -127,7 +127,7 @@ create_audio_specific_config(audio_config_t const &audio_config) {
|
||||
|
||||
if (audio_config.sbr) {
|
||||
w.put_bits(11, mtx::aac::SYNC_EXTENSION_TYPE);
|
||||
write_object_type(MP4AOT_SBR);
|
||||
write_object_type(mtx::mp4::AUDIO_OBJECT_TYPE_SBR);
|
||||
w.put_bits(1, 1); // sbr_present_flag
|
||||
write_sampling_frequency(audio_config.output_sample_rate ? audio_config.output_sample_rate : audio_config.sample_rate * 2);
|
||||
}
|
||||
@ -976,22 +976,22 @@ header_c::read_ga_specific_config() {
|
||||
|
||||
// Frame length in samples; see ISO/IEC 14496-3:2005, section
|
||||
// 4.5.1.1 "GASpecificConfig()" in 4.5 "Overall data structure".
|
||||
if (!mtx::included_in<int>(object_type, MP4AOT_SBR, MP4AOT_ER_AAC_LD))
|
||||
if (!mtx::included_in<int>(object_type, mtx::mp4::AUDIO_OBJECT_TYPE_SBR, mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LD))
|
||||
config.samples_per_frame = frame_length_flag ? 960 : 1024;
|
||||
else if (MP4AOT_ER_AAC_LD == object_type)
|
||||
else if (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LD == object_type)
|
||||
config.samples_per_frame = frame_length_flag ? 480 : 512;
|
||||
|
||||
if (!config.channels)
|
||||
read_program_config_element();
|
||||
|
||||
if ((MP4AOT_AAC_SCALABLE == object_type) || (MP4AOT_ER_AAC_SCALABLE == object_type))
|
||||
if ((mtx::mp4::AUDIO_OBJECT_TYPE_AAC_SCALABLE == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE == object_type))
|
||||
m_bc->skip_bits(3); // layer_nr
|
||||
|
||||
if (extension_flag) {
|
||||
if (MP4AOT_ER_BSAC == object_type)
|
||||
if (mtx::mp4::AUDIO_OBJECT_TYPE_ER_BSAC == object_type)
|
||||
m_bc->skip_bits(5 + 11); // num_of_sub_frame, layer_length
|
||||
|
||||
if ((MP4AOT_ER_AAC_LC == object_type) || (MP4AOT_ER_AAC_LTP == object_type) || (MP4AOT_ER_AAC_SCALABLE == object_type) || (MP4AOT_ER_AAC_LD == object_type))
|
||||
if ((mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LC == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LTP == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LD == object_type))
|
||||
m_bc->skip_bits(1 + 1 + 1); // aac_section_data_resilience_flag, aac_scalefactor_data_resilience_flag, aac_spectral_data_resilience_flag
|
||||
|
||||
m_bc->skip_bit(); // extension_flag3
|
||||
@ -1128,8 +1128,8 @@ header_c::parse_audio_specific_config(mtx::bits::reader_c &bc,
|
||||
if (channel_config < 8)
|
||||
config.channels = s_aac_channel_configuration[channel_config];
|
||||
|
||||
if ( (MP4AOT_SBR == object_type)
|
||||
|| ( (MP4AOT_PS == object_type)
|
||||
if ( (mtx::mp4::AUDIO_OBJECT_TYPE_SBR == object_type)
|
||||
|| ( (mtx::mp4::AUDIO_OBJECT_TYPE_PS == object_type)
|
||||
&& !( (m_bc->peek_bits(3) & 0x03)
|
||||
&& !(m_bc->peek_bits(9) & 0x3f)))) {
|
||||
config.sbr = true;
|
||||
@ -1138,21 +1138,21 @@ header_c::parse_audio_specific_config(mtx::bits::reader_c &bc,
|
||||
object_type = read_object_type();
|
||||
}
|
||||
|
||||
if ( (MP4AOT_AAC_MAIN == object_type) || (MP4AOT_AAC_LC == object_type) || (MP4AOT_AAC_SSR == object_type) || (MP4AOT_AAC_LTP == object_type) || (MP4AOT_AAC_SCALABLE == object_type)
|
||||
|| (MP4AOT_TWINVQ == object_type) || (MP4AOT_ER_AAC_LC == object_type) || (MP4AOT_ER_AAC_LTP == object_type) || (MP4AOT_ER_AAC_SCALABLE == object_type) || (MP4AOT_ER_TWINVQ == object_type)
|
||||
|| (MP4AOT_ER_BSAC == object_type) || (MP4AOT_ER_AAC_LD == object_type))
|
||||
if ( (mtx::mp4::AUDIO_OBJECT_TYPE_AAC_MAIN == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_AAC_LC == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_AAC_SSR == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_AAC_LTP == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_AAC_SCALABLE == object_type)
|
||||
|| (mtx::mp4::AUDIO_OBJECT_TYPE_TWINVQ == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LC == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LTP == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_TWINVQ == object_type)
|
||||
|| (mtx::mp4::AUDIO_OBJECT_TYPE_ER_BSAC == object_type) || (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LD == object_type))
|
||||
read_ga_specific_config();
|
||||
|
||||
else if (MP4AOT_ER_AAC_ELD == object_type)
|
||||
else if (mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_ELD == object_type)
|
||||
read_eld_specific_config();
|
||||
|
||||
else if (MP4AOT_ER_CELP)
|
||||
else if (mtx::mp4::AUDIO_OBJECT_TYPE_ER_CELP)
|
||||
read_er_celp_specific_config();
|
||||
|
||||
else
|
||||
throw unsupported_feature_x{fmt::format("AAC object type {0} in audio-specific config", object_type)};
|
||||
|
||||
if ((MP4AOT_ER_AAC_LC == object_type) || ((MP4AOT_ER_AAC_LTP <= object_type) && (MP4AOT_ER_PARAM >= object_type))) {
|
||||
if ((mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LC == object_type) || ((mtx::mp4::AUDIO_OBJECT_TYPE_ER_AAC_LTP <= object_type) && (mtx::mp4::AUDIO_OBJECT_TYPE_ER_PARAM >= object_type))) {
|
||||
int ep_config = m_bc->get_bits(2);
|
||||
if ((2 == ep_config) || (3 == ep_config))
|
||||
read_error_protection_specific_config();
|
||||
@ -1161,7 +1161,7 @@ header_c::parse_audio_specific_config(mtx::bits::reader_c &bc,
|
||||
}
|
||||
|
||||
if ( look_for_sync_extension
|
||||
&& (MP4AOT_SBR != extension_object_type)
|
||||
&& (mtx::mp4::AUDIO_OBJECT_TYPE_SBR != extension_object_type)
|
||||
&& (m_bc->get_remaining_bits() >= 16)) {
|
||||
|
||||
auto prior_position = m_bc->get_bit_position();
|
||||
@ -1169,7 +1169,7 @@ header_c::parse_audio_specific_config(mtx::bits::reader_c &bc,
|
||||
|
||||
if (mtx::aac::SYNC_EXTENSION_TYPE == sync_extension_type) {
|
||||
extension_object_type = read_object_type();
|
||||
if (MP4AOT_SBR == extension_object_type) {
|
||||
if (mtx::mp4::AUDIO_OBJECT_TYPE_SBR == extension_object_type) {
|
||||
config.sbr = m_bc->get_bit();
|
||||
if (config.sbr)
|
||||
config.output_sample_rate = read_sample_rate();
|
||||
|
@ -312,24 +312,24 @@ codec_c::look_up_audio_format(uint16_t audio_format) {
|
||||
|
||||
codec_c const
|
||||
codec_c::look_up_object_type_id(unsigned int object_type_id) {
|
||||
return look_up( ( (MP4OTI_MPEG4Audio == object_type_id)
|
||||
|| (MP4OTI_MPEG2AudioMain == object_type_id)
|
||||
|| (MP4OTI_MPEG2AudioLowComplexity == object_type_id)
|
||||
|| (MP4OTI_MPEG2AudioScaleableSamplingRate == object_type_id)) ? type_e::A_AAC
|
||||
: MP4OTI_MPEG1Audio == object_type_id ? type_e::A_MP2
|
||||
: MP4OTI_MPEG2AudioPart3 == object_type_id ? type_e::A_MP3
|
||||
: MP4OTI_DTS == object_type_id ? type_e::A_DTS
|
||||
: MP4OTI_VORBIS == object_type_id ? type_e::A_VORBIS
|
||||
: ( (MP4OTI_MPEG2VisualSimple == object_type_id)
|
||||
|| (MP4OTI_MPEG2VisualMain == object_type_id)
|
||||
|| (MP4OTI_MPEG2VisualSNR == object_type_id)
|
||||
|| (MP4OTI_MPEG2VisualSpatial == object_type_id)
|
||||
|| (MP4OTI_MPEG2VisualHigh == object_type_id)
|
||||
|| (MP4OTI_MPEG2Visual422 == object_type_id)
|
||||
|| (MP4OTI_MPEG1Visual == object_type_id)) ? type_e::V_MPEG12
|
||||
: MP4OTI_MPEG4Visual == object_type_id ? type_e::V_MPEG4_P2
|
||||
: MP4OTI_VOBSUB == object_type_id ? type_e::S_VOBSUB
|
||||
: type_e::UNKNOWN);
|
||||
return look_up( ( (mtx::mp4::OBJECT_TYPE_MPEG4Audio == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG2AudioMain == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG2AudioLowComplexity == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG2AudioScaleableSamplingRate == object_type_id)) ? type_e::A_AAC
|
||||
: mtx::mp4::OBJECT_TYPE_MPEG1Audio == object_type_id ? type_e::A_MP2
|
||||
: mtx::mp4::OBJECT_TYPE_MPEG2AudioPart3 == object_type_id ? type_e::A_MP3
|
||||
: mtx::mp4::OBJECT_TYPE_DTS == object_type_id ? type_e::A_DTS
|
||||
: mtx::mp4::OBJECT_TYPE_VORBIS == object_type_id ? type_e::A_VORBIS
|
||||
: ( (mtx::mp4::OBJECT_TYPE_MPEG2VisualSimple == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG2VisualMain == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG2VisualSNR == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG2VisualSpatial == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG2VisualHigh == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG2Visual422 == object_type_id)
|
||||
|| (mtx::mp4::OBJECT_TYPE_MPEG1Visual == object_type_id)) ? type_e::V_MPEG12
|
||||
: mtx::mp4::OBJECT_TYPE_MPEG4Visual == object_type_id ? type_e::V_MPEG4_P2
|
||||
: mtx::mp4::OBJECT_TYPE_VOBSUB == object_type_id ? type_e::S_VOBSUB
|
||||
: type_e::UNKNOWN);
|
||||
}
|
||||
|
||||
bool
|
||||
|
153
src/common/mp4.h
153
src/common/mp4.h
@ -13,74 +13,99 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mtx::mp4 {
|
||||
|
||||
// Object type identifications.
|
||||
// See http://gpac.sourceforge.net/tutorial/mediatypes.htm
|
||||
#define MP4OTI_MPEG4Systems1 0x01
|
||||
#define MP4OTI_MPEG4Systems2 0x02
|
||||
#define MP4OTI_MPEG4Visual 0x20
|
||||
#define MP4OTI_MPEG4Audio 0x40
|
||||
#define MP4OTI_MPEG2VisualSimple 0x60
|
||||
#define MP4OTI_MPEG2VisualMain 0x61
|
||||
#define MP4OTI_MPEG2VisualSNR 0x62
|
||||
#define MP4OTI_MPEG2VisualSpatial 0x63
|
||||
#define MP4OTI_MPEG2VisualHigh 0x64
|
||||
#define MP4OTI_MPEG2Visual422 0x65
|
||||
#define MP4OTI_MPEG2AudioMain 0x66
|
||||
#define MP4OTI_MPEG2AudioLowComplexity 0x67
|
||||
#define MP4OTI_MPEG2AudioScaleableSamplingRate 0x68
|
||||
#define MP4OTI_MPEG2AudioPart3 0x69
|
||||
#define MP4OTI_MPEG1Visual 0x6A
|
||||
#define MP4OTI_MPEG1Audio 0x6B
|
||||
#define MP4OTI_JPEG 0x6C
|
||||
#define MP4OTI_DTS 0xA9
|
||||
#define MP4OTI_VORBIS 0xDD
|
||||
#define MP4OTI_VOBSUB 0xE0
|
||||
constexpr auto OBJECT_TYPE_MPEG4Systems1 = 0x01;
|
||||
constexpr auto OBJECT_TYPE_MPEG4Systems2 = 0x02;
|
||||
constexpr auto OBJECT_TYPE_MPEG4Visual = 0x20;
|
||||
constexpr auto OBJECT_TYPE_MPEG4Audio = 0x40;
|
||||
constexpr auto OBJECT_TYPE_MPEG2VisualSimple = 0x60;
|
||||
constexpr auto OBJECT_TYPE_MPEG2VisualMain = 0x61;
|
||||
constexpr auto OBJECT_TYPE_MPEG2VisualSNR = 0x62;
|
||||
constexpr auto OBJECT_TYPE_MPEG2VisualSpatial = 0x63;
|
||||
constexpr auto OBJECT_TYPE_MPEG2VisualHigh = 0x64;
|
||||
constexpr auto OBJECT_TYPE_MPEG2Visual422 = 0x65;
|
||||
constexpr auto OBJECT_TYPE_MPEG2AudioMain = 0x66;
|
||||
constexpr auto OBJECT_TYPE_MPEG2AudioLowComplexity = 0x67;
|
||||
constexpr auto OBJECT_TYPE_MPEG2AudioScaleableSamplingRate = 0x68;
|
||||
constexpr auto OBJECT_TYPE_MPEG2AudioPart3 = 0x69;
|
||||
constexpr auto OBJECT_TYPE_MPEG1Visual = 0x6A;
|
||||
constexpr auto OBJECT_TYPE_MPEG1Audio = 0x6B;
|
||||
constexpr auto OBJECT_TYPE_JPEG = 0x6C;
|
||||
constexpr auto OBJECT_TYPE_DTS = 0xA9;
|
||||
constexpr auto OBJECT_TYPE_VORBIS = 0xDD;
|
||||
constexpr auto OBJECT_TYPE_VOBSUB = 0xE0;
|
||||
|
||||
// Audio object type identifactors
|
||||
// This list comes from
|
||||
#define MP4AOT_AAC_MAIN 0x01 // Main
|
||||
#define MP4AOT_AAC_LC 0x02 // Low Complexity
|
||||
#define MP4AOT_AAC_SSR 0x03 // Scalable Sample Rate
|
||||
#define MP4AOT_AAC_LTP 0x04 // Long Term Prediction
|
||||
#define MP4AOT_SBR 0x05 // Spectral Band Replication
|
||||
#define MP4AOT_AAC_SCALABLE 0x06 // Scalable
|
||||
#define MP4AOT_TWINVQ 0x07 // TwinVQ Vector Quantizer
|
||||
#define MP4AOT_CELP 0x08 // Code Excited Linear Prediction
|
||||
#define MP4AOT_HVXC 0x09 // Harmonic Vector eXcitation Coding
|
||||
#define MP4AOT_TTSI 0x0c // Text-To-Speech Interface
|
||||
#define MP4AOT_MAINSYNTH 0x0d // Main Synthesis
|
||||
#define MP4AOT_WAVESYNTH 0x0e // Wavetable Synthesis
|
||||
#define MP4AOT_MIDI 0x0f // General MIDI
|
||||
#define MP4AOT_SAFX 0x10 // Algorithmic Synthesis and Audio Effects
|
||||
#define MP4AOT_ER_AAC_LC 0x11 // Error Resilient Low Complexity
|
||||
#define MP4AOT_ER_AAC_LTP 0x13 // Error Resilient Long Term Prediction
|
||||
#define MP4AOT_ER_AAC_SCALABLE 0x14 // Error Resilient Scalable
|
||||
#define MP4AOT_ER_TWINVQ 0x15 // Error Resilient Twin Vector Quantizer
|
||||
#define MP4AOT_ER_BSAC 0x16 // Error Resilient Bit-Sliced Arithmetic Coding
|
||||
#define MP4AOT_ER_AAC_LD 0x17 // Error Resilient Low Delay
|
||||
#define MP4AOT_ER_CELP 0x18 // Error Resilient Code Excited Linear Prediction
|
||||
#define MP4AOT_ER_HVXC 0x19 // Error Resilient Harmonic Vector eXcitation Coding
|
||||
#define MP4AOT_ER_HILN 0x1a // Error Resilient Harmonic and Individual Lines plus Noise
|
||||
#define MP4AOT_ER_PARAM 0x1b // Error Resilient Parametric
|
||||
#define MP4AOT_SSC 0x1c // SinuSoidal Coding
|
||||
#define MP4AOT_PS 0x1d // Parametric Stereo
|
||||
#define MP4AOT_SURROUND 0x1e // MPEG Surround
|
||||
#define MP4AOT_L1 0x20 // Layer 1
|
||||
#define MP4AOT_L2 0x21 // Layer 2
|
||||
#define MP4AOT_L3 0x22 // Layer 3
|
||||
#define MP4AOT_DST 0x23 // Direct Stream Transfer
|
||||
#define MP4AOT_ALS 0x24 // Audio LosslesS
|
||||
#define MP4AOT_SLS 0x25 // Scalable LosslesS
|
||||
#define MP4AOT_SLS_NON_CORE 0x26 // Scalable LosslesS (non core)
|
||||
#define MP4AOT_ER_AAC_ELD 0x27 // Error Resilient Enhanced Low Delay
|
||||
#define MP4AOT_SMR_SIMPLE 0x28 // Symbolic Music Representation Simple
|
||||
#define MP4AOT_SMR_MAIN 0x29 // Symbolic Music Representation Main
|
||||
#define MP4AOT_USAC_NOSBR 0x2a // Unified Speech and Audio Coding (no SBR)
|
||||
#define MP4AOT_SAOC 0x2b // Spatial Audio Object Coding
|
||||
#define MP4AOT_LD_SURROUND 0x2c // Low Delay MPEG Surround
|
||||
#define MP4AOT_USAC 0x2d // Unified Speech and Audio Coding
|
||||
constexpr auto AUDIO_OBJECT_TYPE_AAC_MAIN = 0x01; // Main
|
||||
constexpr auto AUDIO_OBJECT_TYPE_AAC_LC = 0x02; // Low Complexity
|
||||
constexpr auto AUDIO_OBJECT_TYPE_AAC_SSR = 0x03; // Scalable Sample Rate
|
||||
constexpr auto AUDIO_OBJECT_TYPE_AAC_LTP = 0x04; // Long Term Prediction
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SBR = 0x05; // Spectral Band Replication
|
||||
constexpr auto AUDIO_OBJECT_TYPE_AAC_SCALABLE = 0x06; // Scalable
|
||||
constexpr auto AUDIO_OBJECT_TYPE_TWINVQ = 0x07; // TwinVQ Vector Quantizer
|
||||
constexpr auto AUDIO_OBJECT_TYPE_CELP = 0x08; // Code Excited Linear Prediction
|
||||
constexpr auto AUDIO_OBJECT_TYPE_HVXC = 0x09; // Harmonic Vector eXcitation Coding
|
||||
constexpr auto AUDIO_OBJECT_TYPE_TTSI = 0x0c; // Text-To-Speech Interface
|
||||
constexpr auto AUDIO_OBJECT_TYPE_MAINSYNTH = 0x0d; // Main Synthesis
|
||||
constexpr auto AUDIO_OBJECT_TYPE_WAVESYNTH = 0x0e; // Wavetable Synthesis
|
||||
constexpr auto AUDIO_OBJECT_TYPE_MIDI = 0x0f; // General MIDI
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SAFX = 0x10; // Algorithmic Synthesis and Audio Effects
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_AAC_LC = 0x11; // Error Resilient Low Complexity
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_AAC_LTP = 0x13; // Error Resilient Long Term Prediction
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE = 0x14; // Error Resilient Scalable
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_TWINVQ = 0x15; // Error Resilient Twin Vector Quantizer
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_BSAC = 0x16; // Error Resilient Bit-Sliced Arithmetic Coding
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_AAC_LD = 0x17; // Error Resilient Low Delay
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_CELP = 0x18; // Error Resilient Code Excited Linear Prediction
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_HVXC = 0x19; // Error Resilient Harmonic Vector eXcitation Coding
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_HILN = 0x1a; // Error Resilient Harmonic and Individual Lines plus Noise
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_PARAM = 0x1b; // Error Resilient Parametric
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SSC = 0x1c; // SinuSoidal Coding
|
||||
constexpr auto AUDIO_OBJECT_TYPE_PS = 0x1d; // Parametric Stereo
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SURROUND = 0x1e; // MPEG Surround
|
||||
constexpr auto AUDIO_OBJECT_TYPE_L1 = 0x20; // Layer 1
|
||||
constexpr auto AUDIO_OBJECT_TYPE_L2 = 0x21; // Layer 2
|
||||
constexpr auto AUDIO_OBJECT_TYPE_L3 = 0x22; // Layer 3
|
||||
constexpr auto AUDIO_OBJECT_TYPE_DST = 0x23; // Direct Stream Transfer
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ALS = 0x24; // Audio LosslesS
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SLS = 0x25; // Scalable LosslesS
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SLS_NON_CORE = 0x26; // Scalable LosslesS (non core)
|
||||
constexpr auto AUDIO_OBJECT_TYPE_ER_AAC_ELD = 0x27; // Error Resilient Enhanced Low Delay
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SMR_SIMPLE = 0x28; // Symbolic Music Representation Simple
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SMR_MAIN = 0x29; // Symbolic Music Representation Main
|
||||
constexpr auto AUDIO_OBJECT_TYPE_USAC_NOSBR = 0x2a; // Unified Speech and Audio Coding (no SBR)
|
||||
constexpr auto AUDIO_OBJECT_TYPE_SAOC = 0x2b; // Spatial Audio Object Coding
|
||||
constexpr auto AUDIO_OBJECT_TYPE_LD_SURROUND = 0x2c; // Low Delay MPEG Surround
|
||||
constexpr auto AUDIO_OBJECT_TYPE_USAC = 0x2d; // Unified Speech and Audio Coding
|
||||
|
||||
// Atom data types for free-form data
|
||||
#define MP4ADT_JPEG 0x0d // JPEG image
|
||||
#define MP4ADT_PNG 0x0e // PNG image
|
||||
#define MP4ADT_BMP 0x1b // BMP image
|
||||
constexpr auto ATOM_DATA_TYPE_JPEG = 0x0d; // JPEG image
|
||||
constexpr auto ATOM_DATA_TYPE_PNG = 0x0e; // PNG image
|
||||
constexpr auto ATOM_DATA_TYPE_BMP = 0x1b; // BMP image
|
||||
|
||||
// ESDS descriptor types (tags)
|
||||
constexpr auto DESCRIPTOR_TYPE_O = 0x01;
|
||||
constexpr auto DESCRIPTOR_TYPE_IO = 0x02;
|
||||
constexpr auto DESCRIPTOR_TYPE_ES = 0x03;
|
||||
constexpr auto DESCRIPTOR_TYPE_DEC_CONFIG = 0x04;
|
||||
constexpr auto DESCRIPTOR_TYPE_DEC_SPECIFIC = 0x05;
|
||||
constexpr auto DESCRIPTOR_TYPE_SL_CONFIG = 0x06;
|
||||
constexpr auto DESCRIPTOR_TYPE_CONTENT_ID = 0x07;
|
||||
constexpr auto DESCRIPTOR_TYPE_SUPPL_CONTENT_ID = 0x08;
|
||||
constexpr auto DESCRIPTOR_TYPE_IP_PTR = 0x09;
|
||||
constexpr auto DESCRIPTOR_TYPE_IPMP_PTR = 0x0A;
|
||||
constexpr auto DESCRIPTOR_TYPE_IPMP = 0x0B;
|
||||
constexpr auto DESCRIPTOR_TYPE_REGISTRATION = 0x0D;
|
||||
constexpr auto DESCRIPTOR_TYPE_ESID_INC = 0x0E;
|
||||
constexpr auto DESCRIPTOR_TYPE_ESID_REF = 0x0F;
|
||||
constexpr auto DESCRIPTOR_TYPE_FILE_IO = 0x10;
|
||||
constexpr auto DESCRIPTOR_TYPE_FILE_O = 0x11;
|
||||
constexpr auto DESCRIPTOR_TYPE_EXT_PROFILE_LEVEL = 0x13;
|
||||
constexpr auto DESCRIPTOR_TYPE_TAGS_START = 0x80;
|
||||
constexpr auto DESCRIPTOR_TYPE_TAGS_END = 0xFE;
|
||||
|
||||
} // namespace mtx::mp4
|
||||
|
@ -157,27 +157,6 @@ struct PACKED_STRUCTURE qt_image_description_t {
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
// one byte tag identifiers
|
||||
#define MP4DT_O 0x01
|
||||
#define MP4DT_IO 0x02
|
||||
#define MP4DT_ES 0x03
|
||||
#define MP4DT_DEC_CONFIG 0x04
|
||||
#define MP4DT_DEC_SPECIFIC 0x05
|
||||
#define MP4DT_SL_CONFIG 0x06
|
||||
#define MP4DT_CONTENT_ID 0x07
|
||||
#define MP4DT_SUPPL_CONTENT_ID 0x08
|
||||
#define MP4DT_IP_PTR 0x09
|
||||
#define MP4DT_IPMP_PTR 0x0A
|
||||
#define MP4DT_IPMP 0x0B
|
||||
#define MP4DT_REGISTRATION 0x0D
|
||||
#define MP4DT_ESID_INC 0x0E
|
||||
#define MP4DT_ESID_REF 0x0F
|
||||
#define MP4DT_FILE_IO 0x10
|
||||
#define MP4DT_FILE_O 0x11
|
||||
#define MP4DT_EXT_PROFILE_LEVEL 0x13
|
||||
#define MP4DT_TAGS_START 0x80
|
||||
#define MP4DT_TAGS_END 0xFE
|
||||
|
||||
// MPEG4 esds structure
|
||||
struct esds_t {
|
||||
uint8_t version{};
|
||||
|
@ -138,25 +138,25 @@ read_qtmp4_atom(mm_io_c *read_from,
|
||||
|
||||
static std::string
|
||||
displayable_esds_tag_name(uint8_t tag) {
|
||||
return MP4DT_O == tag ? "O"
|
||||
: MP4DT_IO == tag ? "IO"
|
||||
: MP4DT_ES == tag ? "ES"
|
||||
: MP4DT_DEC_CONFIG == tag ? "DEC_CONFIG"
|
||||
: MP4DT_DEC_SPECIFIC == tag ? "DEC_SPECIFIC"
|
||||
: MP4DT_SL_CONFIG == tag ? "SL_CONFIG"
|
||||
: MP4DT_CONTENT_ID == tag ? "CONTENT_ID"
|
||||
: MP4DT_SUPPL_CONTENT_ID == tag ? "SUPPL_CONTENT_ID"
|
||||
: MP4DT_IP_PTR == tag ? "IP_PTR"
|
||||
: MP4DT_IPMP_PTR == tag ? "IPMP_PTR"
|
||||
: MP4DT_IPMP == tag ? "IPMP"
|
||||
: MP4DT_REGISTRATION == tag ? "REGISTRATION"
|
||||
: MP4DT_ESID_INC == tag ? "ESID_INC"
|
||||
: MP4DT_ESID_REF == tag ? "ESID_REF"
|
||||
: MP4DT_FILE_IO == tag ? "FILE_IO"
|
||||
: MP4DT_FILE_O == tag ? "FILE_O"
|
||||
: MP4DT_EXT_PROFILE_LEVEL == tag ? "EXT_PROFILE_LEVEL"
|
||||
: MP4DT_TAGS_START == tag ? "TAGS_START"
|
||||
: MP4DT_TAGS_END == tag ? "TAGS_END"
|
||||
return mtx::mp4::DESCRIPTOR_TYPE_O == tag ? "O"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_IO == tag ? "IO"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_ES == tag ? "ES"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_DEC_CONFIG == tag ? "DEC_CONFIG"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_DEC_SPECIFIC == tag ? "DEC_SPECIFIC"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_SL_CONFIG == tag ? "SL_CONFIG"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_CONTENT_ID == tag ? "CONTENT_ID"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_SUPPL_CONTENT_ID == tag ? "SUPPL_CONTENT_ID"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_IP_PTR == tag ? "IP_PTR"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_IPMP_PTR == tag ? "IPMP_PTR"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_IPMP == tag ? "IPMP"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_REGISTRATION == tag ? "REGISTRATION"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_ESID_INC == tag ? "ESID_INC"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_ESID_REF == tag ? "ESID_REF"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_FILE_IO == tag ? "FILE_IO"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_FILE_O == tag ? "FILE_O"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_EXT_PROFILE_LEVEL == tag ? "EXT_PROFILE_LEVEL"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_TAGS_START == tag ? "TAGS_START"
|
||||
: mtx::mp4::DESCRIPTOR_TYPE_TAGS_END == tag ? "TAGS_END"
|
||||
: "unknown";
|
||||
}
|
||||
|
||||
@ -1072,7 +1072,7 @@ qtmp4_reader_c::handle_covr_atom(qt_atom_t parent,
|
||||
|
||||
try {
|
||||
auto type = m_in->read_uint32_be();
|
||||
if (!mtx::included_in<int>(type, MP4ADT_BMP, MP4ADT_JPEG, MP4ADT_PNG))
|
||||
if (!mtx::included_in<int>(type, mtx::mp4::ATOM_DATA_TYPE_BMP, mtx::mp4::ATOM_DATA_TYPE_JPEG, mtx::mp4::ATOM_DATA_TYPE_PNG))
|
||||
return;
|
||||
|
||||
m_in->skip(4);
|
||||
@ -1083,8 +1083,8 @@ qtmp4_reader_c::handle_covr_atom(qt_atom_t parent,
|
||||
|
||||
auto attachment = std::make_shared<attachment_t>();
|
||||
|
||||
attachment->name = fmt::format("cover.{}", type == MP4ADT_PNG ? "png" : type == MP4ADT_BMP ? "bmp" : "jpg");
|
||||
attachment->mime_type = fmt::format("image/{}", type == MP4ADT_PNG ? "png" : type == MP4ADT_BMP ? "bmp" : "jpeg");
|
||||
attachment->name = fmt::format("cover.{}", type == mtx::mp4::ATOM_DATA_TYPE_PNG ? "png" : type == mtx::mp4::ATOM_DATA_TYPE_BMP ? "bmp" : "jpg");
|
||||
attachment->mime_type = fmt::format("image/{}", type == mtx::mp4::ATOM_DATA_TYPE_PNG ? "png" : type == mtx::mp4::ATOM_DATA_TYPE_BMP ? "bmp" : "jpeg");
|
||||
attachment->data = m_in->read(data_size);
|
||||
attachment->ui_id = m_attachment_id++;
|
||||
attachment->to_all_files = ATTACH_MODE_TO_ALL_FILES == attach_mode;
|
||||
@ -1721,9 +1721,9 @@ qtmp4_reader_c::create_video_packetizer_mpeg4_p2(qtmp4_demuxer_c &dmx) {
|
||||
|
||||
void
|
||||
qtmp4_reader_c::create_video_packetizer_mpeg1_2(qtmp4_demuxer_c &dmx) {
|
||||
int version = !dmx.esds_parsed ? (dmx.fourcc.value() & 0xff) - '0'
|
||||
: dmx.esds.object_type_id == MP4OTI_MPEG1Visual ? 1
|
||||
: 2;
|
||||
int version = !dmx.esds_parsed ? (dmx.fourcc.value() & 0xff) - '0'
|
||||
: dmx.esds.object_type_id == mtx::mp4::OBJECT_TYPE_MPEG1Visual ? 1
|
||||
: 2;
|
||||
dmx.ptzr = add_packetizer(new mpeg1_2_video_packetizer_c(this, m_ti, version, -1.0, dmx.v_width, dmx.v_height, 0, 0, false));
|
||||
|
||||
show_packetizer_info(dmx.id, PTZR(dmx.ptzr));
|
||||
@ -3173,7 +3173,7 @@ qtmp4_demuxer_c::parse_esds_atom(mm_io_c &io,
|
||||
|
||||
mxdebug_if(m_debug_headers, fmt::format("{0}esds: version: {1}, flags: {2}\n", space(lsp + 1), static_cast<unsigned int>(esds.version), esds.flags));
|
||||
|
||||
if (MP4DT_ES == tag) {
|
||||
if (mtx::mp4::DESCRIPTOR_TYPE_ES == tag) {
|
||||
auto len = io.read_mp4_descriptor_len();
|
||||
esds.esid = io.read_uint16_be();
|
||||
esds.stream_priority = io.read_uint8();
|
||||
@ -3187,7 +3187,7 @@ qtmp4_demuxer_c::parse_esds_atom(mm_io_c &io,
|
||||
tag = io.read_uint8();
|
||||
mxdebug_if(m_debug_headers, fmt::format("{0}tag is 0x{1:02x} ({2}).\n", space(lsp + 1), static_cast<unsigned int>(tag), displayable_esds_tag_name(tag)));
|
||||
|
||||
if (MP4DT_DEC_CONFIG != tag)
|
||||
if (mtx::mp4::DESCRIPTOR_TYPE_DEC_CONFIG != tag)
|
||||
return false;
|
||||
|
||||
auto len = io.read_mp4_descriptor_len();
|
||||
@ -3213,7 +3213,7 @@ qtmp4_demuxer_c::parse_esds_atom(mm_io_c &io,
|
||||
tag = io.read_uint8();
|
||||
mxdebug_if(m_debug_headers, fmt::format("{0}tag is 0x{1:02x} ({2}).\n", space(lsp + 1), static_cast<unsigned int>(tag), displayable_esds_tag_name(tag)));
|
||||
|
||||
if (MP4DT_DEC_SPECIFIC == tag) {
|
||||
if (mtx::mp4::DESCRIPTOR_TYPE_DEC_SPECIFIC == tag) {
|
||||
len = io.read_mp4_descriptor_len();
|
||||
if (!len)
|
||||
throw mtx::input::header_parsing_x();
|
||||
@ -3235,7 +3235,7 @@ qtmp4_demuxer_c::parse_esds_atom(mm_io_c &io,
|
||||
|
||||
}
|
||||
|
||||
if (MP4DT_SL_CONFIG == tag) {
|
||||
if (mtx::mp4::DESCRIPTOR_TYPE_SL_CONFIG == tag) {
|
||||
len = io.read_mp4_descriptor_len();
|
||||
if (!len)
|
||||
throw mtx::input::header_parsing_x{};
|
||||
|
@ -216,26 +216,26 @@ TEST(Codec, LookUpFourCC) {
|
||||
}
|
||||
|
||||
TEST(Codec, LookUpObjectTypeId) {
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2AudioMain).is(codec_c::type_e::A_AAC));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2AudioLowComplexity).is(codec_c::type_e::A_AAC));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2AudioScaleableSamplingRate).is(codec_c::type_e::A_AAC));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2AudioPart3).is(codec_c::type_e::A_MP3));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2AudioMain).is(codec_c::type_e::A_AAC));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2AudioLowComplexity).is(codec_c::type_e::A_AAC));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2AudioScaleableSamplingRate).is(codec_c::type_e::A_AAC));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2AudioPart3).is(codec_c::type_e::A_MP3));
|
||||
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG1Audio).is(codec_c::type_e::A_MP2));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG1Audio).is(codec_c::type_e::A_MP2));
|
||||
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_DTS).is(codec_c::type_e::A_DTS));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_DTS).is(codec_c::type_e::A_DTS));
|
||||
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG4Visual).is(codec_c::type_e::V_MPEG4_P2));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG4Visual).is(codec_c::type_e::V_MPEG4_P2));
|
||||
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2VisualSimple).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2VisualMain).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2VisualSNR).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2VisualSpatial).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2VisualHigh).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG2Visual422).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_MPEG1Visual).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2VisualSimple).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2VisualMain).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2VisualSNR).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2VisualSpatial).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2VisualHigh).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG2Visual422).is(codec_c::type_e::V_MPEG12));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_MPEG1Visual).is(codec_c::type_e::V_MPEG12));
|
||||
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(MP4OTI_VOBSUB).is(codec_c::type_e::S_VOBSUB));
|
||||
EXPECT_TRUE(codec_c::look_up_object_type_id(mtx::mp4::OBJECT_TYPE_VOBSUB).is(codec_c::type_e::S_VOBSUB));
|
||||
}
|
||||
|
||||
TEST(Codec, LookUpOverloading) {
|
||||
|
Loading…
Reference in New Issue
Block a user