From patchwork Sun Jul 7 23:14: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: 13849 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 0EB97449BD2 for ; Mon, 8 Jul 2019 02:14:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E8F2C68AEDB; Mon, 8 Jul 2019 02:14:30 +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 8911468AECA for ; Mon, 8 Jul 2019 02:14:30 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id y4so6422359wrm.2 for ; Sun, 07 Jul 2019 16:14:30 -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=UXo21mgNHbq9H0vRGJaLKiJWgY0M+DnplmRM+w9jgP8=; b=tqZJgClLaL8dA0cqqZpYLzGhrNyVLB/vKBKhgWFKD7f+89eM8jx4Rvv983LufvApjR n3Ve+nws3uVPOuIjjNXgO0w5aYpaB8IwI1TPN2OJFrT3InJzH9zHfx7AsvC9aNUyLFM5 YNQ2nX/L17W7NKo2eniRSz1Q4Q1+foWhtK7fmLkAiwjRR6ibVhgL+1TjVDO5kZveM0sV k5MtqkrC+7dk3PkcCQ3XoF5iiPwLJmoE2AAZfppVD8RCgMGz7YFypfCkarX4s1tI3kzC I1SAP63vEWrN9a+bcq/s5nqYbZL8bWTuOEgLSs6v8//HOG4vXjvlPnexM0DviyrKa1wm wb/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=UXo21mgNHbq9H0vRGJaLKiJWgY0M+DnplmRM+w9jgP8=; b=smIxF91TbX+kMn2KPyv8/PkcdbQ+I1pHqBs/j5WQ1pRJclDehIDnwDxEwit45jmzBb EV+3Yl1l1u70CXxfXqK+Ji7MVK4X6xMH0ckkkJldjyYYwDncPWg9YNsryh/MLQ08JLdg Iw8G8sKjeG+0nCb7bJFLizGN1D+vLCHBrMiEDxYZ+Tva8A4huYR4qtCeGSTxiU6k/a0H bsuAK5U/ElNMY8QR9i5TKVW67szwNT3+Zh5UGwrcKUXep2CvyphHB+FSPh3NAUKbd+ea NaFj5lTOJ/vk/jLt9csg+fdImv411xOcLI5pYgVqUFxZD+6U1NwqhjHlMkUt/FqhtJHN paCg== X-Gm-Message-State: APjAAAV8Dr3l2pqRjt0ghDNDzBFlHyW/qFTMBpzcnQpAqTPoW5fNK+kC 8viDsay6CTrqYCBcjEi//SEZK7Ys X-Google-Smtp-Source: APXvYqwBc59C189mnhqKW1k0CJkDlMuBU+rwQtaRq49RqrKws35FMtfenMBKENg188cN6dtJ9zNtGQ== X-Received: by 2002:adf:e8c8:: with SMTP id k8mr14740452wrn.285.1562541269794; Sun, 07 Jul 2019 16:14:29 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b8f.dynamic.kabel-deutschland.de. [188.192.139.143]) by smtp.gmail.com with ESMTPSA id r16sm42557919wrr.42.2019.07.07.16.14.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 07 Jul 2019 16:14:29 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Jul 2019 01:14:02 +0200 Message-Id: <20190707231402.46388-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190707231402.46388-1-andreas.rheinhardt@gmail.com> References: <20190707231402.46388-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/12] 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" Given the recent changes to ff_cbs_delete_unit, it is no longer sensible to use a return value for ff_cbs_h264_delete_sei_message; instead, use asserts to ensure that the required conditions are met and remove the callers' checks for the return value. Also, document said conditions. An assert that is essentially equivalent to the one used in ff_cbs_delete_unit has been removed, too. Signed-off-by: Andreas Rheinhardt --- libavcodec/cbs_h264.h | 11 +++++++---- libavcodec/cbs_h2645.c | 11 ++++------- 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..b39e7480c9 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -478,10 +478,13 @@ 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. + * + * Requires nal_unit to be a unit in access_unit and position to be >= 0 + * and < the payload count of the SEI nal_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 484b145852..b286269913 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; @@ -1662,7 +1662,6 @@ int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, if (&au->units[i] == nal) break; } - av_assert0(i < au->nb_units && "NAL unit not in access unit."); ff_cbs_delete_unit(ctx, au, i); } else { @@ -1673,6 +1672,4 @@ int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, 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 e40baa3371..1c1c340d8f 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -437,15 +437,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); } } } @@ -469,13 +463,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; }