From patchwork Mon Jun 17 03:42:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13582 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 AEDBB447E9D for ; Mon, 17 Jun 2019 06:52:06 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9954868A77E; Mon, 17 Jun 2019 06:52:06 +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 86032689D68 for ; Mon, 17 Jun 2019 06:51:59 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id r16so8231092wrl.11 for ; Sun, 16 Jun 2019 20:51:59 -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=T+RAjspVmQKIooQbBxlShWbPGPJispxq4YWOsn3OWYU=; b=BqIG0NDMZTfyhzJi4JoQM/RBv00IbMdrsHNArK8SqA4iKUrLySoXHV8HwEQrZwQwUQ BbtKyqZhugs3KCTB0na1TXNnpxiqaD6jHG9LZmBa/FCxQLWZMegcjsmAg7S+tU0tK9km KSSo65sK4ygl4q34pJfUO4/qEr6gPD311EO7I3/8kt+kb/ZqNjN0ph1c1v+cAAnvuMZz Y0AGaCovGnOVJF6BmiINrc+Y8saAlE1nczayq1rgu0Gpimcz6t83X/oUkdmI7IPjSHg8 wIhN0rCBx7crv25izX4xJFcqAM6G5w8C2FvPKan9QBhpZvnoETIlupfVoTgdd9hBJc/f m3+g== 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=T+RAjspVmQKIooQbBxlShWbPGPJispxq4YWOsn3OWYU=; b=bDVXospcRH2I+7XAgSwyqEkp7byofG6C6UZQ4dYhh3RxP+ndVw19m1z8/vYaSM9AvA Gi4/R0boZeKSwkDJa3GQEk28Ktl/UhEX4MCd1hgTyyPhgb+qAHYoFcWwGYTRBOkAypKj aIfdH04wicbRBNkOFY1CemQFwSV0uIUA5rYiqzJfxkeJDNjRo49CdV4d6lD1UtTjJz3u 5cV9WGuDNDkkeO8sYk+hVTf+miZxB1s6nPQU5AlWY3T3kiYMERlW4HMjjYjm6QoF6hFH 3LQzHQMZLhxz+yzEY3QweACldF7gzOgcPtO4ro9btKDkvCXXG65yNq8hrusmGTTr5fUH rwsw== X-Gm-Message-State: APjAAAXTNHnOmlvRKUyURxSwIo6NR996/KKc3kiVYhHcRE92B12p2Fbf iRZzZhPX6IbK4JAuxMHZJB6TLnoe X-Google-Smtp-Source: APXvYqwMqEA4rkUKkwBXdeMfFc314z9AxxFRAxXmfMIOOivqBZbFDTGzIakRFpeNV8xhat0yXVnApQ== X-Received: by 2002:adf:c614:: with SMTP id n20mr16023865wrg.17.1560743042035; Sun, 16 Jun 2019 20:44:02 -0700 (PDT) Received: from localhost.localdomain (ipbcc063db.dynamic.kabel-deutschland.de. [188.192.99.219]) by smtp.gmail.com with ESMTPSA id x83sm9632889wmb.42.2019.06.16.20.44.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 16 Jun 2019 20:44:01 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jun 2019 05:42:16 +0200 Message-Id: <20190617034223.21195-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190617034223.21195-1-andreas.rheinhardt@gmail.com> References: <20190617034223.21195-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/18] cbs_h264, h264_metadata: Deleting SEI messages never fails 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" Deleting a unit from a fragment in CBS only fails if there is no unit in the fragment corresponding to the position given as argument to ff_cbs_delete_unit. Given that ff_cbs_h264_delete_sei_message asserts this to be so, we know that the call to ff_cbs_delete_unit can never fail and hence ff_cbs_h264_delete_sei_message doesn't need a return value at all. The existing checks for these return values can be deleted. Signed-off-by: Andreas Rheinhardt --- libavcodec/cbs_h264.h | 8 ++++---- libavcodec/cbs_h2645.c | 12 +++++------- libavcodec/h264_metadata_bsf.c | 21 +++++---------------- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index a31be298ba..f63c19ffc0 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -479,9 +479,9 @@ int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, * Deletes from nal_unit, which must be an SEI NAL unit. If this is the * last message in nal_unit, also deletes it from access_unit. */ -int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, - CodedBitstreamFragment *access_unit, - CodedBitstreamUnit *nal_unit, - int position); +void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, + CodedBitstreamFragment *access_unit, + CodedBitstreamUnit *nal_unit, + int position); #endif /* AVCODEC_CBS_H264_H */ diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 0456937710..a3bad83736 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1644,10 +1644,10 @@ int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, return 0; } -int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, - CodedBitstreamFragment *au, - CodedBitstreamUnit *nal, - int position) +void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, + CodedBitstreamFragment *au, + CodedBitstreamUnit *nal, + int position) { H264RawSEI *sei = nal->content; @@ -1664,7 +1664,7 @@ int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, } av_assert0(i < au->nb_units && "NAL unit not in access unit."); - return ff_cbs_delete_unit(ctx, au, i); + ff_cbs_delete_unit(ctx, au, i); } else { cbs_h264_free_sei_payload(&sei->payload[position]); @@ -1672,7 +1672,5 @@ int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, memmove(sei->payload + position, sei->payload + position + 1, (sei->payload_count - position) * sizeof(*sei->payload)); - - return 0; } } diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index d05b75be14..c7969f1152 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -438,15 +438,9 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) for (j = sei->payload_count - 1; j >= 0; j--) { if (sei->payload[j].payload_type == - H264_SEI_TYPE_FILLER_PAYLOAD) { - err = ff_cbs_h264_delete_sei_message(ctx->cbc, au, - &au->units[i], j); - if (err < 0) { - av_log(bsf, AV_LOG_ERROR, "Failed to delete " - "filler SEI message.\n"); - goto fail; - } - } + H264_SEI_TYPE_FILLER_PAYLOAD) + ff_cbs_h264_delete_sei_message(ctx->cbc, au, + &au->units[i], j); } } } @@ -470,13 +464,8 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) if (ctx->display_orientation == REMOVE || ctx->display_orientation == INSERT) { - err = ff_cbs_h264_delete_sei_message(ctx->cbc, au, - &au->units[i], j); - if (err < 0) { - av_log(bsf, AV_LOG_ERROR, "Failed to delete " - "display orientation SEI message.\n"); - goto fail; - } + ff_cbs_h264_delete_sei_message(ctx->cbc, au, + &au->units[i], j); continue; }