From patchwork Sun Sep 20 17:24:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 22541 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 099BA44B700 for ; Sun, 20 Sep 2020 20:25:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D4DF468B9D8; Sun, 20 Sep 2020 20:25:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B229568B779 for ; Sun, 20 Sep 2020 20:25:07 +0300 (EEST) Received: by mail-qk1-f177.google.com with SMTP id 16so12589768qkf.4 for ; Sun, 20 Sep 2020 10:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=DLMc7e+Pue1iF3IGap0iPSMZD5YzqAOWMY/yDUnAYno=; b=nzxiuDCcRdcNUogm4bvQvZDI0v6/sYmOTROaGW8gLBtP3UmT3atT4GbFGKLiQqWtEm noylnq8zB7N0sMU6sf/4UfcQU+zksAoelUcWVaaN0H2LsGT5ZwJzFB5Mnhk8kMqhxtzl 6h7djtSLMEmimZVHvAeokFP7E9mt+zJBRDwsOVu2TVAryclR8txsNep6QxIQth0fHzym CnPm3L/3a17kWQv4B2zbERw9Of7U6bKOJajVGOrC+e9PC/1y8t2QF3HU7qmWZp+oCV5Y ZmDuOSF7yFiQq0NcEcQbu9WhRt0m2pmcLk44J2p4wD1Im9N9ED2hUGdoFwQ/Yxuc5UyA bqAg== 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=DLMc7e+Pue1iF3IGap0iPSMZD5YzqAOWMY/yDUnAYno=; b=TwDnmp6Ik9IwA3EYYs4NNFl2Vvmy3+I1PTkBfBjQNkulvuGV+v7b1L7AYhZRbedSh+ I+OktlhqUmDCmNq5Du/KnMrkkh+mBBBsiKpFrPRcstNID9TGrWSyB4yhFqI9s05Rek1j rcmukZYLHlGZt8iWO4hCAIFOm2PIOCyKrtdYOVrO7svPPLNdLhnrIhSxYWOrFzzPqn5T X6kMtdpvT2w9J/zEYnad3tOGNz4S6KQLzNtD6sDvj7YwLSoQpvKG+RJ4TibfeMFfvl7P d7k660J2z2lvkS1du9iYGg1jM50r6ONSVDRLVb+44SI7biGdCeYEsNPTf6faTm3B8Aja hzVA== X-Gm-Message-State: AOAM532l5HvpdB4acW+PHUO2xwGktRp7tRxvCQ8tGRBM2Bwp/QjMRoHd nTOAgVdZmNP6mfU9o8e+JVbce2jSbqh8EQ== X-Google-Smtp-Source: ABdhPJw4HrT3aI1r5V5H7qFgqTF/1w6b9Us5NTxBgyTg71ISg0DL+Jwdga3uI0gWoF6Wo599QCyjgQ== X-Received: by 2002:a05:620a:5f4:: with SMTP id z20mr43045815qkg.260.1600622705741; Sun, 20 Sep 2020 10:25:05 -0700 (PDT) Received: from localhost.localdomain ([191.83.208.67]) by smtp.gmail.com with ESMTPSA id g19sm6970762qka.84.2020.09.20.10.25.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 10:25:05 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 20 Sep 2020 14:24:40 -0300 Message-Id: <20200920172443.4763-1-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/cbs: add an AVClass to CodedBitstreamType for option handling 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" So unit parsing may be configured with caller set options. Signed-off-by: James Almer --- libavcodec/cbs.c | 9 +++++++++ libavcodec/cbs_internal.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 7c1aa005c2..e73e18f398 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -23,6 +23,7 @@ #include "libavutil/avassert.h" #include "libavutil/buffer.h" #include "libavutil/common.h" +#include "libavutil/opt.h" #include "cbs.h" #include "cbs_internal.h" @@ -101,6 +102,10 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr, av_freep(&ctx); return AVERROR(ENOMEM); } + if (type->priv_class) { + *(const AVClass **)ctx->priv_data = type->priv_class; + av_opt_set_defaults(ctx->priv_data); + } } ctx->decompose_unit_types = NULL; @@ -123,6 +128,10 @@ void ff_cbs_close(CodedBitstreamContext **ctx_ptr) ctx->codec->close(ctx); av_freep(&ctx->write_buffer); + + if (ctx->codec->priv_class && ctx->priv_data) + av_opt_free(ctx->priv_data); + av_freep(&ctx->priv_data); av_freep(ctx_ptr); } diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index d991e1eedf..10530af69f 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -86,6 +86,12 @@ typedef const struct CodedBitstreamUnitTypeDescriptor { typedef struct CodedBitstreamType { enum AVCodecID codec_id; + // A class for the private data, used to declare private AVOptions. + // This field is NULL for types that do not declare any options. + // If this field is non-NULL, the first member of the filter private data + // must be a pointer to AVClass. + const AVClass *priv_class; + size_t priv_data_size; // List of unit type descriptors for this codec.