Commit 063357c9 authored by Laurent Aimar's avatar Laurent Aimar

Converted subpicture widget/epg to YUVP.

parent 52cd14db
......@@ -41,17 +41,26 @@ static subpicture_region_t * vout_OSDEpgSlider(int x, int y,
int width, int height,
float ratio)
{
video_format_t fmt;
subpicture_region_t *region;
/* Create a new subpicture region */
video_format_Init(&fmt, VLC_CODEC_YUVA);
video_palette_t palette = {
.i_entries = 4,
.palette = {
[0] = { 0xff, 0x80, 0x80, 0x00 },
[1] = { 0x00, 0x80, 0x80, 0x00 },
[2] = { 0xff, 0x80, 0x80, 0xff },
[3] = { 0x00, 0x80, 0x80, 0xff },
},
};
video_format_t fmt;
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 = 1;
fmt.i_sar_den = 1;
fmt.p_palette = &palette;
region = subpicture_region_New(&fmt);
subpicture_region_t *region = subpicture_region_New(&fmt);
if (!region)
return NULL;
......@@ -65,24 +74,16 @@ static subpicture_region_t * vout_OSDEpgSlider(int x, int y,
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
#define WRITE_COMP(plane, value) \
picture->p[plane].p_pixels[picture->p[plane].i_pitch * j + i] = value
/* Draw the slider. */
/* Slider border. */
bool is_outline = j == 0 || j == height - 1 ||
i == 0 || i == width - 1;
WRITE_COMP(0, is_outline ? 0x00 : 0xff);
WRITE_COMP(1, 0x80);
WRITE_COMP(2, 0x80);
/* We can see the video through the part of the slider
which corresponds to the leaving time. */
bool is_border = j < 3 || j > height - 4 ||
i < 3 || i > width - 4 ||
i < filled_part_width;
WRITE_COMP(3, is_border ? 0xff : 0x00);
#undef WRITE_COMP
picture->p->p_pixels[picture->p->i_pitch * j + i] = 2 * is_border + is_outline;
}
}
......
......@@ -46,22 +46,22 @@
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;
}
}
}
......@@ -73,8 +73,8 @@ static void DrawRect(subpicture_region_t *r, int fill,
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 */
......@@ -83,17 +83,17 @@ static void DrawTriangle(subpicture_region_t *r, int fill,
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 {
......@@ -101,17 +101,17 @@ static void DrawTriangle(subpicture_region_t *r, int fill,
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;
}
}
}
......@@ -122,28 +122,31 @@ static void DrawTriangle(subpicture_region_t *r, int fill,
*/
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 = 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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment