From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 1109B495FA for ; Wed, 14 Feb 2024 02:56:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 13FB168D17D; Wed, 14 Feb 2024 04:56:43 +0200 (EET) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8A61868D16D for ; Wed, 14 Feb 2024 04:56:35 +0200 (EET) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6e10614c276so529462b3a.3 for ; Tue, 13 Feb 2024 18:56:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707879392; x=1708484192; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=kqSEio8jNMaBl7dUX0EsEsTSP1kmrgbdmc4YGpLG6qE=; b=fnX0gLf932ytiQfM3Or7OdBRxk+ftT4XpgbYMlieniDvbhB3WQjDYL7QMlXmwOWZyB vQYkwvJ6bcBHVzMz8F0qqRf+IJKxYNU1GHgOX62+QOvUds93gIVx/5h/2ntr8UeT3IgJ x33NtAyNOZcKCGRu4F8cCGwhi4hlb+t2GJntoLBBjzrJf3fzduKb6RH3I+MR852qTPZS 5N1aKFi1VXrH5fSygKyjC72lQeL598fxTexyha+sGfbhuX5p+lhXOZOGuD1IneawvDdF ayCslMWUkTut9OEIgkCnDMV5XOjOnsugLRwwYkCANdI7CR5CjJOW2YXGzGdMRXv0HZKA 7s8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707879392; x=1708484192; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kqSEio8jNMaBl7dUX0EsEsTSP1kmrgbdmc4YGpLG6qE=; b=RUXfRNST3EA6Q9xT2ZZ3LIaGUhG+ZOh+xz7VC2HuoEJIvCUhcV8LyB6lVMmJjRNJ4J h5WTlh+g3DAguE+EUk6Hckf6xBWy/uuJfLuVlYBGGYQcKaQ6OxWUHizd31gINIwtgbXU ocCqRfjunBYfyMzrv46weavK2fQv7vLCwLIib6ivjNdTmcOUzCMMa7w5dTpvssFxDXMc omIiSnO+U/A0k/RzYEEsd3KBLkJRHDrXlPuHdR8Fkww1VWdE5aSkoGNZ7S9ZtawwiF+n LjbCi9Vu8IWjdyGFnBGXYMJ422kt9uy/Lqnj8h/eYYGrbC75yyq5Vv98vBuezmrC9+EE 5DBA== X-Gm-Message-State: AOJu0YwrU6WCoLGD512+Awd02YxmXa1z/BCrFgPNqlExwr8AK9iqGLDa Hv90XTSukvKq/P2LBebMSezbuN0m1Vjxv8Oixk1Jch0FXvRqUBJ0VSKDMlny X-Google-Smtp-Source: AGHT+IHTmpiVAq5Kq24k/CspglY05Wc/YcsyHRG25v5brtQJA3hqNilk5as3D7tVfgrVNeCpi/KxoQ== X-Received: by 2002:a05:6a20:6f90:b0:19e:5110:be0 with SMTP id gv16-20020a056a206f9000b0019e51100be0mr1641367pzb.54.1707879392239; Tue, 13 Feb 2024 18:56:32 -0800 (PST) Received: from [192.168.0.18] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id d4-20020a170902c18400b001d916995423sm2730318pld.99.2024.02.13.18.56.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 18:56:31 -0800 (PST) Message-ID: <5d765e09-0037-407c-b21d-1ff3531c2185@gmail.com> Date: Tue, 13 Feb 2024 23:56:33 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240214015515.1027-1-ovchinnikov.dmitrii@gmail.com> From: James Almer In-Reply-To: <20240214015515.1027-1-ovchinnikov.dmitrii@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH 1/9] libavutil: add hwcontext_amf. 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 2/13/2024 10:55 PM, Dmitrii Ovchinnikov wrote: > +const FormatMap format_map[] = > +{ > + { AV_PIX_FMT_NONE, AMF_SURFACE_UNKNOWN }, > + { AV_PIX_FMT_NV12, AMF_SURFACE_NV12 }, > + { AV_PIX_FMT_BGR0, AMF_SURFACE_BGRA }, > + { AV_PIX_FMT_RGB0, AMF_SURFACE_RGBA }, > + { AV_PIX_FMT_BGRA, AMF_SURFACE_BGRA }, > + { AV_PIX_FMT_ARGB, AMF_SURFACE_ARGB }, > + { AV_PIX_FMT_RGBA, AMF_SURFACE_RGBA }, > + { AV_PIX_FMT_GRAY8, AMF_SURFACE_GRAY8 }, > + { AV_PIX_FMT_YUV420P, AMF_SURFACE_YUV420P }, > + { AV_PIX_FMT_YUYV422, AMF_SURFACE_YUY2 }, > + { AV_PIX_FMT_P010, AMF_SURFACE_P010 }, > + { AV_PIX_FMT_YUV420P10, AMF_SURFACE_P010 }, yuv420p10 is not equal to p010. > + { AV_PIX_FMT_YUV420P12, AMF_SURFACE_P012 }, > + { AV_PIX_FMT_YUV420P12, AMF_SURFACE_P012 }, Why the duplication? And there's AV_PIX_FMT_P012. > + { AV_PIX_FMT_YUV420P16, AMF_SURFACE_P016 }, AV_PIX_FMT_P016? > + { AV_PIX_FMT_YUV422P10LE, AMF_SURFACE_Y210 }, AV_PIX_FMT_Y210? > + { AV_PIX_FMT_YUV444P10LE, AMF_SURFACE_Y416 }, > +}; [...] > diff --git a/libavutil/hwcontext_amf.h b/libavutil/hwcontext_amf.h > new file mode 100644 > index 0000000000..0161b9a29c > --- /dev/null > +++ b/libavutil/hwcontext_amf.h > @@ -0,0 +1,105 @@ > +/* > + * 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 AVUTIL_HWCONTEXT_AMF_H > +#define AVUTIL_HWCONTEXT_AMF_H > +#include > +#include > +#include > +#include "pixfmt.h" > + > +#include "libavformat/avformat.h" lavu can't depend on lavf. > +#include "libavutil/hwcontext.h" > + > +#define FFMPEG_AMF_WRITER_ID L"ffmpeg_amf" Bad namespace. And this doesn't need to be public. > + > +typedef struct AmfTraceWriter { Ditto namespace. Does this need to be public? > + AMFTraceWriterVtbl *vtbl; > + void *avctx; > + void *avcl; > +} AmfTraceWriter; > + > +typedef struct AVAMFDeviceContextInternal { If this is internal, then define it in an internal header and put only the typedef here. > + amf_handle library; ///< handle to DLL library > + AMFFactory *factory; ///< pointer to AMF factory > + AMFDebug *debug; ///< pointer to AMF debug interface > + AMFTrace *trace; ///< pointer to AMF trace interface > + > + amf_uint64 version; ///< version of AMF runtime > + AMFContext *context; ///< AMF context > + AMF_MEMORY_TYPE mem_type; > +} AVAMFDeviceContextInternal; > + > +/** > + * This struct is allocated as AVHWDeviceContext.hwctx > + */ > + > +typedef struct AVAMFDeviceContext { > + AVBufferRef *internal; AVAMFDeviceContextInternal *internal. Can't say if this is needed here at all or not. > +} AVAMFDeviceContext; > + > +typedef struct AMFFramesContext { Again namespace. > + AMFSurface * surfaces; > + int nb_surfaces; > +} AMFFramesContext; > + > +/** > +* Error handling helper > +*/ > +#define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \ > + if (!(exp)) { \ > + av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \ > + return ret_value; \ > + } > + > +#define AMF_GOTO_FAIL_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \ > + if (!(exp)) { \ > + av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \ > + ret = ret_value; \ > + goto fail; \ > + } > + > +#define AMF_TIME_BASE_Q (AVRational){1, AMF_SECOND} These should probably be internal. > + > +typedef struct FormatMap { > + enum AVPixelFormat av_format; > + enum AMF_SURFACE_FORMAT amf_format; > +} FormatMap; > + > +extern const FormatMap format_map[]; This doesn't need to be in a public header. > +enum AMF_SURFACE_FORMAT av_amf_av_to_amf_format(enum AVPixelFormat fmt); Namespace. > +enum AVPixelFormat av_amf_to_av_format(enum AMF_SURFACE_FORMAT fmt); > +extern AmfTraceWriter av_amf_trace_writer; Same as AmfTraceWriter, this probably doesn't need to be public. > + > +int av_amf_context_init(AVAMFDeviceContextInternal* internal, void* avcl); > +int av_amf_load_library(AVAMFDeviceContextInternal* internal, void* avcl); > +int av_amf_create_context( AVAMFDeviceContextInternal * internal, > + void* avcl, > + const char *device, > + AVDictionary *opts, int flags); > +int av_amf_context_internal_create(AVAMFDeviceContextInternal * internal, > + void* avcl, > + const char *device, > + AVDictionary *opts, int flags); > +void av_amf_context_internal_free(void *opaque, uint8_t *data); > +int av_amf_context_derive(AVAMFDeviceContextInternal * internal, > + AVHWDeviceContext *child_device_ctx, AVDictionary *opts, > + int flags); These should probably take a AVAMFDeviceContext pointer. > + > +#endif /* AVUTIL_HWCONTEXT_AMF_H */ > diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h > index 4df516ee6a..48d2dc012c 100644 > --- a/libavutil/hwcontext_internal.h > +++ b/libavutil/hwcontext_internal.h > @@ -175,5 +175,6 @@ extern const HWContextType ff_hwcontext_type_vdpau; > extern const HWContextType ff_hwcontext_type_videotoolbox; > extern const HWContextType ff_hwcontext_type_mediacodec; > extern const HWContextType ff_hwcontext_type_vulkan; > +extern const HWContextType ff_hwcontext_type_amf; > > #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */ > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c > index f6d4d01460..ebc79b0c74 100644 > --- a/libavutil/pixdesc.c > +++ b/libavutil/pixdesc.c > @@ -2125,6 +2125,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { > .name = "cuda", > .flags = AV_PIX_FMT_FLAG_HWACCEL, > }, > + [AV_PIX_FMT_AMF] = { > + .name = "amf", > + .flags = AV_PIX_FMT_FLAG_HWACCEL, > + }, > [AV_PIX_FMT_AYUV64LE] = { > .name = "ayuv64le", > .nb_components = 4, > diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h > index 9c87571f49..06459be62c 100644 > --- a/libavutil/pixfmt.h > +++ b/libavutil/pixfmt.h > @@ -251,6 +251,10 @@ enum AVPixelFormat { > * exactly as for system memory frames. > */ > AV_PIX_FMT_CUDA, > + /** > + * HW acceleration through AMF. data[3] contain AMFSurface pointer > + */ > + AV_PIX_FMT_AMF, This is an ABI break, it needs to be the last entry before AV_PIX_FMT_NB. > > AV_PIX_FMT_0RGB, ///< packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined > AV_PIX_FMT_RGB0, ///< packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".