mirror of https://github.com/mpv-player/mpv
rpi: add support for codecs other than h264
FFmpeg now supports h264 and mpeg2. At least vc-1 will probably follow.
This commit is contained in:
parent
66ed50aa00
commit
2cf9ee989c
|
@ -56,7 +56,7 @@ struct vd_lavc_hwdec {
|
||||||
void (*lock)(struct lavc_ctx *ctx);
|
void (*lock)(struct lavc_ctx *ctx);
|
||||||
void (*unlock)(struct lavc_ctx *ctx);
|
void (*unlock)(struct lavc_ctx *ctx);
|
||||||
// Optional; if a special hardware decoder is needed (instead of "hwaccel").
|
// Optional; if a special hardware decoder is needed (instead of "hwaccel").
|
||||||
const char *(*get_codec)(struct lavc_ctx *ctx);
|
const char *(*get_codec)(struct lavc_ctx *ctx, const char *codec);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -18,6 +18,21 @@
|
||||||
#include "lavc.h"
|
#include "lavc.h"
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
|
||||||
|
static const char *const codecs[][2] = {
|
||||||
|
{"h264", "h264_mmal"},
|
||||||
|
{"mpeg2video", "mpeg2_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)
|
static int init_decoder(struct lavc_ctx *ctx, int w, int h)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -35,14 +50,12 @@ static int init(struct lavc_ctx *ctx)
|
||||||
static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
|
static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
|
||||||
const char *decoder)
|
const char *decoder)
|
||||||
{
|
{
|
||||||
if (strcmp(decoder, "h264") != 0)
|
return map_codec(decoder) ? 0 : HWDEC_ERR_NO_CODEC;
|
||||||
return HWDEC_ERR_NO_CODEC;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *get_codec(struct lavc_ctx *ctx)
|
static const char *get_codec(struct lavc_ctx *ctx, const char *codec)
|
||||||
{
|
{
|
||||||
return "h264_mmal";
|
return map_codec(codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct vd_lavc_hwdec mp_vd_lavc_rpi = {
|
const struct vd_lavc_hwdec mp_vd_lavc_rpi = {
|
||||||
|
|
|
@ -327,7 +327,7 @@ static int init(struct dec_video *vd, const char *decoder)
|
||||||
if (hwdec) {
|
if (hwdec) {
|
||||||
ctx->software_fallback_decoder = talloc_strdup(ctx, decoder);
|
ctx->software_fallback_decoder = talloc_strdup(ctx, decoder);
|
||||||
if (hwdec->get_codec)
|
if (hwdec->get_codec)
|
||||||
decoder = hwdec->get_codec(ctx);
|
decoder = hwdec->get_codec(ctx, decoder);
|
||||||
MP_VERBOSE(vd, "Trying hardware decoding.\n");
|
MP_VERBOSE(vd, "Trying hardware decoding.\n");
|
||||||
} else {
|
} else {
|
||||||
MP_VERBOSE(vd, "Using software decoding.\n");
|
MP_VERBOSE(vd, "Using software decoding.\n");
|
||||||
|
|
Loading…
Reference in New Issue