#include <windows.h>
#endif
#include "compat.h"
-#include "wav_reader.h"
-#include "caf_reader.h"
+#include "pcm_reader.h"
#include "aacenc.h"
#include "m4af.h"
#include "progress.h"
{
int i, sigs[] = { SIGINT, SIGHUP, SIGTERM };
for (i = 0; i < sizeof(sigs)/sizeof(sigs[0]); ++i) {
- struct sigaction sa = { 0 };
+ struct sigaction sa;
+ memset(&sa, 0, sizeof sa);
sa.sa_handler = signal_handler;
sa.sa_flags |= SA_RESTART;
sigaction(sigs[i], &sa, 0);
goto END;
}
}
- if ((reader = pcm_open_sint16_converter(reader)) != 0)
- reader = extrapolater_open(reader);
+ if ((reader = pcm_open_native_converter(reader)) != 0)
+ if ((reader = pcm_open_sint16_converter(reader)) != 0)
+ reader = extrapolater_open(reader);
return reader;
END:
return 0;
pcm_reader_t *reader = 0;
HANDLE_AACENCODER encoder = 0;
AACENC_InfoStruct aacinfo = { 0 };
- LIB_INFO lib_info = { 0 };
m4af_ctx_t *m4af = 0;
const pcm_sample_description_t *sample_format;
- int downsampled_timescale = 0;
int frame_count = 0;
int sbr_mode = 0;
unsigned scale_shift = 0;
sample_format = pcm_get_format(reader);
- /*
- * We use explicit/hierarchical signaling for LOAS.
- * Other than that, we request implicit signaling to FDK library, then
- * append explicit/backward-compatible signaling to ASC in case of MP4FF.
- *
- * Explicit/backward-compatible signaling of SBR is the most recommended
- * way in MPEG4 part3 spec, and seems the only way supported by iTunes.
- * Since FDK library does not support it, we have to do it on our side.
- */
sbr_mode = aacenc_is_sbr_active((aacenc_param_t*)¶ms);
if (sbr_mode && !aacenc_is_sbr_ratio_available()) {
fprintf(stderr, "WARNING: Only dual-rate SBR is available "
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 : 0;
+ 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;
if (!params.transport_format) {
uint32_t scale;
- uint8_t mp4asc[32];
- uint32_t ascsize = sizeof(mp4asc);
unsigned framelen = aacinfo.frameLength;
scale = sample_format->sample_rate >> scale_shift;
if ((m4af = m4af_create(M4AF_CODEC_MP4A, scale, &m4af_io,
params.output_fp)) < 0)
goto END;
- aacenc_mp4asc((aacenc_param_t*)¶ms, aacinfo.confBuf,
- aacinfo.confSize, mp4asc, &ascsize);
- m4af_set_decoder_specific_info(m4af, 0, mp4asc, ascsize);
- m4af_set_fixed_frame_duration(m4af, 0,
- framelen >> scale_shift);
+ m4af_set_decoder_specific_info(m4af, 0,
+ aacinfo.confBuf, aacinfo.confSize);
+ m4af_set_fixed_frame_duration(m4af, 0, framelen >> scale_shift);
m4af_set_vbr_mode(m4af, 0, params.bitrate_mode);
m4af_set_priming_mode(m4af, params.gapless_mode + 1);
m4af_begin_write(m4af);