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 54DF540C8E for ; Thu, 19 Feb 2026 11:36:45 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'r+dgLnQid1jOg9pRHuGskeusdl7qjeJBIg6Lc0o+EUc=', expected b'2oxaxzeulURaCkLdUAxgvLo0G4rvnM8KKgyphxDbRwQ=')) 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=1771500986; 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=r+dgLnQid1jOg9pRHuGskeusdl7qjeJBIg6Lc0o+EUc=; b=Hlw7ADWGdZkAUcJ3OEdTe3YdfSn1huFaLkJRjTlIzFDjD9Xan6rK+tan97rsyyoO7zs0W aDST7IO7hK1f6inS+2+sa+H1ay5FycR2Xof1ncqFz4oUgQ+Qha4R99/cdYZndRZuq+BgaSD LkXJXvNnMiPHoVOOwPRQ43GBY3cJvEt1G6sjPQ4rHi+UAAfnMXq5QW7X3lp8l/K84G7chP5 Q3rMjOhJHof2CYlSJSba0mHOIB50NBEcPYyTVeGHplWhoyXvTV9/Xkt2jGr/zPGdPZTSK2b LGmuiruO6BQnxtbVSwRwruO8gGU7pQMnZ9rvS0RBKurSwrLJjlBA8yHzYSsg== Received: from [172.18.0.3] (unknown [172.18.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 8A47E6912CD; Thu, 19 Feb 2026 13:36:26 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1771500973; b=aEWVkRFBy+jDDvUT6KSatAq1llHdIBZbj2JYWdI7H1PkulQBOk8xT2na0WKxr2YL1+LAn O6XAgFKyoQsTCGIGLTjYvRgdQScKnrtn+SWSbf4JG1xxxKJpq72S0LArAlccMdE5v/U5h2j Yx6+FfNsS5zALsSNZqC040oA5bZ1pw4W1/QqTR8C8YowkuaiiD0K6ImmeiTbPFnGTTxXHmK xM2YXC/b5iP3CBAI2bwWUfQYn35jp1LirQEdfXK/AigXQ2MkEH/dHOXCLk3B3eLYZeIndr5 5O4s4jA/T5eqEBIdune4dK5HMnM75wtMSCV18pyXqKwyuDGKqfUPgfkX8waw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1771500973; 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=DHj8GmSjeeeD2nw4ODzmC+EG2qxpzW4ynNj/EMwJdKA=; b=QAgMzoSl4g1B0QDoWO1CIuiqBqqhHkKHVdZu4xhPW90mOqqvguziZUpnBTOw44Z2lNxUW A/9GCvAG8Q4m30ASiZBQENnniX7Q2V5PK6J22T027QzW4CQm37Jw86RGNuxxB5tlsKmNaG/ eVsndeqaX0rcTQj4/iA03+0QLzYBuk0clAeQruYULRn5TWzihjcfuWm/HK2C7ZPaB4Ztpvx txuqTxBTa2DbeD4TLEnmNYOLSEoj2sDAnIxLD82do0o4emOCPnTT1eoe1drJIFKgPeqfVZ7 MQyRJY6Wk4u2CvqXky7scwsVRo/gx5a+zBt3XbslcXKthls/O4Xgzz1yQL+g== 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=1771500964; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=2oxaxzeulURaCkLdUAxgvLo0G4rvnM8KKgyphxDbRwQ=; b=O6fy2r0C+w8lcuCK4OBk/tW0n1l2/gDuSHT4woUOptOAJR0L6PJzKdoJdE/jWTMkbyHsE IHxkOugsNVT5zq5UYC7H/tMOCFeqoLr0wdYvaXQjsI6kLvRwnNiRyZzkyqB92Trvt6f5yVT UupvILQTRarM2EoUvVlap8BSx/gKc+pOQpXzeL1iRmGQANJEcJM99Ppw/qdA0/yoHMbnlL1 uVClfjsQYdbSBNldpn5gi9wINilUVW3v4QEFyizu+A1DgyGOxzKeUs/M5U1Mrt9VIoPlMKm NMvuyhkpA+XRC70VI3KH5k6q+Pc2PbnrTjEyvAHpW+D7FwfrB3YHgFE6P93Q== MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Feb 2026 11:36:03 -0000 Message-ID: <177150096419.25.13741924957209540492@29965ddac10e> Message-ID-Hash: XRAQFK7LTFQTRCDECYBLNP5BHOZQEJCJ X-Message-ID-Hash: XRAQFK7LTFQTRCDECYBLNP5BHOZQEJCJ 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] Reduce size of snow allocations (PR #21793) 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: mkver via ffmpeg-devel Cc: mkver Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21793 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21793 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21793.patch >>From 9a1d99a7506414045c6e2b0f5433caa33370bb21 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 9 Feb 2026 14:33:01 +0100 Subject: [PATCH 1/2] avcodec/snow: Only allocate emu_edge_buffer for encoder Also allocate it during init and move it to the encoder's context. Signed-off-by: Andreas Rheinhardt --- libavcodec/snow.c | 6 +----- libavcodec/snow.h | 1 - libavcodec/snowenc.c | 9 ++++++++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 006d84d8ce..094b893c96 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -540,10 +540,7 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) { int plane_index, level, orientation; if(!s->scratchbuf) { - int emu_buf_size; - emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1); - if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) || - !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size)) + if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE)) return AVERROR(ENOMEM); } @@ -642,7 +639,6 @@ av_cold void ff_snow_common_end(SnowContext *s) av_freep(&s->block); av_freep(&s->scratchbuf); - av_freep(&s->emu_edge_buffer); for(i=0; ilast_picture[i]); diff --git a/libavcodec/snow.h b/libavcodec/snow.h index 83dc6c1256..82417c3324 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -168,7 +168,6 @@ typedef struct SnowContext{ slice_buffer sb; uint8_t *scratchbuf; - uint8_t *emu_edge_buffer; AVMotionVector *avmv; unsigned avmv_size; diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 20a41f11a4..f34130f184 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -68,6 +68,8 @@ typedef struct SnowEncContext { uint64_t encoding_error[SNOW_MAX_PLANES]; + uint8_t *emu_edge_buffer; + IDWTELEM obmc_scratchpad[MB_SIZE * MB_SIZE * 12 * 2]; } SnowEncContext; @@ -286,6 +288,10 @@ static av_cold int encode_init(AVCodecContext *avctx) if ((ret = get_encode_buffer(s, s->input_picture)) < 0) return ret; + enc->emu_edge_buffer = av_calloc(avctx->width + 128, 2 * (2 * MB_SIZE + HTAPS_MAX - 1)); + if (!enc->emu_edge_buffer) + return AVERROR(ENOMEM); + if (enc->motion_est == FF_ME_ITER) { int size= s->b_width * s->b_height << 2*s->block_max_depth; for(i=0; imax_ref_frames; i++){ @@ -770,7 +776,7 @@ static int get_block_rd(SnowEncContext *enc, int mb_x, int mb_y, const uint8_t *src = s->input_picture->data[plane_index]; IDWTELEM *pred = enc->obmc_scratchpad + plane_index * block_size * block_size * 4; uint8_t *cur = s->scratchbuf; - uint8_t *tmp = s->emu_edge_buffer; + uint8_t *tmp = enc->emu_edge_buffer; const int b_stride = s->b_width << s->block_max_depth; const int b_height = s->b_height<< s->block_max_depth; const int w= p->width; @@ -2088,6 +2094,7 @@ static av_cold int encode_end(AVCodecContext *avctx) enc->m.s.me.temp = NULL; av_freep(&enc->m.s.me.scratchpad); + av_freep(&enc->emu_edge_buffer); av_freep(&avctx->stats_out); -- 2.52.0 >>From 8de00b910c237943c7956f2851ce2ccf3014091d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 9 Feb 2026 17:57:30 +0100 Subject: [PATCH 2/2] avcodec/snow: Reduce sizeof(SnowContext) Each SubBand currently contains an array of 519 uint8_t[32], yet most of these are unused: For both the decoder and the encoder, at most 34 contexts are actually used: The only variable index is context+2, where context is the result of av_log2() and therefore in the 0..31 range. There are also several accesses using compile-time indices, the highest of which is 30. FATE passes with 31 contexts and maybe these are enough, but I don't know. Reducing the number to 34 reduces sizeof(SnowContext) from 2141664B to 155104B here (on x64). Signed-off-by: Andreas Rheinhardt --- libavcodec/snow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/snow.h b/libavcodec/snow.h index 82417c3324..f8f45b8763 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -92,7 +92,7 @@ typedef struct SubBand{ int stride_line; ///< Stride measured in lines, not pixels. x_and_coeff * x_coeff; struct SubBand *parent; - uint8_t state[/*7*2*/ 7 + 512][32]; + uint8_t state[34][32]; }SubBand; typedef struct Plane{ -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org