summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-08-19 21:33:18 +0200
committerwm4 <wm4@nowhere>2015-08-19 21:33:18 +0200
commitbffd78748fb7fb1248424b1d4d2d67eb31c8762f (patch)
tree92e1038645675c95d6fffb85b3a78ee5c299ee24
parentcab1f6439c201d877e709c45bb6a119feddc6a53 (diff)
downloadmpv-bffd78748fb7fb1248424b1d4d2d67eb31c8762f.tar.bz2
mpv-bffd78748fb7fb1248424b1d4d2d67eb31c8762f.tar.xz
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.
-rw-r--r--video/decode/dxva2.c7
-rw-r--r--video/decode/lavc.h5
-rw-r--r--video/decode/rpi.c2
-rw-r--r--video/decode/vaapi.c5
-rw-r--r--video/decode/vd_lavc.c13
-rw-r--r--video/decode/vda.c2
-rw-r--r--video/decode/vdpau.c5
-rw-r--r--video/decode/videotoolbox.c2
8 files changed, 16 insertions, 25 deletions
diff --git a/video/decode/dxva2.c b/video/decode/dxva2.c
index c87093812c..5e06f505ac 100644
--- a/video/decode/dxva2.c
+++ b/video/decode/dxva2.c
@@ -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;
diff --git a/video/decode/lavc.h b/video/decode/lavc.h
index f37f9cc4e6..590697d056 100644
--- a/video/decode/lavc.h
+++ b/video/decode/lavc.h
@@ -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
diff --git a/video/decode/rpi.c b/video/decode/rpi.c
index 44a550fe2e..819369de0d 100644
--- a/video/decode/rpi.c
+++ b/video/decode/rpi.c
@@ -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;
}
diff --git a/video/decode/vaapi.c b/video/decode/vaapi.c
index cace8e733e..33dfb365b8 100644
--- a/video/decode/vaapi.c
+++ b/video/decode/vaapi.c
@@ -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;
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index b8042a007d..62fd0cebb7 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -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;
diff --git a/video/decode/vda.c b/video/decode/vda.c
index 372061f194..538d21b753 100644
--- a/video/decode/vda.c
+++ b/video/decode/vda.c
@@ -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
diff --git a/video/decode/vdpau.c b/video/decode/vdpau.c
index dfa5164ae9..9a3e7e27cf 100644
--- a/video/decode/vdpau.c
+++ b/video/decode/vdpau.c
@@ -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;
diff --git a/video/decode/videotoolbox.c b/video/decode/videotoolbox.c
index c4f7c05f05..470f6b6cf3 100644
--- a/video/decode/videotoolbox.c
+++ b/video/decode/videotoolbox.c
@@ -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);