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:
wm4 2015-08-19 21:33:18 +02:00
parent cab1f6439c
commit bffd78748f
8 changed files with 16 additions and 25 deletions

View File

@ -205,14 +205,11 @@ static void dxva2_release_img(void *ptr)
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)
{
DXVA2Context *ctx = s->hwdec_priv;
if (fmt != IMGFMT_DXVA2)
return NULL;
int i, old_unused = -1;
for (i = 0; i < ctx->num_surfaces; i++) {
surface_info *info = &ctx->surface_infos[i];
@ -652,7 +649,7 @@ fail:
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;

View File

@ -43,12 +43,11 @@ struct vd_lavc_hwdec {
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);
int (*init_decoder)(struct lavc_ctx *ctx, 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);
struct mp_image *(*allocate_image)(struct lavc_ctx *ctx, 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

View File

@ -18,7 +18,7 @@
#include "lavc.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;
}

View File

@ -179,7 +179,7 @@ static bool has_profile(VAProfile *va_profiles, int num_profiles, VAProfile p)
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);
@ -270,8 +270,7 @@ error:
return res;
}
static struct mp_image *allocate_image(struct lavc_ctx *ctx, int format,
int w, int h)
static struct mp_image *allocate_image(struct lavc_ctx *ctx, int w, int h)
{
struct priv *p = ctx->hwdec_priv;

View File

@ -529,9 +529,8 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
ctx->hwdec_fmt = ctx->hwdec->image_format;
ctx->hwdec_profile = avctx->profile;
ctx->hwdec_request_reinit = false;
if (ctx->hwdec->init_decoder && change) {
if (ctx->hwdec->init_decoder(ctx, ctx->hwdec_fmt,
ctx->hwdec_w, ctx->hwdec_h) < 0)
if (change) {
if (ctx->hwdec->init_decoder(ctx, ctx->hwdec_w, ctx->hwdec_h) < 0)
{
ctx->hwdec_fmt = 0;
break;
@ -580,12 +579,10 @@ static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags)
int w = pic->width;
int h = pic->height;
if (ctx->hwdec->init_decoder) {
if (imgfmt != ctx->hwdec_fmt && w != ctx->hwdec_w && h != ctx->hwdec_h)
return -1;
}
if (imgfmt != ctx->hwdec_fmt && w != ctx->hwdec_w && h != ctx->hwdec_h)
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)
return -1;

View File

@ -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);
}
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);
#if HAVE_VDA_DEFAULT_INIT2

View File

@ -30,7 +30,7 @@ struct priv {
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;
@ -44,8 +44,7 @@ static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH);
}
static struct mp_image *allocate_image(struct lavc_ctx *ctx, int fmt,
int w, int h)
static struct mp_image *allocate_image(struct lavc_ctx *ctx, int w, int h)
{
struct priv *p = ctx->hwdec_priv;

View File

@ -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);
}
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);