From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 311E44C19C for ; Sun, 6 Jul 2025 08:06:06 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 4DDFB690FBB; Sun, 6 Jul 2025 11:06:03 +0300 (EEST) Received: from out203-205-221-202.mail.qq.com (out203-205-221-202.mail.qq.com [203.205.221.202]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 13F51690FB5 for ; Sun, 6 Jul 2025 11:05:55 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1751789148; bh=dS0o7ZbmT4PCUJR9zNruVFs/JiSGlEgnpYSCUTkysAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NLdZ2eaAGyjoHMbGIRUOXZPlO9sZPUUQ6nvkUKSHsrX4BueOfGXcTD/BQ3XZls0yM yaYbuRDKlQ81ucC2BZkhEihlei+p9ogplzJyXnzOaHOrobX0Cpzli5YeGgXtqGWazg oaG6WJ8vV7acqk8rt7lGjyHCkUQCd43EMvXxkJTg= Received: from ZHILIZHAO-MB1.tencent.com ([240e:3b7:3270:6ba0:d8a2:be3b:874a:de6f]) by newxmesmtplogicsvrszc13-1.qq.com (NewEsmtp) with SMTP id 1682969A; Sun, 06 Jul 2025 16:05:40 +0800 X-QQ-mid: xmsmtpt1751789140t9gdb23y0 Message-ID: X-QQ-XMAILINFO: NSJPTvnisrLjyr4LYGA6mMFffy0hiP2i69Ta8SJuppX6gtH2w42Ap8IGEGSDQZ EbFq9i4EXJKkuyBu+QdvxdIH2dxrbXFPcal16fBKwBcjLZIGTdgt0C0W+zHIJYmayuaCfuWmAahV csU9GAn/EyNRDrI4RwPSQQQW1izhTdwqW0lzwEX+1aWlTeKiBz56aHe5cP/4cHyd63N3+YVnyzTc EuOze2qfzXMR4tRRuFaHyWvDKR4lQCIhlEHKdfIHfJdKdvo6b5Ip0wut0OjYm4S3suLZitjOfpKF Rrn/rJjI5HICw5KvmVrFYmdFTsHwxYdiIdvZQOU452fq+Qhn6HnrSAt3fQMwbc706s/A192JOExK bx5AODFqx++gW+BdDwLMogPmoKEmZzNj5rl7DW/C4OGVv1q/BR2RRnaWD6TEQK7AZIvOwlsu95m/ a2eN58xkNd/ZD60XU5+F2nC1F6yeaIdnfNTDexRozTCDZlVKAA9c/DtWUir5354QA1GytpaRw8sS mG9djwWh/jkssGTOS5PNOcs4RV9rkP8w7Yzh45/RxMssxMfnPzGcJv1+SR785V/qC2wGlq52BN2s IBcSVTjGyD7x8KSKNOHYKlurxyJgwop1beb/Qv4LbBnUEelVtvimOInhP6whiTyMA0kI6zTFtByF j/1ZRcRVbcpYPfldenNHftQ+DNxeF2oFjuTp/C70D/9XUS2EZUtd3bA3DsWgszd0HnfU2NpP1OO4 APewZG7KmrZ0DPWQNiyMY9pL7IzuzkEttA3nopahbXEc5K3IkCNrmgpo7NZIFc9slYFsxBh5Hyru aL8wgZcnN5qgpMTd6ZlGuKP62vNfD3VaxZl2kFB/0LLoXnF4ey6pQvs+c0GZtHaQ6qTFf/d4jfvb C8XD3OHgK78qEhvEJZ4lSqLzN4qiTb7YTMfOf/NXIb7Ac+1iHKJSCAvZhAgq/YwzefGx+QjGldQ4 YMQHAsNczr/9eLioxhwfRGxa5Db8YUM4tu4N+6OYdVLnqPlhJnHF7ACux1GJudaFNvmwMSc8WXI3 77T33nig== X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Sun, 6 Jul 2025 16:05:38 +0800 X-OQ-MSGID: <20250706080538.63652-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250706080523.63265-1-quinkblack@foxmail.com> References: <20250706080523.63265-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: Add ohcodec device and pixel format 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 Cc: Zhao Zhili Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Zhao Zhili --- configure | 5 ++++ doc/APIchanges | 6 +++++ libavutil/Makefile | 2 ++ libavutil/hwcontext.c | 4 +++ libavutil/hwcontext.h | 2 ++ libavutil/hwcontext_internal.h | 1 + libavutil/hwcontext_oh.c | 47 ++++++++++++++++++++++++++++++++++ libavutil/hwcontext_oh.h | 34 ++++++++++++++++++++++++ libavutil/pixdesc.c | 4 +++ libavutil/pixfmt.h | 2 ++ libavutil/version.h | 4 +-- 11 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 libavutil/hwcontext_oh.c create mode 100644 libavutil/hwcontext_oh.h diff --git a/configure b/configure index 63d11de207..729d1577a3 100755 --- a/configure +++ b/configure @@ -320,6 +320,7 @@ External library support: if openssl, gnutls or libtls is not used [no] --enable-mediacodec enable Android MediaCodec support [no] --enable-mediafoundation enable encoding via MediaFoundation [auto] + --enable-ohcodec enable OpenHarmony Codec support [no] --disable-metal disable Apple Metal framework [autodetect] --enable-libmysofa enable libmysofa, needed for sofalizer filter [no] --enable-openal enable OpenAL 1.1 capture support [no] @@ -1997,6 +1998,7 @@ EXTERNAL_LIBRARY_LIST=" libzvbi lv2 mediacodec + ohcodec openal opengl openssl @@ -7165,6 +7167,9 @@ enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_co check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } || die "ERROR: mmal not found" && check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; } +enabled ohcodec && { check_lib ohcodec "multimedia/player_framework/native_avcodec_videodecoder.h" \ + OH_VideoDecoder_CreateByName -lnative_media_codecbase -lnative_media_core -lnative_media_vdec || + die "ERROR: missing native_media libs"; } enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h" alGetError || { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do check_lib openal 'AL/al.h' alGetError "${al_extralibs}" && break; done } || diff --git a/doc/APIchanges b/doc/APIchanges index 9c03e541fd..92801769b6 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,12 @@ API changes, most recent first: Add AV3DReferenceDisplaysInfo and AV3DReferenceDisplay structs. Add av_tdrdi_alloc() and av_tdrdi_get_display(). +2025-06-30 - xxxxxxxxxx - lavu 60.4.100 - pixfmt.h + Add AV_PIX_FMT_OHCODEC. + +2025-06-30 - xxxxxxxxxx - lavu 60.4.100 - hwcontext.h + Add AV_HWDEVICE_TYPE_OHCODEC and AVOHCodecDeviceContext. + 2025-05-21 - xxxxxxxxxx - lavu 60.3.100 - avassert.h Add av_unreachable() and av_assume() macros. diff --git a/libavutil/Makefile b/libavutil/Makefile index 94a56bb72f..ee77e51c08 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -51,6 +51,7 @@ HEADERS = adler32.h \ hwcontext_qsv.h \ hwcontext_mediacodec.h \ hwcontext_opencl.h \ + hwcontext_oh.h \ hwcontext_vaapi.h \ hwcontext_videotoolbox.h \ hwcontext_vdpau.h \ @@ -210,6 +211,7 @@ OBJS-$(CONFIG_AMF) += hwcontext_amf.o OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o OBJS-$(CONFIG_MACOS_KPERF) += macos_kperf.o OBJS-$(CONFIG_MEDIACODEC) += hwcontext_mediacodec.o +OBJS-$(CONFIG_OHCODEC) += hwcontext_oh.o OBJS-$(CONFIG_OPENCL) += hwcontext_opencl.o OBJS-$(CONFIG_QSV) += hwcontext_qsv.o OBJS-$(CONFIG_VAAPI) += hwcontext_vaapi.o diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 3111a44651..83bd7457e8 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -68,6 +68,9 @@ static const HWContextType * const hw_table[] = { #endif #if CONFIG_AMF &ff_hwcontext_type_amf, +#endif +#if CONFIG_OHCODEC + &ff_hwcontext_type_oh, #endif NULL, }; @@ -86,6 +89,7 @@ static const char *const hw_type_names[] = { [AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec", [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", [AV_HWDEVICE_TYPE_AMF] = "amf", + [AV_HWDEVICE_TYPE_OHCODEC] = "ohcodec", }; typedef struct FFHWDeviceContext { diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index 96042ba197..94fd11da73 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -39,6 +39,8 @@ enum AVHWDeviceType { AV_HWDEVICE_TYPE_VULKAN, AV_HWDEVICE_TYPE_D3D12VA, AV_HWDEVICE_TYPE_AMF, + /* OpenHarmony Codec device */ + AV_HWDEVICE_TYPE_OHCODEC, }; /** diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h index db23579c9e..dcfdc2016a 100644 --- a/libavutil/hwcontext_internal.h +++ b/libavutil/hwcontext_internal.h @@ -164,5 +164,6 @@ 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; +extern const HWContextType ff_hwcontext_type_oh; #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */ diff --git a/libavutil/hwcontext_oh.c b/libavutil/hwcontext_oh.c new file mode 100644 index 0000000000..6d1f27cfc5 --- /dev/null +++ b/libavutil/hwcontext_oh.c @@ -0,0 +1,47 @@ +/* + * This file is part of FFmpeg. + * + * Copyright (c) 2025 Zhao Zhili + * + * 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 "hwcontext.h" +#include "hwcontext_internal.h" +#include "hwcontext_oh.h" + +static int oh_device_create(AVHWDeviceContext *ctx, const char *device, + AVDictionary *opts, int flags) +{ + if (device && device[0]) { + av_log(ctx, AV_LOG_ERROR, "Device selection unsupported.\n"); + return AVERROR_UNKNOWN; + } + + return 0; +} + +const HWContextType ff_hwcontext_type_oh = { + .type = AV_HWDEVICE_TYPE_OHCODEC, + .name = "ohcodec", + .device_hwctx_size = sizeof(AVOHCodecDeviceContext), + .device_create = oh_device_create, + .pix_fmts = (const enum AVPixelFormat[]) { + AV_PIX_FMT_OHCODEC, + AV_PIX_FMT_NONE + }, +}; diff --git a/libavutil/hwcontext_oh.h b/libavutil/hwcontext_oh.h new file mode 100644 index 0000000000..2794f85b7d --- /dev/null +++ b/libavutil/hwcontext_oh.h @@ -0,0 +1,34 @@ +/* + * This file is part of FFmpeg. + * + * Copyright (c) 2025 Zhao Zhili + * + * 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_OH_H +#define AVUTIL_HWCONTEXT_OH_H + +/** + * OpenHarmony codec device + */ +typedef struct AVOHCodecDeviceContext { + /** + * Pointer to OHNativeWindow + */ + void *native_window; +} AVOHCodecDeviceContext; + +#endif /* AVUTIL_HWCONTEXT_OH_H */ diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 53adde5aba..efa4c2db64 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -3167,6 +3167,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_BE, }, + [AV_PIX_FMT_OHCODEC] = { + .name = "ohcodec", + .flags = AV_PIX_FMT_FLAG_HWACCEL, + }, }; static const char * const color_range_names[] = { diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index bf1b8ed008..b697306201 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -488,6 +488,8 @@ enum AVPixelFormat { AV_PIX_FMT_GBRAP32BE, ///< planar GBRA 4:4:4:4 128bpp, big-endian AV_PIX_FMT_GBRAP32LE, ///< planar GBRA 4:4:4:4 128bpp, little-endian + AV_PIX_FMT_OHCODEC, /// hardware decoding through openharmony + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; diff --git a/libavutil/version.h b/libavutil/version.h index 2c0aa3e35e..29cd31e229 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,8 +79,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 60 -#define LIBAVUTIL_VERSION_MINOR 4 -#define LIBAVUTIL_VERSION_MICRO 101 +#define LIBAVUTIL_VERSION_MINOR 5 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ -- 2.46.0 _______________________________________________ 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".