---
 libavcodec/avcodec.h |    6 +++++-
 libavcodec/flacenc.c |   21 ++++++++++++++++++---
 libavcodec/version.h |    3 +++
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2122545..984c2d3 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2538,12 +2538,16 @@ typedef struct AVCodecContext {
     int use_lpc;
 #endif
 
+#if FF_API_GLOBAL_LPC
     /**
      * LPC coefficient precision - used by FLAC encoder
      * - encoding: Set by user.
      * - decoding: unused
+     *
+     * @deprecated Use FLAC encoder private options instead.
      */
-    int lpc_coeff_precision;
+    attribute_deprecated int lpc_coeff_precision;
+#endif
 
     /**
      * - encoding: Set by user.
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index d93bfb5..3dfee71 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -21,6 +21,7 @@
 
 #include "libavutil/crc.h"
 #include "libavutil/md5.h"
+#include "libavutil/opt.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "golomb.h"
@@ -80,6 +81,7 @@ typedef struct FlacFrame {
 } FlacFrame;
 
 typedef struct FlacEncodeContext {
+    AVClass *class;
     PutBitContext pb;
     int channels;
     int samplerate;
@@ -399,6 +401,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
     }
     s->max_blocksize = s->avctx->frame_size;
 
+#if FF_API_GLOBAL_LPC
     /* set LPC precision */
     if (avctx->lpc_coeff_precision > 0) {
         if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {
@@ -407,10 +410,8 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
             return -1;
         }
         s->options.lpc_coeff_precision = avctx->lpc_coeff_precision;
-    } else {
-        /* default LPC precision */
-        s->options.lpc_coeff_precision = 15;
     }
+#endif
 
     /* set maximum encoded frame size in verbatim mode */
     s->max_framesize = ff_flac_get_max_frame_size(s->avctx->frame_size,
@@ -1325,6 +1326,19 @@ static av_cold int flac_encode_close(AVCodecContext 
*avctx)
     return 0;
 }
 
+static const AVOption options[] = {
+    { "lpc_coeff_precision", "LPC coefficient precision",
+       offsetof(FlacEncodeContext, options) + offsetof(CompressionOptions, 
lpc_coeff_precision),
+       FF_OPT_TYPE_INT, 15, 0, MAX_LPC_PRECISION, AV_OPT_FLAG_ENCODING_PARAM | 
AV_OPT_FLAG_AUDIO_PARAM },
+    { NULL },
+};
+
+static const AVClass flac_encoder_class = {
+    "FLAC encoder",
+    av_default_item_name,
+    options,
+    LIBAVUTIL_VERSION_INT,
+};
 
 AVCodec ff_flac_encoder = {
     "flac",
@@ -1338,4 +1352,5 @@ AVCodec ff_flac_encoder = {
     .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
     .sample_fmts = (const enum 
AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
+    .priv_class= &flac_encoder_class,
 };
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 3d13f79..cad1dec 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -74,5 +74,8 @@
 #ifndef FF_API_HURRY_UP
 #define FF_API_HURRY_UP         (LIBAVCODEC_VERSION_MAJOR < 53)
 #endif
+#ifndef FF_API_GLOBAL_LPC
+#define FF_API_GLOBAL_LPC       (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
-- 
1.7.4.1

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to