]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/flacenc.c
Merge remote branch 'qatar/master'
[ffmpeg] / libavcodec / flacenc.c
index d6f0f87376e10535991024a21906c5b2968d7d91..051de69c40527bb34441b39f9e979e3c67fea000 100644 (file)
@@ -211,13 +211,11 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
     int freq = avctx->sample_rate;
     int channels = avctx->channels;
     FlacEncodeContext *s = avctx->priv_data;
-    int i, level;
+    int i, level, ret;
     uint8_t *streaminfo;
 
     s->avctx = avctx;
 
-    ff_lpc_init(&s->lpc_ctx);
-
     if (avctx->sample_fmt != AV_SAMPLE_FMT_S16)
         return -1;
 
@@ -287,17 +285,6 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
     s->options.max_partition_order = ((int[]){  2,  2,  3,  3,  3,  8,  8,  8,  8,  8,  8,  8,  8})[level];
 
     /* set compression option overrides from AVCodecContext */
-#if FF_API_USE_LPC
-    /* for compatibility with deprecated AVCodecContext.use_lpc */
-    if (avctx->use_lpc == 0) {
-        s->options.lpc_type = AV_LPC_TYPE_FIXED;
-    } else if (avctx->use_lpc == 1) {
-        s->options.lpc_type = AV_LPC_TYPE_LEVINSON;
-    } else if (avctx->use_lpc > 1) {
-        s->options.lpc_type   = AV_LPC_TYPE_CHOLESKY;
-        s->options.lpc_passes = avctx->use_lpc - 1;
-    }
-#endif
     if (avctx->lpc_type > AV_LPC_TYPE_DEFAULT) {
         if (avctx->lpc_type > AV_LPC_TYPE_CHOLESKY) {
             av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type);
@@ -438,9 +425,12 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
     if (!avctx->coded_frame)
         return AVERROR(ENOMEM);
 
+    ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,
+                      s->options.max_prediction_order, AV_LPC_TYPE_LEVINSON);
+
     dprint_compression_options(s);
 
-    return 0;
+    return ret;
 }
 
 
@@ -1316,6 +1306,7 @@ static av_cold int flac_encode_close(AVCodecContext *avctx)
     if (avctx->priv_data) {
         FlacEncodeContext *s = avctx->priv_data;
         av_freep(&s->md5ctx);
+        ff_lpc_end(&s->lpc_ctx);
     }
     av_freep(&avctx->extradata);
     avctx->extradata_size = 0;
@@ -1324,7 +1315,7 @@ static av_cold int flac_encode_close(AVCodecContext *avctx)
 }
 
 
-AVCodec flac_encoder = {
+AVCodec ff_flac_encoder = {
     "flac",
     AVMEDIA_TYPE_AUDIO,
     CODEC_ID_FLAC,