/*****************************************************************************
* video_widgets.c : OSD widgets manipulation functions
*****************************************************************************
- * Copyright (C) 2004-2010 the VideoLAN team
+ * Copyright (C) 2004-2010 VLC authors and VideoLAN
* $Id$
*
* Author: Yoann Peronneau <yoann@videolan.org>
* Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
static void DrawRect(subpicture_region_t *r, int fill,
int x1, int y1, int x2, int y2)
{
- uint8_t *a = r->p_picture->A_PIXELS;
- int pitch = r->p_picture->A_PITCH;
+ uint8_t *p = r->p_picture->p->p_pixels;
+ int pitch = r->p_picture->p->i_pitch;
if (fill == STYLE_FILLED) {
for (int y = y1; y <= y2; y++) {
for (int x = x1; x <= x2; x++)
- a[x + pitch * y] = 0xff;
+ p[x + pitch * y] = 1;
}
} else {
for (int y = y1; y <= y2; y++) {
- a[x1 + pitch * y] = 0xff;
- a[x2 + pitch * y] = 0xff;
+ p[x1 + pitch * y] = 1;
+ p[x2 + pitch * y] = 1;
}
for (int x = x1; x <= x2; x++) {
- a[x + pitch * y1] = 0xff;
- a[x + pitch * y2] = 0xff;
+ p[x + pitch * y1] = 1;
+ p[x + pitch * y2] = 1;
}
}
}
static void DrawTriangle(subpicture_region_t *r, int fill,
int x1, int y1, int x2, int y2)
{
- uint8_t *a = r->p_picture->A_PIXELS;
- int pitch = r->p_picture->A_PITCH;
+ uint8_t *p = r->p_picture->p->p_pixels;
+ int pitch = r->p_picture->p->i_pitch;
const int mid = y1 + (y2 - y1) / 2;
/* TODO factorize it */
for (int y = y1; y <= mid; y++) {
int h = y - y1;
for (int x = x1; x <= x1 + h && x <= x2; x++) {
- a[x + pitch * y ] = 0xff;
- a[x + pitch * (y2 - h)] = 0xff;
+ p[x + pitch * y ] = 1;
+ p[x + pitch * (y2 - h)] = 1;
}
}
} else {
for (int y = y1; y <= mid; y++) {
int h = y - y1;
- a[x1 + pitch * y ] = 0xff;
- a[x1 + h + pitch * y ] = 0xff;
- a[x1 + pitch * (y2 - h)] = 0xff;
- a[x1 + h + pitch * (y2 - h)] = 0xff;
+ p[x1 + pitch * y ] = 1;
+ p[x1 + h + pitch * y ] = 1;
+ p[x1 + pitch * (y2 - h)] = 1;
+ p[x1 + h + pitch * (y2 - h)] = 1;
}
}
} else {
for (int y = y1; y <= mid; y++) {
int h = y - y1;
for (int x = x1; x >= x1 - h && x >= x2; x--) {
- a[x + pitch * y ] = 0xff;
- a[x + pitch * (y2 - h)] = 0xff;
+ p[x + pitch * y ] = 1;
+ p[x + pitch * (y2 - h)] = 1;
}
}
} else {
for (int y = y1; y <= mid; y++) {
int h = y - y1;
- a[ x1 + pitch * y ] = 0xff;
- a[ x1 - h + pitch * y ] = 0xff;
- a[ x1 + pitch * (y2 - h)] = 0xff;
- a[ x1 - h + pitch * (y2 - h)] = 0xff;
+ p[ x1 + pitch * y ] = 1;
+ p[ x1 - h + pitch * y ] = 1;
+ p[ x1 + pitch * (y2 - h)] = 1;
+ p[ x1 - h + pitch * (y2 - h)] = 1;
}
}
}
*/
static subpicture_region_t *OSDRegion(int x, int y, int width, int height)
{
+ video_palette_t palette = {
+ .i_entries = 2,
+ .palette = {
+ [0] = { 0xff, 0x80, 0x80, 0x00 },
+ [1] = { 0xff, 0x80, 0x80, 0xff },
+ },
+ };
+
video_format_t fmt;
- video_format_Init(&fmt, VLC_CODEC_YUVA);
+ video_format_Init(&fmt, VLC_CODEC_YUVP);
fmt.i_width =
fmt.i_visible_width = width;
fmt.i_height =
fmt.i_visible_height = height;
- fmt.i_sar_num = 0;
+ fmt.i_sar_num = 1;
fmt.i_sar_den = 1;
+ fmt.p_palette = &palette;
subpicture_region_t *r = subpicture_region_New(&fmt);
if (!r)
return NULL;
r->i_x = x;
r->i_y = y;
+ memset(r->p_picture->p->p_pixels, 0, r->p_picture->p->i_pitch * height);
- for (int i = 0; i < r->p_picture->i_planes; i++) {
- plane_t *p = &r->p_picture->p[i];
- int colors[PICTURE_PLANE_MAX] = {
- 0xff, 0x80, 0x80, 0x00
- };
- memset(p->p_pixels, colors[i], p->i_pitch * height);
- }
return r;
}
bool has_dst_changed, const video_format_t *fmt_dst,
mtime_t ts)
{
- VLC_UNUSED(subpic); VLC_UNUSED(ts); VLC_UNUSED(fmt_src);
- VLC_UNUSED(has_dst_changed); VLC_UNUSED(fmt_dst);
+ VLC_UNUSED(subpic); VLC_UNUSED(ts);
+ VLC_UNUSED(fmt_src); VLC_UNUSED(has_src_changed);
+ VLC_UNUSED(fmt_dst);
- if (!has_src_changed && !has_dst_changed)
+ if (!has_dst_changed)
return VLC_SUCCESS;
return VLC_EGENERIC;
}
mtime_t ts)
{
subpicture_updater_sys_t *sys = subpic->updater.p_sys;
- VLC_UNUSED(fmt_dst); VLC_UNUSED(ts);
+ VLC_UNUSED(fmt_src); VLC_UNUSED(ts);
+
+ video_format_t fmt = *fmt_dst;
+ fmt.i_width = fmt.i_width * fmt.i_sar_num / fmt.i_sar_den;
+ fmt.i_visible_width = fmt.i_visible_width * fmt.i_sar_num / fmt.i_sar_den;
+ fmt.i_x_offset = fmt.i_x_offset * fmt.i_sar_num / fmt.i_sar_den;
+ fmt.i_sar_num = 1;
+ fmt.i_sar_den = 1;
- subpic->i_original_picture_width = fmt_src->i_width;
- subpic->i_original_picture_height = fmt_src->i_height;
+ subpic->i_original_picture_width = fmt.i_width;
+ subpic->i_original_picture_height = fmt.i_height;
if (sys->type == OSD_HOR_SLIDER || sys->type == OSD_VERT_SLIDER)
- subpic->p_region = OSDSlider(sys->type, sys->position, fmt_src);
+ subpic->p_region = OSDSlider(sys->type, sys->position, &fmt);
else
- subpic->p_region = OSDIcon(sys->type, fmt_src);
+ subpic->p_region = OSDIcon(sys->type, &fmt);
}
static void OSDWidgetDestroy(subpicture_t *subpic)
if (!var_InheritBool(vout, "osd"))
return;
if (type == OSD_HOR_SLIDER || type == OSD_VERT_SLIDER)
- position = __MIN(__MAX(position, 0), 100);
+ position = VLC_CLIP(position, 0, 100);
subpicture_updater_sys_t *sys = malloc(sizeof(*sys));
if (!sys)
subpic->b_absolute = true;
subpic->b_fade = true;
- spu_DisplaySubpicture(vout_GetSpu(vout), subpic);
+ vout_PutSubpicture(vout, subpic);
}
void vout_OSDSlider(vout_thread_t *vout, int channel, int position, short type)