28 #define DEFAULT_FRAME_SIZE 4096
29 #define DEFAULT_SAMPLE_SIZE 16
30 #define MAX_CHANNELS 8
31 #define ALAC_EXTRADATA_SIZE 36
32 #define ALAC_FRAME_HEADER_SIZE 55
33 #define ALAC_FRAME_FOOTER_SIZE 3
35 #define ALAC_ESCAPE_CODE 0x1FF
36 #define ALAC_MAX_LPC_ORDER 30
37 #define DEFAULT_MAX_PRED_ORDER 6
38 #define DEFAULT_MIN_PRED_ORDER 4
39 #define ALAC_MAX_LPC_PRECISION 9
40 #define ALAC_MAX_LPC_SHIFT 9
42 #define ALAC_CHMODE_LEFT_RIGHT 0
43 #define ALAC_CHMODE_LEFT_SIDE 1
44 #define ALAC_CHMODE_RIGHT_SIDE 2
45 #define ALAC_CHMODE_MID_SIDE 3
79 const int16_t *input_samples)
84 const int16_t *sptr = input_samples + ch;
93 int k,
int write_sample_size)
156 memcpy(s->
lpc[ch].
lpc_coeff, coefs[opt_order-1], opt_order*
sizeof(
int));
168 sum[0] = sum[1] = sum[2] = sum[3] = 0;
169 for (i = 2; i < n; i++) {
170 lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2];
171 rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2];
172 sum[2] +=
FFABS((lt + rt) >> 1);
173 sum[3] +=
FFABS(lt - rt);
179 score[0] = sum[0] + sum[1];
180 score[1] = sum[0] + sum[3];
181 score[2] = sum[1] + sum[3];
182 score[3] = sum[2] + sum[3];
186 for (i = 1; i < 4; i++) {
187 if (score[i] < score[best]) {
210 for (i = 0; i < n; i++) {
211 right[i] = left[i] - right[i];
218 for (i = 0; i < n; i++) {
220 right[i] = left[i] - right[i];
221 left[i] = tmp + (right[i] >> 31);
228 for (i = 0; i < n; i++) {
230 left[i] = (tmp + right[i]) >> 1;
231 right[i] = tmp - right[i];
260 residual[0] = samples[0];
262 residual[i] = samples[i] - samples[i-1];
265 for (i = lpc.
lpc_order + 1; i < s->avctx->frame_size; i++) {
266 int sum = 1 << (lpc.
lpc_quant - 1), res_val, j;
269 sum += (samples[lpc.
lpc_order-j] - samples[0]) *
277 res_val = residual[i];
281 int neg = (res_val < 0);
283 while(index >= 0 && (neg ? (res_val < 0):(res_val > 0))) {
285 int sign = (val ?
FFSIGN(val) : 0);
305 int sign_modifier = 0, i, k;
311 k = av_log2((history >> 9) + 3);
328 if (history < 128 && i < s->avctx->frame_size) {
329 unsigned int block_size = 0;
331 k = 7 - av_log2(history) + ((history + 16) >> 6);
333 while (*samples == 0 && i < s->avctx->frame_size) {
340 sign_modifier = (block_size <= 0xFFFF);
351 int prediction_type = 0;
379 if (prediction_type == 15) {
470 "invalid prediction orders: min=%d max=%d\n",
489 int buf_size,
void *
data)
493 int i, out_bytes, verbatim_flag = 0;
500 if (buf_size < 2 * s->max_coded_frame_size) {