1
0
mirror of https://github.com/nu774/fdkaac.git synced 2025-01-23 20:20:43 +01:00

add --include-sbr-delay

This commit is contained in:
nu774 2013-10-27 21:31:35 +09:00
parent c9ac59e8d3
commit be234dc464

View File

@ -149,6 +149,9 @@ PROGNAME " %s\n"
" 0: iTunSMPB (default)\n" " 0: iTunSMPB (default)\n"
" 1: ISO standard (edts + sgpd)\n" " 1: ISO standard (edts + sgpd)\n"
" 2: Both\n" " 2: Both\n"
" --include-sbr-delay Count SBR decoder delay in encoder delay\n"
" This is not iTunes compatible, but is default\n"
" behavior of FDK library.\n"
" -I, --ignorelength Ignore length of WAV header\n" " -I, --ignorelength Ignore length of WAV header\n"
" -S, --silent Don't print progress messages\n" " -S, --silent Don't print progress messages\n"
" --moov-before-mdat Place moov box before mdat box on m4a output\n" " --moov-before-mdat Place moov box before mdat box on m4a output\n"
@ -204,6 +207,7 @@ typedef struct aacenc_param_ex_t {
char *output_filename; char *output_filename;
FILE *output_fp; FILE *output_fp;
unsigned gapless_mode; unsigned gapless_mode;
unsigned include_sbr_delay;
unsigned ignore_length; unsigned ignore_length;
int silent; int silent;
int moov_before_mdat; int moov_before_mdat;
@ -226,6 +230,7 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
int ch; int ch;
unsigned n; unsigned n;
#define OPT_INCLUDE_SBR_DELAY M4AF_FOURCC('s','d','l','y')
#define OPT_MOOV_BEFORE_MDAT M4AF_FOURCC('m','o','o','v') #define OPT_MOOV_BEFORE_MDAT M4AF_FOURCC('m','o','o','v')
#define OPT_RAW_CHANNELS M4AF_FOURCC('r','c','h','n') #define OPT_RAW_CHANNELS M4AF_FOURCC('r','c','h','n')
#define OPT_RAW_RATE M4AF_FOURCC('r','r','a','t') #define OPT_RAW_RATE M4AF_FOURCC('r','r','a','t')
@ -248,6 +253,7 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
{ "header-period", required_argument, 0, 'P' }, { "header-period", required_argument, 0, 'P' },
{ "gapless-mode", required_argument, 0, 'G' }, { "gapless-mode", required_argument, 0, 'G' },
{ "include-sbr-delay", no_argument, 0, OPT_INCLUDE_SBR_DELAY },
{ "ignorelength", no_argument, 0, 'I' }, { "ignorelength", no_argument, 0, 'I' },
{ "silent", no_argument, 0, 'S' }, { "silent", no_argument, 0, 'S' },
{ "moov-before-mdat", no_argument, 0, OPT_MOOV_BEFORE_MDAT }, { "moov-before-mdat", no_argument, 0, OPT_MOOV_BEFORE_MDAT },
@ -348,6 +354,9 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
} }
params->gapless_mode = n; params->gapless_mode = n;
break; break;
case OPT_INCLUDE_SBR_DELAY:
params->include_sbr_delay = 1;
break;
case 'I': case 'I':
params->ignore_length = 1; params->ignore_length = 1;
break; break;
@ -791,9 +800,15 @@ int main(int argc, char **argv)
goto END; goto END;
if (m4af) { if (m4af) {
uint32_t delay = aacinfo.encoderDelay; uint32_t delay = aacinfo.encoderDelay;
uint32_t padding;
int64_t frames_read = pcm_get_position(reader); int64_t frames_read = pcm_get_position(reader);
uint32_t padding = frame_count * aacinfo.frameLength
- frames_read - aacinfo.encoderDelay; if (sbr_mode && params.profile != AOT_ER_AAC_ELD &&
!params.include_sbr_delay)
delay -= 481 << 1;
if (sbr_mode && (delay & 1))
++delay;
padding = frame_count * aacinfo.frameLength - frames_read - delay;
m4af_set_priming(m4af, 0, delay >> downsampled_timescale, m4af_set_priming(m4af, 0, delay >> downsampled_timescale,
padding >> downsampled_timescale); padding >> downsampled_timescale);
if (finalize_m4a(m4af, &params, encoder) < 0) if (finalize_m4a(m4af, &params, encoder) < 0)