[vlc-devel] [PATCH 02/18] video_output: pass the input video context with the source format
Steve Lhomme
robux4 at ycbcr.xyz
Fri Nov 15 15:51:04 CET 2019
Keep it and release it at the same time.
---
src/video_output/video_output.c | 23 +++++++++++++++++++----
src/video_output/vout_internal.h | 1 +
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 0bbf45a7658..ee4daf4c380 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -749,7 +749,7 @@ typedef struct {
} vout_filter_t;
static void ThreadChangeFilters(vout_thread_t *vout,
- const video_format_t *source,
+ const video_format_t *source, vlc_video_context *src_vctx,
const char *filters,
const bool *new_deinterlace,
bool is_locked)
@@ -867,6 +867,9 @@ static void ThreadChangeFilters(vout_thread_t *vout,
if (source) {
video_format_Clean(&vout->p->filter.src_fmt);
video_format_Copy(&vout->p->filter.src_fmt, source);
+ if (vout->p->filter.src_vctx)
+ vlc_video_context_Release(vout->p->filter.src_vctx);
+ vout->p->filter.src_vctx = src_vctx ? vlc_video_context_Hold(src_vctx) : NULL;
}
if (!is_locked)
@@ -926,8 +929,9 @@ static int ThreadDisplayPreparePicture(vout_thread_t *vout, bool reuse,
msg_Dbg(vout, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
}
}
+ vlc_video_context *pic_vctx = picture_GetVideoContext(decoded);
if (!VideoFormatIsCropArEqual(&decoded->format, &vout->p->filter.src_fmt))
- ThreadChangeFilters(vout, &decoded->format, NULL, NULL, true);
+ ThreadChangeFilters(vout, &decoded->format, pic_vctx, NULL, NULL, true);
}
}
@@ -1520,6 +1524,7 @@ static int vout_Start(vout_thread_t *vout, vlc_video_context *vctx, const vout_c
sys->filter.configuration = NULL;
video_format_Copy(&sys->filter.src_fmt, &sys->original);
+ sys->filter.src_vctx = vctx ? vlc_video_context_Hold(vctx) : NULL;
static const struct filter_video_callbacks static_cbs = {
VoutVideoFilterStaticNewPicture,
@@ -1620,6 +1625,11 @@ error:
if (sys->filter.chain_static != NULL)
filter_chain_Delete(sys->filter.chain_static);
video_format_Clean(&sys->filter.src_fmt);
+ if (sys->filter.src_vctx)
+ {
+ vlc_video_context_Release(sys->filter.src_vctx);
+ sys->filter.src_vctx = NULL;
+ }
if (sys->decoder_fifo != NULL)
{
picture_fifo_Delete(sys->decoder_fifo);
@@ -1632,10 +1642,10 @@ static void ThreadControl(vout_thread_t *vout, vout_control_cmd_t cmd)
{
switch(cmd.type) {
case VOUT_CONTROL_CHANGE_FILTERS:
- ThreadChangeFilters(vout, NULL, cmd.string, NULL, false);
+ ThreadChangeFilters(vout, NULL, NULL, cmd.string, NULL, false);
break;
case VOUT_CONTROL_CHANGE_INTERLACE:
- ThreadChangeFilters(vout, NULL, NULL, &cmd.boolean, false);
+ ThreadChangeFilters(vout, NULL, NULL, NULL, &cmd.boolean, false);
break;
case VOUT_CONTROL_MOUSE_STATE:
ThreadProcessMouseState(vout, &cmd.mouse);
@@ -1716,6 +1726,11 @@ static void vout_ReleaseDisplay(vout_thread_t *vout)
filter_chain_Delete(sys->filter.chain_interactive);
filter_chain_Delete(sys->filter.chain_static);
video_format_Clean(&sys->filter.src_fmt);
+ if (sys->filter.src_vctx)
+ {
+ vlc_video_context_Release(sys->filter.src_vctx);
+ sys->filter.src_vctx = NULL;
+ }
free(sys->filter.configuration);
if (sys->decoder_fifo != NULL)
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 42c00de9809..0ca81871fee 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -163,6 +163,7 @@ struct vout_thread_sys_t
vlc_mutex_t lock;
char *configuration;
video_format_t src_fmt;
+ vlc_video_context *src_vctx;
struct filter_chain_t *chain_static;
struct filter_chain_t *chain_interactive;
bool has_deint;
--
2.17.1
More information about the vlc-devel
mailing list