summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-11 23:08:35 +0200
committerwm4 <wm4@nowhere>2014-08-11 23:09:39 +0200
commitb8f025a58a8dddc42442527229a20b7e45edcc22 (patch)
tree62f61b447bb122bf16656cdf80e175c9ff1f367e
parent056622c33e2ba305df4b1602149af01967bbb9ca (diff)
downloadmpv-b8f025a58a8dddc42442527229a20b7e45edcc22.tar.bz2
mpv-b8f025a58a8dddc42442527229a20b7e45edcc22.tar.xz
video: don't keep multiple pointers to hwdec info struct
This makes a certain corner case simpler at a later point.
-rw-r--r--player/video.c2
-rw-r--r--video/decode/dec_video.h2
-rw-r--r--video/decode/vd_lavc.c4
-rw-r--r--video/out/vo.h2
-rw-r--r--video/out/vo_opengl.c31
-rw-r--r--video/out/vo_vaapi.c7
-rw-r--r--video/out/vo_vdpau.c7
7 files changed, 29 insertions, 26 deletions
diff --git a/player/video.c b/player/video.c
index 73e8ef9d49..5b2748c894 100644
--- a/player/video.c
+++ b/player/video.c
@@ -173,7 +173,7 @@ static void recreate_video_filters(struct MPContext *mpctx)
vf_destroy(d_video->vfilter);
d_video->vfilter = vf_new(mpctx->global);
- d_video->vfilter->hwdec = &d_video->hwdec_info;
+ d_video->vfilter->hwdec = d_video->hwdec_info;
vf_append_filter_list(d_video->vfilter, opts->vf_settings);
diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h
index c9513ac3cd..5298a5616f 100644
--- a/video/decode/dec_video.h
+++ b/video/decode/dec_video.h
@@ -35,7 +35,7 @@ struct dec_video {
struct vf_chain *vfilter; // video filter chain
struct vo *vo; // (still) needed by video_set/get_colors
const struct vd_functions *vd_driver;
- struct mp_hwdec_info hwdec_info; // video output hwdec handles
+ struct mp_hwdec_info *hwdec_info; // video output hwdec handles
struct sh_stream *header;
char *decoder_desc;
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index de5c1eb672..1cd4503968 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -227,7 +227,7 @@ static struct vd_lavc_hwdec *probe_hwdec(struct dec_video *vd, bool autoprobe,
MP_VERBOSE(vd, "Requested hardware decoder not compiled.\n");
return NULL;
}
- int r = hwdec_probe(hwdec, &vd->hwdec_info, decoder);
+ int r = hwdec_probe(hwdec, vd->hwdec_info, decoder);
if (r == HWDEC_ERR_EMULATED) {
if (autoprobe)
return NULL;
@@ -342,7 +342,7 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
if (!lavc_codec)
return;
- ctx->hwdec_info = &vd->hwdec_info;
+ ctx->hwdec_info = vd->hwdec_info;
ctx->pix_fmt = AV_PIX_FMT_NONE;
ctx->hwdec = hwdec;
diff --git a/video/out/vo.h b/video/out/vo.h
index 7fbaa8e431..1d8182f71a 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -52,7 +52,7 @@ enum mp_voctrl {
VOCTRL_GET_EQUALIZER, // struct voctrl_get_equalizer_args*
/* for hardware decoding */
- VOCTRL_GET_HWDEC_INFO, // struct mp_hwdec_info*
+ VOCTRL_GET_HWDEC_INFO, // struct mp_hwdec_info**
// Redraw the image previously passed to draw_image() (basically, repeat
// the previous draw_image call). If this is handled, the OSD should also
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index c6464f09e9..7e6a03bbcf 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -60,6 +60,7 @@ struct gl_priv {
struct gl_video *renderer;
struct gl_hwdec *hwdec;
+ struct mp_hwdec_info hwdec_info;
// Options
struct gl_video_opts *renderer_opts;
@@ -183,7 +184,6 @@ static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
return 0;
}
-
static void load_hwdec_driver(struct gl_priv *p,
const struct gl_hwdec_driver *drv)
{
@@ -193,7 +193,7 @@ static void load_hwdec_driver(struct gl_priv *p,
.driver = drv,
.log = mp_log_new(hwdec, p->vo->log, drv->api_name),
.mpgl = p->glctx,
- .info = talloc_zero(hwdec, struct mp_hwdec_info),
+ .info = &p->hwdec_info,
.gl_texture_target = GL_TEXTURE_2D,
};
mpgl_lock(p->glctx);
@@ -208,9 +208,8 @@ static void load_hwdec_driver(struct gl_priv *p,
mpgl_unlock(p->glctx);
}
-static void request_hwdec_api(struct mp_hwdec_info *info, const char *api_name)
+static void request_hwdec_api(struct gl_priv *p, const char *api_name)
{
- struct gl_priv *p = info->load_api_ctx;
// Load at most one hwdec API
if (p->hwdec)
return;
@@ -218,24 +217,18 @@ static void request_hwdec_api(struct mp_hwdec_info *info, const char *api_name)
const struct gl_hwdec_driver *drv = mpgl_hwdec_drivers[n];
if (api_name && strcmp(drv->api_name, api_name) == 0) {
load_hwdec_driver(p, drv);
- if (p->hwdec) {
- *info = *p->hwdec->info;
+ if (p->hwdec)
return;
- }
}
}
}
-static void get_hwdec_info(struct gl_priv *p, struct mp_hwdec_info *info)
+static void call_request_hwdec_api(struct mp_hwdec_info *info,
+ const char *api_name)
{
- if (p->hwdec) {
- *info = *p->hwdec->info;
- } else {
- *info = (struct mp_hwdec_info) {
- .load_api = request_hwdec_api,
- .load_api_ctx = p,
- };
- }
+ struct vo *vo = info->load_api_ctx;
+ assert(&((struct gl_priv *)vo->priv)->hwdec_info == info);
+ request_hwdec_api(vo->priv, api_name);
}
static void unload_hwdec_driver(struct gl_priv *p)
@@ -363,7 +356,8 @@ static int control(struct vo *vo, uint32_t request, void *data)
return true;
}
case VOCTRL_GET_HWDEC_INFO: {
- get_hwdec_info(p, data);
+ struct mp_hwdec_info **arg = data;
+ *arg = &p->hwdec_info;
return true;
}
case VOCTRL_REDRAW_FRAME:
@@ -432,6 +426,9 @@ static int preinit(struct vo *vo)
mpgl_unset_context(p->glctx);
+ p->hwdec_info.load_api = call_request_hwdec_api;
+ p->hwdec_info.load_api_ctx = vo;
+
return 0;
err_out:
diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c
index 7e32563395..3c760ac07c 100644
--- a/video/out/vo_vaapi.c
+++ b/video/out/vo_vaapi.c
@@ -70,6 +70,7 @@ struct priv {
struct vo *vo;
VADisplay display;
struct mp_vaapi_ctx *mpvaapi;
+ struct mp_hwdec_info hwdec_info;
struct mp_image_params image_params;
struct mp_rect src_rect;
@@ -516,8 +517,8 @@ static int control(struct vo *vo, uint32_t request, void *data)
p->deint = *(int*)data ? p->deint_type : 0;
return VO_TRUE;
case VOCTRL_GET_HWDEC_INFO: {
- struct mp_hwdec_info *arg = data;
- arg->vaapi_ctx = p->mpvaapi;
+ struct mp_hwdec_info **arg = data;
+ *arg = &p->hwdec_info;
return true;
}
case VOCTRL_GET_COLORSPACE: {
@@ -598,6 +599,8 @@ static int preinit(struct vo *vo)
goto fail;
}
+ p->hwdec_info.vaapi_ctx = p->mpvaapi;
+
if (va_guess_if_emulated(p->mpvaapi)) {
MP_WARN(vo, "VA-API is most likely emulated via VDPAU.\n"
"It's better to use VDPAU directly with: --vo=vdpau\n");
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index 949d149a55..7cf11543ed 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -73,6 +73,7 @@ struct vdpctx {
struct vdp_functions *vdp;
VdpDevice vdp_device;
uint64_t preemption_counter;
+ struct mp_hwdec_info hwdec_info;
struct m_color colorkey;
@@ -1004,6 +1005,8 @@ static int preinit(struct vo *vo)
return -1;
}
+ vc->hwdec_info.vdpau_ctx = vc->mpvdp;
+
vc->video_mixer = mp_vdpau_mixer_create(vc->mpvdp, vo->log);
if (mp_vdpau_guess_if_emulated(vc->mpvdp)) {
@@ -1070,8 +1073,8 @@ static int control(struct vo *vo, uint32_t request, void *data)
vo->want_redraw = true;
return true;
case VOCTRL_GET_HWDEC_INFO: {
- struct mp_hwdec_info *arg = data;
- arg->vdpau_ctx = vc->mpvdp;
+ struct mp_hwdec_info **arg = data;
+ *arg = &vc->hwdec_info;
return true;
}
case VOCTRL_GET_PANSCAN: