mirror of
https://github.com/mpv-player/mpv
synced 2024-11-03 03:19:24 +01:00
8fff125422
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).
78 lines
2.3 KiB
C
78 lines
2.3 KiB
C
#ifndef MPV_LAVC_H
|
|
#define MPV_LAVC_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include "demux/stheader.h"
|
|
#include "video/mp_image.h"
|
|
#include "video/hwdec.h"
|
|
|
|
typedef struct lavc_ctx {
|
|
struct mp_log *log;
|
|
struct MPOpts *opts;
|
|
AVCodecContext *avctx;
|
|
AVFrame *pic;
|
|
struct vd_lavc_hwdec *hwdec;
|
|
int selected_hwdec;
|
|
enum AVPixelFormat pix_fmt;
|
|
int best_csp;
|
|
enum AVDiscard skip_frame;
|
|
const char *software_fallback_decoder;
|
|
|
|
// From VO
|
|
struct mp_hwdec_info *hwdec_info;
|
|
|
|
// For free use by hwdec implementation
|
|
void *hwdec_priv;
|
|
|
|
int hwdec_fmt;
|
|
int hwdec_w;
|
|
int hwdec_h;
|
|
int hwdec_profile;
|
|
} vd_ffmpeg_ctx;
|
|
|
|
struct vd_lavc_hwdec {
|
|
enum hwdec_type type;
|
|
// If not-0: the IMGFMT_ format that should be accepted in the libavcodec
|
|
// get_format callback.
|
|
int image_format;
|
|
int (*probe)(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
|
|
const char *decoder);
|
|
int (*init)(struct lavc_ctx *ctx);
|
|
int (*init_decoder)(struct lavc_ctx *ctx, int fmt, int w, int h);
|
|
void (*uninit)(struct lavc_ctx *ctx);
|
|
// Note: if init_decoder is set, this will always use the values from the
|
|
// last successful init_decoder call. Otherwise, it's up to you.
|
|
struct mp_image *(*allocate_image)(struct lavc_ctx *ctx, int fmt,
|
|
int w, int h);
|
|
// Process the image returned by the libavcodec decoder.
|
|
struct mp_image *(*process_image)(struct lavc_ctx *ctx, struct mp_image *img);
|
|
// 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 {
|
|
HWDEC_ERR_NO_CTX = -2,
|
|
HWDEC_ERR_NO_CODEC = -3,
|
|
HWDEC_ERR_EMULATED = -4, // probing successful, but emulated API detected
|
|
};
|
|
|
|
struct hwdec_profile_entry {
|
|
enum AVCodecID av_codec;
|
|
int ff_profile;
|
|
uint64_t hw_profile;
|
|
};
|
|
|
|
const struct hwdec_profile_entry *hwdec_find_profile(
|
|
struct lavc_ctx *ctx, const struct hwdec_profile_entry *table);
|
|
bool hwdec_check_codec_support(const char *decoder,
|
|
const struct hwdec_profile_entry *table);
|
|
int hwdec_get_max_refs(struct lavc_ctx *ctx);
|
|
|
|
#endif
|