[vlc-devel] [PATCH 1/2] core: es_out: add ES_OUT_SET_VOUT_HIGHLIGHT
Thomas Guillem
thomas at gllm.fr
Fri Jul 13 15:41:43 CEST 2018
A way to send the hl area with palette to the vout without variable and the global lock.
---
include/vlc_es_out.h | 3 ++
include/vlc_vout.h | 11 +++++++
src/input/decoder.c | 17 ++++++++++
src/input/decoder.h | 2 ++
src/input/es_out.c | 11 +++++++
src/input/es_out_timeshift.c | 14 +++++++++
src/video_output/video_output.c | 8 +++++
src/video_output/vout_internal.h | 3 ++
src/video_output/vout_subpictures.c | 49 ++++++++++-------------------
9 files changed, 85 insertions(+), 33 deletions(-)
diff --git a/include/vlc_es_out.h b/include/vlc_es_out.h
index c2a4212130..5736b6de7b 100644
--- a/include/vlc_es_out.h
+++ b/include/vlc_es_out.h
@@ -98,6 +98,9 @@ enum es_out_query_e
ES_OUT_POST_SUBNODE, /* arg1=input_item_node_t *, res=can fail */
+ ES_OUT_SET_VOUT_HIGHLIGHT, /* arg1= es_out_id_t* (spu or vout es),
+ arg2= const vlc_vout_highlight *, res=can fail */
+
/* First value usable for private control */
ES_OUT_PRIVATE_START = 0x10000,
};
diff --git a/include/vlc_vout.h b/include/vlc_vout.h
index 6bb712c17c..1f85322e6d 100644
--- a/include/vlc_vout.h
+++ b/include/vlc_vout.h
@@ -49,6 +49,7 @@
* Video output thread private structure
*/
typedef struct vout_thread_sys_t vout_thread_sys_t;
+typedef struct vlc_vout_highlight vlc_vout_highlight;
/**
* Video output thread descriptor
@@ -64,6 +65,16 @@ struct vout_thread_t {
vout_thread_sys_t *p;
};
+struct vlc_vout_highlight
+{
+ int x_start;
+ int x_end;
+ int y_start;
+ int y_end;
+ bool has_palette;
+ uint8_t palette[4][4];
+};
+
/* Alignment flags */
#define VOUT_ALIGN_LEFT 0x0001
#define VOUT_ALIGN_RIGHT 0x0002
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 69b7d2c19c..f4c23bb0f8 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2449,3 +2449,20 @@ void input_DecoderGetObjects( decoder_t *p_dec,
vlc_object_hold( p_owner->p_aout ) : NULL;
vlc_mutex_unlock( &p_owner->lock );
}
+
+int input_DecoderSetVoutHighlight( decoder_t *dec,
+ const vlc_vout_highlight *vout_hl )
+{
+ struct decoder_owner *p_owner = dec_get_owner( dec );
+
+ vlc_mutex_lock( &p_owner->lock );
+ if( p_owner->p_vout )
+ {
+ fprintf(stderr, "vout_SetHighlight: %p\n", vout_hl );
+ vout_SetHighlight( p_owner->p_vout, vout_hl );
+ vlc_mutex_unlock( &p_owner->lock );
+ return VLC_SUCCESS;
+ }
+ vlc_mutex_unlock( &p_owner->lock );
+ return VLC_EGENERIC;
+}
diff --git a/src/input/decoder.h b/src/input/decoder.h
index 2cfda8cc54..97af858409 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -116,4 +116,6 @@ size_t input_DecoderGetFifoSize( decoder_t *p_dec );
*/
void input_DecoderGetObjects( decoder_t *, vout_thread_t **, audio_output_t ** );
+int input_DecoderSetVoutHighlight( decoder_t *, const vlc_vout_highlight * );
+
#endif
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 676e1816ce..664e1d1b78 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2876,6 +2876,17 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
return VLC_SUCCESS;
}
+ case ES_OUT_SET_VOUT_HIGHLIGHT:
+ {
+ es_out_id_t *es = va_arg( args, es_out_id_t * );
+ const vlc_vout_highlight *vout_hl =
+ va_arg( args, const vlc_vout_highlight * );
+
+ if( es != NULL && es->p_dec )
+ return input_DecoderSetVoutHighlight( es->p_dec, vout_hl );
+ return VLC_EGENERIC;
+ }
+
default:
msg_Err( p_sys->p_input, "unknown query 0x%x in %s", i_query,
__func__ );
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index d17a8f8f2b..a6f27587fe 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -145,6 +145,11 @@ typedef struct attribute_packed
vlc_tick_t i_pts_jitter;
int i_cr_average;
} jitter;
+ struct
+ {
+ es_out_id_t *p_es;
+ const vlc_vout_highlight *p_hl;
+ } vout_hl;
} u;
} ts_cmd_control_t;
@@ -627,6 +632,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
case ES_OUT_SET_TIMES:
case ES_OUT_SET_JITTER:
case ES_OUT_SET_EOS:
+ case ES_OUT_SET_VOUT_HIGHLIGHT:
{
ts_cmd_t cmd;
if( CmdInitControl( &cmd, i_query, args, p_sys->b_delayed ) )
@@ -1505,6 +1511,11 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co
break;
}
+ case ES_OUT_SET_VOUT_HIGHLIGHT:
+ p_cmd->u.control.u.vout_hl.p_es = (es_out_id_t*) va_arg( args, es_out_id_t * );
+ p_cmd->u.control.u.vout_hl.p_hl = va_arg( args, const vlc_vout_highlight * );
+ break;
+
default:
vlc_assert_unreachable();
return VLC_EGENERIC;
@@ -1587,6 +1598,9 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
p_cmd->u.control.u.jitter.i_pts_jitter,
p_cmd->u.control.u.jitter.i_cr_average );
+ case ES_OUT_SET_VOUT_HIGHLIGHT:
+ return es_out_Control( p_out, i_query, p_cmd->u.control.u.vout_hl.p_es->p_es,
+ p_cmd->u.control.u.vout_hl.p_hl );
default:
vlc_assert_unreachable();
return VLC_EGENERIC;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 5db7acf509..4131b9b7d7 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -397,6 +397,14 @@ void vout_FlushSubpictureChannel( vout_thread_t *vout, int channel )
vout_control_PushInteger(&vout->p->control, VOUT_CONTROL_FLUSH_SUBPICTURE,
channel);
}
+void vout_SetHighlight( vout_thread_t *vout,
+ const vlc_vout_highlight *vout_hl )
+{
+ vlc_mutex_lock(&vout->p->spu_lock);
+ if (vout->p->spu)
+ spu_SetHighlight(vout->p->spu, vout_hl);
+ vlc_mutex_unlock(&vout->p->spu_lock);
+}
/**
* Allocates a video output picture buffer.
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index b6940ba070..f00c9996ad 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -219,6 +219,7 @@ void vout_ManageWrapper(vout_thread_t *);
int spu_ProcessMouse(spu_t *, const vlc_mouse_t *, const video_format_t *);
void spu_Attach( spu_t *, vlc_object_t *input, bool );
void spu_ChangeMargin(spu_t *, int);
+void spu_SetHighlight(spu_t *, const vlc_vout_highlight*);
/**
* This function will (un)pause the display of pictures.
@@ -274,4 +275,6 @@ void vout_DisplayTitle( vout_thread_t *p_vout, const char *psz_title );
*/
bool vout_IsEmpty( vout_thread_t *p_vout );
+void vout_SetHighlight( vout_thread_t *p_vout, const vlc_vout_highlight * );
+
#endif
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index e5bcc1555d..fc39b866e0 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -1141,11 +1141,8 @@ static subpicture_t *SpuRenderSubpictures(spu_t *spu,
/*****************************************************************************
* UpdateSPU: update subpicture settings
- *****************************************************************************
- * This function is called from CropCallback and at initialization time, to
- * retrieve crop information from the input.
*****************************************************************************/
-static void UpdateSPU(spu_t *spu, vlc_object_t *object)
+static void UpdateSPU(spu_t *spu, const vlc_vout_highlight *hl)
{
spu_private_t *sys = spu->p;
vlc_value_t val;
@@ -1155,43 +1152,29 @@ static void UpdateSPU(spu_t *spu, vlc_object_t *object)
sys->force_palette = false;
sys->force_crop = false;
- if (var_Get(object, "highlight", &val) || !val.b_bool) {
+ if (hl == NULL) {
vlc_mutex_unlock(&sys->lock);
return;
}
sys->force_crop = true;
- sys->crop.x = var_GetInteger(object, "x-start");
- sys->crop.y = var_GetInteger(object, "y-start");
- sys->crop.width = var_GetInteger(object, "x-end") - sys->crop.x;
- sys->crop.height = var_GetInteger(object, "y-end") - sys->crop.y;
+ sys->crop.x = hl->x_start;
+ sys->crop.y = hl->y_start;
+ sys->crop.width = hl->x_end - sys->crop.x;
+ sys->crop.height = hl->y_end - sys->crop.y;
- if (var_Get(object, "menu-palette", &val) == VLC_SUCCESS) {
- memcpy(sys->palette, val.p_address, 16);
+ if (hl->has_palette) {
+ memcpy(sys->palette, hl->palette, 16);
sys->force_palette = true;
}
vlc_mutex_unlock(&sys->lock);
- msg_Dbg(object, "crop: %i,%i,%i,%i, palette forced: %i",
+ msg_Dbg(spu, "crop: %i,%i,%i,%i, palette forced: %i",
sys->crop.x, sys->crop.y,
sys->crop.width, sys->crop.height,
sys->force_palette);
}
-/*****************************************************************************
- * CropCallback: called when the highlight properties are changed
- *****************************************************************************
- * This callback is called from the input thread when we need cropping
- *****************************************************************************/
-static int CropCallback(vlc_object_t *object, char const *var,
- vlc_value_t oldval, vlc_value_t newval, void *data)
-{
- VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(var);
-
- UpdateSPU((spu_t *)data, object);
- return VLC_SUCCESS;
-}
-
/*****************************************************************************
* Buffers allocation callbacks for the filters
*****************************************************************************/
@@ -1390,9 +1373,7 @@ void spu_Destroy(spu_t *spu)
void spu_Attach(spu_t *spu, vlc_object_t *input, bool attach)
{
if (attach) {
- UpdateSPU(spu, input);
- var_Create(input, "highlight", VLC_VAR_BOOL);
- var_AddCallback(input, "highlight", CropCallback, spu);
+ UpdateSPU(spu, NULL);
vlc_mutex_lock(&spu->p->lock);
spu->p->input = input;
@@ -1406,10 +1387,6 @@ void spu_Attach(spu_t *spu, vlc_object_t *input, bool attach)
vlc_mutex_lock(&spu->p->lock);
spu->p->input = NULL;
vlc_mutex_unlock(&spu->p->lock);
-
- /* Delete callbacks */
- var_DelCallback(input, "highlight", CropCallback, spu);
- var_Destroy(input, "highlight");
}
}
@@ -1714,3 +1691,9 @@ void spu_ChangeMargin(spu_t *spu, int margin)
vlc_mutex_unlock(&sys->lock);
}
+void spu_SetHighlight(spu_t *spu, const vlc_vout_highlight *hl)
+{
+ spu_private_t *sys = spu->p;
+
+ UpdateSPU(spu, hl);
+}
--
2.18.0
More information about the vlc-devel
mailing list