From patchwork Wed Aug 24 08:43:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37451 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp2372054pzh; Wed, 24 Aug 2022 01:46:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR6d9rbTxGgMYYR839yts91lEJSo+COL02nnJZpvL4qB+cq/tP7T0tKdqehQDAUDHKZijk+P X-Received: by 2002:a17:907:7601:b0:73d:9f0b:d99f with SMTP id jx1-20020a170907760100b0073d9f0bd99fmr2179289ejc.300.1661330793821; Wed, 24 Aug 2022 01:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661330793; cv=none; d=google.com; s=arc-20160816; b=A+G0KM8hyR3AvPJFjfe3i5ZWQJF67fcxywsXLKA8u1xR9CpVQbgAwqjZW/kQBd5VMw OzY2accMSuq2MPEiGXBlria1EUARswOABBBVU+dPA8/AWKaP3diCF05X553qAQ2uyYHf H0T8dlWbmKZSUSfZJQPqlQhBj+TlbJKo6MhN9DMZOl5WqlXwXo64EDsA/9ymnd/ewvpt OAF4gljUcwMtB1BUfodXfUfJrlCQ4lXe8q4BOdtACInMWc2rHog26P1yPZEaXRNBKt62 sDN+eHX4nVRQ1kX9WhkPF5Kd1aExuzmojsQ+5OxRMmZvGVa1QC+E0mxJXo7GZF4bkBMW HFAQ== 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=Gz9lvVjrPqfNlaKnhGUOGQ2Na2k/6b1DnSJvFopnL90=; b=kPvCxCwFFMCHoDSWYxn398/h0o2furFGa6Kpxn8lPYfAKv0LRfCP3rWBoEj0XenFrf 16iBk6xzGlF7A8UXhHJVrawrRetMXLkXv0uSpCglA5lobCVB9CiPs0Sal81OjBRGTkHY osokxK1QN48mtKuWUvBYF+xVQiFwEIZtsLque/iTsKZ97hjtJ54qCYLHKMaBPqLvKDrq yhGf4TibtGUd0iSGL2JyMMhQDV6QA+5y+5KZMb9Jd7DMHYLDgQfOYs6q+XW4dgUTJKix w809+6I1TCaEMUFncMP/y2mLDoMfRgEyZ2lja1gdBUgebMHK7JTn1Wjns5GG6nnN1GSV 3kAw== 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 qk41-20020a1709077fa900b00733002330edsi1576715ejc.342.2022.08.24.01.46.33; Wed, 24 Aug 2022 01:46:33 -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 2E83968BA7A; Wed, 24 Aug 2022 11:44:08 +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 6A76668BA22 for ; Wed, 24 Aug 2022 11:43:49 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 76ACA240D21 for ; Wed, 24 Aug 2022 10:43:46 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Fj5q_waFaZ_1 for ; Wed, 24 Aug 2022 10:43:45 +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 A1B45240D1D for ; Wed, 24 Aug 2022 10:43:41 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 99A2B3A2243; Wed, 24 Aug 2022 10:43:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Aug 2022 10:43:10 +0200 Message-Id: <20220824084318.333-10-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220824084318.333-1-anton@khirnov.net> References: <20220824084318.333-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/18] lavc/dv.h: move encoder/decoder-specific code to a new header 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: qfR+3Yaw/QI/ dv.h is also used by libavformat, so avoid exposing encoder/decoder code to it. --- libavcodec/dv.c | 8 ++++-- libavcodec/dv.h | 34 ---------------------- libavcodec/dv_internal.h | 62 ++++++++++++++++++++++++++++++++++++++++ libavcodec/dvdec.c | 1 + libavcodec/dvenc.c | 1 + 5 files changed, 70 insertions(+), 36 deletions(-) create mode 100644 libavcodec/dv_internal.h diff --git a/libavcodec/dv.c b/libavcodec/dv.c index b5e54de5dd..eb49978ad8 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -38,8 +38,12 @@ * DV codec. */ -#include "avcodec.h" -#include "dv.h" +#include + +#include "libavutil/pixfmt.h" + +#include "dv_internal.h" +#include "dv_profile.h" static inline void dv_calc_mb_coordinates(const AVDVProfile *d, int chan, int seq, int slot, uint16_t *tbl) diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 859a4e6545..535f01cf0b 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -27,13 +27,6 @@ #ifndef AVCODEC_DV_H #define AVCODEC_DV_H -#include "dv_profile.h" - -typedef struct DVwork_chunk { - uint16_t buf_offset; - uint16_t mb_coordinates[5]; -} DVwork_chunk; - enum dv_section_type { dv_sect_header = 0x1f, dv_sect_subcode = 0x3f, @@ -72,31 +65,4 @@ enum dv_pack_type { */ #define DV_MAX_BPM 8 -int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); - -static inline int dv_work_pool_size(const AVDVProfile *d) -{ - int size = d->n_difchan * d->difseg_size * 27; - if (DV_PROFILE_IS_1080i50(d)) - size -= 3 * 27; - if (DV_PROFILE_IS_720p50(d)) - size -= 4 * 27; - return size; -} - -static inline void dv_calculate_mb_xy(const AVDVProfile *sys, - const uint8_t *buf, - const DVwork_chunk *work_chunk, - int m, int *mb_x, int *mb_y) -{ - *mb_x = work_chunk->mb_coordinates[m] & 0xff; - *mb_y = work_chunk->mb_coordinates[m] >> 8; - - /* We work with 720p frames split in half. - * The odd half-frame (chan == 2,3) is displaced :-( */ - if (sys->height == 720 && !(buf[1] & 0x0C)) - /* shifting the Y coordinate down by 72/2 macro blocks */ - *mb_y -= (*mb_y > 17) ? 18 : -72; -} - #endif /* AVCODEC_DV_H */ diff --git a/libavcodec/dv_internal.h b/libavcodec/dv_internal.h new file mode 100644 index 0000000000..4b4151c88d --- /dev/null +++ b/libavcodec/dv_internal.h @@ -0,0 +1,62 @@ +/* + * DV encoder/decoder shared code + * Copyright (c) 2002 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_DV_INTERNAL_H +#define AVCODEC_DV_INTERNAL_H + +#include + +#include "dv.h" +#include "dv_profile.h" + +typedef struct DVwork_chunk { + uint16_t buf_offset; + uint16_t mb_coordinates[5]; +} DVwork_chunk; + +int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); + +static inline int dv_work_pool_size(const AVDVProfile *d) +{ + int size = d->n_difchan * d->difseg_size * 27; + if (DV_PROFILE_IS_1080i50(d)) + size -= 3 * 27; + if (DV_PROFILE_IS_720p50(d)) + size -= 4 * 27; + return size; +} + +static inline void dv_calculate_mb_xy(const AVDVProfile *sys, + const uint8_t *buf, + const DVwork_chunk *work_chunk, + int m, int *mb_x, int *mb_y) +{ + *mb_x = work_chunk->mb_coordinates[m] & 0xff; + *mb_y = work_chunk->mb_coordinates[m] >> 8; + + /* We work with 720p frames split in half. + * The odd half-frame (chan == 2,3) is displaced :-( */ + if (sys->height == 720 && !(buf[1] & 0x0C)) + /* shifting the Y coordinate down by 72/2 macro blocks */ + *mb_y -= (*mb_y > 17) ? 18 : -72; +} + +#endif // AVCODEC_DV_INTERNAL_H diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 444b137488..297bf7f2fb 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -45,6 +45,7 @@ #include "avcodec.h" #include "codec_internal.h" #include "dv.h" +#include "dv_internal.h" #include "dv_profile_internal.h" #include "dvdata.h" #include "get_bits.h" diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 19291724e0..1f0374b865 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -38,6 +38,7 @@ #include "avcodec.h" #include "codec_internal.h" #include "dv.h" +#include "dv_internal.h" #include "dv_profile_internal.h" #include "dv_tablegen.h" #include "encode.h"