From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 7CC714F19B for ; Fri, 20 Feb 2026 19:40:13 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'fyJK2/d4NR9S3e9G1n79NwlT6EVySnz5qgsnB1HxKs4=', expected b'/Y1mwkBWfOH0ZqsAuujSPpCLVgwu0act2ewHK/7ohSU=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771616393; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=fyJK2/d4NR9S3e9G1n79NwlT6EVySnz5qgsnB1HxKs4=; b=0Ljqd0TYmx9IuOr2DLtEsFW2mJR3oqYCKA8TGw+vpIP/JAeu4EgyDJDSxIIfDFuEmKqYl knyytQJVEtnB9yLXebT97Ha05eKUSw3TNH8xoA/OToOHypas2+wJ85hpRahEZlj+tsinCJr AlUD2tMQGJCD7Jdf7XVhkeCYgkC2LZAl8OhUsZxXb+faMp2yrFmPuPTGICGDqyBv6GrXCoH hILRRS1oV0tZsnxLw8AqQ3kf4zyDNvrsBGBIcWy1eWX5D3ezPDovQne7aFq8/HgtE+ZQbRL cBw1crUT1ybMPe0mJIBC+mV23llEUTde72+/8LN2pDvo9uR2JeYp1JXwIrSA== Received: from [172.18.0.3] (unknown [172.18.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 75B246913E9; Fri, 20 Feb 2026 21:39:53 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1771616378; b=N+9L2kuHhQNzhUHm9d4Xki92QWwq/eRJyk+7p4dHrnoQQyTymCwBj4GsIlqtjGckxOtL1 MoN68ItLvMM22r2rpO7Jhln7pNlHjvNT0CSSE5SlyVpcdeUP/jVGCk0WPWvlkJk5QxaSZHE EcemyNv2tbOL3JuQWnXY+mmlOKOIrYE5IxUmVWgS0E72F3YxcOFyo2mybz0HEWmWn4Dq8ak fSf/bv1c8jY+Zipi9hXiUwRFziGwNohayUXPPt8lcWohBidgnRIblqSZJMyAqurKCgsVI0z 9ti/tZstebtQv8ia99Qm71OJ+5i/D1btbFCW20hSHNe52NdnRwaXO8CD+Tvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1771616378; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=dbyDPX522w0PV7bHsFxWHh3/CveoRFtdPZHXnoAKh6M=; b=ceSw2b/c8WtaR7UtMweohb19lL2gtsO6mbG722fY7CpsJrAU5Myvtq587P+5GvyR0pu/M XoimcSv6IE9I5YzB4l0Kq4In9F9lesQqrGKyIxOIAZ4ySXFEL6f9/xoLSecCaOVpfPtdfe2 rnykzQVDXJSQTfsCUmAtkpXsTMupcKUwV7ZRECRrf7Js62KJGL+oJxPqTW+HWEaTmUmZSUi 8qQXyAHxuAbsWfkR99GsmJkNmPlkt4i4/YgpZfgR2CCo2XQD+rrXTN0pHQQ8WkX2XtuTUQv +89bSIPWc482mUfNCyfucEzDk36MXvGEVYtv1nthQNhzRsLJUeen16rjtsiw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771616356; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=/Y1mwkBWfOH0ZqsAuujSPpCLVgwu0act2ewHK/7ohSU=; b=MnmNqydZTHCtEIXLOVX+amrM9vxjIssE3p0l6DCtX/+X2JNTM/ytuXb1gn/t50xm1fLoO cDM5ImmAl3o8Tp+idVpGhJcwnKFYQjM5WRaGsjixcQZ8lyLKUrC6x+lwjn8ivR8JtaaqyoM HOI8K5M/tzSiM/uJYQM+cSXFy5L4NvhG6zaQqfCCpVVl8yHqvTl572Wj0+boDI/ha5sTd+n PsFQs+pFTsSpILUElxGBcZ4LVjzmEjzejjO9ZoYZ52bncCDV/OecQrfCcxfTaKuI1mOgrXU 7RzP61ngnWubQZZjMyXYZuhQgRrkXjJpnjrtFoSKyVMHlg2ileM5xWiIpkhw== MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Feb 2026 19:39:15 -0000 Message-ID: <177161635631.25.5244601111712529814@29965ddac10e> Message-ID-Hash: PUM3ML65KP7J26U2GVDTFRPBOVHFI2D7 X-Message-ID-Hash: PUM3ML65KP7J26U2GVDTFRPBOVHFI2D7 X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] WIP Fix regration after c3aea7628c (PR #22234) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Daniil Cherednik via ffmpeg-devel Cc: Daniil Cherednik Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #22234 opened by Daniil Cherednik (dcherednik) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22234 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22234.patch Commit c3aea7628c changes frame size. But the encoder and psy code expected frame size was 120 samples. >>From 2eac3c5ce7a3ea956b8231a6246fcbfd781a4b27 Mon Sep 17 00:00:00 2001 From: Daniil Cherednik Date: Fri, 20 Feb 2026 00:40:14 +0200 Subject: [PATCH] Fix regration after c3aea7628c Commit c3aea7628c changes frame size. But the encoder and psy code expected frame size was 120 samples. --- libavcodec/opus/enc.c | 7 +++++-- libavcodec/opus/enc_psy.c | 23 ++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/libavcodec/opus/enc.c b/libavcodec/opus/enc.c index 587e4ed69d..f1775bc653 100644 --- a/libavcodec/opus/enc.c +++ b/libavcodec/opus/enc.c @@ -130,9 +130,12 @@ static void celt_frame_setup_input(OpusEncContext *s, CeltFrame *f) for (int ch = 0; ch < f->channels; ch++) { CeltBlock *b = &f->block[ch]; - const void *input = cur->extended_data[ch]; + const char *input = cur->extended_data[ch]; size_t bps = av_get_bytes_per_sample(cur->format); - memcpy(b->overlap, input, bps*cur->nb_samples); + /* The MDCT overlap is always CELT_OVERLAP samples taken from the end of + * the previous frame, regardless of the encoder's frame_size. */ + memcpy(b->overlap, input+(cur->nb_samples - CELT_OVERLAP)*bps, + CELT_OVERLAP*bps); } av_frame_free(&cur); diff --git a/libavcodec/opus/enc_psy.c b/libavcodec/opus/enc_psy.c index 250cfb567a..08f1ec57c9 100644 --- a/libavcodec/opus/enc_psy.c +++ b/libavcodec/opus/enc_psy.c @@ -258,7 +258,8 @@ int ff_opus_psy_process(OpusPsyContext *s, OpusPacketInfo *p) void ff_opus_psy_celt_frame_init(OpusPsyContext *s, CeltFrame *f, int index) { int i, neighbouring_points = 0, start_offset = 0; - int radius = (1 << s->p.framesize), step_offset = radius*index; + int steps_per_frame = OPUS_BLOCK_SIZE(s->p.framesize) / s->avctx->frame_size; + int step_offset = steps_per_frame*index; int silence = 1; f->start_band = (s->p.mode == OPUS_MODE_HYBRID) ? 17 : 0; @@ -266,8 +267,8 @@ void ff_opus_psy_celt_frame_init(OpusPsyContext *s, CeltFrame *f, int index) f->channels = s->avctx->ch_layout.nb_channels; f->size = s->p.framesize; - for (i = 0; i < (1 << f->size); i++) - silence &= s->steps[index*(1 << f->size) + i]->silence; + for (i = 0; i < steps_per_frame; i++) + silence &= s->steps[index*steps_per_frame + i]->silence; f->silence = silence; if (f->silence) { @@ -282,8 +283,8 @@ void ff_opus_psy_celt_frame_init(OpusPsyContext *s, CeltFrame *f, int index) } } - for (i = start_offset; i < FFMIN(radius, s->inflection_points_count - start_offset); i++) { - if (s->inflection_points[i] < (step_offset + radius)) { + for (i = start_offset; i < FFMIN(steps_per_frame, s->inflection_points_count - start_offset); i++) { + if (s->inflection_points[i] < (step_offset + steps_per_frame)) { neighbouring_points++; } } @@ -316,6 +317,7 @@ static void celt_gauge_psy_weight(OpusPsyContext *s, OpusPsyStep **start, { int i, f, ch; int frame_size = OPUS_BLOCK_SIZE(s->p.framesize); + int steps_per_frame = frame_size / s->avctx->frame_size; float rate, frame_bits = 0; /* Used for the global ROTATE flag */ @@ -329,7 +331,7 @@ static void celt_gauge_psy_weight(OpusPsyContext *s, OpusPsyStep **start, for (i = 0; i < CELT_MAX_BANDS; i++) { float weight = 0.0f; float tonal_contrib = 0.0f; - for (f = 0; f < (1 << s->p.framesize); f++) { + for (f = 0; f < steps_per_frame; f++) { weight = start[f]->stereo[i]; 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]; @@ -425,6 +427,7 @@ static void celt_search_for_intensity(OpusPsyContext *s, CeltFrame *f) static int celt_search_for_tf(OpusPsyContext *s, OpusPsyStep **start, CeltFrame *f) { int i, j, k, cway, config[2][CELT_MAX_BANDS] = { { 0 } }; + int steps_per_frame = OPUS_BLOCK_SIZE(f->size) / s->avctx->frame_size; float score[2] = { 0 }; for (cway = 0; cway < 2; cway++) { @@ -439,7 +442,7 @@ static int celt_search_for_tf(OpusPsyContext *s, OpusPsyStep **start, CeltFrame for (i = 0; i < CELT_MAX_BANDS; i++) { float iscore0 = 0.0f; float iscore1 = 0.0f; - for (j = 0; j < (1 << f->size); j++) { + for (j = 0; j < steps_per_frame; j++) { 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]; @@ -480,7 +483,7 @@ int ff_opus_psy_celt_frame_process(OpusPsyContext *s, CeltFrame *f, int index) void ff_opus_psy_postencode_update(OpusPsyContext *s, CeltFrame *f) { int i, frame_size = OPUS_BLOCK_SIZE(s->p.framesize); - int steps_out = s->p.frames*(frame_size/120); + int steps_out = s->p.frames*(frame_size/s->avctx->frame_size); void *tmp[FF_BUFQUEUE_SIZE]; float ideal_fbits; @@ -522,7 +525,9 @@ av_cold int ff_opus_psy_init(OpusPsyContext *s, AVCodecContext *avctx, s->options = options; s->avctx = avctx; s->bufqueue = bufqueue; - s->max_steps = ceilf(s->options->max_delay_ms/2.5f); + s->max_steps = ceilf(s->options->max_delay_ms * avctx->sample_rate / + (1000.0f * avctx->frame_size)); + s->bsize_analysis = CELT_BLOCK_960; s->avg_is_band = CELT_MAX_BANDS - 1; s->inflection_points_count = 0; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org