From patchwork Thu Aug 25 10:10:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37473 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp231233pzh; Thu, 25 Aug 2022 03:11:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR6xLAB8MxLui/Ja0h8l97DOTGRdeA6sxKhZdWZivCFZQIQRnxGuOZWkhnNAVffHacjeRAb4 X-Received: by 2002:a17:906:5d0f:b0:732:fb97:780d with SMTP id g15-20020a1709065d0f00b00732fb97780dmr1981820ejt.269.1661422286246; Thu, 25 Aug 2022 03:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661422286; cv=none; d=google.com; s=arc-20160816; b=V+d/IZlX0elImdiDJWncnEXxcJs1JrMshIXY2o70nJK7CWyaPewCEQAW7tz0o5j7uG LnVEgKE+zS3BywT9TMelLiS8xkGrtfAKq9oK0VVhvgWuZZYI3/4WMWlv3n9O6UmkieBn 0GKfC8oxGGk6vG88nrNoTS3v13+UbyWMEBCqFCjQ1WozI2XjdznyaJ8d6F77ebeTEfvI GIuyzM15/UC/JIxZahkwgfBbY+OfzzGT/jQGCzSc0kQAali2IWnpbJMyPSZY5vy81HMx w4NTEaINxUxbxTsvk/QJ+I/BJUzb+TqJvE1L6X1Cdew/bGRpvZIjyNX1uzzlpn28+IUW Q15g== 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=xchwmcMbOnRbgWS69Dz8CR+VbYJXjCZpCMRTiPsNEnI=; b=Ed58InXkvGBhObs31s5yp4v/ck00RIZciuM4vog0/WzAdesSOr5gSSgkmRwcqhdXnF C8nFFcLfmVqWlAFaGvAUPvWBnXvZiFL8eUiiec2v64/sxT+DtW/v9m5/K8Kgzg2YMkem L3O56a/O7Y7G6XgNIC/XMkFLLLwcmpVdkoBfBNVlylHSFDdLDdjP2itFngQmLT0IsBIa Dt3t5kgZNg4s9w9oho4BU7ls5HD5JxxVS1sJCkczpMxTadZsJerhAFrbOXeIfdSQgVv/ UUJn+G/QgusUyCix6rTDtFXt6LhyBxQuOEQ5DyGcxkjEEpTSFzvHMBk9qf2Z1MLDJj/t U3fQ== 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 nd21-20020a170907629500b00734bbe8d2e1si3459058ejc.545.2022.08.25.03.11.25; Thu, 25 Aug 2022 03:11:26 -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 79B3068B9DA; Thu, 25 Aug 2022 13:11:22 +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 5FFCB68B511 for ; Thu, 25 Aug 2022 13:11:16 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D6BB9240D0E for ; Thu, 25 Aug 2022 12:11:15 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id vdWmtpy9ck_l for ; Thu, 25 Aug 2022 12:11:15 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (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 1E54A240D03 for ; Thu, 25 Aug 2022 12:11:15 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 1806B3A0ABF; Thu, 25 Aug 2022 12:11:15 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 12:10:33 +0200 Message-Id: <20220825101033.19732-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/dv: remove ff_dvvideo_init() 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: d7PFJNvOAOMy The function contains only two assignments, setting DVVideoContext.avctx and AVCodecContext.chroma_sample_location. However, the decoder does not use the former, and the encoder should not be setting the latter. Therefore move the first assignment to dvenc and the second to dvdec. Make the encoder warn if the user-signalled chroma sample location does not match the supported one, and return an error on higher compliance levels. --- libavcodec/dv.c | 10 ---------- libavcodec/dv.h | 2 -- libavcodec/dvdec.c | 4 +++- libavcodec/dvenc.c | 12 +++++++++++- tests/ref/lavf/mxf_dv25 | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index e2550c4cc1..9e05aa8927 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -184,13 +184,3 @@ int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const AVDVProfile *d) return 0; } - -av_cold int ff_dvvideo_init(AVCodecContext *avctx) -{ - DVVideoContext *s = avctx->priv_data; - - s->avctx = avctx; - avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; - - return 0; -} diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 331b8e846a..2b082d0140 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -97,8 +97,6 @@ enum dv_pack_type { int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d); -int ff_dvvideo_init(AVCodecContext *avctx); - static inline int dv_work_pool_size(const AVDVProfile *d) { int size = d->n_difchan * d->difseg_size * 27; diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index bad8419925..daee2347e6 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -240,6 +240,8 @@ static av_cold int dvvideo_decode_init(AVCodecContext *avctx) DVVideoContext *s = avctx->priv_data; int i; + avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; + ff_idctdsp_init(&s->idsp, avctx); for (i = 0; i < 64; i++) @@ -258,7 +260,7 @@ static av_cold int dvvideo_decode_init(AVCodecContext *avctx) ff_thread_once(&init_static_once, dv_init_static); - return ff_dvvideo_init(avctx); + return 0; } /* decode AC coefficients */ diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 5ba4de3213..b2df976a26 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -55,6 +55,16 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) PixblockDSPContext pdsp; int ret; + s->avctx = avctx; + + if (avctx->chroma_sample_location != AVCHROMA_LOC_TOPLEFT) { + const char *name = av_chroma_location_name(avctx->chroma_sample_location); + av_log(avctx, AV_LOG_WARNING, "Only top-left chroma location is supported " + "in DV, input value is: %s\n", name ? name : "unknown"); + if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL) + return AVERROR(EINVAL); + } + s->sys = av_dv_codec_profile2(avctx->width, avctx->height, avctx->pix_fmt, avctx->time_base); if (!s->sys) { av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. " @@ -91,7 +101,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) } #endif - return ff_dvvideo_init(avctx); + return 0; } /* bit budget for AC only in 5 MBs */ diff --git a/tests/ref/lavf/mxf_dv25 b/tests/ref/lavf/mxf_dv25 index 5022f1f62d..95a58906a0 100644 --- a/tests/ref/lavf/mxf_dv25 +++ b/tests/ref/lavf/mxf_dv25 @@ -1,3 +1,3 @@ -3339def72599c79ad5860c6860cc3123 *tests/data/lavf/lavf.mxf_dv25 +59d632e097e6f45c28445b2ab862ffe8 *tests/data/lavf/lavf.mxf_dv25 3834413 tests/data/lavf/lavf.mxf_dv25 tests/data/lavf/lavf.mxf_dv25 CRC=0xbdaf7f52