From patchwork Sun Feb 21 19:51:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 25863 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 DB6EB449DB5 for ; Sun, 21 Feb 2021 21:53:36 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B004B689246; Sun, 21 Feb 2021 21:53:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0126688050 for ; Sun, 21 Feb 2021 21:53:30 +0200 (EET) Received: by mail-wr1-f41.google.com with SMTP id h98so12093030wrh.11 for ; Sun, 21 Feb 2021 11:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=51jsgz9/gqXvtrugxWgaEf56PaUtND7XaaDIJ13z28g=; b=tpLnLyvlEg5iYQA17u67beKJ0+QxYEhLQRjLQ7Dn1GyBg/VqoZak7LYzmDZKO9nxCe acwoEytOOS8UghtKSK7rFRyy3i1fflHfzwmqVPwXf55s2rpkUPYEgQG9WzK3Atjd44uS 0Fcyv8Q4iLnByBq67WXW3Y5Sg9VpJ5OmUzB6xG8B2pJ3JphInA1AJlVHfLtLB/qepP5I Ww+BEcbeZAT25CcyeojwKLip+qRF3th9FVreaFZuqna9a6x2i2dccubY6sfK+nT7F941 gwsj7On0s0hFQMQ3iv/wske2sUTrPrrmNzvimAsSpDlA7F9zA0Y5gLS4OFo+ba4RcSdj 0WTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=51jsgz9/gqXvtrugxWgaEf56PaUtND7XaaDIJ13z28g=; b=BRs1jq1eA3mW1NUYlz8QX1lMFRtk8olVC8Ihmft8uBcSpTSrvQbJaqkpH+r9m2vV3m hGRhnreprZqKXYvKueqcqaaymX3vW2DLrDgjAiNIFt9WfyZkrYsbnS24dWH8S9/Zk1pM fm9acu8xtEPPFLdptpdgIJCtKZWhaQ1Dl6Y8lVkwDAkP424YieQJfgrxvv8U44j+7d5Q zJfPJgHLnnoGFcty6Gg/rZQ+qAp8OZlkmZhWsv/Pv18mUHsJMxgccMqetkR6/zciMRdm dEDNO+5gAkLGFWd5SnhdNWrxR5X79sxcAG3kJ/CCNCixcGcZoIDrAuXwWB4EQQSKLDKG S1YQ== X-Gm-Message-State: AOAM5336qSSocxDDGSS9IzLFCB2yqfNG4LQw7I3/8Dv43tkDcHE3+DIx w2jHzNKQ8wtTp5T6IE4OnMLgsr39lfTYOQ== X-Google-Smtp-Source: ABdhPJxHZ9ub2q3/wAArlJvh4dTfq2pprru2OOnWa0IJFGn7AmO8MIYuIHsfPsL/EgSVKCOfbLPx4A== X-Received: by 2002:adf:fa4c:: with SMTP id y12mr6375783wrr.427.1613937210279; Sun, 21 Feb 2021 11:53:30 -0800 (PST) Received: from localhost.localdomain (cpc91226-cmbg18-2-0-cust7.5-4.cable.virginm.net. [82.0.29.8]) by smtp.gmail.com with ESMTPSA id z18sm1780372wrs.19.2021.02.21.11.53.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 11:53:29 -0800 (PST) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Feb 2021 19:51:08 +0000 Message-Id: <20210221195125.1901683-1-sw@jkqxz.net> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 01/18] cbs_sei: Delete SEI NAL units containing no messages 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When we remove the last SEI message from a NAL unit, the unit itself should also be deleted. --- libavcodec/cbs_sei.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c index c49830ad77..14f1cae506 100644 --- a/libavcodec/cbs_sei.c +++ b/libavcodec/cbs_sei.c @@ -353,7 +353,7 @@ void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx, { int err, i, j; - for (i = 0; i < au->nb_units; i++) { + for (i = au->nb_units - 1; i >= 0; i--) { CodedBitstreamUnit *unit = &au->units[i]; SEIRawMessageList *list; @@ -365,5 +365,10 @@ void ff_cbs_sei_delete_message_type(CodedBitstreamContext *ctx, if (list->messages[j].payload_type == payload_type) cbs_sei_delete_message(list, j); } + + if (list->nb_messages == 0) { + // The SEI NAL unit is now empty, so get rid of it. + ff_cbs_delete_unit(au, i); + } } }