* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/opt.h"
+
#include "avcodec.h"
#include "put_bits.h"
#include "internal.h"
} AlacLPCContext;
typedef struct AlacEncodeContext {
+ const AVClass *class;
+ AVCodecContext *avctx;
int frame_size; /**< current frame size */
int verbatim; /**< current frame verbatim mode flag */
int compression_level;
RiceContext rc;
AlacLPCContext lpc[2];
LPCContext lpc_ctx;
- AVCodecContext *avctx;
} AlacEncodeContext;
static void init_sample_buffers(AlacEncodeContext *s, int channels,
- uint8_t const *samples[2])
+ const uint8_t *samples[2])
{
int ch, i;
int shift = av_get_bytes_per_sample(s->avctx->sample_fmt) * 8 -
enum AlacRawDataBlockType element, int instance,
const uint8_t *samples0, const uint8_t *samples1)
{
- uint8_t const *samples[2] = { samples0, samples1 };
+ const uint8_t *samples[2] = { samples0, samples1 };
int i, j, channels;
int prediction_type = 0;
PutBitContext *pb = &s->pbctx;
/* samples are channel-interleaved in verbatim mode */
if (s->avctx->sample_fmt == AV_SAMPLE_FMT_S32P) {
int shift = 32 - s->avctx->bits_per_raw_sample;
- int32_t const *samples_s32[2] = { (const int32_t *)samples0,
+ const int32_t *samples_s32[2] = { (const int32_t *)samples0,
(const int32_t *)samples1 };
for (i = 0; i < s->frame_size; i++)
for (j = 0; j < channels; j++)
put_sbits(pb, s->avctx->bits_per_raw_sample,
samples_s32[j][i] >> shift);
} else {
- int16_t const *samples_s16[2] = { (const int16_t *)samples0,
+ const int16_t *samples_s16[2] = { (const int16_t *)samples0,
(const int16_t *)samples1 };
for (i = 0; i < s->frame_size; i++)
for (j = 0; j < channels; j++)
avctx->channels,
avctx->bits_per_raw_sample);
- avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
+ avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata) {
ret = AVERROR(ENOMEM);
goto error;
AV_WB8(alac_extradata+20, s->rc.k_modifier);
}
- s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->min_prediction_order >= 0) {
if (avctx->min_prediction_order < MIN_LPC_ORDER ||
avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {
s->min_prediction_order = avctx->min_prediction_order;
}
- s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;
if (avctx->max_prediction_order >= 0) {
if (avctx->max_prediction_order < MIN_LPC_ORDER ||
avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {
s->max_prediction_order = avctx->max_prediction_order;
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (s->max_prediction_order < s->min_prediction_order) {
av_log(avctx, AV_LOG_ERROR,
return 0;
}
+#define OFFSET(x) offsetof(AlacEncodeContext, x)
+#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, { .i64 = DEFAULT_MIN_PRED_ORDER }, MIN_LPC_ORDER, ALAC_MAX_LPC_ORDER, AE },
+ { "max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, { .i64 = DEFAULT_MAX_PRED_ORDER }, MIN_LPC_ORDER, ALAC_MAX_LPC_ORDER, AE },
+
+ { NULL },
+};
+
+static const AVClass alacenc_class = {
+ .class_name = "alacenc",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_alac_encoder = {
.name = "alac",
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_ALAC,
.priv_data_size = sizeof(AlacEncodeContext),
+ .priv_class = &alacenc_class,
.init = alac_encode_init,
.encode2 = alac_encode_frame,
.close = alac_encode_close,
- .capabilities = CODEC_CAP_SMALL_LAST_FRAME,
+ .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME,
.channel_layouts = ff_alac_channel_layouts,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P,
AV_SAMPLE_FMT_S16P,