From: Marius Gavrilescu Date: Thu, 8 Dec 2016 16:34:05 +0000 (+0200) Subject: Imported Upstream version 0.6.3 X-Git-Tag: upstream/0.6.3^0 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;ds=sidebyside;h=9b7e1ca68c3a594f6657ad1d3d151cd74b3e0228;hp=f75c9c7b3e90df13b91f3de94c6374c58e4c3d52;p=fdkaac.git Imported Upstream version 0.6.3 --- diff --git a/ChangeLog b/ChangeLog index 771eb87..4455a7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,18 @@ -2014-09-13 nu774 +2015-02-14 nu774 * update ChangeLog [HEAD] - * bump version [v0.6.1] + * bump version [v0.6.2] + + * take stco->co64 switch due to mdat relocation into account on finalizing m4a + + * fix incorrect iTunSMPB written when interrupted by signals + +2014-09-13 nu774 + + * update ChangeLog [origin/master] + + * bump version 2014-09-12 nu774 @@ -10,7 +20,7 @@ 2014-08-17 nu774 - * update INSTALL [origin/master] + * update INSTALL * add m4 macros diff --git a/MSVC/fdk-aac.vcxproj b/MSVC/fdk-aac.vcxproj index 9bf4fe6..2035c14 100644 --- a/MSVC/fdk-aac.vcxproj +++ b/MSVC/fdk-aac.vcxproj @@ -5,75 +5,69 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {D7D4B982-8B16-4A10-8B1C-9527BD789709} Win32Proj - fdkaac + fdk-aac + + + v140_xp + v120_xp + v110_xp + v100 - + StaticLibrary - true Unicode - - StaticLibrary + + true + + false - true - Unicode - - - - - - + - - $(Configuration)Lib\ - - - $(Configuration)Lib\ - - + NotUsing Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_LIB;%(PreprocessorDefinitions) ../fdk-aac/libaacenc/include;../fdk-aac/libFDK/include;../fdk-aac/libMpegTPEnc/include;../fdk-aac/libPCMutils/include;../fdk-aac/libSBRenc/include;../fdk-aac/libSYS/include - true - - Windows - true - - + + + Disabled + + + - Level3 - NotUsing MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - ../fdk-aac/libaacenc/include;../fdk-aac/libFDK/include;../fdk-aac/libMpegTPEnc/include;../fdk-aac/libPCMutils/include;../fdk-aac/libSBRenc/include;../fdk-aac/libSYS/include - true + /Qvec-report:1 %(AdditionalOptions) + + + + + __x86_64__;%(PreprocessorDefinitions) - - Windows - true - true - true - diff --git a/MSVC/fdkaac.sln b/MSVC/fdkaac.sln index 5507930..5a4c448 100644 --- a/MSVC/fdkaac.sln +++ b/MSVC/fdkaac.sln @@ -8,17 +8,27 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|Win32.ActiveCfg = Debug|Win32 {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|Win32.Build.0 = Debug|Win32 + {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|x64.ActiveCfg = Debug|x64 + {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|x64.Build.0 = Debug|x64 {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|Win32.ActiveCfg = Release|Win32 {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|Win32.Build.0 = Release|Win32 + {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|x64.ActiveCfg = Release|x64 + {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|x64.Build.0 = Release|x64 {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|Win32.ActiveCfg = Debug|Win32 {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|Win32.Build.0 = Debug|Win32 + {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|x64.ActiveCfg = Debug|x64 + {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|x64.Build.0 = Debug|x64 {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|Win32.ActiveCfg = Release|Win32 {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|Win32.Build.0 = Release|Win32 + {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|x64.ActiveCfg = Release|x64 + {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MSVC/fdkaac.vcxproj b/MSVC/fdkaac.vcxproj index 229e8ad..0a59d91 100644 --- a/MSVC/fdkaac.vcxproj +++ b/MSVC/fdkaac.vcxproj @@ -5,55 +5,50 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA} Win32Proj fdkaac + + v140_xp + v120_xp + v110_xp + v100 + - + Application - true Unicode - - Application + + true + + false - true - Unicode - - - - - - + - - - true - cli_$(Configuration)\ - - - false - $(Configuration)Cli\ - - + - - Level3 - Disabled - HAVE_STDINT_H;inline=__inline;_CRT_SECURE_NO_WARNINGS;WIN32;_CONSOLE;_DEBUG;%(PreprocessorDefinitions) + HAVE_STDINT_H;inline=__inline;_CRT_SECURE_NO_WARNINGS;WIN32;_CONSOLE;%(PreprocessorDefinitions) ./include;../missings;.;.. - true Console @@ -67,31 +62,19 @@ copy ..\fdk-aac\libSYS\include\genericStds.h include\fdk-aac\ copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ - + + + Disabled + + + - Level3 - - MaxSpeed - true - true - HAVE_STDINT_H;inline=__inline;_CRT_SECURE_NO_WARNINGS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions) - ./include;../missings;.;.. - true - Console - true true true - - copy ..\fdk-aac\libAACdec\include\aacdecoder_lib.h include\fdk-aac\ -copy ..\fdk-aac\libAACenc\include\aacenc_lib.h include\fdk-aac\ -copy ..\fdk-aac\libSYS\include\FDK_Audio.h include\fdk-aac\ -copy ..\fdk-aac\libSYS\include\genericStds.h include\fdk-aac\ -copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ - diff --git a/README b/README index fba5b64..f11010d 100644 --- a/README +++ b/README @@ -52,15 +52,6 @@ OPTIONS 39 : MPEG-4 AAC ELD - 129 - : MPEG-2 AAC LC - - 132 - : MPEG-2 HE-AAC (SBR) - - 156 - : MPEG-2 HE-AAC v2 (SBR+PS) - -b, --bitrate \ : Target bitrate (for CBR) diff --git a/man/fdkaac.1 b/man/fdkaac.1 index 922641e..39987a6 100644 --- a/man/fdkaac.1 +++ b/man/fdkaac.1 @@ -1,10 +1,13 @@ -.TH FDKAAC 1 "November, 2013" +.\" Automatically generated by Pandoc 1.17.1 +.\" +.TH "FDKAAC" "1" "November, 2013" "" "" +.hy .SH NAME .PP fdkaac \- command line frontend for libfdk\-aac encoder .SH SYNOPSIS .PP -\f[B]fdkaac\f[] [OPTIONS][FILE] +\f[B]fdkaac\f[] [OPTIONS] [FILE] .SH DESCRIPTION .PP \f[B]fdkaac\f[] reads linear PCM audio in either WAV, raw PCM, or CAF @@ -56,21 +59,6 @@ MPEG\-4 AAC LD MPEG\-4 AAC ELD .RS .RE -.TP -.B 129 -MPEG\-2 AAC LC -.RS -.RE -.TP -.B 132 -MPEG\-2 HE\-AAC (SBR) -.RS -.RE -.TP -.B 156 -MPEG\-2 HE\-AAC v2 (SBR+PS) -.RS -.RE .RE .TP .B \-b, \-\-bitrate diff --git a/src/aacenc.c b/src/aacenc.c index a6984fe..0dd47bb 100644 --- a/src/aacenc.c +++ b/src/aacenc.c @@ -13,6 +13,13 @@ #include #include "aacenc.h" +int aacenc_is_explicit_bw_compatible_sbr_signaling_available() +{ + LIB_INFO lib_info; + aacenc_get_lib_info(&lib_info); + return lib_info.version > 0x03040900; +} + int aacenc_is_sbr_ratio_available() { #if AACENCODER_LIB_VL0 < 3 || (AACENCODER_LIB_VL0==3 && AACENCODER_LIB_VL1<4) @@ -20,15 +27,14 @@ int aacenc_is_sbr_ratio_available() #else LIB_INFO lib_info; aacenc_get_lib_info(&lib_info); - return lib_info.version > 0x03040000; + return lib_info.version > 0x03040800; #endif } int aacenc_is_sbr_active(const aacenc_param_t *params) { switch (params->profile) { - case AOT_SBR: case AOT_PS: case AOT_MP2_SBR: case AOT_MP2_PS: - case AOT_DABPLUS_SBR: case AOT_DABPLUS_PS: + case AOT_SBR: case AOT_PS: case AOT_DRM_SBR: case AOT_DRM_MPEG_PS: return 1; } @@ -39,9 +45,9 @@ int aacenc_is_sbr_active(const aacenc_param_t *params) int aacenc_is_dual_rate_sbr(const aacenc_param_t *params) { - if (params->profile == AOT_PS || params->profile == AOT_MP2_PS) + if (params->profile == AOT_PS) return 1; - else if (params->profile == AOT_SBR || params->profile == AOT_MP2_SBR) + else if (params->profile == AOT_SBR) return params->sbr_ratio == 0 || params->sbr_ratio == 2; else if (params->profile == AOT_ER_AAC_ELD && params->lowdelay_sbr) return params->sbr_ratio == 2; @@ -64,6 +70,70 @@ void aacenc_get_lib_info(LIB_INFO *info) free(lib_info); } +static const unsigned aacenc_sampling_freq_tab[] = { + 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, + 16000, 12000, 11025, 8000, 7350, 0, 0, 0 +}; + +static +unsigned sampling_freq_index(unsigned rate) +{ + unsigned i; + for (i = 0; aacenc_sampling_freq_tab[i]; ++i) + if (aacenc_sampling_freq_tab[i] == rate) + return i; + return 0xf; +} + +/* + * Append backward compatible SBR/PS signaling to implicit signaling ASC, + * if SBR/PS is present. + */ +int aacenc_mp4asc(const aacenc_param_t *params, + const uint8_t *asc, uint32_t ascsize, + uint8_t *outasc, uint32_t *outsize) +{ + unsigned asc_sfreq = aacenc_sampling_freq_tab[(asc[0]&0x7)<<1 |asc[1]>>7]; + unsigned shift = aacenc_is_dual_rate_sbr(params); + + switch (params->profile) { + case AOT_SBR: + case AOT_PS: + if (!shift) + break; + if (*outsize < ascsize + 3) + return -1; + memcpy(outasc, asc, ascsize); + /* syncExtensionType:11 (value:0x2b7) */ + outasc[ascsize+0] = 0x2b << 1; + outasc[ascsize+1] = 0x7 << 5; + /* extensionAudioObjectType:5 (value:5)*/ + outasc[ascsize+1] |= 5; + /* sbrPresentFlag:1 (value:1) */ + outasc[ascsize+2] = 0x80; + /* extensionSamplingFrequencyIndex:4 */ + outasc[ascsize+2] |= sampling_freq_index(asc_sfreq << shift) << 3; + if (params->profile == AOT_SBR) { + *outsize = ascsize + 3; + return 0; + } + if (*outsize < ascsize + 5) + return -1; + /* syncExtensionType:11 (value:0x548) */ + outasc[ascsize+2] |= 0x5; + outasc[ascsize+3] = 0x48; + /* psPresentFlag:1 (value:1) */ + outasc[ascsize+4] = 0x80; + *outsize = ascsize + 5; + return 0; + } + if (*outsize < ascsize) + return -1; + memcpy(outasc, asc, ascsize); + *outsize = ascsize; + return 0; +} + static int aacenc_channel_mode(const pcm_sample_description_t *format) { @@ -140,7 +210,7 @@ int aacenc_init(HANDLE_AACENCODER *encoder, const aacenc_param_t *params, aacEncoder_SetParam(*encoder, AACENC_SBR_MODE, params->lowdelay_sbr); #if AACENCODER_LIB_VL0 > 3 || (AACENCODER_LIB_VL0==3 && AACENCODER_LIB_VL1>=4) - if (lib_info.version > 0x03040000) + if (lib_info.version > 0x03040800) aacEncoder_SetParam(*encoder, AACENC_SBR_RATIO, params->sbr_ratio); #endif diff --git a/src/aacenc.h b/src/aacenc.h index ec0bea1..2b7d102 100644 --- a/src/aacenc.h +++ b/src/aacenc.h @@ -30,6 +30,8 @@ typedef struct aacenc_frame_t { uint32_t size, capacity; } aacenc_frame_t; +int aacenc_is_explicit_bw_compatible_sbr_signaling_available(); + int aacenc_is_sbr_ratio_available(); int aacenc_is_sbr_active(const aacenc_param_t *params); @@ -38,6 +40,10 @@ int aacenc_is_dual_rate_sbr(const aacenc_param_t *params); void aacenc_get_lib_info(LIB_INFO *info); +int aacenc_mp4asc(const aacenc_param_t *params, + const uint8_t *asc, uint32_t ascsize, + uint8_t *outasc, uint32_t *outsize); + int aacenc_init(HANDLE_AACENCODER *encoder, const aacenc_param_t *params, const pcm_sample_description_t *format, AACENC_InfoStruct *info); diff --git a/src/compat.h b/src/compat.h index 4f651ab..cc7dcef 100644 --- a/src/compat.h +++ b/src/compat.h @@ -20,9 +20,18 @@ int64_t aacenc_timer(void); FILE *aacenc_fopen(const char *name, const char *mode); +#ifdef _WIN32 void aacenc_getmainargs(int *argc, char ***argv); +#else +#define aacenc_getmainargs(argc, argv) (void)0 +#endif char *aacenc_to_utf8(const char *s); +#ifdef _WIN32 int aacenc_fprintf(FILE *fp, const char *fmt, ...); +#else +#define aacenc_fprintf fprintf +#endif const char *aacenc_basename(const char *path); +int aacenc_seekable(FILE *fp); #endif diff --git a/src/compat_posix.c b/src/compat_posix.c index e101ff7..f895637 100644 --- a/src/compat_posix.c +++ b/src/compat_posix.c @@ -32,20 +32,9 @@ FILE *aacenc_fopen(const char *name, const char *mode) return fp; } -void aacenc_getmainargs(int *argc, char ***argv) +int aacenc_seekable(FILE *fp) { - return; -} - -int aacenc_fprintf(FILE *fp, const char *fmt, ...) -{ - va_list ap; - int cnt; - - va_start(ap, fmt); - cnt = vfprintf(fp, fmt, ap); - va_end(ap); - return cnt; + return fseek(fp, 0, SEEK_CUR) == 0; } /* diff --git a/src/compat_win32.c b/src/compat_win32.c index 4482281..8acbda2 100644 --- a/src/compat_win32.c +++ b/src/compat_win32.c @@ -20,14 +20,7 @@ #include "compat.h" #define WIN32_LEAN_AND_MEAN #include - -typedef struct -{ - int newmode; -} _startupinfo; - -extern -int __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, _startupinfo *); +#include int64_t aacenc_timer(void) { @@ -41,6 +34,11 @@ int64_t aacenc_timer(void) return (int64_t)tv.time * 1000 + tv.millitm; } +int aacenc_seekable(FILE *fp) +{ + return GetFileType((HANDLE)_get_osfhandle(_fileno(fp))) == FILE_TYPE_DISK; +} + static int codepage_decode_wchar(int codepage, const char *from, wchar_t **to) { @@ -98,13 +96,13 @@ void aacenc_free_mainargs(void) void aacenc_getmainargs(int *argc, char ***argv) { int i; - wchar_t **wargv, **envp; - _startupinfo si = { 0 }; + wchar_t **wargv; - __wgetmainargs(argc, &wargv, &envp, 1, &si); + wargv = CommandLineToArgvW(GetCommandLineW(), argc); *argv = malloc((*argc + 1) * sizeof(char*)); for (i = 0; i < *argc; ++i) codepage_encode_wchar(CP_UTF8, wargv[i], &(*argv)[i]); + LocalFree(wargv); (*argv)[*argc] = 0; __aacenc_argv__ = *argv; atexit(aacenc_free_mainargs); diff --git a/src/m4af.c b/src/m4af.c index 1c51c00..7f3b180 100644 --- a/src/m4af.c +++ b/src/m4af.c @@ -39,6 +39,14 @@ typedef struct m4af_chunk_entry_t { uint32_t duration; } m4af_chunk_entry_t; +typedef struct m4af_itmf_entry_t { + uint32_t fcc; + char *name; + uint32_t type_code; + char *data; + uint32_t data_size; +} m4af_itmf_entry_t; + typedef struct m4af_track_t { uint32_t codec; uint32_t timescale; @@ -1374,7 +1382,6 @@ uint64_t m4af_patch_moov(m4af_ctx_t *ctx, uint32_t moov_size, uint32_t offset) static void m4af_shift_mdat_pos(m4af_ctx_t *ctx, uint32_t offset) { - unsigned i, j; int64_t begin, end; char *buf; diff --git a/src/m4af.h b/src/m4af.h index 09ebe93..3a04742 100644 --- a/src/m4af.h +++ b/src/m4af.h @@ -71,14 +71,6 @@ typedef struct m4af_io_callbacks_t { m4af_tell_callback tell; } m4af_io_callbacks_t; -typedef struct m4af_itmf_entry_t { - uint32_t fcc; - char *name; - uint32_t type_code; - char *data; - uint32_t data_size; -} m4af_itmf_entry_t; - typedef struct m4af_ctx_t m4af_ctx_t; diff --git a/src/main.c b/src/main.c index 6ffb7b1..1eb9a0e 100644 --- a/src/main.c +++ b/src/main.c @@ -117,9 +117,6 @@ PROGNAME " %s\n" " 29: MPEG-4 HE-AAC v2 (SBR+PS)\n" " 23: MPEG-4 AAC LD\n" " 39: MPEG-4 AAC ELD\n" -" 129: MPEG-2 AAC LC\n" -" 132: MPEG-2 HE-AAC (SBR)\n" -" 156: MPEG-2 HE-AAC v2 (SBR+PS)\n" " -b, --bitrate Bitrate in bits per seconds (for CBR)\n" " -m, --bitrate-mode Bitrate configuration\n" " 0: CBR (default)\n" @@ -702,7 +699,6 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params) { pcm_io_context_t io = { 0 }; pcm_reader_t *reader = 0; - struct stat stb = { 0 }; if ((params->input_fp = aacenc_fopen(params->input_filename, "rb")) == 0) { aacenc_fprintf(stderr, "ERROR: %s: %s\n", params->input_filename, @@ -710,8 +706,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params) goto FAIL; } io.cookie = params->input_fp; - if (fstat(fileno(params->input_fp), &stb) == 0 - && (stb.st_mode & S_IFMT) == S_IFREG) + if (aacenc_seekable(params->input_fp)) io.vtbl = &pcm_io_vtbl; else io.vtbl = &pcm_io_vtbl_noseek; @@ -803,12 +798,14 @@ int main(int argc, char **argv) params.sbr_ratio = 2; } scale_shift = aacenc_is_dual_rate_sbr((aacenc_param_t*)¶ms); - params.sbr_signaling = - (params.transport_format == TT_MP4_LOAS) ? 2 : - (params.transport_format == TT_MP4_RAW) ? 1 : 0; - if (sbr_mode && !scale_shift) - params.sbr_signaling = 2; - + params.sbr_signaling = 0; + if (sbr_mode) { + if (params.transport_format == TT_MP4_LOAS || !scale_shift) + params.sbr_signaling = 2; + if (params.transport_format == TT_MP4_RAW && + aacenc_is_explicit_bw_compatible_sbr_signaling_available()) + params.sbr_signaling = 1; + } if (aacenc_init(&encoder, (aacenc_param_t*)¶ms, sample_format, &aacinfo) < 0) goto END; @@ -834,9 +831,17 @@ int main(int argc, char **argv) params.output_fp)) < 0) goto END; m4af_set_num_channels(m4af, 0, sample_format->channels_per_frame); - m4af_set_decoder_specific_info(m4af, 0, - aacinfo.confBuf, aacinfo.confSize); m4af_set_fixed_frame_duration(m4af, 0, framelen >> scale_shift); + if (aacenc_is_explicit_bw_compatible_sbr_signaling_available()) + m4af_set_decoder_specific_info(m4af, 0, + aacinfo.confBuf, aacinfo.confSize); + else { + uint8_t mp4asc[32]; + uint32_t ascsize = sizeof(mp4asc); + aacenc_mp4asc((aacenc_param_t*)¶ms, aacinfo.confBuf, + aacinfo.confSize, mp4asc, &ascsize); + m4af_set_decoder_specific_info(m4af, 0, mp4asc, ascsize); + } m4af_set_vbr_mode(m4af, 0, params.bitrate_mode); m4af_set_priming_mode(m4af, params.gapless_mode + 1); m4af_begin_write(m4af); diff --git a/src/pcm_float_converter.c b/src/pcm_float_converter.c index 594879f..3d7ce3e 100644 --- a/src/pcm_float_converter.c +++ b/src/pcm_float_converter.c @@ -41,7 +41,6 @@ static int64_t get_position(pcm_reader_t *reader) static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes) { - unsigned i; pcm_float_converter_t *self = (pcm_float_converter_t *)reader; const pcm_sample_description_t *sfmt = pcm_get_format(self->src); nframes = pcm_read_frames(self->src, buffer, nframes); diff --git a/version.h b/version.h index 151b33e..10bb7c4 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #ifndef VERSION_H #define VERSION_H -const char *fdkaac_version = "0.6.2"; +const char *fdkaac_version = "0.6.3"; #endif