]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/alacenc.c
lavc: Check CODEC_CAP_VARIABLE_FRAME_SIZE && !frame
[ffmpeg] / libavcodec / alacenc.c
index 7e29a24c6ff3fc9ee739dff53f14dfdb9f14c884..e8d1bc03f25ef739de058fb674bc58abff5f1569 100644 (file)
@@ -2,20 +2,20 @@
  * ALAC audio encoder
  * Copyright (c) 2008  Jaikrishnan Menon <realityman@gmx.net>
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -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,6 +400,14 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
         return -1;
     }
 
+    /* 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;
+    }
+
     // Set default compression level
     if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
         s->compression_level = 2;