[FFmpeg-devel] [PATCH 1/2] avfilter/asrc_sine: rename some beep variables for more generic use
Marton Balint
cus at passwd.hu
Wed Nov 6 22:47:50 EET 2024
Signed-off-by: Marton Balint <cus at passwd.hu>
---
libavfilter/asrc_sine.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/libavfilter/asrc_sine.c b/libavfilter/asrc_sine.c
index 96b603dd26..de9815c9c1 100644
--- a/libavfilter/asrc_sine.c
+++ b/libavfilter/asrc_sine.c
@@ -42,8 +42,7 @@ typedef struct SineContext {
int64_t pts;
uint32_t phi; ///< current phase of the sine (2pi = 1<<32)
uint32_t dphi; ///< phase increment between two samples
- unsigned beep_period;
- unsigned beep_index;
+ unsigned index;
unsigned beep_length;
uint32_t phi_beep; ///< current phase of the beep
uint32_t dphi_beep; ///< phase increment of the beep
@@ -154,8 +153,7 @@ static av_cold int init(AVFilterContext *ctx)
make_sin_table(sine->sin);
if (sine->beep_factor) {
- sine->beep_period = sine->sample_rate;
- sine->beep_length = sine->beep_period / 25;
+ sine->beep_length = sine->sample_rate / 25;
sine->dphi_beep = ldexp(sine->beep_factor * sine->frequency, 32) /
sine->sample_rate + 0.5;
}
@@ -243,12 +241,12 @@ static int activate(AVFilterContext *ctx)
for (i = 0; i < nb_samples; i++) {
samples[i] = sine->sin[sine->phi >> (32 - LOG_PERIOD)];
sine->phi += sine->dphi;
- if (sine->beep_index < sine->beep_length) {
+ if (sine->index < sine->beep_length) {
samples[i] += sine->sin[sine->phi_beep >> (32 - LOG_PERIOD)] * 2;
sine->phi_beep += sine->dphi_beep;
}
- if (++sine->beep_index == sine->beep_period)
- sine->beep_index = 0;
+ if (++sine->index == sine->sample_rate)
+ sine->index = 0;
}
frame->pts = sine->pts;
--
2.43.0
More information about the ffmpeg-devel
mailing list