summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-04-25 12:09:09 +0200
committerwm4 <wm4@nowhere>2016-04-25 12:23:38 +0200
commit7e3d8e7134096972989c8fae636e29af10ccaa79 (patch)
tree0be0b873878a87e3656dead0dca3bcd01885c201 /video/decode
parent46e49a37be8b2a8e48eb3143f9d6e7cc07de82e4 (diff)
downloadmpv-7e3d8e7134096972989c8fae636e29af10ccaa79.tar.bz2
mpv-7e3d8e7134096972989c8fae636e29af10ccaa79.tar.xz
vd_lavc: simplify RPI and Mediacodec wrappers
Use the recently added lavc_suffix mechanism to select the wrapper decoder. With all hwdec callbacks being optional, and RPI/Mediacodec having only dummy callbacks, all the callbacks can be removed as well. The result is that the vd_lavc_hwdec struct for both of them is tiny. It's better to move them to vd_lavc.c directly, because they are so trivial and small.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/mediacodec.c68
-rw-r--r--video/decode/rpi.c71
-rw-r--r--video/decode/vd_lavc.c14
3 files changed, 12 insertions, 141 deletions
diff --git a/video/decode/mediacodec.c b/video/decode/mediacodec.c
deleted file mode 100644
index 37ce1b8a2f..0000000000
--- a/video/decode/mediacodec.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "lavc.h"
-#include "common/common.h"
-
-static const char *const codecs[][2] = {
- {"h264", "h264_mediacodec"},
- {0}
-};
-
-static const char *map_codec(const char *c)
-{
- for (int n = 0; codecs[n][0]; n++) {
- if (c && strcmp(codecs[n][0], c) == 0)
- return codecs[n][1];
- }
- return NULL;
-}
-
-static int init_decoder(struct lavc_ctx *ctx, int w, int h)
-{
- return 0;
-}
-
-static void uninit(struct lavc_ctx *ctx)
-{
-}
-
-static int init(struct lavc_ctx *ctx)
-{
- return 0;
-}
-
-static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
- const char *decoder)
-{
- return map_codec(decoder) ? 0 : HWDEC_ERR_NO_CODEC;
-}
-
-static const char *get_codec(struct lavc_ctx *ctx, const char *codec)
-{
- return map_codec(codec);
-}
-
-const struct vd_lavc_hwdec mp_vd_lavc_mediacodec = {
- .type = HWDEC_MEDIACODEC,
- .image_format = IMGFMT_NV12,
- .probe = probe,
- .init = init,
- .uninit = uninit,
- .init_decoder = init_decoder,
- .get_codec = get_codec,
-};
diff --git a/video/decode/rpi.c b/video/decode/rpi.c
deleted file mode 100644
index f2ed6d2549..0000000000
--- a/video/decode/rpi.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "lavc.h"
-#include "common/common.h"
-
-static const char *const codecs[][2] = {
- {"h264", "h264_mmal"},
- {"mpeg2video", "mpeg2_mmal"},
- {"mpeg4", "mpeg4_mmal"},
- {"vc1", "vc1_mmal"},
- {0}
-};
-
-static const char *map_codec(const char *c)
-{
- for (int n = 0; codecs[n][0]; n++) {
- if (c && strcmp(codecs[n][0], c) == 0)
- return codecs[n][1];
- }
- return NULL;
-}
-
-static int init_decoder(struct lavc_ctx *ctx, int w, int h)
-{
- return 0;
-}
-
-static void uninit(struct lavc_ctx *ctx)
-{
-}
-
-static int init(struct lavc_ctx *ctx)
-{
- return 0;
-}
-
-static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
- const char *codec)
-{
- return map_codec(codec) ? 0 : HWDEC_ERR_NO_CODEC;
-}
-
-static const char *get_codec(struct lavc_ctx *ctx, const char *codec)
-{
- return map_codec(codec);
-}
-
-const struct vd_lavc_hwdec mp_vd_lavc_rpi = {
- .type = HWDEC_RPI,
- .image_format = IMGFMT_MMAL,
- .probe = probe,
- .init = init,
- .uninit = uninit,
- .init_decoder = init_decoder,
- .get_codec = get_codec,
-};
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index dc8c896aa5..24c98f2ef1 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -127,8 +127,18 @@ extern const struct vd_lavc_hwdec mp_vd_lavc_vaapi_copy;
extern const struct vd_lavc_hwdec mp_vd_lavc_dxva2;
extern const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy;
extern const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy;
-extern const struct vd_lavc_hwdec mp_vd_lavc_rpi;
-extern const struct vd_lavc_hwdec mp_vd_lavc_mediacodec;
+
+static const struct vd_lavc_hwdec mp_vd_lavc_rpi = {
+ .type = HWDEC_RPI,
+ .lavc_suffix = "_mmal",
+ .image_format = IMGFMT_MMAL,
+};
+
+static const struct vd_lavc_hwdec mp_vd_lavc_mediacodec = {
+ .type = HWDEC_MEDIACODEC,
+ .lavc_suffix = "_mediacodec",
+ .image_format = IMGFMT_NV12,
+};
static const struct vd_lavc_hwdec *const hwdec_list[] = {
#if HAVE_RPI