This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 49975b25a0c7986b3b10eef209018e097cb430f3 Author: Lynne <[email protected]> AuthorDate: Wed Sep 23 20:27:35 2026 +0900 Commit: James Almer <[email protected]> CommitDate: Fri Sep 25 02:13:39 2026 +0000 avcodec/opus/enc: fix the pre-emphasis filter state between frames The trailing CELT_OVERLAP samples of a frame are filtered again as the overlap of the next frame, so the filter state saved for the next frame has to be the one from right before them. The code relied on packets being assembled from 120 sample input frames for this, which is no longer the case since c3aea7628c, and saved the state from the end of the previous frame instead. The first overlap sample of every frame was then filtered differently than when it was encoded as part of the previous frame. --- libavcodec/opus/enc.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/libavcodec/opus/enc.c b/libavcodec/opus/enc.c index 8e942a293e..6d402e6af9 100644 --- a/libavcodec/opus/enc.c +++ b/libavcodec/opus/enc.c @@ -170,34 +170,29 @@ static void celt_frame_setup_input(OpusEncContext *s, CeltFrame *f) /* Apply the pre emphasis filter */ static void celt_apply_preemph_filter(OpusEncContext *s, CeltFrame *f) { - const int subframesize = s->avctx->frame_size; - const int subframes = OPUS_BLOCK_SIZE(s->packet.framesize) / subframesize; + const int frame_len = OPUS_BLOCK_SIZE(s->packet.framesize); const float c = ff_opus_deemph_weights[0]; - /* Filter overlap */ for (int ch = 0; ch < f->channels; ch++) { CeltBlock *b = &f->block[ch]; float m = b->emph_coeff; + + /* Filter the overlap (the trailing CELT_OVERLAP samples of the previous frame) */ for (int i = 0; i < CELT_OVERLAP; i++) { float sample = b->overlap[i]; b->overlap[i] = sample - m; m = sample * c; } - b->emph_coeff = m; - } - /* Filter the samples but do not update the last subframe's coeff - overlap ^^^ */ - for (int sf = 0; sf < subframes; sf++) { - for (int ch = 0; ch < f->channels; ch++) { - CeltBlock *b = &f->block[ch]; - float m = b->emph_coeff; - for (int i = 0; i < subframesize; i++) { - float sample = b->samples[sf*subframesize + i]; - b->samples[sf*subframesize + i] = sample - m; - m = sample * c; - } - if (sf != (subframes - 1)) + /* Filter the samples. The trailing CELT_OVERLAP samples are filtered + * again as the next frame's overlap, so the filter state saved for + * the next frame is the one from right before them. */ + for (int i = 0; i < frame_len; i++) { + float sample = b->samples[i]; + if (i == frame_len - CELT_OVERLAP) b->emph_coeff = m; + b->samples[i] = sample - m; + m = sample * c; } } } -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
