History

avutil/hwcontext: Add ohcodec device and pixel format

Zhao Zhili committed 1 year ago

Commit fbda5ff1 parent 7b13d1711 files · +109 −2Browse files

Unified · Split

11 files
  1. configure +5 −0
  2. doc/APIchanges +6 −0
  3. libavutil/Makefile +2 −0
  4. libavutil/hwcontext.c +4 −0
  5. libavutil/hwcontext.h +2 −0
  6. libavutil/hwcontext_internal.h +1 −0
  7. libavutil/hwcontext_oh.c +47 −0
  8. libavutil/hwcontext_oh.h +34 −0
  9. libavutil/pixdesc.c +4 −0
  10. libavutil/pixfmt.h +2 −0
  11. libavutil/version.h +2 −2
configure+5−0
@@ -322,6 +322,7 @@ External library support: · 321 unmodified lines
322322 --enable-mediafoundation enable encoding via MediaFoundation [auto]
323323 --disable-metal disable Apple Metal framework [autodetect]
324324 --enable-libmysofa enable libmysofa, needed for sofalizer filter [no]
325+ --enable-ohcodec enable OpenHarmony Codec support [no]
325326 --enable-openal enable OpenAL 1.1 capture support [no]
326327 --enable-opencl enable OpenCL processing [no]
327328 --enable-opengl enable OpenGL rendering [no]
@@ -1997,6 +1998,7 @@ EXTERNAL_LIBRARY_LIST=" · 1669 unmodified lines
19971998 libzvbi
19981999 lv2
19992000 mediacodec
2001+ ohcodec
20002002 openal
20012003 opengl
20022004 openssl
@@ -7171,6 +7173,9 @@ enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_co · 5168 unmodified lines
71717173 check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } ||
71727174 die "ERROR: mmal not found" &&
71737175 check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; }
7176+enabled ohcodec && { check_lib ohcodec "multimedia/player_framework/native_avcodec_videodecoder.h" \
7177+ OH_VideoDecoder_CreateByName -lnative_media_codecbase -lnative_media_core -lnative_media_vdec ||
7178+ die "ERROR: missing native_media libs"; }
71747179 enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h" alGetError ||
71757180 { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
71767181 check_lib openal 'AL/al.h' alGetError "${al_extralibs}" && break; done } ||
doc/APIchanges+6−0
@@ -2,6 +2,12 @@ The last version increases of all libraries were on 2025-03-28 · 1 unmodified line
22
33 API changes, most recent first:
44
5+2025-07-18 - xxxxxxxxxx - lavu 60.5.100 - pixfmt.h
6+ Add AV_PIX_FMT_OHCODEC.
7+
8+2025-07-18 - xxxxxxxxxx - lavu 60.5.100 - hwcontext.h
9+ Add AV_HWDEVICE_TYPE_OHCODEC and AVOHCodecDeviceContext.
10+
511 2025-07-xx - xxxxxxxxxd - lavfi 11.2.100 - avfilter.h
612 Add AVFilterGraph->max_buffered_frames.
713
libavutil/Makefile+2−0
@@ -51,6 +51,7 @@ HEADERS = adler32.h \ · 50 unmodified lines
5151 hwcontext_qsv.h \
5252 hwcontext_mediacodec.h \
5353 hwcontext_opencl.h \
54+ hwcontext_oh.h \
5455 hwcontext_vaapi.h \
5556 hwcontext_videotoolbox.h \
5657 hwcontext_vdpau.h \
@@ -210,6 +211,7 @@ OBJS-$(CONFIG_AMF) += hwcontext_amf.o · 153 unmodified lines
210211 OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o
211212 OBJS-$(CONFIG_MACOS_KPERF) += macos_kperf.o
212213 OBJS-$(CONFIG_MEDIACODEC) += hwcontext_mediacodec.o
214+OBJS-$(CONFIG_OHCODEC) += hwcontext_oh.o
213215 OBJS-$(CONFIG_OPENCL) += hwcontext_opencl.o
214216 OBJS-$(CONFIG_QSV) += hwcontext_qsv.o
215217 OBJS-$(CONFIG_VAAPI) += hwcontext_vaapi.o
libavutil/hwcontext.c+4−0
@@ -68,6 +68,9 @@ static const HWContextType * const hw_table[] = { · 67 unmodified lines
6868 #endif
6969 #if CONFIG_AMF
7070 &ff_hwcontext_type_amf,
71+#endif
72+#if CONFIG_OHCODEC
73+ &ff_hwcontext_type_oh,
7174 #endif
7275 NULL,
7376 };
@@ -86,6 +89,7 @@ static const char *const hw_type_names[] = { · 12 unmodified lines
8689 [AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",
8790 [AV_HWDEVICE_TYPE_VULKAN] = "vulkan",
8891 [AV_HWDEVICE_TYPE_AMF] = "amf",
92+ [AV_HWDEVICE_TYPE_OHCODEC] = "ohcodec",
8993 };
9094
9195 typedef struct FFHWDeviceContext {
libavutil/hwcontext.h+2−0
@@ -39,6 +39,8 @@ enum AVHWDeviceType { · 38 unmodified lines
3939 AV_HWDEVICE_TYPE_VULKAN,
4040 AV_HWDEVICE_TYPE_D3D12VA,
4141 AV_HWDEVICE_TYPE_AMF,
42+ /* OpenHarmony Codec device */
43+ AV_HWDEVICE_TYPE_OHCODEC,
4244 };
4345
4446 /**
libavutil/hwcontext_internal.h+1−0
@@ -164,5 +164,6 @@ extern const HWContextType ff_hwcontext_type_videotoolbox; · 163 unmodified lines
164164 extern const HWContextType ff_hwcontext_type_mediacodec;
165165 extern const HWContextType ff_hwcontext_type_vulkan;
166166 extern const HWContextType ff_hwcontext_type_amf;
167+extern const HWContextType ff_hwcontext_type_oh;
167168
168169 #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */
libavutil/hwcontext_oh.c+47−0
@@ -0,0 +1,47 @@
1+/*
2+ * This file is part of FFmpeg.
3+ *
4+ * Copyright (c) 2025 Zhao Zhili <quinkblack@foxmail.com>
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include <multimedia/player_framework/native_avcodec_base.h>
22+
23+#include "hwcontext.h"
24+#include "hwcontext_internal.h"
25+#include "hwcontext_oh.h"
26+
27+static int oh_device_create(AVHWDeviceContext *ctx, const char *device,
28+ AVDictionary *opts, int flags)
29+{
30+ if (device && device[0]) {
31+ av_log(ctx, AV_LOG_ERROR, "Device selection unsupported.\n");
32+ return AVERROR_UNKNOWN;
33+ }
34+
35+ return 0;
36+}
37+
38+const HWContextType ff_hwcontext_type_oh = {
39+ .type = AV_HWDEVICE_TYPE_OHCODEC,
40+ .name = "ohcodec",
41+ .device_hwctx_size = sizeof(AVOHCodecDeviceContext),
42+ .device_create = oh_device_create,
43+ .pix_fmts = (const enum AVPixelFormat[]) {
44+ AV_PIX_FMT_OHCODEC,
45+ AV_PIX_FMT_NONE
46+ },
47+};
libavutil/hwcontext_oh.h+34−0
@@ -0,0 +1,34 @@
1+/*
2+ * This file is part of FFmpeg.
3+ *
4+ * Copyright (c) 2025 Zhao Zhili <quinkblack@foxmail.com>
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#ifndef AVUTIL_HWCONTEXT_OH_H
22+#define AVUTIL_HWCONTEXT_OH_H
23+
24+/**
25+ * OpenHarmony codec device
26+ */
27+typedef struct AVOHCodecDeviceContext {
28+ /**
29+ * Pointer to OHNativeWindow
30+ */
31+ void *native_window;
32+} AVOHCodecDeviceContext;
33+
34+#endif /* AVUTIL_HWCONTEXT_OH_H */
libavutil/pixdesc.c+4−0
@@ -3263,6 +3263,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { · 3262 unmodified lines
32633263 },
32643264 .flags = AV_PIX_FMT_FLAG_BE,
32653265 },
3266+ [AV_PIX_FMT_OHCODEC] = {
3267+ .name = "ohcodec",
3268+ .flags = AV_PIX_FMT_FLAG_HWACCEL,
3269+ },
32663270 };
32673271
32683272 static const char * const color_range_names[] = {
libavutil/pixfmt.h+2−0
@@ -497,6 +497,8 @@ enum AVPixelFormat { · 496 unmodified lines
497497 AV_PIX_FMT_GBRP12MSBBE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, big-endian
498498 AV_PIX_FMT_GBRP12MSBLE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, little-endian
499499
500+ AV_PIX_FMT_OHCODEC, /// hardware decoding through openharmony
501+
500502 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
501503 };
502504
libavutil/version.h+2−2
@@ -79,8 +79,8 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 60
82−#define LIBAVUTIL_VERSION_MINOR 4
83−#define LIBAVUTIL_VERSION_MICRO 101
82+#define LIBAVUTIL_VERSION_MINOR 5
83+#define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
8686 LIBAVUTIL_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t