From patchwork Wed Jun 19 23:45: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: 13619 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 92A01448AA5 for ; Thu, 20 Jun 2019 02:55:28 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 78C6A68AAC2; Thu, 20 Jun 2019 02:55:28 +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 D326D68A0C7 for ; Thu, 20 Jun 2019 02:55:25 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id n4so1058084wrs.3 for ; Wed, 19 Jun 2019 16:55:25 -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=k7gsQ7sgG8A43uzOe3r0EKFINc57CGFDSULQ+QN0O7o=; b=plDqTJaNM2UXAXmVJ4c/9bJOMQJo1NlPfKa7sF3pU9ytG5eg6WNyDIArX9LC9VKqIk ou1tdxtMgEBesBUvJuoifL5j1oaAMx6/nyjfN5U4PZUztB7nn1n/G67uUGLC12Rv84Yo 0/ZoT7d5IzzDN6+NM7oNrEU4fsQpumjJcoyIfLpkgNcO4oCdhaVmbchKAw6N7TUoYuQb 4jXG4vKLqLaYctOt6h/ngS9Jed0S4+7Cjx0Fw2komUOmAEuHwZHKdB/hmbxQK6Fswh2Q Z5MUwhhh3ZwMU2HUB61V8RgfqE2bO/fHJZCi8AFhv8A2kQRhLevllFq60IoLFUlV/+oB 0QIA== 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=k7gsQ7sgG8A43uzOe3r0EKFINc57CGFDSULQ+QN0O7o=; b=jK87pXXudgrE7mCcQ3RGQChtx/uo7ySGnXyNYYx4NueQL0I148FLr1L0lvLRNgFzcX GjyPxigkj8w1dGLdVaccTDAA2zg4aIepveKRAPtvsNnkgwTwIv78JR6Zfim4trN//gII Oto930z4u/8dVVLJETW8Cf7NKVS18GhUzphXvBor7kTMkf6n8d6yP0EWh8bX6tENv4KO Jh4lGWncZ381wmSC5TIH6sce2496pkbsjtLoHD4qPtrKO3Khfz60JCuoLfiaPMOXwEir DtIi+UGR1Hsi2eVfOyWnPMet4sn4aRDLIA2fGmZh5rLZjToj8lEAQ3TQawRinKIYmon3 lztQ== X-Gm-Message-State: APjAAAVwVUIVM6SE5iJhFrNBK/5zPOM262T3tGqVnG1pH+XbCwHJsc3h fXoBH5xr5jClDp1kaW9MmxzLwbA1 X-Google-Smtp-Source: APXvYqwjOesmEPIWFCSyIHL65ZxbCZE2eEGNw1cXkB/jffl4Pv+N5KPbP1GI0W9jRF/UpL/a7JQoLA== X-Received: by 2002:a05:6000:12c5:: with SMTP id l5mr10209704wrx.338.1560988525372; Wed, 19 Jun 2019 16:55:25 -0700 (PDT) Received: from localhost.localdomain (ipbcc063db.dynamic.kabel-deutschland.de. [188.192.99.219]) by smtp.gmail.com with ESMTPSA id t63sm2758989wmt.6.2019.06.19.16.55.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 16:55:24 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 20 Jun 2019 01:45:02 +0200 Message-Id: <20190619234521.15619-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190619234521.15619-1-andreas.rheinhardt@gmail.com> References: <20190617034223.21195-1-andreas.rheinhardt@gmail.com> <20190619234521.15619-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/31] 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 | 14 +++++++------- libavcodec/h264_metadata_bsf.c | 21 +++++---------------- 3 files changed, 16 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..117e13e0c7 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,9 @@ 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); + // This call never fails because we already asserted + // that i is a valid index of one of au's units. + ff_cbs_delete_unit(ctx, au, i); } else { cbs_h264_free_sei_payload(&sei->payload[position]); @@ -1672,7 +1674,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 e3c29cc9ad..d760ee3182 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -441,15 +441,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); } } } @@ -473,13 +467,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; }