1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-19 18:05:21 +00:00

video: don't keep multiple pointers to hwdec info struct

This makes a certain corner case simpler at a later point.
This commit is contained in:
wm4 2014-08-11 23:08:35 +02:00
parent 056622c33e
commit b8f025a58a
7 changed files with 29 additions and 26 deletions

View File

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

View File

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

View File

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

View File

@ -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

View File

@ -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:

View File

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

View File

@ -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: