From patchwork Sat May 30 16:05:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20015 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 A3DCA44AA6F for ; Sat, 30 May 2020 19:10:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6727F68B14F; Sat, 30 May 2020 19:06:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6570668B0DF for ; Sat, 30 May 2020 19:06:45 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id h5so1248454wrc.7 for ; Sat, 30 May 2020 09:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/O0m7X+li93e8fyS21wjbh7p1NDVkH2w02nyej6svMA=; b=oYJRuOcyD8zDZx75+WGxu7n8iYGbXRJU+PiVQYBB8HEGNDbyOsgTUFfnrLq5PH31n7 5BaLcZq6sRKrT1qC/YP+quduDTV841DSx+04eWaa+mZcF9BMa6BAFuq1r6bvRmme3iEW 4NuNUxPh9Nvtg1h+HJZqT3dCdl67KhcXChMdOSZVlN3++MXpP2bJD4h8jbBag4tdo2zH Kr0pim0yZ0IGQ41pZYmNnBfZ/OhcrR5BiEKNAdBY0jRY/0khY1Amsvet1+/Q2jBERN4Z 0h45B9QDnAd8g4E0Uf1A0YKHtvUgjmq1PRKXcLcNJpMtTTkxAKez7nu8691Lq3aiHzIY of+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/O0m7X+li93e8fyS21wjbh7p1NDVkH2w02nyej6svMA=; b=dcuJRVpjCdULPEzEh0bGkfi52Hyk9hEBMCvj04WOSk+Espp87gt4PZWrTiL949hkBy eO2VnGWMXyq2wIU81HNk8Cq6chR8pd4tqUq6a8VHYup75MNPipAS/i0v/SwnWOmrVwsS nnNVpivfJe6lNPeZK7y04BIeF578SVoMN+8RyFNMCGPP/D6rB1N2Ee5TSTfromvgIIKr XK24whnttnzRvH+BJKF7FFxpdUcL4Zw0C8xSKEQB9/9kX8K/L82EQOK0G0kX9YFhSgY8 VMdiHI8AcdRL9Jika3XD7t3V4QLdkyC0HJOP3AdvGlgvnqvUAVdUsqf41+rF+PD10qnJ QbxQ== X-Gm-Message-State: AOAM531RoR8G9+Sx3lKv6qHReK/mu4m9QRj0SdAYyyqzPcNxPf1nvvEU kkkw2ZLykPY6uzGuM1doBj/q5cwU X-Google-Smtp-Source: ABdhPJxEV8SI/2SVrncZ5n1afmUGrDdn6LJoq/bio5jd/UyOvrX2kb7bU1CuxzJloFdDt6PnaE33HA== X-Received: by 2002:a5d:4d01:: with SMTP id z1mr14988283wrt.29.1590854804537; Sat, 30 May 2020 09:06:44 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id v27sm15186517wrv.81.2020.05.30.09.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 09:06:43 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 May 2020 18:05:32 +0200 Message-Id: <20200530160541.29517-27-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> References: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 27/36] avcodec/mjpega_dump_header_bsf: Cosmetics 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Reindentation; furthermore, the names of the out and out_buf variables have been switched: The latter is now an AVBufferRef * whereas the former is directly used for writing. And some variables have been put into a smaller scope. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpega_dump_header_bsf.c | 50 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/libavcodec/mjpega_dump_header_bsf.c b/libavcodec/mjpega_dump_header_bsf.c index 2d49b042ec..4ea55e88ba 100644 --- a/libavcodec/mjpega_dump_header_bsf.c +++ b/libavcodec/mjpega_dump_header_bsf.c @@ -33,15 +33,14 @@ static int mjpega_dump_header(AVBSFContext *ctx, AVPacket *pkt) { - uint8_t *out_buf; unsigned dqt = 0, dht = 0, sof0 = 0; - int ret = 0, i; + int ret; ret = ff_bsf_get_packet_ref(ctx, pkt); if (ret < 0) return ret; - for (i = 0; i < pkt->size - 3; i++) { + for (int i = 0; i < pkt->size - 3; i++) { if (pkt->data[i] == 0xff) { switch (pkt->data[i + 1]) { case DQT: dqt = i + 46U; break; @@ -49,31 +48,32 @@ static int mjpega_dump_header(AVBSFContext *ctx, AVPacket *pkt) case SOF0: sof0 = i + 46U; break; case SOS: { - AVBufferRef *out = NULL; + AVBufferRef *out_buf = NULL; + uint8_t *out; - ret = ff_buffer_padded_realloc(&out, pkt->size + 44U); - if (ret < 0) - goto fail; + ret = ff_buffer_padded_realloc(&out_buf, pkt->size + 44U); + if (ret < 0) + goto fail; - out_buf = out->data; - bytestream_put_byte(&out_buf, 0xff); - bytestream_put_byte(&out_buf, SOI); - bytestream_put_byte(&out_buf, 0xff); - bytestream_put_byte(&out_buf, APP1); - bytestream_put_be16(&out_buf, 42); /* size */ - bytestream_put_be32(&out_buf, 0); - bytestream_put_buffer(&out_buf, "mjpg", 4); - bytestream_put_be32(&out_buf, pkt->size + 44U); /* field size */ - bytestream_put_be32(&out_buf, pkt->size + 44U); /* pad field size */ - bytestream_put_be32(&out_buf, 0); /* next ptr */ - bytestream_put_be32(&out_buf, dqt); /* quant off */ - bytestream_put_be32(&out_buf, dht); /* huff off */ - bytestream_put_be32(&out_buf, sof0); /* image off */ - bytestream_put_be32(&out_buf, i + 46U); /* scan off */ - bytestream_put_be32(&out_buf, i + 46U + AV_RB16(pkt->data + i + 2)); /* data off */ - bytestream_put_buffer(&out_buf, pkt->data + 2, pkt->size - 2); /* skip already written SOI */ + out = out_buf->data; + bytestream_put_byte(&out, 0xff); + bytestream_put_byte(&out, SOI); + bytestream_put_byte(&out, 0xff); + bytestream_put_byte(&out, APP1); + bytestream_put_be16(&out, 42); /* size */ + bytestream_put_be32(&out, 0); + bytestream_put_buffer(&out, "mjpg", 4); + bytestream_put_be32(&out, pkt->size + 44U); /* field size */ + bytestream_put_be32(&out, pkt->size + 44U); /* pad field size */ + bytestream_put_be32(&out, 0); /* next ptr */ + bytestream_put_be32(&out, dqt); /* quant off */ + bytestream_put_be32(&out, dht); /* huff off */ + bytestream_put_be32(&out, sof0); /* image off */ + bytestream_put_be32(&out, i + 46U); /* scan off */ + bytestream_put_be32(&out, i + 46U + AV_RB16(pkt->data + i + 2)); /* data off */ + bytestream_put_buffer(&out, pkt->data + 2, pkt->size - 2); /* skip already written SOI */ - ff_packet_replace_buffer(pkt, out); + ff_packet_replace_buffer(pkt, out_buf); return 0; } case APP1: