History

lavu/hwcontext: add AV_HWDEVICE_TYPE_MEDIACODEC

Aman Gupta committed 8 years ago

Commit e4d9f051 parent 54509728 files · +99 −1Browse files

Unified · Split

8 files
  1. doc/APIchanges +4 −0
  2. libavutil/Makefile +2 −0
  3. libavutil/hwcontext.c +4 −0
  4. libavutil/hwcontext.h +1 −0
  5. libavutil/hwcontext_internal.h +1 −0
  6. libavutil/hwcontext_mediacodec.c +50 −0
  7. libavutil/hwcontext_mediacodec.h +36 −0
  8. libavutil/version.h +1 −1
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2017-10-21 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2017-xx-xx - xxxxxxx - lavu 56.6.100 - hwcontext.h hwcontext_mediacodec.h
19+ Add AV_HWDEVICE_TYPE_MEDIACODEC and a new installed header with
20+ MediaCodec-specific hwcontext definitions.
21+
1822 2017-xx-xx - xxxxxxc - lavc 58.7.100 - avcodec.h
1923 Add AV_CODEC_CAP_HARDWARE, AV_CODEC_CAP_HYBRID, and AVCodec.wrapper_name,
2024 and mark all AVCodecs accordingly.
libavutil/Makefile+2−0
@@ -37,6 +37,7 @@ HEADERS = adler32.h \ · 36 unmodified lines
3737 hwcontext_drm.h \
3838 hwcontext_dxva2.h \
3939 hwcontext_qsv.h \
40+ hwcontext_mediacodec.h \
4041 hwcontext_vaapi.h \
4142 hwcontext_videotoolbox.h \
4243 hwcontext_vdpau.h \
@@ -166,6 +167,7 @@ OBJS-$(CONFIG_OPENCL) += hwcontext_opencl.o · 123 unmodified lines
166167 OBJS-$(CONFIG_VAAPI) += hwcontext_vaapi.o
167168 OBJS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.o
168169 OBJS-$(CONFIG_VDPAU) += hwcontext_vdpau.o
170+OBJS-$(CONFIG_MEDIACODEC) += hwcontext_mediacodec.o
169171
170172 OBJS += $(COMPAT_OBJS:%=../compat/%)
171173
libavutil/hwcontext.c+4−0
@@ -55,6 +55,9 @@ static const HWContextType * const hw_table[] = { · 54 unmodified lines
5555 #endif
5656 #if CONFIG_VIDEOTOOLBOX
5757 &ff_hwcontext_type_videotoolbox,
58+#endif
59+#if CONFIG_MEDIACODEC
60+ &ff_hwcontext_type_mediacodec,
5861 #endif
5962 NULL,
6063 };
@@ -69,6 +72,7 @@ static const char *const hw_type_names[] = { · 8 unmodified lines
6972 [AV_HWDEVICE_TYPE_VAAPI] = "vaapi",
7073 [AV_HWDEVICE_TYPE_VDPAU] = "vdpau",
7174 [AV_HWDEVICE_TYPE_VIDEOTOOLBOX] = "videotoolbox",
75+ [AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",
7276 };
7377
7478 enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
libavutil/hwcontext.h+1−0
@@ -35,6 +35,7 @@ enum AVHWDeviceType { · 34 unmodified lines
3535 AV_HWDEVICE_TYPE_D3D11VA,
3636 AV_HWDEVICE_TYPE_DRM,
3737 AV_HWDEVICE_TYPE_OPENCL,
38+ AV_HWDEVICE_TYPE_MEDIACODEC,
3839 };
3940
4041 typedef struct AVHWDeviceInternal AVHWDeviceInternal;
libavutil/hwcontext_internal.h+1−0
@@ -166,5 +166,6 @@ extern const HWContextType ff_hwcontext_type_qsv; · 165 unmodified lines
166166 extern const HWContextType ff_hwcontext_type_vaapi;
167167 extern const HWContextType ff_hwcontext_type_vdpau;
168168 extern const HWContextType ff_hwcontext_type_videotoolbox;
169+extern const HWContextType ff_hwcontext_type_mediacodec;
169170
170171 #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */
libavutil/hwcontext_mediacodec.c+50−0
@@ -0,0 +1,50 @@
1+/*
2+ * This file is part of FFmpeg.
3+ *
4+ * FFmpeg is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU Lesser General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2.1 of the License, or (at your option) any later version.
8+ *
9+ * FFmpeg is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public
15+ * License along with FFmpeg; if not, write to the Free Software
16+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+ */
18+
19+#include "config.h"
20+
21+#include "buffer.h"
22+#include "common.h"
23+#include "hwcontext.h"
24+#include "hwcontext_internal.h"
25+#include "hwcontext_mediacodec.h"
26+
27+static int mc_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_mediacodec = {
39+ .type = AV_HWDEVICE_TYPE_MEDIACODEC,
40+ .name = "mediacodec",
41+
42+ .device_hwctx_size = sizeof(AVMediaCodecDeviceContext),
43+
44+ .device_create = mc_device_create,
45+
46+ .pix_fmts = (const enum AVPixelFormat[]){
47+ AV_PIX_FMT_MEDIACODEC,
48+ AV_PIX_FMT_NONE
49+ },
50+};
libavutil/hwcontext_mediacodec.h+36−0
@@ -0,0 +1,36 @@
1+/*
2+ * This file is part of FFmpeg.
3+ *
4+ * FFmpeg is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU Lesser General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2.1 of the License, or (at your option) any later version.
8+ *
9+ * FFmpeg is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public
15+ * License along with FFmpeg; if not, write to the Free Software
16+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+ */
18+
19+#ifndef AVUTIL_HWCONTEXT_MEDIACODEC_H
20+#define AVUTIL_HWCONTEXT_MEDIACODEC_H
21+
22+/**
23+ * MediaCodec details.
24+ *
25+ * Allocated as AVHWDeviceContext.hwctx
26+ */
27+typedef struct AVMediaCodecDeviceContext {
28+ /**
29+ * android/view/Surface handle, to be filled by the user.
30+ *
31+ * This is the default surface used by decoders on this device.
32+ */
33+ void *surface;
34+} AVMediaCodecDeviceContext;
35+
36+#endif /* AVUTIL_HWCONTEXT_MEDIACODEC_H */
libavutil/version.h+1−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 56
82−#define LIBAVUTIL_VERSION_MINOR 5
82+#define LIBAVUTIL_VERSION_MINOR 6
8383 #define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

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