[vlc-devel] [PATCH] vmem: allow clients get and update additional format info
Rémi Denis-Courmont
remi at remlab.net
Wed Feb 3 17:37:40 CET 2016
On Sunday 31 January 2016 09:48:53 Sergey Radionov wrote:
> ---
> modules/video_output/vmem.c | 44
> ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38
> insertions(+), 6 deletions(-)
>
> diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
> index 5a6d869..bed22c8 100644
> --- a/modules/video_output/vmem.c
> +++ b/modules/video_output/vmem.c
> @@ -3,6 +3,7 @@
>
> ***************************************************************************
> ** * Copyright (C) 2008 VLC authors and VideoLAN
> * Copyrgiht (C) 2010 Rémi Denis-Courmont
> + * Copyright (C) 2016 Sergey Radionov <rsatom at gmail.com>
> *
> * Authors: Sam Hocevar <sam at zoy.org>
> *
> @@ -168,6 +169,27 @@ static int Open(vlc_object_t *object)
> video_format_t fmt;
> video_format_ApplyRotation(&fmt, &vd->fmt);
>
> + enum {
> + fmt_len,
> + fmt_offset,
> + fmt_visible_len,
> + fmt_sar,
> + fmt_update
> + };
> + unsigned fmt_x[] = {
> + fmt.i_width,
> + fmt.i_x_offset,
> + fmt.i_visible_width,
> + vd->source.i_sar_num,
> + FALSE
> + };
> + unsigned fmt_y[] = {
> + fmt.i_height,
> + fmt.i_y_offset,
> + fmt.i_visible_height,
> + vd->source.i_sar_den,
> + FALSE
> + };
IMHO, this is needlessly ugly. Use video_format_t instead of a table, this is
also more extensible.
Also a separate patch is needed for a proper accessor in LibVLC.
> if (setup != NULL) {
> char chroma[5];
>
> @@ -176,7 +198,7 @@ static int Open(vlc_object_t *object)
> memset(sys->pitches, 0, sizeof(sys->pitches));
> memset(sys->lines, 0, sizeof(sys->lines));
>
> - sys->count = setup(&sys->opaque, chroma, &fmt.i_width,
> &fmt.i_height, + sys->count = setup(&sys->opaque, chroma, fmt_x,
> fmt_y,
> sys->pitches, sys->lines);
> if (sys->count == 0) {
> msg_Err(vd, "video format setup failure (no pictures)");
> @@ -190,8 +212,8 @@ static int Open(vlc_object_t *object)
> fmt.i_chroma = vlc_fourcc_GetCodecFromString(VIDEO_ES, chroma);
> free(chroma);
>
> - fmt.i_width = var_InheritInteger(vd, "vmem-width");
> - fmt.i_height = var_InheritInteger(vd, "vmem-height");
> + fmt_x[fmt_len] = var_InheritInteger(vd, "vmem-width");
> + fmt_y[fmt_len] = var_InheritInteger(vd, "vmem-height");
> sys->pitches[0] = var_InheritInteger(vd, "vmem-pitch");
> sys->lines[0] = fmt.i_height;
> for (size_t i = 1; i < PICTURE_PLANE_MAX; i++)
> @@ -202,9 +224,19 @@ static int Open(vlc_object_t *object)
> sys->count = 1;
> sys->cleanup = NULL;
> }
> - fmt.i_x_offset = fmt.i_y_offset = 0;
> - fmt.i_visible_width = fmt.i_width;
> - fmt.i_visible_height = fmt.i_height;
> +
> + fmt.i_width = fmt_x[fmt_len];
> + fmt.i_height = fmt_y[fmt_len];
> + if (fmt_x[fmt_update] || fmt_y[fmt_update]) {
> + fmt.i_x_offset = fmt_x[fmt_offset];
> + fmt.i_y_offset = fmt_y[fmt_offset];
> + fmt.i_visible_width = fmt_x[fmt_visible_len];
> + fmt.i_visible_height = fmt_y[fmt_visible_len];
> + } else {
> + fmt.i_x_offset = fmt.i_y_offset = 0;
> + fmt.i_visible_width = fmt.i_width;
> + fmt.i_visible_height = fmt.i_height;
> + }
>
> if (!fmt.i_chroma) {
> msg_Err(vd, "vmem-chroma should be 4 characters long");
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list