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 3D62D4FD47 for ; Tue, 1 Jul 2025 12:53:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id E6FE268ECB8; Tue, 1 Jul 2025 15:53:17 +0300 (EEST) Received: from out162-62-57-210.mail.qq.com (out162-62-57-210.mail.qq.com [162.62.57.210]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id E1D4D68C24B for ; Tue, 1 Jul 2025 15:53:10 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1751374380; bh=obtFJV0aKZqoLb1huZ9Zlg8GlwSjapfu5I4tPYfCkUg=; h=From:To:Cc:Subject:Date; b=WkEN+0tBpChrEkJF9s2SVFHoakpMylapICRouH2w84YA60hYFa5i6ucLx/bfWYgc1 t56peDJ+itCVdHTygVnKE1Eqe8ULUBZLzI5vuLG1hkEDVjD8i325UTOT3K7gsHjiOF gsI5OgBTj2nn3wAJaKklnJxoglVaNP9k7dpz9JhQ= Received: from localhost.localdomain ([119.147.10.242]) by newxmesmtplogicsvrszb20-0.qq.com (NewEsmtp) with SMTP id D3A968F9; Tue, 01 Jul 2025 20:52:58 +0800 X-QQ-mid: xmsmtpt1751374378tou9quvxk Message-ID: X-QQ-XMAILINFO: OVAgSpUT8SOPf+jZ16fvKiFO80uYds4GOHX/SF+JCcMwFagSiaFTm6JCp2vOg+ LTP7U7Ikvp3gdXXedn6xoD854wtiN7/qHhjK6sDOfZxu/R6SbLfQGt5yl0A3LTuRgMI0plRZ41vt ZqrIh3QxFEKHFXK8yV7Rs+Y9St4T+j5nEAZH3gTYNeI72tdewI2lBN2Zi6zwKaN0gNZ30pE6f5Hv 8uSlzySYGwj776CJf6KLbIvzuM7VeIJ6PtiS5fuCyJcnHef0XhSmyPDBE9kr0pMZJWgdtsuPLlRA 8A3SC316TimxiPK9GcufQXL/maNEbM5/faS2zEkJ2NCEAVZ1nwI7qRYZaK/PA6fuAzH0JVgP7OKW sv3aT1UfvgeX1x88Xrpm59mttrghcchRGNWo3gwRvy/uugmgXF6psKR8CTVEZisF4KUzSiqtRrKO 0BcI8ycn8ZqMKgmisKQPttQ/kv1Clbk8SStIQISivlZftNahK5ohZqlUt9P3r8XfiHMUYNucVfmh 9etkOB8r8hyFTlpIB3IK+WKPNZS2AyA+x1tQGiw3uWNe+nOeA98zpxVlXHE9S/zp+eh7T6DZYmZh GRVB1sIX1Jg3X7V757W9EirGfP7UmD+ncxlHWCtaKhK2mI4xYXOE2ADfreTzzdi6ynYhNnEj0sHm 968vnXXuvatFXM+Efbelbax6TxY6wbRCKnKZF0LFgLYn/XpKLk3o6WnS/gTe8q+jGFDQ5IvIj6Rv foTLdbhHJHhAZU7TZp+2ktjiI9E9RflB6CHm4cNp+RYe8nnJlUUdMb6iQPWySv2jiNRjjFzrFJGG 3se1LmlZsxar40vAqwouF/hq+uHBFvfLdtEhqj3eFBup6sNE3hSCxq9auFKAqo7qp1InjnrF0ixi 6aSGg2Ng7egD4jpK5w6lmjgdnjSqW/G/iheg6z4PRrZuIRz9hg2d2fCNdDqal+RQx+U1yfZ5fjnl 5+6FU+CABxYxrz5uP8QSJQXrKKWkFAY5yww0gvYaTd5XHaa9daoIUvnmbtvOIxh7Dv9p2zB1w= X-QQ-XMRINFO: NyFYKkN4Ny6FSmKK/uo/jdU= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Jul 2025 20:52:57 +0800 X-OQ-MSGID: <20250701125257.14490-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] 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 | 2 +- 11 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 libavutil/hwcontext_oh.c create mode 100644 libavutil/hwcontext_oh.h diff --git a/configure b/configure index 976a21b931..6b5ac96bc3 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 @@ -7163,6 +7165,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 91710bb27d..53ae8d7282 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,12 @@ The last version increases of all libraries were on 2025-03-28 API changes, most recent first: +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 9ef118016b..8d7fd89004 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 \ @@ -208,6 +209,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 2979f80233..6e82f039c5 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 60 -#define LIBAVUTIL_VERSION_MINOR 3 +#define LIBAVUTIL_VERSION_MINOR 4 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 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".