From patchwork Mon Dec 9 22:26:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 16685 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 3444E44AA6E for ; Tue, 10 Dec 2019 00:34:08 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B04868B72D; Tue, 10 Dec 2019 00:34:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D81B68B71D for ; Tue, 10 Dec 2019 00:34:01 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id d16so17896860wre.10 for ; Mon, 09 Dec 2019 14:34:01 -0800 (PST) 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=HIgeJDWfJ1vnzc02OBnUKP7btBdMF133TTYRhoAN5VA=; b=O9Zj65FGuZdfAhPglY05xIs9K2752wm79QOp51WE2yjKPpXgzRFRcuvNDWAhQG6DDk uO7Urc3LZkD+wPiXm+B4XvTFBC6fWQs6tixBCYZsf04Vb594lVzhm01/uGHdi01jnwQo WpCcTg4FpOz5nezIeDrCxjLjhyXoR6B47g9k1Nvh3AnUhIEfK209WS+xziUR08xf4GKy T5qjMGfapmaup+yYm4OKjyP8VeaOWk2Yh0BKe2ZVZnzqV/6/XaV0PeWKd1t3v9dPBSro 2S4Q1cCs0ONCKSmGf1XFEw1zyyaxaIFmGxfesREtxslX/RhcpYbc6U5yozuBDzJKDIEO iE1w== 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=HIgeJDWfJ1vnzc02OBnUKP7btBdMF133TTYRhoAN5VA=; b=HsMkRIj97lvdF139Q5iW2qz2trwCWqXp6WqSpXlPSBFFTZ1zQ0Riekv0WzZKTGuOie dNpvoku7cz3jNR0keSNWwVUlRaadC8WuH0IzxegpPdTFwEIq3YZCJnnKKy/WyvrBauLO gHvMzgDPOVIymHd8Q0rOxmQf1TvuLC0M7wUURllr5UuVvXX1JzurFRnumXkwQtpARsTd j3dHfqiezRR+ct0IjItdWB2rBcIRQKsz31ncnHoPTayuzfuNRtKB443H+QlOcl7R4rvi wjJTht8PaqlOurT2oXHTbdShZJ/ty+4XnPIcjI1Lf4XBgfNyNY81aoehzbLkfi6Y4r42 soMg== X-Gm-Message-State: APjAAAUuloBGLOJbJR6SwvHurg7bI8/eewjcJbSzj6iqeymoryHJkZin kX05iRW/K3odZ0jmw2WZyarfOZFm X-Google-Smtp-Source: APXvYqx1v4AwFcCe3XqbhEcOuK7KM8IxWUi3xO2dbHGZn/yGHabeXq/4qNPzyRFRVUNl4owxGLxU8w== X-Received: by 2002:a5d:49c3:: with SMTP id t3mr4564719wrs.113.1575930840449; Mon, 09 Dec 2019 14:34:00 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08e23.dynamic.kabel-deutschland.de. [188.192.142.35]) by smtp.gmail.com with ESMTPSA id v22sm865893wml.11.2019.12.09.14.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 14:34:00 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 Dec 2019 23:26:02 +0100 Message-Id: <20191209222604.28920-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191209222604.28920-1-andreas.rheinhardt@gmail.com> References: <20191209222604.28920-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/7] avcodec/cbs_h2645: Remove dead code to delete trailing zeroes 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" Trailing zeroes are already discarded when splitting a fragment, which makes the code to remove them when decomposing slices dead code. Signed-off-by: Andreas Rheinhardt --- This of course presupposes that the fragment has been split via cbs_h2645_split_fragment(). And the current code is buggy even when one does not make this assumption: The trailing zeroes should be discarded before one reads the header. And then the GetBitContext needs to reinitialized (otherwise, some of those trailing zeroes might be considered valid data when reading the header). libavcodec/cbs_h2645.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 7c92ae4871..be82a8cd5f 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -857,13 +857,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, pos = get_bits_count(&gbc); len = unit->data_size; - if (!unit->data[len - 1]) { - int z; - for (z = 0; z < len && !unit->data[len - z - 1]; z++); - av_log(ctx->log_ctx, AV_LOG_DEBUG, "Deleted %d trailing zeroes " - "from slice data.\n", z); - len -= z; - } slice->data_size = len - pos / 8; slice->data_ref = av_buffer_ref(unit->data_ref); @@ -1039,13 +1032,6 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, pos = get_bits_count(&gbc); len = unit->data_size; - if (!unit->data[len - 1]) { - int z; - for (z = 0; z < len && !unit->data[len - z - 1]; z++); - av_log(ctx->log_ctx, AV_LOG_DEBUG, "Deleted %d trailing zeroes " - "from slice data.\n", z); - len -= z; - } slice->data_size = len - pos / 8; slice->data_ref = av_buffer_ref(unit->data_ref);