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
322 --enable-mediafoundation enable encoding via MediaFoundation [auto]322 --enable-mediafoundation enable encoding via MediaFoundation [auto]
323 --disable-metal disable Apple Metal framework [autodetect]323 --disable-metal disable Apple Metal framework [autodetect]
324 --enable-libmysofa enable libmysofa, needed for sofalizer filter [no]324 --enable-libmysofa enable libmysofa, needed for sofalizer filter [no]
325 --enable-ohcodec enable OpenHarmony Codec support [no]
325 --enable-openal enable OpenAL 1.1 capture support [no]326 --enable-openal enable OpenAL 1.1 capture support [no]
326 --enable-opencl enable OpenCL processing [no]327 --enable-opencl enable OpenCL processing [no]
327 --enable-opengl enable OpenGL rendering [no]328 --enable-opengl enable OpenGL rendering [no]
@@ -1997,6 +1998,7 @@ EXTERNAL_LIBRARY_LIST=" · 1669 unmodified lines
1997 libzvbi1998 libzvbi
1998 lv21999 lv2
1999 mediacodec2000 mediacodec
2001 ohcodec
2000 openal2002 openal
2001 opengl2003 opengl
2002 openssl2004 openssl
@@ -7171,6 +7173,9 @@ enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_co · 5168 unmodified lines
7171 check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } ||7173 check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } ||
7172 die "ERROR: mmal not found" &&7174 die "ERROR: mmal not found" &&
7173 check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; }7175 check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; }
7176enabled 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"; }
7174enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h" alGetError ||7179enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h" alGetError ||
7175 { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do7180 { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
7176 check_lib openal 'AL/al.h' alGetError "${al_extralibs}" && break; done } ||7181 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
2 2
3API changes, most recent first:3API changes, most recent first:
4 4
52025-07-18 - xxxxxxxxxx - lavu 60.5.100 - pixfmt.h
6 Add AV_PIX_FMT_OHCODEC.
7
82025-07-18 - xxxxxxxxxx - lavu 60.5.100 - hwcontext.h
9 Add AV_HWDEVICE_TYPE_OHCODEC and AVOHCodecDeviceContext.
10
52025-07-xx - xxxxxxxxxd - lavfi 11.2.100 - avfilter.h112025-07-xx - xxxxxxxxxd - lavfi 11.2.100 - avfilter.h
6 Add AVFilterGraph->max_buffered_frames.12 Add AVFilterGraph->max_buffered_frames.
7 13
libavutil/Makefile+2−0
@@ -51,6 +51,7 @@ HEADERS = adler32.h \ · 50 unmodified lines
51 hwcontext_qsv.h \51 hwcontext_qsv.h \
52 hwcontext_mediacodec.h \52 hwcontext_mediacodec.h \
53 hwcontext_opencl.h \53 hwcontext_opencl.h \
54 hwcontext_oh.h \
54 hwcontext_vaapi.h \55 hwcontext_vaapi.h \
55 hwcontext_videotoolbox.h \56 hwcontext_videotoolbox.h \
56 hwcontext_vdpau.h \57 hwcontext_vdpau.h \
@@ -210,6 +211,7 @@ OBJS-$(CONFIG_AMF) += hwcontext_amf.o · 153 unmodified lines
210OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o211OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o
211OBJS-$(CONFIG_MACOS_KPERF) += macos_kperf.o212OBJS-$(CONFIG_MACOS_KPERF) += macos_kperf.o
212OBJS-$(CONFIG_MEDIACODEC) += hwcontext_mediacodec.o213OBJS-$(CONFIG_MEDIACODEC) += hwcontext_mediacodec.o
214OBJS-$(CONFIG_OHCODEC) += hwcontext_oh.o
213OBJS-$(CONFIG_OPENCL) += hwcontext_opencl.o215OBJS-$(CONFIG_OPENCL) += hwcontext_opencl.o
214OBJS-$(CONFIG_QSV) += hwcontext_qsv.o216OBJS-$(CONFIG_QSV) += hwcontext_qsv.o
215OBJS-$(CONFIG_VAAPI) += hwcontext_vaapi.o217OBJS-$(CONFIG_VAAPI) += hwcontext_vaapi.o
libavutil/hwcontext.c+4−0
@@ -68,6 +68,9 @@ static const HWContextType * const hw_table[] = { · 67 unmodified lines
68#endif68#endif
69#if CONFIG_AMF69#if CONFIG_AMF
70 &ff_hwcontext_type_amf,70 &ff_hwcontext_type_amf,
71#endif
72#if CONFIG_OHCODEC
73 &ff_hwcontext_type_oh,
71#endif74#endif
72 NULL,75 NULL,
73};76};
@@ -86,6 +89,7 @@ static const char *const hw_type_names[] = { · 12 unmodified lines
86 [AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",89 [AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",
87 [AV_HWDEVICE_TYPE_VULKAN] = "vulkan",90 [AV_HWDEVICE_TYPE_VULKAN] = "vulkan",
88 [AV_HWDEVICE_TYPE_AMF] = "amf",91 [AV_HWDEVICE_TYPE_AMF] = "amf",
92 [AV_HWDEVICE_TYPE_OHCODEC] = "ohcodec",
89};93};
90 94
91typedef struct FFHWDeviceContext {95typedef struct FFHWDeviceContext {
libavutil/hwcontext.h+2−0
@@ -39,6 +39,8 @@ enum AVHWDeviceType { · 38 unmodified lines
39 AV_HWDEVICE_TYPE_VULKAN,39 AV_HWDEVICE_TYPE_VULKAN,
40 AV_HWDEVICE_TYPE_D3D12VA,40 AV_HWDEVICE_TYPE_D3D12VA,
41 AV_HWDEVICE_TYPE_AMF,41 AV_HWDEVICE_TYPE_AMF,
42 /* OpenHarmony Codec device */
43 AV_HWDEVICE_TYPE_OHCODEC,
42};44};
43 45
44/**46/**
libavutil/hwcontext_internal.h+1−0
@@ -164,5 +164,6 @@ extern const HWContextType ff_hwcontext_type_videotoolbox; · 163 unmodified lines
164extern const HWContextType ff_hwcontext_type_mediacodec;164extern const HWContextType ff_hwcontext_type_mediacodec;
165extern const HWContextType ff_hwcontext_type_vulkan;165extern const HWContextType ff_hwcontext_type_vulkan;
166extern const HWContextType ff_hwcontext_type_amf;166extern const HWContextType ff_hwcontext_type_amf;
167extern const HWContextType ff_hwcontext_type_oh;
167 168
168#endif /* AVUTIL_HWCONTEXT_INTERNAL_H */169#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
27static 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
38const 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 */
27typedef 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
3263 },3263 },
3264 .flags = AV_PIX_FMT_FLAG_BE,3264 .flags = AV_PIX_FMT_FLAG_BE,
3265 },3265 },
3266 [AV_PIX_FMT_OHCODEC] = {
3267 .name = "ohcodec",
3268 .flags = AV_PIX_FMT_FLAG_HWACCEL,
3269 },
3266};3270};
3267 3271
3268static const char * const color_range_names[] = {3272static const char * const color_range_names[] = {
libavutil/pixfmt.h+2−0
@@ -497,6 +497,8 @@ enum AVPixelFormat { · 496 unmodified lines
497 AV_PIX_FMT_GBRP12MSBBE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, big-endian497 AV_PIX_FMT_GBRP12MSBBE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, big-endian
498 AV_PIX_FMT_GBRP12MSBLE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, little-endian498 AV_PIX_FMT_GBRP12MSBLE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, little-endian
499 499
500 AV_PIX_FMT_OHCODEC, /// hardware decoding through openharmony
501
500 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 versions502 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
501};503};
502 504
libavutil/version.h+2−2
@@ -79,8 +79,8 @@ · 78 unmodified lines
79 */79 */
80 80
81#define LIBAVUTIL_VERSION_MAJOR 6081#define LIBAVUTIL_VERSION_MAJOR 60
82#define LIBAVUTIL_VERSION_MINOR 482#define LIBAVUTIL_VERSION_MINOR 5
83#define LIBAVUTIL_VERSION_MICRO 10183#define LIBAVUTIL_VERSION_MICRO 100
84 84
85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
86 LIBAVUTIL_VERSION_MINOR, \86 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