diff options
author | wm4 <wm4@nowhere> | 2015-03-29 15:12:11 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-29 16:09:56 +0200 |
commit | 8fff12542279960ff6e0a14f186d5c4c4d2bdfe4 (patch) | |
tree | c14e7d25ece5613d91cb507d40872a63825dfc2d /video/decode | |
parent | 38b05daf7d16898f4a63e4ccf48479d8964e6e19 (diff) | |
download | mpv-8fff12542279960ff6e0a14f186d5c4c4d2bdfe4.tar.bz2 mpv-8fff12542279960ff6e0a14f186d5c4c4d2bdfe4.tar.xz |
RPI support
This requires FFmpeg git master for accelerated hardware decoding.
Keep in mind that FFmpeg must be compiled with --enable-mmal. Libav
will also work.
Most things work. Screenshots don't work with accelerated/opaque
decoding (except using full window screenshot mode). Subtitles are
very slow - even simple but huge overlays can cause frame drops.
This always uses fullscreen mode. It uses dispmanx and mmal directly,
and there are no window managers or anything on this level.
vo_opengl also kind of works, but is pretty useless and slow. It can't
use opaque hardware decoding (copy back can be used by forcing the
option --vd=lavc:h264_mmal). Keep in mind that the dispmanx backend
is preferred over the X11 ones in case you're trying on X11; but X11
is even more useless on RPI.
This doesn't correctly reject extended h264 profiles and thus doesn't
fallback to software decoding. The hw supports only up to the high
profile, and will e.g. return garbage for Hi10P video.
This sets a precedent of enabling hw decoding by default, but only
if RPI support is compiled (which most hopefully it will be disabled
on desktop Linux platforms). While it's more or less required to use
hw decoding on the weak RPI, it causes more problems than it solves
on real platforms (Linux has the Intel GPU problem, OSX still has
some cases with broken decoding.) So I can live with this compromise
of having different defaults depending on the platform.
Raspberry Pi 2 is required. This wasn't tested on the original RPI,
though at least decoding itself seems to work (but full playback was
not tested).
Diffstat (limited to 'video/decode')
-rw-r--r-- | video/decode/lavc.h | 2 | ||||
-rw-r--r-- | video/decode/rpi.c | 56 | ||||
-rw-r--r-- | video/decode/vd_lavc.c | 9 |
3 files changed, 66 insertions, 1 deletions
diff --git a/video/decode/lavc.h b/video/decode/lavc.h index 85cf49abab..eaddd4abc2 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -52,6 +52,8 @@ struct vd_lavc_hwdec { // For horrible Intel shit-drivers only void (*lock)(struct lavc_ctx *ctx); void (*unlock)(struct lavc_ctx *ctx); + // Optional; if a special hardware decoder is needed (instead of "hwaccel"). + const char *(*get_codec)(struct lavc_ctx *ctx); }; enum { diff --git a/video/decode/rpi.c b/video/decode/rpi.c new file mode 100644 index 0000000000..44a550fe2e --- /dev/null +++ b/video/decode/rpi.c @@ -0,0 +1,56 @@ +/* + * This file is part of mpv. + * + * mpv is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mpv. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "lavc.h" +#include "common/common.h" + +static int init_decoder(struct lavc_ctx *ctx, int fmt, 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) +{ + if (strcmp(decoder, "h264") != 0) + return HWDEC_ERR_NO_CODEC; + return 0; +} + +static const char *get_codec(struct lavc_ctx *ctx) +{ + return "h264_mmal"; +} + +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 eecc130208..b328d24102 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -121,8 +121,12 @@ const struct vd_lavc_hwdec mp_vd_lavc_vda; const struct vd_lavc_hwdec mp_vd_lavc_vaapi; const struct vd_lavc_hwdec mp_vd_lavc_vaapi_copy; const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy; +const struct vd_lavc_hwdec mp_vd_lavc_rpi; static const struct vd_lavc_hwdec *const hwdec_list[] = { +#if HAVE_RPI + &mp_vd_lavc_rpi, +#endif #if HAVE_VDPAU_HWACCEL &mp_vd_lavc_vdpau, #endif @@ -303,6 +307,8 @@ static int init(struct dec_video *vd, const char *decoder) if (hwdec) { ctx->software_fallback_decoder = talloc_strdup(ctx, decoder); + if (hwdec->get_codec) + decoder = hwdec->get_codec(ctx); MP_INFO(vd, "Using hardware decoding.\n"); } else if (vd->opts->hwdec_api != HWDEC_NONE) { MP_INFO(vd, "Using software decoding.\n"); @@ -370,7 +376,8 @@ static void init_avctx(struct dec_video *vd, const char *decoder, if (ctx->hwdec) { avctx->thread_count = 1; avctx->get_format = get_format_hwdec; - avctx->get_buffer2 = get_buffer2_hwdec; + if (ctx->hwdec->allocate_image) + avctx->get_buffer2 = get_buffer2_hwdec; if (ctx->hwdec->init(ctx) < 0) goto error; } else { |