From c9f23c7c737251ceb6f278fd3d3d016d754bf497 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 21 Oct 2021 19:09:59 +0200 Subject: [PATCH] mp4: Wire it in and make it compile cleanly. This switches to our local copy of libmp4ff. The configure script now turns on support for the aac audio format even if libmp4ff is not installed. Some changes to mp4.c were necessary to silence warnings, most of which are trivial. The single notably non-trivial change is the missing initialization of chunk_sample and chunk in mp4ff_chunk_of_sample(). --- aac_afh.c | 6 +----- configure.ac | 12 +++++------- mp4.c | 25 ++++++++++++------------- mp4.h | 2 +- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/aac_afh.c b/aac_afh.c index 5c1225b6..d8ad48a1 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -10,11 +10,7 @@ #include #include "para.h" - -/* To get the mp4ff_tag_t and mp4ff_metadata_t typedefs. */ -#define USE_TAGGING -#include - +#include "mp4.h" #include "error.h" #include "portable_io.h" #include "afh.h" diff --git a/configure.ac b/configure.ac index b817979f..9056002a 100644 --- a/configure.ac +++ b/configure.ac @@ -291,12 +291,10 @@ AC_DEFUN([NEED_FLAC_OBJECTS], [{ }]) ########################################################################### faad STASH_FLAGS -LIB_ARG_WITH([faad], [-lfaad -lmp4ff]) +LIB_ARG_WITH([faad], [-lfaad]) HAVE_FAAD=yes AC_CHECK_HEADER(neaacdec.h, [], HAVE_FAAD=no) -AC_CHECK_HEADER(mp4ff.h, [], HAVE_FAAD=no) AC_CHECK_LIB([faad], [NeAACDecOpen], [], HAVE_FAAD=no) -AC_CHECK_LIB([mp4ff], [mp4ff_meta_get_artist], [], HAVE_FAAD=no) LIB_SUBST_FLAGS(faad) UNSTASH_FLAGS ########################################################################### mad @@ -434,7 +432,7 @@ if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes && test -n "$BISON" && \ NEED_OPUS_OBJECTS() && server_errlist_objs="$server_errlist_objs opus_afh opus_common" NEED_FLAC_OBJECTS && server_errlist_objs="$server_errlist_objs flac_afh" if test $HAVE_FAAD = yes; then - server_errlist_objs="$server_errlist_objs aac_afh" + server_errlist_objs="$server_errlist_objs aac_afh mp4" fi server_objs="$server_errlist_objs" AC_SUBST(server_objs, add_dot_o($server_objs)) @@ -693,7 +691,7 @@ NEED_OPUS_OBJECTS && recv_errlist_objs="$recv_errlist_objs opus_afh opus_common" NEED_FLAC_OBJECTS && recv_errlist_objs="$recv_errlist_objs flac_afh" if test $HAVE_FAAD = yes; then - recv_errlist_objs="$recv_errlist_objs aac_afh" + recv_errlist_objs="$recv_errlist_objs aac_afh mp4" fi recv_objs="$recv_errlist_objs" AC_SUBST(recv_objs, add_dot_o($recv_objs)) @@ -728,7 +726,7 @@ NEED_FLAC_OBJECTS && { audio_format_handlers="$audio_format_handlers flac" } if test $HAVE_FAAD = yes; then - afh_errlist_objs="$afh_errlist_objs aac_afh" + afh_errlist_objs="$afh_errlist_objs aac_afh mp4" audio_format_handlers="$audio_format_handlers aac" fi @@ -786,7 +784,7 @@ NEED_FLAC_OBJECTS && { play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh" } if test $HAVE_FAAD = yes; then - play_errlist_objs="$play_errlist_objs aac_afh aacdec_filter" + play_errlist_objs="$play_errlist_objs aac_afh aacdec_filter mp4" fi if test $HAVE_MAD = yes; then play_errlist_objs="$play_errlist_objs mp3dec_filter" diff --git a/mp4.c b/mp4.c index d04137a9..58838d55 100644 --- a/mp4.c +++ b/mp4.c @@ -14,7 +14,7 @@ int32_t mp4ff_total_tracks(const mp4ff_t * f) return f->total_tracks; } -int32_t mp4ff_read_data(mp4ff_t * f, int8_t * data, uint32_t size) +int32_t mp4ff_read_data(mp4ff_t * f, void *data, uint32_t size) { int32_t result = 1; @@ -724,7 +724,6 @@ static int32_t mp4ff_read_esds(mp4ff_t * f) } static int32_t mp4ff_read_mp4a(mp4ff_t * f) { - uint64_t size; int32_t i; uint8_t atom_type = 0; uint8_t header_size = 0; @@ -750,7 +749,7 @@ static int32_t mp4ff_read_mp4a(mp4ff_t * f) mp4ff_read_int16(f); - size = mp4ff_atom_read_header(f, &atom_type, &header_size); + mp4ff_atom_read_header(f, &atom_type, &header_size); if (atom_type == ATOM_ESDS) { mp4ff_read_esds(f); } @@ -828,7 +827,7 @@ static int32_t mp4ff_read_mvhd(mp4ff_t * f) } static int32_t mp4ff_tag_add_field(mp4ff_metadata_t * tags, const char *item, - char *value, int32_t len) + const char *value, int32_t len) { void *backup = (void *) tags->tags; @@ -924,8 +923,7 @@ char *mp4ff_read_string(mp4ff_t * f, uint32_t length) return str; } -static int32_t mp4ff_set_metadata_name(mp4ff_t * f, const uint8_t atom_type, - char **name) +static int32_t mp4ff_set_metadata_name(const uint8_t atom_type, char **name) { static char *tag_names[] = { "unknown", "title", "artist", "writer", "album", @@ -1132,8 +1130,7 @@ static int32_t mp4ff_parse_tag(mp4ff_t * f, const uint8_t parent_atom_type, if (data) { if (!done) { if (name == NULL) - mp4ff_set_metadata_name(f, parent_atom_type, - &name); + mp4ff_set_metadata_name(parent_atom_type, &name); if (name) mp4ff_tag_add_field(&(f->tags), name, data, len); } @@ -1331,13 +1328,13 @@ int32_t parse_atoms(mp4ff_t * f, int meta_only) return 0; } -int32_t mp4ff_get_decoder_config(const mp4ff_t * f, const int track, +void mp4ff_get_decoder_config(const mp4ff_t * f, const int track, unsigned char **ppBuf, unsigned int *pBufSize) { if (track >= f->total_tracks) { *ppBuf = NULL; *pBufSize = 0; - return 1; + return; } if (f->track[track]->decoderConfig == NULL @@ -1348,7 +1345,7 @@ int32_t mp4ff_get_decoder_config(const mp4ff_t * f, const int track, *ppBuf = malloc(f->track[track]->decoderConfigLen); if (*ppBuf == NULL) { *pBufSize = 0; - return 1; + return; } memcpy(*ppBuf, f->track[track]->decoderConfig, f->track[track]->decoderConfigLen); @@ -1443,6 +1440,8 @@ static int32_t mp4ff_chunk_of_sample(const mp4ff_t * f, const int32_t track, int32_t chunk2entry; int32_t chunk1, chunk2, chunk1samples, range_samples, total = 0; + *chunk_sample = 0; + *chunk = 1; if (f->track[track] == NULL) { return -1; } @@ -1695,7 +1694,7 @@ typedef struct { #define stricmp strcasecmp -membuffer *membuffer_create() +membuffer *membuffer_create(void) { const unsigned initial_size = 256; @@ -2239,7 +2238,7 @@ static uint32_t modify_moov(mp4ff_t * f, const mp4ff_metadata_t * data, return 1; } -int32_t mp4ff_write_data(mp4ff_t * f, int8_t * data, uint32_t size) +int32_t mp4ff_write_data(mp4ff_t * f, void *data, uint32_t size) { int32_t result = 1; diff --git a/mp4.h b/mp4.h index cf8519da..92c995c1 100644 --- a/mp4.h +++ b/mp4.h @@ -100,7 +100,7 @@ typedef struct } mp4ff_t; int32_t mp4ff_total_tracks(const mp4ff_t *f); -int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int track, +void mp4ff_get_decoder_config(const mp4ff_t *f, const int track, unsigned char** ppBuf, unsigned int* pBufSize); mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f); void mp4ff_close(mp4ff_t *f); -- 2.39.5