aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/opusenc_psy.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-05-28 14:38:10 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:44 -0300
commitcc37640a72a96c2674d8ee93fe3b766405a027c4 (patch)
tree61bddfa0ee0a18faa99a8f2619e6247158877628 /libavcodec/opusenc_psy.c
parent045d6b9abfd8f44e4cedab65ec794267b186eba9 (diff)
downloadffmpeg-cc37640a72a96c2674d8ee93fe3b766405a027c4.tar.gz
opus: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/opusenc_psy.c')
-rw-r--r--libavcodec/opusenc_psy.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/libavcodec/opusenc_psy.c b/libavcodec/opusenc_psy.c
index 5a50db942f..1c8f69269c 100644
--- a/libavcodec/opusenc_psy.c
+++ b/libavcodec/opusenc_psy.c
@@ -83,7 +83,7 @@ static void step_collect_psy_metrics(OpusPsyContext *s, int index)
st->index = index;
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < s->avctx->ch_layout.nb_channels; ch++) {
const int lap_size = (1 << s->bsize_analysis);
for (i = 1; i <= FFMIN(lap_size, index); i++) {
const int offset = i*120;
@@ -105,7 +105,7 @@ static void step_collect_psy_metrics(OpusPsyContext *s, int index)
st->bands[ch][i] = &st->coeffs[ch][ff_celt_freq_bands[i] << s->bsize_analysis];
}
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < s->avctx->ch_layout.nb_channels; ch++) {
for (i = 0; i < CELT_MAX_BANDS; i++) {
float avg_c_s, energy = 0.0f, dist_dev = 0.0f;
const int range = ff_celt_freq_range[i] << s->bsize_analysis;
@@ -128,7 +128,7 @@ static void step_collect_psy_metrics(OpusPsyContext *s, int index)
st->silence = !silence;
- if (s->avctx->channels > 1) {
+ if (s->avctx->ch_layout.nb_channels > 1) {
for (i = 0; i < CELT_MAX_BANDS; i++) {
float incompat = 0.0f;
const float *coeffs1 = st->bands[0][i];
@@ -140,7 +140,7 @@ static void step_collect_psy_metrics(OpusPsyContext *s, int index)
}
}
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < s->avctx->ch_layout.nb_channels; ch++) {
for (i = 0; i < CELT_MAX_BANDS; i++) {
OpusBandExcitation *ex = &s->ex[ch][i];
float bp_e = bessel_filter(&s->bfilter_lo[ch][i], st->energy[ch][i]);
@@ -259,7 +259,7 @@ void ff_opus_psy_celt_frame_init(OpusPsyContext *s, CeltFrame *f, int index)
f->start_band = (s->p.mode == OPUS_MODE_HYBRID) ? 17 : 0;
f->end_band = ff_celt_band_end[s->p.bandwidth];
- f->channels = s->avctx->channels;
+ f->channels = s->avctx->ch_layout.nb_channels;
f->size = s->p.framesize;
for (i = 0; i < (1 << f->size); i++)
@@ -327,7 +327,7 @@ static void celt_gauge_psy_weight(OpusPsyContext *s, OpusPsyStep **start,
float tonal_contrib = 0.0f;
for (f = 0; f < (1 << s->p.framesize); f++) {
weight = start[f]->stereo[i];
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < s->avctx->ch_layout.nb_channels; ch++) {
weight += start[f]->change_amp[ch][i] + start[f]->tone[ch][i] + start[f]->energy[ch][i];
tonal_contrib += start[f]->tone[ch][i];
}
@@ -384,7 +384,7 @@ static void celt_search_for_dual_stereo(OpusPsyContext *s, CeltFrame *f)
float td1, td2;
f->dual_stereo = 0;
- if (s->avctx->channels < 2)
+ if (s->avctx->ch_layout.nb_channels < 2)
return;
bands_dist(s, f, &td1);
@@ -402,7 +402,7 @@ static void celt_search_for_intensity(OpusPsyContext *s, CeltFrame *f)
/* TODO: fix, make some heuristic up here using the lambda value */
float end_band = 0;
- if (s->avctx->channels < 2)
+ if (s->avctx->ch_layout.nb_channels < 2)
return;
for (i = f->end_band; i >= end_band; i--) {
@@ -436,7 +436,7 @@ static int celt_search_for_tf(OpusPsyContext *s, OpusPsyStep **start, CeltFrame
float iscore0 = 0.0f;
float iscore1 = 0.0f;
for (j = 0; j < (1 << f->size); j++) {
- for (k = 0; k < s->avctx->channels; k++) {
+ for (k = 0; k < s->avctx->ch_layout.nb_channels; k++) {
iscore0 += start[j]->tone[k][i]*start[j]->change_amp[k][i]/mag[0];
iscore1 += start[j]->tone[k][i]*start[j]->change_amp[k][i]/mag[1];
}
@@ -540,7 +540,7 @@ av_cold int ff_opus_psy_init(OpusPsyContext *s, AVCodecContext *avctx,
goto fail;
}
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < s->avctx->ch_layout.nb_channels; ch++) {
for (i = 0; i < CELT_MAX_BANDS; i++) {
bessel_init(&s->bfilter_hi[ch][i], 1.0f, 19.0f, 100.0f, 1);
bessel_init(&s->bfilter_lo[ch][i], 1.0f, 20.0f, 100.0f, 0);