avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUT

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2024-01-20 12:26:08 -03:00
parent a12cd3be98
commit 65ddc74988
100 changed files with 20 additions and 1792 deletions

View file

@ -37,18 +37,6 @@
#define DEPREC AV_OPT_FLAG_DEPRECATED
static const AVOption options[]={
#if FF_API_OLD_CHANNEL_LAYOUT
{"ich" , "set input channel count (Deprecated, use ichl)",
OFFSET(user_in_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
{"in_channel_count" , "set input channel count (Deprecated, use in_chlayout)",
OFFSET(user_in_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
{"och" , "set output channel count (Deprecated, use ochl)",
OFFSET(user_out_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
{"out_channel_count" , "set output channel count (Deprecated, use out_chlayout)",
OFFSET(user_out_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
{"uch" , "set used channel count" , OFFSET(user_used_ch_count), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
{"used_channel_count" , "set used channel count" , OFFSET(user_used_ch_count), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
#endif
{"isr" , "set input sample rate" , OFFSET( in_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
{"in_sample_rate" , "set input sample rate" , OFFSET( in_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
{"osr" , "set output sample rate" , OFFSET(out_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
@ -59,16 +47,6 @@ static const AVOption options[]={
{"out_sample_fmt" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
{"tsf" , "set internal sample format" , OFFSET(user_int_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
{"internal_sample_fmt" , "set internal sample format" , OFFSET(user_int_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
#if FF_API_OLD_CHANNEL_LAYOUT
{"icl" , "set input channel layout (Deprecated, use ichl)",
OFFSET(user_in_ch_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, INT64_MIN, INT64_MAX, PARAM|DEPREC, .unit = "channel_layout"},
{"in_channel_layout" , "set input channel layout (Deprecated, use in_chlayout)",
OFFSET(user_in_ch_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, INT64_MIN, INT64_MAX, PARAM|DEPREC, .unit = "channel_layout"},
{"ocl" , "set output channel layout (Deprecated, use ochl)",
OFFSET(user_out_ch_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, INT64_MIN, INT64_MAX, PARAM|DEPREC, .unit = "channel_layout"},
{"out_channel_layout" , "set output channel layout (Deprecated, use out_chlayout)",
OFFSET(user_out_ch_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, INT64_MIN, INT64_MAX, PARAM|DEPREC, .unit = "channel_layout"},
#endif
{"ichl" , "set input channel layout" , OFFSET(user_in_chlayout ), AV_OPT_TYPE_CHLAYOUT, {.str=NULL }, 0, 0 , PARAM, .unit = "chlayout"},
{"in_chlayout" , "set input channel layout" , OFFSET(user_in_chlayout ), AV_OPT_TYPE_CHLAYOUT, {.str=NULL }, 0, 0 , PARAM, .unit = "chlayout"},
{"ochl" , "set output channel layout" , OFFSET(user_out_chlayout), AV_OPT_TYPE_CHLAYOUT, {.str=NULL }, 0, 0 , PARAM, .unit = "chlayout"},

View file

@ -64,37 +64,14 @@
int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
{
int nb_in, nb_out, in, out;
int user_in_chlayout_nb_channels, user_out_chlayout_nb_channels;
if (!s || s->in_convert) // s needs to be allocated but not initialized
return AVERROR(EINVAL);
memset(s->matrix, 0, sizeof(s->matrix));
memset(s->matrix_flt, 0, sizeof(s->matrix_flt));
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
user_in_chlayout_nb_channels = av_get_channel_layout_nb_channels(s->user_in_ch_layout);
FF_ENABLE_DEPRECATION_WARNINGS
if (!user_in_chlayout_nb_channels)
#endif
user_in_chlayout_nb_channels = s->user_in_chlayout.nb_channels;
nb_in =
#if FF_API_OLD_CHANNEL_LAYOUT
(s->user_in_ch_count > 0) ? s->user_in_ch_count :
#endif
user_in_chlayout_nb_channels;
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
user_out_chlayout_nb_channels = av_get_channel_layout_nb_channels(s->user_out_ch_layout);
FF_ENABLE_DEPRECATION_WARNINGS
if (!user_out_chlayout_nb_channels)
#endif
user_out_chlayout_nb_channels = s->user_out_chlayout.nb_channels;
nb_out =
#if FF_API_OLD_CHANNEL_LAYOUT
(s->user_out_ch_count > 0) ? s->user_out_ch_count :
#endif
user_out_chlayout_nb_channels;
nb_in = s->user_in_chlayout.nb_channels;
nb_out = s->user_out_chlayout.nb_channels;
for (out = 0; out < nb_out; out++) {
for (in = 0; in < nb_in; in++)
s->matrix_flt[out][in] = s->matrix[out][in] = matrix[in];
@ -146,27 +123,6 @@ static int sane_layout(AVChannelLayout *ch_layout) {
return 1;
}
#if FF_API_OLD_CHANNEL_LAYOUT
av_cold int swr_build_matrix(uint64_t in_ch_layout_param, uint64_t out_ch_layout_param,
double center_mix_level, double surround_mix_level,
double lfe_mix_level, double maxval,
double rematrix_volume, double *matrix_param,
int stride, enum AVMatrixEncoding matrix_encoding, void *log_context)
{
AVChannelLayout in_ch_layout = { 0 }, out_ch_layout = { 0 };
int ret;
ret = av_channel_layout_from_mask(&in_ch_layout, in_ch_layout_param);
ret |= av_channel_layout_from_mask(&out_ch_layout, out_ch_layout_param);
if (ret < 0)
return ret;
return swr_build_matrix2(&in_ch_layout, &out_ch_layout, center_mix_level, surround_mix_level,
lfe_mix_level, maxval, rematrix_volume, matrix_param,
stride, matrix_encoding, log_context);
}
#endif
av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelLayout *out_layout,
double center_mix_level, double surround_mix_level,
double lfe_mix_level, double maxval,

View file

@ -36,52 +36,6 @@ int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map){
return 0;
}
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate,
int log_offset, void *log_ctx){
if(!s) s= swr_alloc();
if(!s) return NULL;
s->log_level_offset= log_offset;
s->log_ctx= log_ctx;
if (av_opt_set_int(s, "ocl", out_ch_layout, 0) < 0)
goto fail;
if (av_opt_set_int(s, "osf", out_sample_fmt, 0) < 0)
goto fail;
if (av_opt_set_int(s, "osr", out_sample_rate, 0) < 0)
goto fail;
if (av_opt_set_int(s, "icl", in_ch_layout, 0) < 0)
goto fail;
if (av_opt_set_int(s, "isf", in_sample_fmt, 0) < 0)
goto fail;
if (av_opt_set_int(s, "isr", in_sample_rate, 0) < 0)
goto fail;
if (av_opt_set_int(s, "ich", av_get_channel_layout_nb_channels(s-> user_in_ch_layout), 0) < 0)
goto fail;
if (av_opt_set_int(s, "och", av_get_channel_layout_nb_channels(s->user_out_ch_layout), 0) < 0)
goto fail;
av_opt_set_int(s, "uch", 0, 0);
return s;
fail:
av_log(s, AV_LOG_ERROR, "Failed to set option\n");
swr_free(&s);
return NULL;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
int swr_alloc_set_opts2(struct SwrContext **ps,
const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
const AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate,
@ -117,14 +71,6 @@ int swr_alloc_set_opts2(struct SwrContext **ps,
av_opt_set_int(s, "uch", 0, 0);
#if FF_API_OLD_CHANNEL_LAYOUT
// Clear old API values so they don't take precedence in swr_init()
av_opt_set_int(s, "icl", 0, 0);
av_opt_set_int(s, "ocl", 0, 0);
av_opt_set_int(s, "ich", 0, 0);
av_opt_set_int(s, "och", 0, 0);
#endif
return 0;
fail:
av_log(s, AV_LOG_ERROR, "Failed to set option\n");
@ -213,65 +159,7 @@ av_cold int swr_init(struct SwrContext *s){
av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is invalid\n", s->out_sample_rate);
return AVERROR(EINVAL);
}
#if FF_API_OLD_CHANNEL_LAYOUT
s->out.ch_count = s-> user_out_ch_count;
s-> in.ch_count = s-> user_in_ch_count;
// if the old/new fields are set inconsistently, prefer the old ones
if (s->user_used_ch_count && s->user_used_ch_count != s->user_used_chlayout.nb_channels) {
av_channel_layout_uninit(&s->used_ch_layout);
s->used_ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
s->used_ch_layout.nb_channels = s->user_used_ch_count;
} else if (av_channel_layout_check(&s->user_used_chlayout)) {
ret = av_channel_layout_copy(&s->used_ch_layout, &s->user_used_chlayout);
if (ret < 0)
return ret;
}
if ((s->user_in_ch_count && s->user_in_ch_count != s->user_in_chlayout.nb_channels) ||
(s->user_in_ch_layout && (s->user_in_chlayout.order != AV_CHANNEL_ORDER_NATIVE ||
s->user_in_chlayout.u.mask != s->user_in_ch_layout))) {
av_channel_layout_uninit(&s->in_ch_layout);
if (s->user_in_ch_layout)
av_channel_layout_from_mask(&s->in_ch_layout, s->user_in_ch_layout);
else {
s->in_ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
s->in_ch_layout.nb_channels = s->user_in_ch_count;
}
} else if (av_channel_layout_check(&s->user_in_chlayout))
av_channel_layout_copy(&s->in_ch_layout, &s->user_in_chlayout);
if ((s->user_out_ch_count && s->user_out_ch_count != s->user_out_chlayout.nb_channels) ||
(s->user_out_ch_layout && (s->user_out_chlayout.order != AV_CHANNEL_ORDER_NATIVE ||
s->user_out_chlayout.u.mask != s->user_out_ch_layout))) {
av_channel_layout_uninit(&s->out_ch_layout);
if (s->user_out_ch_layout)
av_channel_layout_from_mask(&s->out_ch_layout, s->user_out_ch_layout);
else {
s->out_ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
s->out_ch_layout.nb_channels = s->user_out_ch_count;
}
} else if (av_channel_layout_check(&s->user_out_chlayout))
av_channel_layout_copy(&s->out_ch_layout, &s->user_out_chlayout);
if (!s->out.ch_count)
s->out.ch_count = s->out_ch_layout.nb_channels;
if (!s-> in.ch_count)
s-> in.ch_count = s->in_ch_layout.nb_channels;
if (!(ret = av_channel_layout_check(&s->in_ch_layout)) || s->in_ch_layout.nb_channels > SWR_CH_MAX) {
if (ret)
av_channel_layout_describe(&s->in_ch_layout, l1, sizeof(l1));
av_log(s, AV_LOG_WARNING, "Input channel layout \"%s\" is invalid or unsupported.\n", ret ? l1 : "");
return AVERROR(EINVAL);
}
if (!(ret = av_channel_layout_check(&s->out_ch_layout)) || s->out_ch_layout.nb_channels > SWR_CH_MAX) {
if (ret)
av_channel_layout_describe(&s->out_ch_layout, l2, sizeof(l2));
av_log(s, AV_LOG_WARNING, "Output channel layout \"%s\" is invalid or unsupported.\n", ret ? l2 : "");
return AVERROR(EINVAL);
}
#else
s->out.ch_count = s-> user_out_chlayout.nb_channels;
s-> in.ch_count = s-> user_in_chlayout.nb_channels;
@ -294,7 +182,6 @@ av_cold int swr_init(struct SwrContext *s){
ret |= av_channel_layout_copy(&s->used_ch_layout, &s->user_used_chlayout);
if (ret < 0)
return ret;
#endif
s->int_sample_fmt= s->user_int_sample_fmt;
@ -423,13 +310,6 @@ av_cold int swr_init(struct SwrContext *s){
}
av_channel_layout_describe(&s->out_ch_layout, l2, sizeof(l2));
#if FF_API_OLD_CHANNEL_LAYOUT
if (s->out_ch_layout.order != AV_CHANNEL_ORDER_UNSPEC && s->out.ch_count != s->out_ch_layout.nb_channels) {
av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", l2, s->out.ch_count);
ret = AVERROR(EINVAL);
goto fail;
}
#endif
av_channel_layout_describe(&s->in_ch_layout, l1, sizeof(l1));
if (s->in_ch_layout.order != AV_CHANNEL_ORDER_UNSPEC && s->used_ch_layout.nb_channels != s->in_ch_layout.nb_channels) {
av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_layout.nb_channels);

View file

@ -234,35 +234,6 @@ int swr_init(struct SwrContext *s);
*/
int swr_is_initialized(struct SwrContext *s);
#if FF_API_OLD_CHANNEL_LAYOUT
/**
* Allocate SwrContext if needed and set/reset common parameters.
*
* This function does not require s to be allocated with swr_alloc(). On the
* other hand, swr_alloc() can use swr_alloc_set_opts() to set the parameters
* on the allocated context.
*
* @param s existing Swr context if available, or NULL if not
* @param out_ch_layout output channel layout (AV_CH_LAYOUT_*)
* @param out_sample_fmt output sample format (AV_SAMPLE_FMT_*).
* @param out_sample_rate output sample rate (frequency in Hz)
* @param in_ch_layout input channel layout (AV_CH_LAYOUT_*)
* @param in_sample_fmt input sample format (AV_SAMPLE_FMT_*).
* @param in_sample_rate input sample rate (frequency in Hz)
* @param log_offset logging level offset
* @param log_ctx parent logging context, can be NULL
*
* @see swr_init(), swr_free()
* @return NULL on error, allocated context otherwise
* @deprecated use @ref swr_alloc_set_opts2()
*/
attribute_deprecated
struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate,
int log_offset, void *log_ctx);
#endif
/**
* Allocate SwrContext if needed and set/reset common parameters.
*
@ -399,40 +370,6 @@ int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensatio
*/
int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map);
#if FF_API_OLD_CHANNEL_LAYOUT
/**
* Generate a channel mixing matrix.
*
* This function is the one used internally by libswresample for building the
* default mixing matrix. It is made public just as a utility function for
* building custom matrices.
*
* @param in_layout input channel layout
* @param out_layout output channel layout
* @param center_mix_level mix level for the center channel
* @param surround_mix_level mix level for the surround channel(s)
* @param lfe_mix_level mix level for the low-frequency effects channel
* @param rematrix_maxval if 1.0, coefficients will be normalized to prevent
* overflow. if INT_MAX, coefficients will not be
* normalized.
* @param[out] matrix mixing coefficients; matrix[i + stride * o] is
* the weight of input channel i in output channel o.
* @param stride distance between adjacent input channels in the
* matrix array
* @param matrix_encoding matrixed stereo downmix mode (e.g. dplii)
* @param log_ctx parent logging context, can be NULL
* @return 0 on success, negative AVERROR code on failure
* @deprecated use @ref swr_build_matrix2()
*/
attribute_deprecated
int swr_build_matrix(uint64_t in_layout, uint64_t out_layout,
double center_mix_level, double surround_mix_level,
double lfe_mix_level, double rematrix_maxval,
double rematrix_volume, double *matrix,
int stride, enum AVMatrixEncoding matrix_encoding,
void *log_ctx);
#endif
/**
* Generate a channel mixing matrix.
*

View file

@ -32,15 +32,6 @@ int swr_config_frame(SwrContext *s, const AVFrame *out, const AVFrame *in)
swr_close(s);
if (in) {
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
// if the old/new fields are set inconsistently, prefer the old ones
if ((in->channel_layout && (in->ch_layout.order != AV_CHANNEL_ORDER_NATIVE ||
in->ch_layout.u.mask != in->channel_layout))) {
av_channel_layout_from_mask(&ch_layout, in->channel_layout);
FF_ENABLE_DEPRECATION_WARNINGS
} else
#endif
if ((ret = av_channel_layout_copy(&ch_layout, &in->ch_layout)) < 0)
goto fail;
if ((ret = av_opt_set_chlayout(s, "ichl", &ch_layout, 0)) < 0)
@ -52,16 +43,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
if (out) {
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
// if the old/new fields are set inconsistently, prefer the old ones
if ((out->channel_layout && (out->ch_layout.order != AV_CHANNEL_ORDER_NATIVE ||
out->ch_layout.u.mask != out->channel_layout))) {
av_channel_layout_uninit(&ch_layout);
av_channel_layout_from_mask(&ch_layout, out->channel_layout);
FF_ENABLE_DEPRECATION_WARNINGS
} else
#endif
if ((ret = av_channel_layout_copy(&ch_layout, &out->ch_layout)) < 0)
goto fail;
if ((ret = av_opt_set_chlayout(s, "ochl", &ch_layout, 0)) < 0)
@ -87,15 +68,6 @@ static int config_changed(SwrContext *s,
int ret = 0, err;
if (in) {
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
// if the old/new fields are set inconsistently, prefer the old ones
if ((in->channel_layout && (in->ch_layout.order != AV_CHANNEL_ORDER_NATIVE ||
in->ch_layout.u.mask != in->channel_layout))) {
av_channel_layout_from_mask(&ch_layout, in->channel_layout);
FF_ENABLE_DEPRECATION_WARNINGS
} else
#endif
if ((err = av_channel_layout_copy(&ch_layout, &in->ch_layout)) < 0)
return err;
if (av_channel_layout_compare(&s->in_ch_layout, &ch_layout) ||
@ -106,16 +78,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
if (out) {
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
// if the old/new fields are set inconsistently, prefer the old ones
if ((out->channel_layout && (out->ch_layout.order != AV_CHANNEL_ORDER_NATIVE ||
out->ch_layout.u.mask != out->channel_layout))) {
av_channel_layout_uninit(&ch_layout);
av_channel_layout_from_mask(&ch_layout, out->channel_layout);
FF_ENABLE_DEPRECATION_WARNINGS
} else
#endif
if ((err = av_channel_layout_copy(&ch_layout, &out->ch_layout)) < 0)
return err;
if (av_channel_layout_compare(&s->out_ch_layout, &ch_layout) ||
@ -169,14 +131,7 @@ static inline int available_samples(AVFrame *out)
if (av_sample_fmt_is_planar(out->format)) {
return samples;
} else {
int channels;
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
channels = av_get_channel_layout_nb_channels(out->channel_layout);
FF_ENABLE_DEPRECATION_WARNINGS
if (!channels)
#endif
channels = out->ch_layout.nb_channels;
int channels = out->ch_layout.nb_channels;
return samples / channels;
}
}

View file

@ -114,13 +114,6 @@ struct SwrContext {
const int *channel_map; ///< channel index (or -1 if muted channel) map
int engine;
#if FF_API_OLD_CHANNEL_LAYOUT
int user_used_ch_count; ///< User set used channel count
int user_in_ch_count; ///< User set input channel count
int user_out_ch_count; ///< User set output channel count
int64_t user_in_ch_layout; ///< User set input channel layout
int64_t user_out_ch_layout; ///< User set output channel layout
#endif
AVChannelLayout user_used_chlayout; ///< User set used channel layout
AVChannelLayout user_in_chlayout; ///< User set input channel layout
AVChannelLayout user_out_chlayout; ///< User set output channel layout