From patchwork Tue Jan 19 05:43:05 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: 25034 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 3842D4496CE for ; Tue, 19 Jan 2021 07:43:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1DCAC6881E5; Tue, 19 Jan 2021 07:43:15 +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 8C54B6806FE for ; Tue, 19 Jan 2021 07:43:08 +0200 (EET) Received: from mx0.ehosting.ca (localhost [127.0.0.1]) by mx0.i-mecca.net (Postfix) with ESMTP id 12AC4161749 for ; Mon, 18 Jan 2021 21:43:07 -0800 (PST) Received: from ns2.i-mecca.net (unknown [192.168.1.2]) by mx0.i-mecca.net (Postfix) with ESMTP id 71319161748 for ; Mon, 18 Jan 2021 21:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joescat.com; s=mail; h=date:from:to:subject; bh=VbhRjq1tyTwRsaFwXQrhFRG8TohZmQrHEe9CjOJFTu4=; b=LgyBLJdK3r0OBoY0gg4IxjblTbYv37GZo1GEbTwda+KyU4C7WkSzu8HOrmX6deWA9+ rNA0v2McHrAaGBPhb+5YFMAsApYu92FmCdtWPIqa4fye74rEHleY3IWntTr1HqufEOns 4r04SAeGMYjVEI95fxXtuD6jIyZbfvMamb8E1d3txFWgq8Yg4yUehML7ohPczAUHkKd/ ZWyuFp0241D4J1qnAoSFAa7t/hIzFe/07tjFTiFmK19LEsK2Rr1qEHxuaA+T+NRmGCvh xs4ueBJL7RsARys2pIpqnsLBLwSMgPji2yAzzcZFh33YpJfXkM0Qwgving8uicVxo8YQ 1wRQ== 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 EEC323001F6 for ; Tue, 19 Jan 2021 00:43:04 -0500 (EST) From: Jose Da Silva To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Jan 2021 21:43:05 -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: <202101182143.05604.digital@joescat.com> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/xbmenc: xbm Lower 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" Two minor memory improvements. First bug reduces memory needed to about 6/7 the needed amount, which allows you to host almost 7 pictures in the same memory needed for 6 Second is a recalculation of the total additional memory for headers etc. size = avctx->height x (linesize * 6 + 1) + (31+32+38+4+1) Subject: [PATCH 2/3] avcodec/xbmenc: xbm Lower memory use Small 6/7th size memory reduction. size = avctx->height x (linesize * 6 + 1) + (31+32+38+4+1) Signed-off-by: Joe Da Silva --- libavcodec/xbmenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index 3fc0e3185a..193ced652a 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -32,7 +32,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, linesize = (avctx->width + 7) / 8; commas = avctx->height * linesize; - size = avctx->height * (linesize * 7 + 2) + 109; + size = avctx->height * (linesize * 6 + 1) + 106; if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) return ret; @@ -41,7 +41,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, buf += snprintf(buf, 32, "#define image_width %u\n", avctx->width); buf += snprintf(buf, 33, "#define image_height %u\n", avctx->height); - buf += snprintf(buf, 40, "static unsigned char image_bits[] = {\n"); + buf += snprintf(buf, 39, "static unsigned char image_bits[] = {\n"); for (i = 0; i < avctx->height; i++) { for (j = 0; j < linesize; j++) { buf += snprintf(buf, 6, " 0x%02X", ff_reverse[*ptr++]);