summaryrefslogtreecommitdiff
path: root/libavcodec/alacenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-04 01:12:34 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-04 01:12:34 +0100
commitad1c8dd6734f0aa7a7a87b4669a166715c114b46 (patch)
treec03c08f30bf1a7e8d9859abc48de3391bb05c6a0 /libavcodec/alacenc.c
parentd6da16dca5a64ed7ab2db54710a0c703f179d3ba (diff)
parentfd16f567987524a769d5d4f1f69089f000386ac2 (diff)
downloadffmpeg-ad1c8dd6734f0aa7a7a87b4669a166715c114b46.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: fate: add dxtory test adx_parser: rewrite. adxdec: Validate channel count to fix a division by zero. adxdec: Do not require extradata. cmdutils: K&R reformatting cosmetics alacdec: implement the 2-pass prediction type. alacenc: implement the 2-pass prediction type. alacenc: do not generate invalid multi-channel ALAC files alacdec: fill in missing or guessed info about the extradata format. utvideo: proper median prediction for interlaced videos lavu: bump lavu minor for av_popcount64 dca: K&R formatting cosmetics dct: K&R formatting cosmetics lavf: flush decoders in avformat_find_stream_info(). win32: detect number of CPUs using affinity Add av_popcount64 snow: Restore three mistakenly removed casts. Conflicts: cmdutils.c doc/APIchanges libavcodec/adx_parser.c libavcodec/adxdec.c libavcodec/alacenc.c libavutil/avutil.h tests/fate/screen.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/alacenc.c')
-rw-r--r--libavcodec/alacenc.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index 305a5b825b..e8d1bc03f2 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -348,6 +348,7 @@ static void alac_entropy_coder(AlacEncodeContext *s)
static void write_compressed_frame(AlacEncodeContext *s)
{
int i, j;
+ int prediction_type = 0;
if (s->avctx->channels == 2)
alac_stereo_decorrelation(s);
@@ -358,7 +359,7 @@ static void write_compressed_frame(AlacEncodeContext *s)
calc_predictor_params(s, i);
- put_bits(&s->pbctx, 4, 0); // prediction type : currently only type 0 has been RE'd
+ put_bits(&s->pbctx, 4, prediction_type);
put_bits(&s->pbctx, 4, s->lpc[i].lpc_quant);
put_bits(&s->pbctx, 3, s->rc.rice_modifier);
@@ -373,6 +374,14 @@ static void write_compressed_frame(AlacEncodeContext *s)
for (i = 0; i < s->avctx->channels; i++) {
alac_linear_predictor(s, i);
+
+ // TODO: determine when this will actually help. for now it's not used.
+ if (prediction_type == 15) {
+ // 2nd pass 1st order filter
+ for (j = s->avctx->frame_size - 1; j > 0; j--)
+ s->predictor_buf[j] -= s->predictor_buf[j - 1];
+ }
+
alac_entropy_coder(s);
}
}
@@ -391,8 +400,11 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
return -1;
}
- if(avctx->channels > 2) {
- av_log(avctx, AV_LOG_ERROR, "channels > 2 not supported\n");
+ /* TODO: Correctly implement multi-channel ALAC.
+ It is similar to multi-channel AAC, in that it has a series of
+ single-channel (SCE), channel-pair (CPE), and LFE elements. */
+ if (avctx->channels > 2) {
+ av_log(avctx, AV_LOG_ERROR, "only mono or stereo input is currently supported\n");
return AVERROR_PATCHWELCOME;
}