From patchwork Wed Sep 12 01:08:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 10295 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp4272472jap; Tue, 11 Sep 2018 18:09:07 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbmXJG6dpCdqkWV9O+/TnBB4k2/U2cj9hNFH4Jms4FTSIjEl7hfGyNQSUxLsGqJi6ruYL7f X-Received: by 2002:adf:f30b:: with SMTP id i11-v6mr20775642wro.161.1536714547147; Tue, 11 Sep 2018 18:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536714547; cv=none; d=google.com; s=arc-20160816; b=ZMz31GonP5ItJqeAnXOaAgLuaNCGWeP8YCSRMz5vm9DC0wKeg/Es8NC+salQaCfdIa orgeasl3I17lufLyiDWxVxcdCz/i0N1SsTuKV3p76TSw+A8Lqk2jctyJz/LItFJyNWIg Qr3b3il8qbMXQuxD8++mE0DZvMSJofJYWGd4/OvCNlVKVkoQL4APl750gB4Fm0mdtWw1 SjYQYE6GzqVGJ0zwC7mt2aLFmfXTjF4i/gDWM96RE335WoYLNIVHHIRFfTLtkqhRMZ/E wt8jM0GFLPe+1mt2WqbVicHYw26v2D13tYsWanrOMhVArBz9g1hciocX9yk6HMoi+pG3 j3sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=Jt6maDJij2oyi+5Jx2GY33aIV+Ip/qw3SQliVqHTXRg=; b=OctvUaqTBaOYazDQKw68zSX9NTfEall+kmkzy9TlCZsOx6PWP+6+Rmimc65rdQQKRY VDzHSLF80w48/U5XWaYrPGyhEb6T7F61qhZYtFQPu5jYoPOscNc6ZroW6QWZX8co5Ppq El7k1So+O286Sdcso5vKukiqSbBF1Ooiz90vyPTjXaIxPb4avomDxgeluBxCOuAB1Oh1 8vH+L3iJZzATrYO5CKb08zE9ppbihnhfKKop/fh+mUwbRl2/bvQNKTncb7fpyPqJMhjp HsbSQsBGf7nEqTGUuzp0IzQGTPARtKgyS7hmoK/PCh+gD00Mskqykf7ghWDKHkepKYAn CNdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h186-v6si1889312wmf.145.2018.09.11.18.09.06; Tue, 11 Sep 2018 18:09:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7531D68A501; Wed, 12 Sep 2018 04:08:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-3.mx.upcmail.net (vie01a-qmta-pe02-3.mx.upcmail.net [62.179.121.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8409168A1AD for ; Wed, 12 Sep 2018 04:08:40 +0300 (EEST) Received: from [172.31.218.43] (helo=vie01a-dmta-pe05-1.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fzteE-0004m1-3r for ffmpeg-devel@ffmpeg.org; Wed, 12 Sep 2018 03:08:50 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fzte8-0005b1-N0 for ffmpeg-devel@ffmpeg.org; Wed, 12 Sep 2018 03:08:44 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id aR8j1y00d0S5wYM01R8kL5; Wed, 12 Sep 2018 03:08:44 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 12 Sep 2018 03:08:07 +0200 Message-Id: <20180912010808.31637-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180912010808.31637-1-michael@niedermayer.cc> References: <20180912010808.31637-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/bintext: Use ff_get_buffer instead of ff_reget_buffer and simplify 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" reget seems unneeded and it is slower Signed-off-by: Michael Niedermayer --- libavcodec/bintext.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c index b14a2a9c29..d85f2c2dd4 100644 --- a/libavcodec/bintext.c +++ b/libavcodec/bintext.c @@ -96,11 +96,6 @@ static av_cold int decode_init(AVCodecContext *avctx) if (avctx->width < FONT_WIDTH || avctx->height < s->font_height) return AVERROR_INVALIDDATA; - - s->frame = av_frame_alloc(); - if (!s->frame) - return AVERROR(ENOMEM); - return 0; } @@ -149,8 +144,9 @@ static int decode_frame(AVCodecContext *avctx, if ((avctx->width / FONT_WIDTH) * (avctx->height / s->font_height) / 256 > buf_size) return AVERROR_INVALIDDATA; + s->frame = data; s->x = s->y = 0; - if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) + if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0) return ret; s->frame->pict_type = AV_PICTURE_TYPE_I; s->frame->palette_has_changed = 1; @@ -208,21 +204,10 @@ static int decode_frame(AVCodecContext *avctx, } } - if ((ret = av_frame_ref(data, s->frame)) < 0) - return ret; *got_frame = 1; return buf_size; } -static av_cold int decode_end(AVCodecContext *avctx) -{ - XbinContext *s = avctx->priv_data; - - av_frame_free(&s->frame); - - return 0; -} - #if CONFIG_BINTEXT_DECODER AVCodec ff_bintext_decoder = { .name = "bintext", @@ -231,7 +216,6 @@ AVCodec ff_bintext_decoder = { .id = AV_CODEC_ID_BINTEXT, .priv_data_size = sizeof(XbinContext), .init = decode_init, - .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, }; @@ -244,7 +228,6 @@ AVCodec ff_xbin_decoder = { .id = AV_CODEC_ID_XBIN, .priv_data_size = sizeof(XbinContext), .init = decode_init, - .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, }; @@ -257,7 +240,6 @@ AVCodec ff_idf_decoder = { .id = AV_CODEC_ID_IDF, .priv_data_size = sizeof(XbinContext), .init = decode_init, - .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, };