From patchwork Tue Oct 16 21:01:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 10688 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 1C9CF446E46 for ; Wed, 17 Oct 2018 00:09:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 75EE968A57D; Wed, 17 Oct 2018 00:08:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 089EA68A31C for ; Wed, 17 Oct 2018 00:08:51 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id n1-v6so27193261wrt.10 for ; Tue, 16 Oct 2018 14:09:16 -0700 (PDT) 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=9K/E+i5GvX4Ir6o+gl0oTthm/jSRi5Ki2teCcURD4YM=; b=rmI/Cvky6qxQXWPRqUtqvldcF7aV9+FNxJzuuzcjPOvFvqk/y28i/jcuru847RG13S z6cIBjC8WiCVA/u8nC6xBW5PBOS/kkdyWZEO9+w5haCid95KhzjUcpohJ0vJ1U6TxRk6 inmXjbTbd25/xp7TUiBKZ156aAmJW3KadBrgc4uFwyJ5ZGo2jLGBL1TSsI1DIVX7+ZgL OfKng68xYl/qyQwAb7/ycuXI8JWSRhnwHtQVA/MO3PLGjT7SQTQYfaV53R6AbpkGzvXx 1KV7mk/HQJMz6w24W1V1hpcIHgGb+AD5SpOqpWKhiEfRPC8z9hjWvQ5DaOYtH4NGnqjo 4kBA== 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=9K/E+i5GvX4Ir6o+gl0oTthm/jSRi5Ki2teCcURD4YM=; b=oTR+/iBmbFTataf8wO1etzWM5aDtqqpat7+Sb6S77O8Lj8r0wT2TnSANWcMfCRNSQF PDeXLLV6JPMRrV13AvbTH+bGMTanYC1GOO2d/tSqk7ugGkqOCni8m4gIJXTvSyCfmS8a eDJmu5hoKtUDA/OF6qQ/z6y317WlWaRk3R+LnLkQs6IdjVaJvvSBwTk6q0pyc3mudppj LlXet4EG9Qpd1cDm9l85fHHRFCDy0AW6Zvijg6p4ZQVdajAP57VqyddMiyM/XrLDgev9 CitIOb96BQPwGOQ5mIXudNesQQ01bbnMjJ/loNCSHRXEvnBwifuYYF7Uwn0Z7BaNOH23 FxsA== X-Gm-Message-State: ABuFfojOGqPlLdpbnZgguJegvl3vwiZRkkFzUZgpkAbUbKmjDT9KGsmU SyN+dXuK+QMIHqLOhVmna13J6Hprhxo= X-Google-Smtp-Source: ACcGV62ihDIa2a7FfsHYTXQ5W5Hia9xxEjvzyjNFTnYnPWgOXbcn2Fkl9j4FSNcNHOjjMeSz+mfieA== X-Received: by 2002:adf:9021:: with SMTP id h30-v6mr21475055wrh.248.1539723693288; Tue, 16 Oct 2018 14:01:33 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id a205-v6sm10708413wmh.19.2018.10.16.14.01.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 14:01:32 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Oct 2018 22:01:26 +0100 Message-Id: <20181016210128.7652-1-sw@jkqxz.net> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] cbs_h264: Actually decompose end-of-sequence NAL units 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" 64c50c0e978cd556dc2da238dfe0bb367e7c1ab9 declared support for decomposing them but omitted to implement it; this adds an implementation. Also do the same for end-of-stream NAL units, since they are equivalent. --- For an example of both, see the end of Sharp_MP_PAFF_1r2.jvt (also tested as part of fate-cbs-h264). libavcodec/cbs_h2645.c | 32 ++++++++++++++++++++++++++- libavcodec/cbs_h264_syntax_template.c | 18 +++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 4b31601c0f..a1b92c87ce 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -872,7 +872,21 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, break; case H264_NAL_END_SEQUENCE: - return 0; + case H264_NAL_END_STREAM: + { + err = ff_cbs_alloc_unit_content(ctx, unit, + sizeof(H264RawNALUnitHeader), + NULL); + if (err < 0) + return err; + + err = (unit->type == H264_NAL_END_SEQUENCE ? + cbs_h264_read_end_of_sequence : + cbs_h264_read_end_of_stream)(ctx, &gbc, unit->content); + if (err < 0) + return err; + } + break; default: return AVERROR(ENOSYS); @@ -1147,6 +1161,22 @@ static int cbs_h264_write_nal_unit(CodedBitstreamContext *ctx, } break; + case H264_NAL_END_SEQUENCE: + { + err = cbs_h264_write_end_of_sequence(ctx, pbc, unit->content); + if (err < 0) + return err; + } + break; + + case H264_NAL_END_STREAM: + { + err = cbs_h264_write_end_of_stream(ctx, pbc, unit->content); + if (err < 0) + return err; + } + break; + default: av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for " "NAL unit type %"PRIu32".\n", unit->type); diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 1c8d7d5eae..1a9fb9cfeb 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -1375,3 +1375,21 @@ static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } + +static int FUNC(end_of_sequence)(CodedBitstreamContext *ctx, RWContext *rw, + H264RawNALUnitHeader *current) +{ + HEADER("End of Sequence"); + + return FUNC(nal_unit_header)(ctx, rw, current, + 1 << H264_NAL_END_SEQUENCE); +} + +static int FUNC(end_of_stream)(CodedBitstreamContext *ctx, RWContext *rw, + H264RawNALUnitHeader *current) +{ + HEADER("End of Stream"); + + return FUNC(nal_unit_header)(ctx, rw, current, + 1 << H264_NAL_END_STREAM); +}