xine-lib 1.2.13-20230125hg15249
Data Structures | Macros | Enumerations | Functions | Variables
color.c File Reference
#include <xine/xine_internal.h>
#include "xine_mmx.h"

Data Structures

struct  rgb2yuy2_s
 

Macros

#define ALIGN4(ptr)   ((uintptr_t)(ptr) & ~(uintptr_t)3)
 
#define C_YUV420_YUYV_PROGRESSIVE(p_y1, p_y2, p_u, p_ut, p_ub, p_v, p_vt, p_vb, p_line1, p_line2)
 
#define C_YUV420_YUYV_INTERLACED(p_y1, p_y2, p_u, p_ut, p_ub, p_v, p_vt, p_vb, p_line1, p_line2)
 
#define C_YUYV_YUV420()
 
#define KB   0.114
 
#define KR   0.299
 
#define YR   (219.0/255.0)*KR*SCALEFACTOR
 
#define YG   (219.0/255.0)*(1.0-KB-KR)*SCALEFACTOR
 
#define YB   (219.0/255.0)*KB*SCALEFACTOR
 
#define UR   (112.0/255.0)*(KR/(KB-1.0))*SCALEFACTOR
 
#define UG   (112.0/255.0)*((1.0-KB-KR)/(KB-1.0))*SCALEFACTOR
 
#define UB   (112.0/255.0)*SCALEFACTOR
 
#define VR   (112.0/255.0)*SCALEFACTOR
 
#define VG   (112.0/255.0)*((1.0-KB-KR)/(KR-1.0))*SCALEFACTOR
 
#define VB   (112.0/255.0)*(KB/(KR-1.0))*SCALEFACTOR
 
#define GET_Y(v)   ((v) >> 13)
 
#define GET_U(v)   ((v) >> 55)
 
#define GET_V(v)   ((v) >> 34)
 

Enumerations

enum  rgb_fmt_t {
  rgb_bgr = 0 , rgb_rgb , rgb_bgra , rgb_argb ,
  rgb_rgba , rgb_rgb555le , rgb_rgb555be , rgb_rgb565le ,
  rgb_rgb565be , rgb_bgra_clut , rgb_rgba_clut , rgb_pal8 ,
  rgb_pal4 , rgb_pal2 , rgb_pal1
}
 

Functions

void init_yuv_planes (yuv_planes_t *yuv_planes, int width, int height)
 
void free_yuv_planes (yuv_planes_t *yuv_planes)
 
static void yuv444_to_yuy2_c (const yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch)
 
static void hscale_chroma_line (uint8_t *restrict dst, const uint8_t *restrict src, int src_width)
 
static void vscale_chroma_line (uint8_t *restrict dst, int pitch, const uint8_t *restrict src1, const uint8_t *restrict src2, int width)
 
static void upsample_c_plane_c (const uint8_t *src, int src_width, int src_height, uint8_t *dest, unsigned int src_pitch, unsigned int dest_pitch)
 
static void yuv9_to_yv12_c (const uint8_t *restrict y_src, int y_src_pitch, uint8_t *restrict y_dest, int y_dest_pitch, const uint8_t *restrict u_src, int u_src_pitch, uint8_t *restrict u_dest, int u_dest_pitch, const uint8_t *restrict v_src, int v_src_pitch, uint8_t *restrict v_dest, int v_dest_pitch, int width, int height)
 
static void yuv411_to_yv12_c (const uint8_t *restrict y_src, int y_src_pitch, uint8_t *restrict y_dest, int y_dest_pitch, const uint8_t *restrict u_src, int u_src_pitch, uint8_t *restrict u_dest, int u_dest_pitch, const uint8_t *restrict v_src, int v_src_pitch, uint8_t *restrict v_dest, int v_dest_pitch, int width, int height)
 
static void yv12_to_yuy2_c (const uint8_t *restrict y_src, int y_src_pitch, const uint8_t *restrict u_src, int u_src_pitch, const uint8_t *restrict v_src, int v_src_pitch, uint8_t *restrict yuy2_map, int yuy2_pitch, int width, int height, int progressive)
 
static void yuy2_to_yv12_c (const uint8_t *restrict yuy2_map, int yuy2_pitch, uint8_t *restrict y_dst, int y_dst_pitch, uint8_t *restrict u_dst, int u_dst_pitch, uint8_t *restrict v_dst, int v_dst_pitch, int width, int height)
 
void init_yuv_conversion (void)
 
rgb2yuy2_trgb2yuy2_alloc (int color_matrix, const char *format)
 
void rgb2yuy2_free (rgb2yuy2_t *rgb2yuy2)
 
void rgb2yuy2_palette (rgb2yuy2_t *rgb2yuy2, const uint8_t *pal, int num_colors, int bits_per_pixel)
 
void rgb2yuy2_slice (rgb2yuy2_t *rgb2yuy2, const uint8_t *restrict in, int ipitch, uint8_t *restrict out, int opitch, int width, int height)
 
void rgb2yv12_slice (rgb2yuy2_t *rgb2yuy2, const uint8_t *src, int src_stride, uint8_t *y_dst, int y_pitch, uint8_t *u_dst, int u_pitch, uint8_t *v_dst, int v_pitch, int width, int height)
 

Variables

int y_r_table [256]
 
int y_g_table [256]
 
int y_b_table [256]
 
int uv_br_table [256]
 
int u_r_table [256]
 
int u_g_table [256]
 
int v_b_table [256]
 
int v_g_table [256]
 
int u_b_table [256]
 
int v_r_table [256]
 
void(* yuv444_to_yuy2 )(const yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch)
 
void(* yuv9_to_yv12 )(const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, int width, int height)
 
void(* yuv411_to_yv12 )(const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, int width, int height)
 
void(* yv12_to_yuy2 )(const unsigned char *y_src, int y_src_pitch, const unsigned char *u_src, int u_src_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *yuy2_map, int yuy2_pitch, int width, int height, int progressive)
 
void(* yuy2_to_yv12 )(const unsigned char *yuy2_map, int yuy2_pitch, unsigned char *y_dst, int y_dst_pitch, unsigned char *u_dst, int u_dst_pitch, unsigned char *v_dst, int v_dst_pitch, int width, int height)
 

Macro Definition Documentation

◆ ALIGN4

#define ALIGN4 ( ptr)    ((uintptr_t)(ptr) & ~(uintptr_t)3)

◆ C_YUV420_YUYV_INTERLACED

#define C_YUV420_YUYV_INTERLACED ( p_y1,
p_y2,
p_u,
p_ut,
p_ub,
p_v,
p_vt,
p_vb,
p_line1,
p_line2 )
Value:
*p_line1++ = *p_y1++; *p_line2++ = *p_y2++; \
*p_line1++ = (*p_ut++ + *p_u * 7) >> 3; *p_line2++ = (*p_u++ * 5 + *p_ub++ * 3) >> 3; \
*p_line1++ = *p_y1++; *p_line2++ = *p_y2++; \
*p_line1++ = (*p_vt++ + *p_v * 7) >> 3; *p_line2++ = (*p_v++ * 5 + *p_vb++ * 3) >> 3; \

Referenced by yv12_to_yuy2_c().

◆ C_YUV420_YUYV_PROGRESSIVE

#define C_YUV420_YUYV_PROGRESSIVE ( p_y1,
p_y2,
p_u,
p_ut,
p_ub,
p_v,
p_vt,
p_vb,
p_line1,
p_line2 )
Value:
utmp = 3 * *p_u++; \
vtmp = 3 * *p_v++; \
*p_line1++ = *p_y1++; *p_line2++ = *p_y2++; \
*p_line1++ = (*p_ut++ + utmp) >> 2; *p_line2++ = (utmp + *p_ub++) >> 2; \
*p_line1++ = *p_y1++; *p_line2++ = *p_y2++; \
*p_line1++ = (*p_vt++ + vtmp) >> 2; *p_line2++ = (vtmp + *p_vb++) >> 2; \

Referenced by yv12_to_yuy2_c().

◆ C_YUYV_YUV420

#define C_YUYV_YUV420 ( )
Value:
*p_y1++ = *p_line1++; *p_y2++ = *p_line2++; \
*p_u++ = (*p_line1++ + *p_line2++)>>1; \
*p_y1++ = *p_line1++; *p_y2++ = *p_line2++; \
*p_v++ = (*p_line1++ + *p_line2++)>>1;

Referenced by yuy2_to_yv12_c().

◆ GET_U

#define GET_U ( v)    ((v) >> 55)

Referenced by rgb2yuy2_slice().

◆ GET_V

#define GET_V ( v)    ((v) >> 34)

Referenced by rgb2yuy2_slice().

◆ GET_Y

#define GET_Y ( v)    ((v) >> 13)

Referenced by rgb2yuy2_slice().

◆ KB

#define KB   0.114

◆ KR

#define KR   0.299

◆ UB

#define UB   (112.0/255.0)*SCALEFACTOR

◆ UG

#define UG   (112.0/255.0)*((1.0-KB-KR)/(KB-1.0))*SCALEFACTOR

◆ UR

#define UR   (112.0/255.0)*(KR/(KB-1.0))*SCALEFACTOR

◆ VB

#define VB   (112.0/255.0)*(KB/(KR-1.0))*SCALEFACTOR

◆ VG

#define VG   (112.0/255.0)*((1.0-KB-KR)/(KR-1.0))*SCALEFACTOR

◆ VR

#define VR   (112.0/255.0)*SCALEFACTOR

◆ YB

#define YB   (219.0/255.0)*KB*SCALEFACTOR

◆ YG

#define YG   (219.0/255.0)*(1.0-KB-KR)*SCALEFACTOR

◆ YR

#define YR   (219.0/255.0)*KR*SCALEFACTOR

Enumeration Type Documentation

◆ rgb_fmt_t

enum rgb_fmt_t
Enumerator
rgb_bgr 
rgb_rgb 
rgb_bgra 
rgb_argb 
rgb_rgba 
rgb_rgb555le 
rgb_rgb555be 
rgb_rgb565le 
rgb_rgb565be 
rgb_bgra_clut 
rgb_rgba_clut 
rgb_pal8 
rgb_pal4 
rgb_pal2 
rgb_pal1 

Function Documentation

◆ free_yuv_planes()

void free_yuv_planes ( yuv_planes_t * yuv_planes)

◆ hscale_chroma_line()

static void hscale_chroma_line ( uint8_t *restrict dst,
const uint8_t *restrict src,
int src_width )
static

References v.

Referenced by upsample_c_plane_c().

◆ init_yuv_conversion()

void init_yuv_conversion ( void )

◆ init_yuv_planes()

void init_yuv_planes ( yuv_planes_t * yuv_planes,
int width,
int height )

◆ rgb2yuy2_alloc()

rgb2yuy2_t * rgb2yuy2_alloc ( int color_matrix,
const char * format )

◆ rgb2yuy2_free()

void rgb2yuy2_free ( rgb2yuy2_t * rgb2yuy2)

◆ rgb2yuy2_palette()

void rgb2yuy2_palette ( rgb2yuy2_t * rgb2yuy2,
const uint8_t * pal,
int num_colors,
int bits_per_pixel )

◆ rgb2yuy2_slice()

void rgb2yuy2_slice ( rgb2yuy2_t * rgb2yuy2,
const uint8_t *restrict in,
int ipitch,
uint8_t *restrict out,
int opitch,
int width,
int height )

◆ rgb2yv12_slice()

void rgb2yv12_slice ( rgb2yuy2_t * rgb2yuy2,
const uint8_t * src,
int src_stride,
uint8_t * y_dst,
int y_pitch,
uint8_t * u_dst,
int u_pitch,
uint8_t * v_dst,
int v_pitch,
int width,
int height )

◆ upsample_c_plane_c()

static void upsample_c_plane_c ( const uint8_t * src,
int src_width,
int src_height,
uint8_t * dest,
unsigned int src_pitch,
unsigned int dest_pitch )
static

◆ vscale_chroma_line()

static void vscale_chroma_line ( uint8_t *restrict dst,
int pitch,
const uint8_t *restrict src1,
const uint8_t *restrict src2,
int width )
static

References ALIGN4, and width.

Referenced by upsample_c_plane_c().

◆ yuv411_to_yv12_c()

static void yuv411_to_yv12_c ( const uint8_t *restrict y_src,
int y_src_pitch,
uint8_t *restrict y_dest,
int y_dest_pitch,
const uint8_t *restrict u_src,
int u_src_pitch,
uint8_t *restrict u_dest,
int u_dest_pitch,
const uint8_t *restrict v_src,
int v_src_pitch,
uint8_t *restrict v_dest,
int v_dest_pitch,
int width,
int height )
static

References height, width, and xine_fast_memcpy.

Referenced by init_yuv_conversion().

◆ yuv444_to_yuy2_c()

static void yuv444_to_yuy2_c ( const yuv_planes_t * yuv_planes,
unsigned char * yuy2_map,
int pitch )
static

◆ yuv9_to_yv12_c()

static void yuv9_to_yv12_c ( const uint8_t *restrict y_src,
int y_src_pitch,
uint8_t *restrict y_dest,
int y_dest_pitch,
const uint8_t *restrict u_src,
int u_src_pitch,
uint8_t *restrict u_dest,
int u_dest_pitch,
const uint8_t *restrict v_src,
int v_src_pitch,
uint8_t *restrict v_dest,
int v_dest_pitch,
int width,
int height )
static

◆ yuy2_to_yv12_c()

static void yuy2_to_yv12_c ( const uint8_t *restrict yuy2_map,
int yuy2_pitch,
uint8_t *restrict y_dst,
int y_dst_pitch,
uint8_t *restrict u_dst,
int u_dst_pitch,
uint8_t *restrict v_dst,
int v_dst_pitch,
int width,
int height )
static

References C_YUYV_YUV420, height, restrict, and width.

Referenced by init_yuv_conversion().

◆ yv12_to_yuy2_c()

static void yv12_to_yuy2_c ( const uint8_t *restrict y_src,
int y_src_pitch,
const uint8_t *restrict u_src,
int u_src_pitch,
const uint8_t *restrict v_src,
int v_src_pitch,
uint8_t *restrict yuy2_map,
int yuy2_pitch,
int width,
int height,
int progressive )
static

Variable Documentation

◆ u_b_table

int u_b_table[256]

Referenced by init_yuv_conversion().

◆ u_g_table

int u_g_table[256]

Referenced by init_yuv_conversion().

◆ u_r_table

int u_r_table[256]

Referenced by init_yuv_conversion().

◆ uv_br_table

int uv_br_table[256]

Referenced by init_yuv_conversion().

◆ v_b_table

int v_b_table[256]

Referenced by init_yuv_conversion().

◆ v_g_table

int v_g_table[256]

Referenced by init_yuv_conversion().

◆ v_r_table

int v_r_table[256]

Referenced by init_yuv_conversion().

◆ y_b_table

int y_b_table[256]

Referenced by init_yuv_conversion().

◆ y_g_table

int y_g_table[256]

Referenced by init_yuv_conversion().

◆ y_r_table

int y_r_table[256]

Referenced by init_yuv_conversion().

◆ yuv411_to_yv12

void(* yuv411_to_yv12) (const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, int width, int height) ( const unsigned char * y_src,
int y_src_pitch,
unsigned char * y_dest,
int y_dest_pitch,
const unsigned char * u_src,
int u_src_pitch,
unsigned char * u_dest,
int u_dest_pitch,
const unsigned char * v_src,
int v_src_pitch,
unsigned char * v_dest,
int v_dest_pitch,
int width,
int height )

◆ yuv444_to_yuy2

void(* yuv444_to_yuy2) (const yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch) ( const yuv_planes_t * yuv_planes,
unsigned char * yuy2_map,
int pitch )

◆ yuv9_to_yv12

void(* yuv9_to_yv12) (const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, int width, int height) ( const unsigned char * y_src,
int y_src_pitch,
unsigned char * y_dest,
int y_dest_pitch,
const unsigned char * u_src,
int u_src_pitch,
unsigned char * u_dest,
int u_dest_pitch,
const unsigned char * v_src,
int v_src_pitch,
unsigned char * v_dest,
int v_dest_pitch,
int width,
int height )

◆ yuy2_to_yv12

void(* yuy2_to_yv12) (const unsigned char *yuy2_map, int yuy2_pitch, unsigned char *y_dst, int y_dst_pitch, unsigned char *u_dst, int u_dst_pitch, unsigned char *v_dst, int v_dst_pitch, int width, int height) ( const unsigned char * yuy2_map,
int yuy2_pitch,
unsigned char * y_dst,
int y_dst_pitch,
unsigned char * u_dst,
int u_dst_pitch,
unsigned char * v_dst,
int v_dst_pitch,
int width,
int height )

◆ yv12_to_yuy2

void(* yv12_to_yuy2) (const unsigned char *y_src, int y_src_pitch, const unsigned char *u_src, int u_src_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *yuy2_map, int yuy2_pitch, int width, int height, int progressive) ( const unsigned char * y_src,
int y_src_pitch,
const unsigned char * u_src,
int u_src_pitch,
const unsigned char * v_src,
int v_src_pitch,
unsigned char * yuy2_map,
int yuy2_pitch,
int width,
int height,
int progressive )