From patchwork Mon Apr 1 23:39:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 12554 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 778A1447332 for ; Tue, 2 Apr 2019 02:39:54 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 52FEF68AB60; Tue, 2 Apr 2019 02:39:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 044D568AB21 for ; Tue, 2 Apr 2019 02:39:46 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id o25so1187029wmf.5 for ; Mon, 01 Apr 2019 16:39:46 -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=Pslai785l/jCPQtPTbjfHkWrLZwzRS4iraWqBxwZu60=; b=jWPXAnF0K1sL97T7s7rbaAXoa4CpC1HII1qA90nw/WUIYyuJY8DAzdZY5gXwvon0fo nhMFd33/htbBVydRPfuNrodHtWspENEdq4x7Sy7GaF94UWFOCM8W7QuusXabdfihXXvj dEylXXAkg4ArnIAFUCltyfWdH2EuVDUHirHJ0tmD9XvtZeNHHmbdaPYUR2v0OPpEEMO3 d5xZ+IdGBYsMAWvVgXV8SNc4Wb+27X9dfNqkPaxp3dQSSGNxPfI8p085jYbPDkFXJ7du 55Q+SSg+eOrUgPw7lVoeKL3NeUXQPmH0nQqiJSIhJGuvTEiEFG2qcK/eAT/YvVrw4jC2 PUqA== 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=Pslai785l/jCPQtPTbjfHkWrLZwzRS4iraWqBxwZu60=; b=QYAkNG17Nezxpctmhz09EVTut9xLUXHFGYSJ7LtgarH5dPwPZ11V1+JOvfzxVWJkmm ZnbmBi5KX54hJnv6yC3GWCMj4uhNzysEoAAhqAkNeEbDyyBmF/pKyEg7z6tZH7q5zY0e Rz9tAZHlPhR+9Ti/7mAEcQKCTk9ad5ptcVarEX9o4amd6h+WL/jUsSHWYmEPavgnWyp8 Jgb7bS8sKWM+ASmxBQcVzXE04pbiPsf4XaBajn1tVo0mz/SS/ABXU9/cCENgKNNFPpry 7B0zO3P4e1qgfGw1GQ6lGUYoU+w7xnRNbcn1OfWL0MhakuOkt9b/BtRHagWaIH9ERjN5 urUQ== X-Gm-Message-State: APjAAAUYe+ZdBhKLCc+LFg9qbHki7jX3cnclxma8sG6oCLzLLuBZAQMH CXAKsY7fI9ZEhbl2LGLd+/e9xTlsgNU= X-Google-Smtp-Source: APXvYqzSmwVM3fpdKPyUF44Fb688UkIEwKmb73stAfZ65T5b443mgtQgDXBKtjT+NxsVyIbBXaUB8w== X-Received: by 2002:a1c:ac07:: with SMTP id v7mr1432292wme.49.1554161985842; Mon, 01 Apr 2019 16:39:45 -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 r30sm27943044wrr.46.2019.04.01.16.39.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 16:39:44 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Apr 2019 00:39:32 +0100 Message-Id: <20190401233940.5941-1-sw@jkqxz.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/9] cbs: Add entrypoint for parser use 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" This can avoid copying due to lack of refcounting in parsers. --- libavcodec/cbs.c | 9 +++++++++ libavcodec/cbs.h | 14 ++++++++++++++ libavcodec/cbs_internal.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index c388be896b..ff98a1e8f4 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -280,6 +280,15 @@ int ff_cbs_read(CodedBitstreamContext *ctx, return cbs_read_fragment_content(ctx, frag); } +int ff_cbs_parse_headers(CodedBitstreamContext *ctx, void *header, + const uint8_t *data, size_t size) +{ + if (!ctx->codec->parse_headers) + return AVERROR(ENOSYS); + + return ctx->codec->parse_headers(ctx, header, data, size); +} + int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag) diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index 967dcd1468..be965ae258 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -278,6 +278,20 @@ int ff_cbs_read(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const uint8_t *data, size_t size); +/** + * Parse headers from a bitstream from a memory region, updating state + * but not storing intermediate results. + * + * If header is not NULL, the decomposition of the header of the last + * displayed unit in the stream is written there. The type and size of + * this is codec-dependent. + * + * This is intended for use in parsers where only header parsing is + * required and the input is not refcounted. + */ +int ff_cbs_parse_headers(CodedBitstreamContext *ctx, void *header, + const uint8_t *data, size_t size); + /** * Write the content of the fragment to its own internal buffer. diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index 53f2e5d187..9783555292 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -55,6 +55,10 @@ typedef struct CodedBitstreamType { // Free the codec internal state. void (*close)(CodedBitstreamContext *ctx); + + // Parse headers only. + int (*parse_headers)(CodedBitstreamContext *ctx, void *header, + const uint8_t *data, size_t size); } CodedBitstreamType;