From patchwork Sun Jan 10 22:11:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Da Silva X-Patchwork-Id: 24888 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 26E6044990B for ; Mon, 11 Jan 2021 00:11:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ED25A68AAE8; Mon, 11 Jan 2021 00:11:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx0-10.i-mecca.net (mx0-10.i-mecca.net [76.74.184.244]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D36AA68A7DD for ; Mon, 11 Jan 2021 00:11:42 +0200 (EET) Received: from mx0.ehosting.ca (localhost [127.0.0.1]) by mx0.i-mecca.net (Postfix) with ESMTP id 0A27E16158F for ; Sun, 10 Jan 2021 14:11:41 -0800 (PST) Received: from ns2.i-mecca.net (unknown [192.168.1.2]) by mx0.i-mecca.net (Postfix) with ESMTP id 6B175161571 for ; Sun, 10 Jan 2021 14:11:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joescat.com; s=mail; h=date:from:to:subject; bh=g7inpk8B5lGJwt2GZe+F+M4rNlsn24JVe3wNP9NIZTs=; b=GzXLRMNeWjFaEuyD34ULNKsDtEoM+ZMZhJVOKkHwlFGotYappVp5HNU+B8D4agdtU1 b6x0AyhCPGkxsniynVp9rfcfdYgtKfkQa9Ud8m+5v+PEK/S3Ksvp1sFzvyaJv0j1yNjC 9qSngIysYSsM1FOoeaPgbuwxmcyiS1Qr9ZX6d8nwo5jlpx6zpMVNBLT9eRE4v53zAkxM KUwUs25C8f/h+GXLMjdLFa8WDYT1jPMtVMUPpnLN8dwZ7aeJ3TWJOzY2ZrnSuZjlyanL c35k0hUyx0khaM2dDV2ClMpFgBG1brZ04Rg1298fPGdCpK/VRp2gHOpT4JaTqKTelm/C Wauw== X-MES: 1.0 X-MM: 1.0 Received: from drived.localnet (d66-183-117-75.bchsia.telus.net [66.183.117.75]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ns2.i-mecca.net (Postfix) with ESMTPSA id 6DBC43001FA for ; Sun, 10 Jan 2021 17:11:39 -0500 (EST) From: Jose Da Silva To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Jan 2021 14:11:39 -0800 User-Agent: KMail/1.13.7 (Linux/2.6.38.8-desktop586-10.mga; KDE/4.6.5; i686; ; ) MIME-Version: 1.0 Message-Id: <202101101411.39756.digital@joescat.com> Subject: [FFmpeg-devel] [PATCH] avcodec/xbmenc: Better xbm memory use X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Small memory reduction which uses approx 6/7th total memory. Assuming \n is 2bytes, we first need {32+33+40+5}=110 but we also need to include the terminating zero => 110+1 = 111 (bug-fix). Then assuming \n is 2bytes, data requires => height * (linesize * 6 + 2) For example, " 0x00, 0x11, 0x22,\n" Subject: [PATCH] avcodec/xbmenc: Better xbm memory use Small memory reduction which uses approx 6/7th total memory. Assuming \n is 2bytes, we first need {32+33+40+5}=110 but we also need to include the terminating zero => 110+1 = 111 Assuming \n is 2bytes, data requires => height * (linesize * 6 + 2) For example, " 0x00, 0x11, 0x22,\n" Signed-off-by: Joe Da Silva --- libavcodec/xbmenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index b25615f2a4..9222947893 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -31,7 +31,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t *ptr, *buf; linesize = (avctx->width + 7) / 8; - size = avctx->height * (linesize * 7 + 2) + 110; + size = avctx->height * (linesize * 6 + 2) + 111; if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) return ret;