From patchwork Sun Oct 6 05:01:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15522 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 B2B94449159 for ; Sun, 6 Oct 2019 08:10:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9E1A0687FBD; Sun, 6 Oct 2019 08:10:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E0115687FE7 for ; Sun, 6 Oct 2019 08:10:29 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id q9so11426957wrm.8 for ; Sat, 05 Oct 2019 22:10:29 -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=U4UNXIVzHTtFjYdGnZ7BeK81JumixiBhkvAJW9eZSKs=; b=gxNJmHbujtlgC2tb08EUlOLRGDTthWC9T5stfUMMBnHJ6XjjZIBuHgPBGnXm2ABf5P NWsQS3snN9WpeBekQux7FPnSqLyQbSlqMrE/RdvoNCG2GVdfrAOEVVOGUa8Kr7690sH2 QYBAv+WBVjYnQLeig1+pBDGcy8+PafVFAFE3wutmIZBat179Hcc5Uv47LibsU6NRXP4A 8qRseXi4uEIfe/cmecQX8uKfBQ0dRKRlpMW1b2K5gXB5+nbRTdh7ROBAMRAG84MmpQxB AXpGRPQH9GTmqxg7EUBjDVd3b5Sd82uc9MNA+Fu1xjBPQ03txTq96Gea7wmuJjlOHYsi Y45g== 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=U4UNXIVzHTtFjYdGnZ7BeK81JumixiBhkvAJW9eZSKs=; b=Ac8+P/ezhfROnABz3HcqB5sp7bUlIJqzK+WI3WOTlP5CNpxQARhwbgOuzhggynPs4n Xi3767pW5GoKMrvMK3MaRwHnu3tNZgk9DJklxV88iCLleogjYr/3bDVU2s4CBuFXxO0r uw9Es4/RDdc23q2RHqiOOqifEx8FlLIP70q33ZPpAZqLSVazGpLi9qytvldD7dJt36yu i8kYYYre+EIWG6Sc3dE/QvpCwDotj09FGmdRgTbHs64Iq3ABpYh7YUcR+xbOMoW6BKNa OWQKKnTGceOQX6UnEkKxfAETmsOyg8DALZdGvzPG2BWZPZHBWqLAvLnQ9RUCP53+pRQ5 JT8g== X-Gm-Message-State: APjAAAUWvQ3v8X1IUbaC/MdJJAdQq3zKBwx9tJJY2NFbeXT8xqVTrpk9 pIu0WzsWUxY+n6wJCu3srA5cjwQSVm8= X-Google-Smtp-Source: APXvYqz7EB9luAcFjUv5HhKnFiDpA0oIpRVh6sPcMkSetlAcqs9GADrE0rlT6csRD1F4PMeGtVBkRA== X-Received: by 2002:adf:cc87:: with SMTP id p7mr17501265wrj.43.1570338629219; Sat, 05 Oct 2019 22:10:29 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08937.dynamic.kabel-deutschland.de. [188.192.137.55]) by smtp.gmail.com with ESMTPSA id s10sm18543014wmf.48.2019.10.05.22.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2019 22:10:28 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 6 Oct 2019 07:01:17 +0200 Message-Id: <20191006050120.26807-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191006050120.26807-1-andreas.rheinhardt@gmail.com> References: <20191006050120.26807-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/10] avcodec/flac_parser: Remove superfluous checks 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" For a parser, the input buffer is always != NULL: In case of flushing, the indicated size of the input buffer will be zero and the input buffer will point to a zeroed buffer of size 0 + AV_INPUT_BUFFER_PADDING. Therefore one does not need to check for whether said buffer is NULL or not. Signed-off-by: Andreas Rheinhardt --- libavcodec/flac_parser.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 8c61f3a88c..1dcb3ef2db 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -584,17 +584,16 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, } /* Find and score new headers. */ - /* buf_size is to zero when padding, so check for this since we do */ + /* buf_size is zero when flushing, so check for this since we do */ /* not want to try to read more input once we have found the end. */ - /* Note that as (non-modified) parameters, buf can be non-NULL, */ - /* while buf_size is 0. */ - while ((buf && buf_size && read_end < buf + buf_size && + /* Also note that buf can't be NULL. */ + while ((buf_size && read_end < buf + buf_size && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) - || ((!buf || !buf_size) && !fpc->end_padded)) { + || (!buf_size && !fpc->end_padded)) { int start_offset; /* Pad the end once if EOF, to check the final region for headers. */ - if (!buf || !buf_size) { + if (!buf_size) { fpc->end_padded = 1; buf_size = MAX_FRAME_HEADER_SIZE; read_end = read_start + MAX_FRAME_HEADER_SIZE; @@ -624,7 +623,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, goto handle_error; } - if (buf && buf_size) { + if (buf_size) { av_fifo_generic_write(fpc->fifo_buf, (void*) read_start, read_end - read_start, NULL); } else { @@ -647,7 +646,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, fpc->nb_headers_buffered = nb_headers; /* Wait till FLAC_MIN_HEADERS to output a valid frame. */ if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) { - if (buf && read_end < buf + buf_size) { + if (read_end < buf + buf_size) { read_start = read_end; continue; } else { @@ -682,7 +681,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, if (fpc->best_header && fpc->best_header->max_score <= 0) { // Only accept a bad header if there is no other option to continue - if (!buf_size || !buf || read_end != buf || fpc->nb_headers_buffered < FLAC_MIN_HEADERS) + if (!buf_size || read_end != buf || fpc->nb_headers_buffered < FLAC_MIN_HEADERS) fpc->best_header = NULL; }