Skip to content

Commit

Permalink
Cleanup of raw audio support - cf #2470
Browse files Browse the repository at this point in the history
- added big-endian formats for s24, s32, flt and dbl
- completed endianness support in mixer
- added qt v7 lpcm support
- added big-endian support for ipcm and fpcm (mp4 raw pcm)
- added missing wave and enda boxes for qtv1 pcm
- MP4Box -info now shows correct info for all pcm muxing types
  • Loading branch information
jeanlf committed May 22, 2023
1 parent 834435a commit 1e5ad5b
Show file tree
Hide file tree
Showing 18 changed files with 567 additions and 133 deletions.
16 changes: 15 additions & 1 deletion applications/mp4box/filedump.c
Expand Up @@ -3501,14 +3501,28 @@ static void DumpStsdInfo(GF_ISOFile *file, u32 trackNum, Bool full_dump, Bool du
fprintf(stderr, "\tInvalid TrueHD audio config\n");
}
fprintf(stderr, "\tTrueHD Audio stream - Sample Rate %u - channels %u - format %u peak rate %u\n", sr, nb_ch, fmt, prate);
} else if (msub_type==GF_QT_SUBTYPE_LPCM) {
Double pcm_sr;
u32 pcm_flags, pcm_size;
if (gf_isom_get_lpcm_config(file, trackNum, stsd_idx, &pcm_sr, &nb_ch, &pcm_flags, &pcm_size) == GF_OK) {
fprintf(stderr, "\tPCM Audio - Sample Rate %f channels %u %u-bits %s %s-endian\n", pcm_sr, nb_ch, pcm_size, (pcm_flags & 1) ? "float" : "int", (pcm_flags & (1<<1)) ? "big" : "little");
} else {
fprintf(stderr, "\tInvalid LPCM audio config\n");
}
} else if (codecid) {
if (gf_isom_is_video_handler_type(mtype) ) {
u32 w, h;
gf_isom_get_visual_info(file, trackNum, stsd_idx, &w, &h);
fprintf(stderr, "\t%s - Resolution %d x %d\n", gf_codecid_name(codecid), w, h);
} else if (mtype==GF_ISOM_MEDIA_AUDIO) {
u32 size, flags;
gf_isom_get_audio_info(file, trackNum, stsd_idx, &sr, &nb_ch, NULL);
fprintf(stderr, "\t%s - Sample Rate %d - %d channel(s)\n", gf_codecid_name(codecid), sr, nb_ch);
if (gf_isom_get_pcm_config(file, trackNum, stsd_idx, &flags, &size)==GF_OK) {
fprintf(stderr, "\tPCM Audio Sample Rate %d %d channel(s) %u-bits %s-endian", sr, nb_ch, size, (flags&1) ? "little" : "big");
} else {
fprintf(stderr, "\t%s - Sample Rate %d - %d channel(s)", gf_codecid_name(codecid), sr, nb_ch);
}
fprintf(stderr, "\n");
} else {
fprintf(stderr, "\t%s\n", gf_codecid_name(codecid) );
}
Expand Down
8 changes: 8 additions & 0 deletions include/gpac/constants.h
Expand Up @@ -837,12 +837,20 @@ typedef enum
GF_AUDIO_FMT_S16_BE,
/*! sample = signed integer, interleaved channels*/
GF_AUDIO_FMT_S32,
/*! sample = signed integer big-endian, interleaved channels*/
GF_AUDIO_FMT_S32_BE,
/*! sample = 1 float, interleaved channels*/
GF_AUDIO_FMT_FLT,
/*! sample = 1 float bytes in big endian, interleaved channels*/
GF_AUDIO_FMT_FLT_BE,
/*! sample = 1 double, interleaved channels*/
GF_AUDIO_FMT_DBL,
/*! sample = 1 double bytes in big-endian order, interleaved channels*/
GF_AUDIO_FMT_DBL_BE,
/*! sample = signed integer, interleaved channels*/
GF_AUDIO_FMT_S24,
/*! sample = signed integer gig-endian, interleaved channels*/
GF_AUDIO_FMT_S24_BE,
/*! not a format, indicates the value of last packed format*/
GF_AUDIO_FMT_LAST_PACKED,
/*! sample = unsigned byte, planar channels*/
Expand Down
18 changes: 16 additions & 2 deletions include/gpac/isomedia.h
Expand Up @@ -362,6 +362,7 @@ enum
GF_QT_SUBTYPE_RGBA = GF_4CC('R','G','B','A'),
GF_QT_SUBTYPE_ABGR = GF_4CC('A','B','G','R'),
GF_QT_SUBTYPE_ALAC = GF_4CC('a','l','a','c'),
GF_QT_SUBTYPE_LPCM = GF_4CC('l','p','c','m'),
GF_ISOM_SUBTYPE_FFV1 = GF_4CC( 'F', 'F', 'V', '1' ),

GF_ISOM_ITEM_TYPE_AUXI = GF_4CC('a', 'u', 'x', 'i'),
Expand Down Expand Up @@ -3116,6 +3117,8 @@ typedef struct
u16 bits_per_sample;
/*! indicates if QTFF signaling should be used, audio codecs only*/
Bool is_qtff;
/*! for lpcm only, indicates format flags*/
u32 lpcm_flags;

/*optional, sample description specific configuration*/
u8 *extension_buf;
Expand Down Expand Up @@ -3913,12 +3916,23 @@ GF_Err gf_isom_get_tmcd_config(GF_ISOFile *isom_file, u32 trackNumber, u32 sampl
\param isom_file the target ISO file
\param trackNumber the target track
\param sampleDescriptionIndex the target sample description index
\param flags set to the pcm config flags (0: big endian, 1: little endian)
\param pcm_size set to PCM sample size (per channel, 16, 24, 32, 64
\param flags set to the pcm config flags (0: big endian, 1: little endian), may be NULL
\param pcm_size set to PCM sample size (per channel, 16, 24, 32, 64, may be NULL
\return error if any
*/
GF_Err gf_isom_get_pcm_config(GF_ISOFile *isom_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *flags, u32 *pcm_size);

/*! gets information of a raw PCM sample description, QT style (lpcm codecid)
\param isom_file the target ISO file
\param trackNumber the target track
\param sampleDescriptionIndex the target sample description index
\param sample_rate set to the pcm sample rate, may be NULL
\param nb_channels set to the pcm channel count, may be NULL
\param flags set to the pcm config flags (1: float, 2: big endian, 4: signed, other flags cf QTFF), may be NULL
\param pcm_size set to PCM sample size (per channel, 16, 24, 32, 64, may be NULL
\return error if any
*/
GF_Err gf_isom_get_lpcm_config(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, Double *sample_rate, u32 *nb_channels, u32 *flags, u32 *pcm_size);


#ifndef GPAC_DISABLE_ISOM_WRITE
Expand Down

0 comments on commit 1e5ad5b

Please sign in to comment.