" 0: iTunSMPB (default)\n"
" 1: ISO standard (edts + sgpd)\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"
" -S, --silent Don't print progress messages\n"
" --moov-before-mdat Place moov box before mdat box on m4a output\n"
char *output_filename;
FILE *output_fp;
unsigned gapless_mode;
+ unsigned include_sbr_delay;
unsigned ignore_length;
int silent;
int moov_before_mdat;
int ch;
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_RAW_CHANNELS M4AF_FOURCC('r','c','h','n')
#define OPT_RAW_RATE M4AF_FOURCC('r','r','a','t')
{ "header-period", required_argument, 0, 'P' },
{ "gapless-mode", required_argument, 0, 'G' },
+ { "include-sbr-delay", no_argument, 0, OPT_INCLUDE_SBR_DELAY },
{ "ignorelength", no_argument, 0, 'I' },
{ "silent", no_argument, 0, 'S' },
{ "moov-before-mdat", no_argument, 0, OPT_MOOV_BEFORE_MDAT },
}
params->gapless_mode = n;
break;
+ case OPT_INCLUDE_SBR_DELAY:
+ params->include_sbr_delay = 1;
+ break;
case 'I':
params->ignore_length = 1;
break;
goto END;
if (m4af) {
uint32_t delay = aacinfo.encoderDelay;
+ uint32_t padding;
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,
padding >> downsampled_timescale);
if (finalize_m4a(m4af, ¶ms, encoder) < 0)