mirror of https://github.com/mpv-player/mpv
vd_lavc: remove unneeded hwdec parameters
All hwdec backends now use a single pixel format, and the format is always checked. Also, the init_decoder callback is now mandatory.
This commit is contained in:
parent
cab1f6439c
commit
bffd78748f
|
@ -205,14 +205,11 @@ static void dxva2_release_img(void *ptr)
|
||||||
av_free(w);
|
av_free(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct mp_image *dxva2_allocate_image(struct lavc_ctx *s, int fmt,
|
static struct mp_image *dxva2_allocate_image(struct lavc_ctx *s,
|
||||||
int img_w, int img_h)
|
int img_w, int img_h)
|
||||||
{
|
{
|
||||||
DXVA2Context *ctx = s->hwdec_priv;
|
DXVA2Context *ctx = s->hwdec_priv;
|
||||||
|
|
||||||
if (fmt != IMGFMT_DXVA2)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
int i, old_unused = -1;
|
int i, old_unused = -1;
|
||||||
for (i = 0; i < ctx->num_surfaces; i++) {
|
for (i = 0; i < ctx->num_surfaces; i++) {
|
||||||
surface_info *info = &ctx->surface_infos[i];
|
surface_info *info = &ctx->surface_infos[i];
|
||||||
|
@ -652,7 +649,7 @@ fail:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dxva2_init_decoder(struct lavc_ctx *s, int fmt, int w, int h)
|
static int dxva2_init_decoder(struct lavc_ctx *s, int w, int h)
|
||||||
{
|
{
|
||||||
DXVA2Context *ctx = s->hwdec_priv;
|
DXVA2Context *ctx = s->hwdec_priv;
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,11 @@ struct vd_lavc_hwdec {
|
||||||
int (*probe)(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
|
int (*probe)(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
|
||||||
const char *decoder);
|
const char *decoder);
|
||||||
int (*init)(struct lavc_ctx *ctx);
|
int (*init)(struct lavc_ctx *ctx);
|
||||||
int (*init_decoder)(struct lavc_ctx *ctx, int fmt, int w, int h);
|
int (*init_decoder)(struct lavc_ctx *ctx, int w, int h);
|
||||||
void (*uninit)(struct lavc_ctx *ctx);
|
void (*uninit)(struct lavc_ctx *ctx);
|
||||||
// Note: if init_decoder is set, this will always use the values from the
|
// 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.
|
// last successful init_decoder call. Otherwise, it's up to you.
|
||||||
struct mp_image *(*allocate_image)(struct lavc_ctx *ctx, int fmt,
|
struct mp_image *(*allocate_image)(struct lavc_ctx *ctx, int w, int h);
|
||||||
int w, int h);
|
|
||||||
// Process the image returned by the libavcodec decoder.
|
// Process the image returned by the libavcodec decoder.
|
||||||
struct mp_image *(*process_image)(struct lavc_ctx *ctx, struct mp_image *img);
|
struct mp_image *(*process_image)(struct lavc_ctx *ctx, struct mp_image *img);
|
||||||
// For horrible Intel shit-drivers only
|
// For horrible Intel shit-drivers only
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "lavc.h"
|
#include "lavc.h"
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
|
||||||
static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
|
static int init_decoder(struct lavc_ctx *ctx, int w, int h)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ static bool has_profile(VAProfile *va_profiles, int num_profiles, VAProfile p)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
|
static int init_decoder(struct lavc_ctx *ctx, int w, int h)
|
||||||
{
|
{
|
||||||
void *tmp = talloc_new(NULL);
|
void *tmp = talloc_new(NULL);
|
||||||
|
|
||||||
|
@ -270,8 +270,7 @@ error:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct mp_image *allocate_image(struct lavc_ctx *ctx, int format,
|
static struct mp_image *allocate_image(struct lavc_ctx *ctx, int w, int h)
|
||||||
int w, int h)
|
|
||||||
{
|
{
|
||||||
struct priv *p = ctx->hwdec_priv;
|
struct priv *p = ctx->hwdec_priv;
|
||||||
|
|
||||||
|
|
|
@ -529,9 +529,8 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
|
||||||
ctx->hwdec_fmt = ctx->hwdec->image_format;
|
ctx->hwdec_fmt = ctx->hwdec->image_format;
|
||||||
ctx->hwdec_profile = avctx->profile;
|
ctx->hwdec_profile = avctx->profile;
|
||||||
ctx->hwdec_request_reinit = false;
|
ctx->hwdec_request_reinit = false;
|
||||||
if (ctx->hwdec->init_decoder && change) {
|
if (change) {
|
||||||
if (ctx->hwdec->init_decoder(ctx, ctx->hwdec_fmt,
|
if (ctx->hwdec->init_decoder(ctx, ctx->hwdec_w, ctx->hwdec_h) < 0)
|
||||||
ctx->hwdec_w, ctx->hwdec_h) < 0)
|
|
||||||
{
|
{
|
||||||
ctx->hwdec_fmt = 0;
|
ctx->hwdec_fmt = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -580,12 +579,10 @@ static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags)
|
||||||
int w = pic->width;
|
int w = pic->width;
|
||||||
int h = pic->height;
|
int h = pic->height;
|
||||||
|
|
||||||
if (ctx->hwdec->init_decoder) {
|
if (imgfmt != ctx->hwdec_fmt && w != ctx->hwdec_w && h != ctx->hwdec_h)
|
||||||
if (imgfmt != ctx->hwdec_fmt && w != ctx->hwdec_w && h != ctx->hwdec_h)
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct mp_image *mpi = ctx->hwdec->allocate_image(ctx, imgfmt, w, h);
|
struct mp_image *mpi = ctx->hwdec->allocate_image(ctx, w, h);
|
||||||
if (!mpi)
|
if (!mpi)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ static void print_vda_error(struct mp_log *log, int lev, char *message,
|
||||||
mp_msg(log, lev, "%s: %d\n", message, error_code);
|
mp_msg(log, lev, "%s: %d\n", message, error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
|
static int init_decoder(struct lavc_ctx *ctx, int w, int h)
|
||||||
{
|
{
|
||||||
av_vda_default_free(ctx->avctx);
|
av_vda_default_free(ctx->avctx);
|
||||||
#if HAVE_VDA_DEFAULT_INIT2
|
#if HAVE_VDA_DEFAULT_INIT2
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct priv {
|
||||||
uint64_t preemption_counter;
|
uint64_t preemption_counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
|
static int init_decoder(struct lavc_ctx *ctx, int w, int h)
|
||||||
{
|
{
|
||||||
struct priv *p = ctx->hwdec_priv;
|
struct priv *p = ctx->hwdec_priv;
|
||||||
|
|
||||||
|
@ -44,8 +44,7 @@ static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
|
||||||
AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH);
|
AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct mp_image *allocate_image(struct lavc_ctx *ctx, int fmt,
|
static struct mp_image *allocate_image(struct lavc_ctx *ctx, int w, int h)
|
||||||
int w, int h)
|
|
||||||
{
|
{
|
||||||
struct priv *p = ctx->hwdec_priv;
|
struct priv *p = ctx->hwdec_priv;
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ static void print_videotoolbox_error(struct mp_log *log, int lev, char *message,
|
||||||
mp_msg(log, lev, "%s: %d\n", message, error_code);
|
mp_msg(log, lev, "%s: %d\n", message, error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
|
static int init_decoder(struct lavc_ctx *ctx, int w, int h)
|
||||||
{
|
{
|
||||||
av_videotoolbox_default_free(ctx->avctx);
|
av_videotoolbox_default_free(ctx->avctx);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue