This commit is contained in:
Wim Taymans 2017-05-26 09:09:31 +02:00
parent 5b037661d9
commit 0f6b3a7cab
33 changed files with 652 additions and 673 deletions

View file

@ -17,8 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
typedef enum
{
typedef enum {
GRAY = 0,
YELLOW,
CYAN,
@ -37,8 +36,7 @@ typedef enum
typedef struct _Pixel Pixel;
struct _Pixel
{
struct _Pixel {
unsigned char R;
unsigned char G;
unsigned char B;
@ -47,8 +45,7 @@ struct _Pixel
unsigned char V;
};
static Pixel colors[N_COLORS] =
{
static Pixel colors[N_COLORS] = {
{191, 191, 191, 0, 0, 0}, /* GRAY */
{191, 191, 0, 0, 0, 0}, /* YELLOW */
{0, 191, 191, 0, 0, 0}, /* CYAN */
@ -63,13 +60,12 @@ static Pixel colors[N_COLORS] =
{9, 9, 9, 0, 0, 0}, /* DARK BLACK */
{29, 29, 29, 0, 0, 0}, /* LIGHT BLACK */
};
/* YUV values are computed in init_colors() */
typedef struct _DrawingData DrawingData;
typedef void (*DrawPixelFunc) (DrawingData *dd,
int x,
Pixel *pixel);
typedef void (*DrawPixelFunc) (DrawingData * dd, int x, Pixel * pixel);
struct _DrawingData {
char *line;
@ -79,8 +75,7 @@ struct _DrawingData {
DrawPixelFunc draw_pixel;
};
static inline void
update_yuv (Pixel *pixel)
static inline void update_yuv(Pixel * pixel)
{
uint16_t y, u, v;
@ -99,8 +94,7 @@ update_yuv (Pixel *pixel)
pixel->V = v + 128;
}
static void
init_colors (void)
static void init_colors(void)
{
int i;
@ -114,16 +108,14 @@ init_colors (void)
}
}
static void
draw_pixel_rgb (DrawingData *dd, int x, Pixel *color)
static void draw_pixel_rgb(DrawingData * dd, int x, Pixel * color)
{
dd->line[3 * x + 0] = color->R;
dd->line[3 * x + 1] = color->G;
dd->line[3 * x + 2] = color->B;
}
static void
draw_pixel_uyvy (DrawingData *dd, int x, Pixel *color)
static void draw_pixel_uyvy(DrawingData * dd, int x, Pixel * color)
{
if (x & 1) {
/* odd pixel */
@ -136,10 +128,7 @@ draw_pixel_uyvy (DrawingData *dd, int x, Pixel *color)
}
}
static int
drawing_data_init (DrawingData *dd,
struct impl *this,
char* data)
static int drawing_data_init(DrawingData * dd, struct impl *this, char *data)
{
struct spa_video_info *format = &this->current_format;
struct spa_rectangle *size = &format->info.raw.size;
@ -150,11 +139,9 @@ drawing_data_init (DrawingData *dd,
if (format->info.raw.format == this->type.video_format.RGB) {
dd->draw_pixel = draw_pixel_rgb;
}
else if (format->info.raw.format == this->type.video_format.UYVY) {
} else if (format->info.raw.format == this->type.video_format.UYVY) {
dd->draw_pixel = draw_pixel_uyvy;
}
else
} else
return SPA_RESULT_NOT_IMPLEMENTED;
dd->line = data;
@ -165,11 +152,7 @@ drawing_data_init (DrawingData *dd,
return SPA_RESULT_OK;
}
static inline void
draw_pixels (DrawingData *dd,
int offset,
Color color,
int length)
static inline void draw_pixels(DrawingData * dd, int offset, Color color, int length)
{
int x;
@ -178,14 +161,12 @@ draw_pixels (DrawingData *dd,
}
}
static inline void
next_line (DrawingData *dd)
static inline void next_line(DrawingData * dd)
{
dd->line += dd->stride;
}
static void
draw_smpte_snow (DrawingData *dd)
static void draw_smpte_snow(DrawingData * dd)
{
int h, w;
int y1, y2;
@ -255,8 +236,7 @@ draw_smpte_snow (DrawingData *dd)
}
}
static void
draw_snow (DrawingData *dd)
static void draw_snow(DrawingData * dd)
{
int x, y;
@ -276,8 +256,7 @@ draw_snow (DrawingData *dd)
}
}
static int
draw (struct impl *this, char *data)
static int draw(struct impl *this, char *data)
{
DrawingData dd;
int res;