vlc | branch: master | Steve Lhomme <[email protected]> | Mon Nov 9 09:44:36 2020 +0100| [05acaa1e459ed2e1b0f163518e3248ba19bb23a3] | committer: Steve Lhomme
video_output: let the deinterlacing code access vout_thread_interlacing_t This is still private compared to the rest of the core. deinterlacing.c contains the video_output logic to switch the deinterlacing mode. We don't pass the vout_thread_interlacing_t anymore as it can be deduced from the vout_thread_t pointer. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=05acaa1e459ed2e1b0f163518e3248ba19bb23a3 --- src/video_output/interlacing.c | 14 ++++++-- src/video_output/video_output.c | 80 ++++++++++++++++++++--------------------- src/video_output/vout_private.h | 13 +++++-- 3 files changed, 60 insertions(+), 47 deletions(-) diff --git a/src/video_output/interlacing.c b/src/video_output/interlacing.c index bb2f1341ea..438bc97555 100644 --- a/src/video_output/interlacing.c +++ b/src/video_output/interlacing.c @@ -61,6 +61,11 @@ static bool DeinterlaceIsModeValid(const char *mode) return false; } +static inline vout_thread_interlacing_t *vout_to_interlacing(vout_thread_t *vout) +{ + return &container_of(vout, vout_sys_t, obj)->interlacing; +} + static int DeinterlaceCallback(vlc_object_t *object, char const *cmd, vlc_value_t oldval, vlc_value_t newval, void *data) { @@ -90,8 +95,9 @@ static int DeinterlaceCallback(vlc_object_t *object, char const *cmd, return VLC_SUCCESS; } -void vout_InitInterlacingSupport(vout_thread_t *vout, vout_thread_interlacing_t *sys) +void vout_InitInterlacingSupport(vout_thread_t *vout) { + vout_thread_interlacing_t *sys = vout_to_interlacing(vout); vlc_value_t val; msg_Dbg(vout, "Deinterlacing available"); @@ -157,14 +163,16 @@ void vout_InitInterlacingSupport(vout_thread_t *vout, vout_thread_interlacing_t sys->is_interlaced = false; } -void vout_ReinitInterlacingSupport(vout_thread_t *vout, vout_thread_interlacing_t *sys) +void vout_ReinitInterlacingSupport(vout_thread_t *vout) { + vout_thread_interlacing_t *sys = vout_to_interlacing(vout); sys->is_interlaced = false; var_SetBool(vout, "deinterlace-needed", false); } -void vout_SetInterlacingState(vout_thread_t *vout, vout_thread_interlacing_t *sys, bool is_interlaced) +void vout_SetInterlacingState(vout_thread_t *vout, bool is_interlaced) { + vout_thread_interlacing_t *sys = vout_to_interlacing(vout); /* Wait 30s before quiting interlacing mode */ const int interlacing_change = (!!is_interlaced) - (!!sys->is_interlaced); diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index b3b9b6ef3c..6befd49832 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -64,9 +64,7 @@ typedef struct vout_thread_sys_t { - struct vout_thread_t obj; - - vout_thread_interlacing_t interlacing; + vout_sys_t obj; vout_thread_private_t private; @@ -188,7 +186,7 @@ typedef struct vout_thread_sys_t } vout_thread_sys_t; #define VOUT_THREAD_TO_SYS(vout) \ - container_of(vout, vout_thread_sys_t, obj.obj) + container_of(vout, vout_thread_sys_t, obj.obj.obj) /* Maximum delay between 2 displayed pictures. @@ -341,7 +339,7 @@ static void vout_UpdateWindowSizeLocked(vout_thread_sys_t *vout) vout_SizeWindow(vout, &sys->original, &width, &height); vlc_mutex_unlock(&sys->display_lock); - msg_Dbg(&vout->obj, "requested window size: %ux%u", width, height); + msg_Dbg(&vout->obj.obj, "requested window size: %ux%u", width, height); vout_window_SetSize(sys->display_cfg.window, width, height); } else vlc_mutex_unlock(&sys->display_lock); @@ -840,7 +838,7 @@ void vout_ChangeViewpoint(vout_thread_t *vout, /* */ static void VoutGetDisplayCfg(vout_thread_sys_t *p_vout, const video_format_t *fmt, vout_display_cfg_t *cfg) { - vout_thread_t *vout = &p_vout->obj; + vout_thread_t *vout = &p_vout->obj.obj; /* Load configuration */ cfg->viewpoint = fmt->pose; @@ -967,7 +965,7 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout, bool flush_displayed) vlc_array_init(&array_static); vlc_array_init(&array_interactive); - if (sys->interlacing.has_deint) + if (sys->obj.interlacing.has_deint) { vout_filter_t *e = malloc(sizeof(*e)); @@ -1025,16 +1023,16 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout, bool flush_displayed) filter_chain_Reset(chain, p_fmt_current, vctx_current, p_fmt_current); for (size_t i = 0; i < vlc_array_count(array); i++) { vout_filter_t *e = vlc_array_item_at_index(array, i); - msg_Dbg(&vout->obj, "Adding '%s' as %s", e->name, a == 0 ? "static" : "interactive"); + msg_Dbg(&vout->obj.obj, "Adding '%s' as %s", e->name, a == 0 ? "static" : "interactive"); filter_t *filter = filter_chain_AppendFilter(chain, e->name, e->cfg, NULL); if (!filter) { - msg_Err(&vout->obj, "Failed to add filter '%s'", e->name); + msg_Err(&vout->obj.obj, "Failed to add filter '%s'", e->name); config_ChainDestroy(e->cfg); } else if (a == 1) /* Add callbacks for interactive filters */ - filter_AddProxyCallbacks(&vout->obj, filter, FilterRestartCallback); + filter_AddProxyCallbacks(&vout->obj.obj, filter, FilterRestartCallback); free(e->name); free(e); @@ -1048,10 +1046,10 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout, bool flush_displayed) } if (!es_format_IsSimilar(p_fmt_current, &fmt_target)) { - msg_Dbg(&vout->obj, "Adding a filter to compensate for format changes"); + msg_Dbg(&vout->obj.obj, "Adding a filter to compensate for format changes"); if (filter_chain_AppendConverter(sys->filter.chain_interactive, &fmt_target) != 0) { - msg_Err(&vout->obj, "Failed to compensate for the format changes, removing all filters"); + msg_Err(&vout->obj.obj, "Failed to compensate for the format changes, removing all filters"); ThreadDelAllFilterCallbacks(vout); filter_chain_Reset(sys->filter.chain_static, &fmt_target, vctx_target, &fmt_target); filter_chain_Reset(sys->filter.chain_interactive, &fmt_target, vctx_target, &fmt_target); @@ -1123,12 +1121,12 @@ static picture_t *ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reus else late_threshold = VOUT_DISPLAY_LATE_THRESHOLD; if (late > late_threshold) { - msg_Warn(&vout->obj, "picture is too late to be displayed (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late)); + msg_Warn(&vout->obj.obj, "picture is too late to be displayed (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late)); picture_Release(decoded); vout_statistic_AddLost(&sys->statistic, 1); continue; } else if (late > 0) { - msg_Dbg(&vout->obj, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late)); + msg_Dbg(&vout->obj.obj, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late)); vout_statistic_AddLate(&sys->statistic, 1); } } @@ -1180,7 +1178,7 @@ static picture_t *ConvertRGB32AndBlend(vout_thread_sys_t *vout, picture_t *pic, .video = &vout_video_cbs, .sys = vout, }; - filter_chain_t *filterc = filter_chain_NewVideo(&vout->obj, false, &owner); + filter_chain_t *filterc = filter_chain_NewVideo(&vout->obj.obj, false, &owner); if (!filterc) return NULL; @@ -1205,7 +1203,7 @@ static picture_t *ConvertRGB32AndBlend(vout_thread_sys_t *vout, picture_t *pic, if (pic) { - vlc_blender_t *swblend = filter_NewBlend(VLC_OBJECT(&vout->obj), &dst.video); + vlc_blender_t *swblend = filter_NewBlend(VLC_OBJECT(&vout->obj.obj), &dst.video); if (swblend) { bool success = picture_BlendSubpicture(pic, swblend, subpic) > 0; @@ -1235,7 +1233,7 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now) return VLC_EGENERIC; if (filtered->date != sys->displayed.current->date) - msg_Warn(&vout->obj, "Unsupported timestamp modifications done by chain_interactive"); + msg_Warn(&vout->obj.obj, "Unsupported timestamp modifications done by chain_interactive"); vout_display_t *vd = sys->display; @@ -1313,9 +1311,9 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now) } if (!sys->spu_blend && sys->spu_blend_chroma != fmt_spu.i_chroma) { sys->spu_blend_chroma = fmt_spu.i_chroma; - sys->spu_blend = filter_NewBlend(VLC_OBJECT(&vout->obj), &fmt_spu); + sys->spu_blend = filter_NewBlend(VLC_OBJECT(&vout->obj.obj), &fmt_spu); if (!sys->spu_blend) - msg_Err(&vout->obj, "Failed to create blending filter, OSD/Subtitles will not work"); + msg_Err(&vout->obj.obj, "Failed to create blending filter, OSD/Subtitles will not work"); } } @@ -1414,7 +1412,7 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now) { static int i = 0; if (((i++)%10) == 0) - msg_Info(&vout->obj, "render: avg %d ms var %d ms", + msg_Info(&vout->obj.obj, "render: avg %d ms var %d ms", (int)(sys->render.avg/1000), (int)(sys->render.var/1000)); } #endif @@ -1471,9 +1469,9 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline) vlc_mutex_lock(&sys->filter.lock); if (sys->filter.changed || - sys->interlacing.has_deint != sys->filter.new_interlaced) + sys->obj.interlacing.has_deint != sys->filter.new_interlaced) { - sys->interlacing.has_deint = sys->filter.new_interlaced; + sys->obj.interlacing.has_deint = sys->filter.new_interlaced; ThreadChangeFilters(vout, true); } vlc_mutex_unlock(&sys->filter.lock); @@ -1717,7 +1715,7 @@ static void ThreadProcessMouseState(vout_thread_sys_t *p_vout, { vlc_mouse_t tmp1, tmp2; const vlc_mouse_t *m; - vout_thread_t *vout = &p_vout->obj; + vout_thread_t *vout = &p_vout->obj.obj; vout_thread_sys_t *sys = p_vout; /* pass mouse coordinates in the filter chains. */ @@ -1774,10 +1772,10 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo .video = &static_cbs, .sys = vout, }; - sys->filter.chain_static = filter_chain_NewVideo(&vout->obj, true, &owner); + sys->filter.chain_static = filter_chain_NewVideo(&vout->obj.obj, true, &owner); owner.video = &interactive_cbs; - sys->filter.chain_interactive = filter_chain_NewVideo(&vout->obj, true, &owner); + sys->filter.chain_interactive = filter_chain_NewVideo(&vout->obj.obj, true, &owner); vout_display_cfg_t dcfg; int x = 0, y = 0, w = 0, h = 0; @@ -1827,7 +1825,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo dcfg.window_props.width = sys->window_width; dcfg.window_props.height = sys->window_height; - sys->display = vout_OpenWrapper(&vout->obj, &sys->private, sys->splitter_name, &dcfg, + sys->display = vout_OpenWrapper(&vout->obj.obj, &sys->private, sys->splitter_name, &dcfg, &sys->original, vctx); if (sys->display == NULL) { vlc_mutex_unlock(&sys->display_lock); @@ -1858,7 +1856,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo sys->spu_blend_chroma = 0; sys->spu_blend = NULL; - video_format_Print(VLC_OBJECT(&vout->obj), "original format", &sys->original); + video_format_Print(VLC_OBJECT(&vout->obj.obj), "original format", &sys->original); return VLC_SUCCESS; error: if (sys->filter.chain_interactive != NULL) @@ -1924,7 +1922,7 @@ static void *Thread(void *object) const bool picture_interlaced = sys->displayed.is_interlaced; - vout_SetInterlacingState(&vout->obj, &sys->interlacing, picture_interlaced); + vout_SetInterlacingState(&vout->obj.obj, picture_interlaced); } } @@ -1942,7 +1940,7 @@ static void vout_ReleaseDisplay(vout_thread_sys_t *vout) vout_FlushUnlocked(vout, true, INT64_MAX); vlc_mutex_lock(&sys->display_lock); - vout_CloseWrapper(&vout->obj, &sys->private, sys->display); + vout_CloseWrapper(&vout->obj.obj, &sys->private, sys->display); sys->display = NULL; vlc_mutex_unlock(&sys->display_lock); @@ -2070,7 +2068,7 @@ static vout_thread_sys_t *vout_CreateCommon(vlc_object_t *object) if (!vout) return NULL; - vout_CreateVars(&vout->obj); + vout_CreateVars(&vout->obj.obj); vout_thread_sys_t *sys = vout; vlc_atomic_rc_init(&sys->rc); @@ -2086,7 +2084,7 @@ vout_thread_t *vout_CreateDummy(vlc_object_t *object) vout_thread_sys_t *sys = vout; sys->dummy = true; - return &vout->obj; + return &vout->obj.obj; } vout_thread_t *vout_Create(vlc_object_t *object) @@ -2094,7 +2092,7 @@ vout_thread_t *vout_Create(vlc_object_t *object) vout_thread_sys_t *p_vout = vout_CreateCommon(object); if (!p_vout) return NULL; - vout_thread_t *vout = &p_vout->obj; + vout_thread_t *vout = &p_vout->obj.obj; vout_thread_sys_t *sys = p_vout; sys->dummy = false; @@ -2132,7 +2130,7 @@ vout_thread_t *vout_Create(vlc_object_t *object) sys->title.timeout = var_InheritInteger(vout, "video-title-timeout"); sys->title.position = var_InheritInteger(vout, "video-title-position"); - vout_InitInterlacingSupport(vout, &sys->interlacing); + vout_InitInterlacingSupport(vout); sys->is_late_dropped = var_InheritBool(vout, "drop-late-frames"); @@ -2201,12 +2199,12 @@ static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *ori if (!sys->window_enabled) { vout_window_cfg_t wcfg = { - .is_fullscreen = var_GetBool(&vout->obj, "fullscreen"), - .is_decorated = var_InheritBool(&vout->obj, "video-deco"), + .is_fullscreen = var_GetBool(&vout->obj.obj, "fullscreen"), + .is_decorated = var_InheritBool(&vout->obj.obj, "video-deco"), // TODO: take pixel A/R, crop and zoom into account #if defined(__APPLE__) || defined(_WIN32) - .x = var_InheritInteger(&vout->obj, "video-x"), - .y = var_InheritInteger(&vout->obj, "video-y"), + .x = var_InheritInteger(&vout->obj.obj, "video-x"), + .y = var_InheritInteger(&vout->obj.obj, "video-y"), #endif }; @@ -2214,7 +2212,7 @@ static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *ori vout_SizeWindow(vout, original, &wcfg.width, &wcfg.height); if (vout_window_Enable(sys->display_cfg.window, &wcfg)) { - msg_Err(&vout->obj, "failed to enable window"); + msg_Err(&vout->obj.obj, "failed to enable window"); return -1; } sys->window_enabled = true; @@ -2225,7 +2223,7 @@ static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *ori static void vout_InitSource(vout_thread_sys_t *vout) { - char *psz_ar = var_InheritString(&vout->obj, "aspect-ratio"); + char *psz_ar = var_InheritString(&vout->obj.obj, "aspect-ratio"); if (psz_ar) { unsigned num, den; if (!GetAspectRatio(psz_ar, &num, &den)) @@ -2233,7 +2231,7 @@ static void vout_InitSource(vout_thread_sys_t *vout) free(psz_ar); } - char *psz_crop = var_InheritString(&vout->obj, "crop"); + char *psz_crop = var_InheritString(&vout->obj.obj, "crop"); if (psz_crop) { unsigned num, den; unsigned y, x; @@ -2299,7 +2297,7 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input if (sys->display != NULL) vout_StopDisplay(cfg->vout); - vout_ReinitInterlacingSupport(cfg->vout, &sys->interlacing); + vout_ReinitInterlacingSupport(cfg->vout); sys->original = original; diff --git a/src/video_output/vout_private.h b/src/video_output/vout_private.h index 9899ce7a69..8befd1bbaf 100644 --- a/src/video_output/vout_private.h +++ b/src/video_output/vout_private.h @@ -43,13 +43,20 @@ struct vout_thread_private_t picture_pool_t *display_pool; }; +typedef struct +{ + vout_thread_t obj; + + vout_thread_interlacing_t interlacing; +} vout_sys_t; + /* */ vout_display_t *vout_OpenWrapper(vout_thread_t *, vout_thread_private_t *, const char *, const vout_display_cfg_t *, video_format_t *, vlc_video_context *); void vout_CloseWrapper(vout_thread_t *, vout_thread_private_t *, vout_display_t *vd); -void vout_InitInterlacingSupport(vout_thread_t *, vout_thread_interlacing_t *); -void vout_ReinitInterlacingSupport(vout_thread_t *, vout_thread_interlacing_t *); -void vout_SetInterlacingState(vout_thread_t *, vout_thread_interlacing_t *, bool is_interlaced); +void vout_InitInterlacingSupport(vout_thread_t *); +void vout_ReinitInterlacingSupport(vout_thread_t *); +void vout_SetInterlacingState(vout_thread_t *, bool is_interlaced); #endif // LIBVLC_VOUT_PRIVATE_H _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
