From patchwork Tue Feb 28 12:06:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 40549 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp1550037pzb; Tue, 28 Feb 2023 04:07:36 -0800 (PST) X-Google-Smtp-Source: AK7set8fJBhTK37t2vLWO1aVG/MOKbCq9Fv3uJgMmtJgMOwtQF/vWlGFkqKw2cMJg0FxOiYD99Ix X-Received: by 2002:a17:907:88c5:b0:877:8ae7:2e44 with SMTP id rq5-20020a17090788c500b008778ae72e44mr2729788ejc.5.1677586056741; Tue, 28 Feb 2023 04:07:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677586056; cv=none; d=google.com; s=arc-20160816; b=c3poexPsLaD7o0IeIVd7cq41UNYRGi740paplUaXSoRHPsxd9rG/G6lGZsGd7sGPX8 TEO9wnq+43NzfVqMrDLWoDHJJL8sSZVjIcLqQddBdoxwjbu+0ZNObo5eqCLN/jUoK5uk 8QPuqdMsSEBCnkc5gvFKAjrLEMeIcaZKP5mcU9FtR7hBnX/urGkzSrkS7N2jk6ht5tgo 8IaWfImrT9uAG0nWo/Jn33mk8kcNO+UKTSbXVmF1RcZGTveoCaugq8gGfIz8db7y4yJe 9LoruV6L6McN4jOza4QVZu4GKfkNJRRLDWqWR9alBt0TyNy5qhOXfKZFHIg/XKT/26EI YE2A== 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:dkim-signature:delivered-to; bh=53pzB1eYonfh7bwxWcrJDRcxMghoUyvHo8lZDxCxOrs=; b=bjiGOm2xOzo+i1m93SQLTmGf0Y1QtMgJ/6GMwf3Jtxm5H1upBmpF/A7j2oav8xJ1Qe JVpxyTNIgDjtVARZvsFW0u1ai8AQ4bp80yg4oYr+HG5Idh3ODETw7XfINys+li0LygZj 9uZxHvjswSo5pvu/KIAzxsY8nt1LGf/8mVDPO1pHFuIGQiDo7FnRssD+XhupveiT3TiG xzNXQI/BntOrFtS54Okml4aGPpDfvH4rcefcwLyxdt6lZOq3G+XlYSOsaYe2IrJzug6D qqHNWGzhPVXo2T6NPK3Clhw5EfrzMABzsrrxdVNPvY9h587Ttz6lRotcF2UiK6tzx8sH cRPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="S/IhJbM9"; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fx1-20020a170906b74100b008cb405fa59csi10083980ejb.73.2023.02.28.04.07.36; Tue, 28 Feb 2023 04:07:36 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="S/IhJbM9"; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B101668AD70; Tue, 28 Feb 2023 14:07:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 31BB5688353 for ; Tue, 28 Feb 2023 14:07:20 +0200 (EET) Received: by mail-oi1-f175.google.com with SMTP id bp19so5007242oib.4 for ; Tue, 28 Feb 2023 04:07:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XcgR1ZyUWc/sHTwJf15ktEUzX6dB9EKFwrQ9+tPDc+g=; b=S/IhJbM955VR+U3aKGEcYgkszeISbUkeZeGAJeCw5MHVOOMtd9XtE4M6trAweidXji yHM/9iEroX5B3ttZGIw8+sle5RfCzzv+bbDmON2K8YnRUsaQF+5IanI6aVzr44Nk6fl+ k2y9maLLQrADzoXQbFCbuhmzeLrLomfd19c+koixmtR3wurMw3FduXHOR5YcOuo/uIdN Nz8Ix0j1uzoSAi66kGLsPnB8reW9kYGHm30FcEUwfD2Wt7v4ZXmpRQfNJM6IS7hZ17fg VtAqAfhPBhZllkGDiF2t4b+pbUJO1VGJvArFaIC/eGqQGGjBGpos5td5Ge6oq87WFz98 Wpdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XcgR1ZyUWc/sHTwJf15ktEUzX6dB9EKFwrQ9+tPDc+g=; b=hxtcWRA6NIMl0GstAH1CNs9lElCi70BJ4LLwZkglgyOTcbBbx9IwDiDLGV/v70gPmT dRa9QtMh2hzMpSF13bBZyaDSHJ8G0jyoH/p4FjHoEHSnA7xJ5FfeiQuxekgWEREekrGm aNI/r2ZvEpcu/IHvCZKylysDzFxr3wsvLVTnnTmbwFlIVC4vRDEyrAf/J4jEGUP0nwXJ X4X3c2SiS9FgVpZ13vIfks4mQCqyoLy4xvxyNBTEFqAamSSBBG3dKwkCC9bQ2J/AoxOw nAX5mV9f6ujesG3A8SDpsHahTJRHQ3Yt1VpqsOUEqUyot2HHfXbHcJXmgB894qv4SX+V yCbQ== X-Gm-Message-State: AO0yUKXxviYQoqFsCZv5izs41pimheoWvDW1V542ZDbmQbD3RQQFQTCw LqM8VuVIqBdhJmdKY0gUAhgQRwDBkkY= X-Received: by 2002:aca:230d:0:b0:37f:a9df:63c2 with SMTP id e13-20020aca230d000000b0037fa9df63c2mr1430146oie.26.1677586038290; Tue, 28 Feb 2023 04:07:18 -0800 (PST) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id v132-20020acade8a000000b003646062e83bsm4269388oig.29.2023.02.28.04.07.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 04:07:17 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Feb 2023 09:06:50 -0300 Message-Id: <20230228120650.1539-2-jamrial@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230228120650.1539-1-jamrial@gmail.com> References: <20230228120650.1539-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] libavcodec/libvpxenc: move libvpx-vp9 init_static_data function to the only place it's used 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: E4XFrj0ZuDeI Signed-off-by: James Almer --- libavcodec/Makefile | 4 +-- libavcodec/libvpx.c | 81 ------------------------------------------ libavcodec/libvpx.h | 10 ------ libavcodec/libvpxenc.c | 41 ++++++++++++++++++++- 4 files changed, 42 insertions(+), 94 deletions(-) delete mode 100644 libavcodec/libvpx.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 389253f5d0..6c797b8e14 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1121,8 +1121,8 @@ OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbisenc.o \ vorbis_data.o OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o -OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o -OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o +OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o +OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o OBJS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc_common.o libwebpenc.o OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER) += libwebpenc_common.o libwebpenc_animencoder.o OBJS-$(CONFIG_LIBX262_ENCODER) += libx264.o diff --git a/libavcodec/libvpx.c b/libavcodec/libvpx.c deleted file mode 100644 index 8601f82bd2..0000000000 --- a/libavcodec/libvpx.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2013 Guillaume Martres - * - * 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 - */ - -#include -#include "libvpx.h" -#include "config.h" -#include "config_components.h" - -#if CONFIG_LIBVPX_VP9_ENCODER -#include -#include -#endif - -static const enum AVPixelFormat vp9_pix_fmts_def[] = { - AV_PIX_FMT_YUV420P, - AV_PIX_FMT_YUVA420P, - AV_PIX_FMT_NONE -}; - -#if CONFIG_LIBVPX_VP9_ENCODER -static const enum AVPixelFormat vp9_pix_fmts_highcol[] = { - AV_PIX_FMT_YUV420P, - AV_PIX_FMT_YUVA420P, - AV_PIX_FMT_YUV422P, - AV_PIX_FMT_YUV440P, - AV_PIX_FMT_YUV444P, - AV_PIX_FMT_GBRP, - AV_PIX_FMT_NONE -}; - -static const enum AVPixelFormat vp9_pix_fmts_highbd[] = { - AV_PIX_FMT_YUV420P, - AV_PIX_FMT_YUVA420P, - AV_PIX_FMT_YUV422P, - AV_PIX_FMT_YUV440P, - AV_PIX_FMT_YUV444P, - AV_PIX_FMT_YUV420P10, - AV_PIX_FMT_YUV422P10, - AV_PIX_FMT_YUV440P10, - AV_PIX_FMT_YUV444P10, - AV_PIX_FMT_YUV420P12, - AV_PIX_FMT_YUV422P12, - AV_PIX_FMT_YUV440P12, - AV_PIX_FMT_YUV444P12, - AV_PIX_FMT_GBRP, - AV_PIX_FMT_GBRP10, - AV_PIX_FMT_GBRP12, - AV_PIX_FMT_NONE -}; -#endif - -av_cold void ff_vp9_init_static(FFCodec *codec) -{ - codec->p.pix_fmts = vp9_pix_fmts_def; -#if CONFIG_LIBVPX_VP9_ENCODER - { - vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx()); - if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) - codec->p.pix_fmts = vp9_pix_fmts_highbd; - else - codec->p.pix_fmts = vp9_pix_fmts_highcol; - } -#endif -} diff --git a/libavcodec/libvpx.h b/libavcodec/libvpx.h index 331feb8745..4671e0edef 100644 --- a/libavcodec/libvpx.h +++ b/libavcodec/libvpx.h @@ -21,16 +21,6 @@ #ifndef AVCODEC_LIBVPX_H #define AVCODEC_LIBVPX_H -#include - -#include "codec_internal.h" - #define MAX_VPX_THREADS 64 -void ff_vp9_init_static(FFCodec *codec); -#if 0 -enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img); -vpx_img_fmt_t ff_vpx_pixfmt_to_imgfmt(enum AVPixelFormat pix); -#endif - #endif /* AVCODEC_LIBVPX_H */ diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 339d4d8146..5e6467a3d0 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1979,6 +1979,45 @@ static av_cold int vp9_init(AVCodecContext *avctx) return vpx_init(avctx, vpx_codec_vp9_cx()); } +static const enum AVPixelFormat vp9_pix_fmts_highcol[] = { + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_YUVA420P, + AV_PIX_FMT_YUV422P, + AV_PIX_FMT_YUV440P, + AV_PIX_FMT_YUV444P, + AV_PIX_FMT_GBRP, + AV_PIX_FMT_NONE +}; + +static const enum AVPixelFormat vp9_pix_fmts_highbd[] = { + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_YUVA420P, + AV_PIX_FMT_YUV422P, + AV_PIX_FMT_YUV440P, + AV_PIX_FMT_YUV444P, + AV_PIX_FMT_YUV420P10, + AV_PIX_FMT_YUV422P10, + AV_PIX_FMT_YUV440P10, + AV_PIX_FMT_YUV444P10, + AV_PIX_FMT_YUV420P12, + AV_PIX_FMT_YUV422P12, + AV_PIX_FMT_YUV440P12, + AV_PIX_FMT_YUV444P12, + AV_PIX_FMT_GBRP, + AV_PIX_FMT_GBRP10, + AV_PIX_FMT_GBRP12, + AV_PIX_FMT_NONE +}; + +static av_cold void vp9_init_static(FFCodec *codec) +{ + vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx()); + if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) + codec->p.pix_fmts = vp9_pix_fmts_highbd; + else + codec->p.pix_fmts = vp9_pix_fmts_highcol; +} + static const AVClass class_vp9 = { .class_name = "libvpx-vp9 encoder", .item_name = av_default_item_name, @@ -2003,6 +2042,6 @@ FFCodec ff_libvpx_vp9_encoder = { .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_AUTO_THREADS, .defaults = defaults, - .init_static_data = ff_vp9_init_static, + .init_static_data = vp9_init_static, }; #endif /* CONFIG_LIBVPX_VP9_ENCODER */