From patchwork Fri May 21 18:00:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27899 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp744155iof; Fri, 21 May 2021 11:02:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8xs3f6c4hswqF74NRelaeMGIliKZtVug8ae7EB8IpKMbQGfn2q8AEsGXujRBvHVGJixah X-Received: by 2002:a05:6402:22a8:: with SMTP id cx8mr12677059edb.296.1621620175371; Fri, 21 May 2021 11:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621620175; cv=none; d=google.com; s=arc-20160816; b=v8OKGpH4y5P5HyIw3ayYSLVH4eM/ypgW2LdJrZcym1QYazVwWdYiUxXVPjfIg+BKAy p2oJt6h6pT9mDlpbtPh8hEeGcc2YuBaFxSALQqUFMq19VK1wcx6FYNWO4b86zR7HmAYC C1OiPWCELloajEXicDdg6NZhXRrNnnNwSjKjI6KbTuLbr/52Kicjk1PwG6t+vFbZ4CGQ QaY2owfsgVsdEnIeNWl3TvS/02+Z+rjSJugayCw2kp6c4JnxzuUe8ZMB2r5vS9VAU3vl 1unF8cVbqyOkq95eq99a5m03kmPG2GJp8aMpkIpIzKGVIi5r+S502MNrNOK/ce0WjftV NuRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=pg6MgrtGHCQIIayqyzl/mxSOnauotpMn4NTB9Qo3at4=; b=R12MBSOOo8ZBEXC0wD4GfSGeoa6J5YRfAj4BuPIpGsYK6sfFLCuPcnD+gUkg++LKsw mbrPVJSqLkKdVNin2t0E8xuYuadqeEUvmbKCP8eGcOcQp1kdqrbhmYCWNySQAkYGzeAE F93GlIP7K1nTR2Ks9/QB9sl6CcFXRXLeiYAxtEGSN2lIsAOvGIsfr5sW/g/oFTfPR6u2 IzEEpsYyRVR+3+t+9hAcmXPIeU+7IHhJ4DK48dM8rzCf9Zstau8URuEwOJYNLCAIyYJz YIyDNSz53S6xNN3q1mgZaJ/1Ro5CUTI6jOGBLczHQJdeW6uMSTnSUBKPIscMUdZTGiE0 o1Jw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e7si7589911edk.255.2021.05.21.11.02.53; Fri, 21 May 2021 11:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D60A8689D2E; Fri, 21 May 2021 21:01:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4BC4A688335 for ; Fri, 21 May 2021 21:01:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4AA2D240698 for ; Fri, 21 May 2021 20:01:15 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id M9jKrLosDi_o for ; Fri, 21 May 2021 20:01:14 +0200 (CEST) Received: from libav.khirnov.net (unknown [IPv6:2a00:c500:561:201:5fb8:4bfe:b578:641e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id C89D9240696 for ; Fri, 21 May 2021 20:01:09 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id D94FC3A13E8; Fri, 21 May 2021 20:01:06 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 May 2021 20:00:37 +0200 Message-Id: <20210521180056.17496-6-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210521180056.17496-1-anton@khirnov.net> References: <20210521180056.17496-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/25] lavc/cbs: avoid an AVCodecContext dependency X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: wTtQC1o/chc4 This will allow to stop including avcodec.h in future commits. --- libavcodec/av1_parser.c | 3 ++- libavcodec/av1dec.c | 5 ++--- libavcodec/cbs.c | 10 ++++------ libavcodec/cbs.h | 11 ++++------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c index b6c8004ee3..29a979111e 100644 --- a/libavcodec/av1_parser.c +++ b/libavcodec/av1_parser.c @@ -73,7 +73,8 @@ static int av1_parser_parse(AVCodecParserContext *ctx, if (avctx->extradata_size && !s->parsed_extradata) { s->parsed_extradata = 1; - ret = ff_cbs_read_extradata_from_codec(s->cbc, td, avctx); + ret = ff_cbs_read_extradata_raw(s->cbc, td, avctx->extradata, + avctx->extradata_size); if (ret < 0) { av_log(avctx, AV_LOG_WARNING, "Failed to parse extradata.\n"); } diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 1dda0f9160..4caa7c3a9d 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -657,9 +657,8 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) av_opt_set_int(s->cbc->priv_data, "operating_point", s->operating_point, 0); if (avctx->extradata && avctx->extradata_size) { - ret = ff_cbs_read_extradata_from_codec(s->cbc, - &s->current_obu, - avctx); + ret = ff_cbs_read_extradata_raw(s->cbc, &s->current_obu, + avctx->extradata, avctx->extradata_size); if (ret < 0) { av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n"); return ret; diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index bbfafb6530..960114cb0e 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -276,13 +276,11 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, par->extradata_size, 1); } -int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, - CodedBitstreamFragment *frag, - const AVCodecContext *avctx) +int ff_cbs_read_extradata_raw(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const uint8_t *data, size_t size) { - return cbs_read_data(ctx, frag, NULL, - avctx->extradata, - avctx->extradata_size, 1); + return cbs_read_data(ctx, frag, NULL, data, size, 1); } int ff_cbs_read_packet(CodedBitstreamContext *ctx, diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index f022282b75..8b432393b8 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -263,15 +263,12 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, const AVCodecParameters *par); /** - * Read the extradata bitstream found in a codec context into a + * Read the extradata bitstream provided as a raw array of bytes into a * fragment, then split into units and decompose. - * - * This acts identical to ff_cbs_read_extradata() for the case where - * you already have a codec context. */ -int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, - CodedBitstreamFragment *frag, - const AVCodecContext *avctx); +int ff_cbs_read_extradata_raw(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const uint8_t *data, size_t size); /** * Read the data bitstream from a packet into a fragment, then