Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
e70d9d1f
Commit
e70d9d1f
authored
Jan 18, 2000
by
Vincent Seguin
Browse files
Changement de l'API de vout (chroma_width)
Nettoyage des YUV. Ne marche qu'en -g pour le moment, le reste arrive.
parent
c871659c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
e70d9d1f
...
...
@@ -22,7 +22,7 @@ VIDEO=X11
# Target architecture and optimization
#ARCH=
ARCH
=
MMX
#
ARCH=MMX
#ARCH=PPC
# Decoder choice - ?? old decoder will be removed soon
...
...
@@ -174,7 +174,7 @@ audio_output_obj = audio_output/audio_output.o \
video_output_obj
=
video_output/video_output.o
\
video_output/video_
$(video)
.o
\
video_output/video_yuv
_c
.o
video_output/video_yuv.o
ac3_decoder_obj
=
ac3_decoder/ac3_decoder.o
\
ac3_decoder/ac3_parse.o
\
...
...
include/config.h
View file @
e70d9d1f
...
...
@@ -338,7 +338,7 @@
/* Define to enable messages queues - disabling messages queue can be usefull
* when debugging, since it allows messages which would not otherwise be printed,
* due to a crash, to be printed anyway */
#define INTF_MSG_QUEUE
//
#define INTF_MSG_QUEUE
/* Format of the header for debug messages. The arguments following this header
* are the file (char *), the function (char *) and the line (int) in which the
...
...
include/video.h
View file @
e70d9d1f
...
...
@@ -32,11 +32,10 @@ typedef struct
int
i_matrix_coefficients
;
/* in YUV type, encoding type */
/* Picture static properties - those properties are fixed at initialization
* and should NOT be modified. Note that for YUV pictures, i_bytes_per_line
* has no signification and is replaced by i_width */
* and should NOT be modified */
int
i_width
;
/* picture width */
int
i_height
;
/* picture height */
int
i_
bytes_per_line
;
/* total number of bytes per line
*/
int
i_
chroma_width
;
/* chroma width
*/
/* Picture dynamic properties - those properties can be changed by the
* decoder */
...
...
include/video_output.h
View file @
e70d9d1f
...
...
@@ -7,6 +7,70 @@
* thread, and destroy a previously oppenned video output thread.
*******************************************************************************/
/*******************************************************************************
* vout_tables_t: pre-calculated convertion tables
*******************************************************************************
* These tables are used by convertion and scaling functions.
*******************************************************************************/
typedef
struct
vout_tables_s
{
void
*
p_base
;
/* base for all translation tables */
union
{
struct
{
u16
*
p_red
,
*
p_green
,
*
p_blue
;
}
rgb16
;
/* color 15, 16 bpp */
struct
{
u32
*
p_red
,
*
p_green
,
*
p_blue
;
}
rgb32
;
/* color 24, 32 bpp */
struct
{
u16
*
p_gray
;
}
gray16
;
/* gray 15, 16 bpp */
struct
{
u32
*
p_gray
;
}
gray32
;
/* gray 24, 32 bpp */
}
yuv
;
void
*
p_trans_optimized
;
/* optimized (all colors) */
}
vout_tables_t
;
/*******************************************************************************
* vout_convert_t: convertion function
*******************************************************************************
* This is the prototype common to all convertion functions. The type of p_pic
* will change depending of the screen depth treated.
* Parameters:
* p_vout video output thread
* p_pic picture address (start address in picture)
* p_y, p_u, p_v Y,U,V samples addresses
* i_width Y samples width
* i_height Y samples height
* i_eol number of Y samples to reach the next line
* i_pic_eol number or pixels to reach the next line
* i_scale if non 0, vertical scaling is 1 - 1/i_scale
* Conditions:
* start x + i_width < picture width
* start y + i_height * (scaling factor) < picture height
* i_width % 16 == 0
*******************************************************************************/
typedef
void
(
vout_convert_t
)(
p_vout_thread_t
p_vout
,
void
*
p_pic
,
yuv_data_t
*
p_y
,
yuv_data_t
*
p_u
,
yuv_data_t
*
p_v
,
int
i_width
,
int
i_height
,
int
i_eol
,
int
i_pic_eol
,
int
i_scale
);
/*******************************************************************************
* vout_scale_t: scaling function
*******************************************************************************
* When a picture can't be scaled unsing the fast i_y_scale parameter of a
* transformation, it is rendered in a temporary buffer then scaled using a
* totally accurate (but also very slow) method.
* This is the prototype common to all scaling functions. The types of p_buffer
* and p_pic will change depending of the screen depth treated.
* Parameters:
* p_vout video output thread
* p_pic picture address (start address in picture)
* p_buffer source picture
* i_width buffer width
* i_height buffer height
* i_eol number of pixels to reach next buffer line
* i_pic_eol number of pixels to reach next picture line
* f_alpha, f_beta horizontal and vertical scaling factors
*******************************************************************************/
typedef
void
(
vout_scale_t
)(
p_vout_thread_t
p_vout
,
void
*
p_pic
,
void
*
p_buffer
,
int
i_width
,
int
i_height
,
int
i_eol
,
int
i_pic_eol
,
float
f_alpha
,
float
f_beta
);
/*******************************************************************************
* vout_thread_t: video output thread descriptor
*******************************************************************************
...
...
@@ -16,34 +80,37 @@
*******************************************************************************/
typedef
struct
vout_thread_s
{
/* Thread properties and lock
s
*/
/* Thread properties and lock */
boolean_t
b_die
;
/* `die' flag */
boolean_t
b_error
;
/* `error' flag */
boolean_t
b_active
;
/* `active' flag */
pthread_t
thread_id
;
/* id for pthread functions */
pthread_mutex_t
lock
;
/* thread lock */
int
*
pi_status
;
/* temporary status flag */
p_vout_sys_t
p_sys
;
/* system output method */
/* C
ommon
display properties */
/* C
urrent
display properties */
boolean_t
b_info
;
/* print additionnal informations */
boolean_t
b_grayscale
;
/* color or grayscale display */
int
i_width
;
/* current output method width */
int
i_height
;
/* current output method height */
int
i_bytes_per_line
;
/* bytes per line (including virtual) */
int
i_screen_depth
;
/* bits per pixel */
int
i_bytes_per_pixel
;
/* real screen depth */
int
i_screen_depth
;
/* bits per pixel
- FIXED
*/
int
i_bytes_per_pixel
;
/* real screen depth
- FIXED
*/
float
f_x_ratio
;
/* horizontal display ratio */
float
f_y_ratio
;
/* vertical display ratio */
float
f_gamma
;
/* gamma */
/* Changed properties values - some of them are treated directly by the
* thread, the over may be ignored or handled by vout_SysManage */
//?? info, grayscale, width, height, bytes per line, x ratio, y ratio, gamma
boolean_t
b_gamma_change
;
/* gamma change indicator */
int
i_new_width
;
/* new width */
int
i_new_height
;
/* new height */
#ifdef STATS
/* Statistics - these numbers are not supposed to be accurate */
/* Statistics - these numbers are not supposed to be accurate, but are a
* good indication of the thread status */
count_t
c_loops
;
/* number of loops */
count_t
c_idle_loops
;
/* number of idle loops */
count_t
c_fps_samples
;
/* picture counts */
...
...
@@ -51,25 +118,17 @@ typedef struct vout_thread_s
#endif
#ifdef DEBUG_VIDEO
/*
V
ideo debugging informations */
/*
Additionnal v
ideo debugging informations */
mtime_t
picture_render_time
;
/* last picture rendering time */
#endif
/* Output method */
p_vout_sys_t
p_sys
;
/* system output method */
/* Video heap */
/* Video heap and translation tables */
picture_t
p_picture
[
VOUT_MAX_PICTURES
];
/* pictures */
/* YUV translation tables - they have to be casted to the appropriate width
* on use. All tables are allocated in the same memory block, based at
* p_trans_base, and shifted depending of the output thread configuration */
byte_t
*
p_trans_base
;
/* base for all translation tables */
void
*
p_trans_red
;
/* regular red */
void
*
p_trans_green
;
/* regular green */
void
*
p_trans_blue
;
/* regular blue */
void
*
p_trans_gray
;
/* regular gray */
void
*
p_trans_optimized
;
/* optimized (all colors) */
vout_tables_t
tables
;
/* translation tables */
vout_convert_t
*
p_ConvertYUV420
;
/* YUV 4:2:0 converter */
vout_convert_t
*
p_ConvertYUV422
;
/* YUV 4:2:2 converter */
vout_convert_t
*
p_ConvertYUV444
;
/* YUV 4:4:4 converter */
vout_scale_t
*
p_Scale
;
/* scaler */
}
vout_thread_t
;
/*******************************************************************************
...
...
@@ -85,7 +144,7 @@ vout_thread_t * vout_CreateThread (
void
vout_DestroyThread
(
vout_thread_t
*
p_vout
,
int
*
pi_status
);
picture_t
*
vout_CreatePicture
(
vout_thread_t
*
p_vout
,
int
i_type
,
int
i_width
,
int
i_height
,
int
i_bytes_per_line
);
int
i_width
,
int
i_height
);
void
vout_DestroyPicture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
);
void
vout_DisplayPicture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
);
void
vout_LinkPicture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
);
...
...
include/video_yuv.h
0 → 100644
View file @
e70d9d1f
/*******************************************************************************
* video_yuv.h: YUV transformation functions
* (c)1999 VideoLAN
*******************************************************************************
* Provides functions prototypes to perform the YUV conversion. The functions
* may be implemented in one of the video_yuv_* files.
*******************************************************************************/
/*******************************************************************************
* Prototypes
*******************************************************************************/
int
vout_InitTables
(
vout_thread_t
*
p_vout
);
int
vout_ResetTables
(
vout_thread_t
*
p_vout
);
void
vout_EndTables
(
vout_thread_t
*
p_vout
);
src/video_output/video_output.c
View file @
e70d9d1f
...
...
@@ -11,7 +11,6 @@
* Preamble
*******************************************************************************/
#include <errno.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
...
...
@@ -27,141 +26,10 @@
#include "video.h"
#include "video_output.h"
#include "video_sys.h"
#include "video_yuv.h"
#include "intf_msg.h"
#include "main.h"
/*******************************************************************************
* Macros
*******************************************************************************/
/* CLIP_BYTE: return value if between 0 and 255, else return nearest boundary
* (0 or 255), used to build translations tables */
#define CLIP_BYTE( i_val ) ( (i_val < 0) ? 0 : ((i_val > 255) ? 255 : i_val) )
/* YUV_GRAYSCALE: parametric macro for YUV grayscale transformation.
* Due to the high performance need of this loop, all possible conditions
* evaluations are made outside the transformation loop. However, the code does
* not change much for two different loops. This macro allows to change slightly
* the content of the loop without having to copy and paste code. It is used in
* RenderYUVPicture function. */
#define YUV_GRAYSCALE( TRANS_GRAY, P_PIC ) \
/* Main loop */
\
for (i_pic_y=0; i_pic_y < p_pic->i_height ; i_pic_y++) \
{ \
for (i_pic_x=0; i_pic_x< p_pic->i_width; i_pic_x+=16) \
{ \
/* Convert 16 pixels (width is always multiple of 16 */
\
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
*P_PIC++ = TRANS_GRAY[ *p_y++ ]; \
} \
/* Skip until beginning of next line */
\
P_PIC += i_eol_offset; \
}
/* YUV_TRANSFORM: parametric macro for YUV transformation.
* Due to the high performance need of this loop, all possible conditions
* evaluations are made outside the transformation loop. However, the code does
* not change much for two different loops. This macro allows to change slightly
* the content of the loop without having to copy and paste code. It is used in
* RenderYUVPicture function. */
#define YUV_TRANSFORM( CHROMA, TRANS_RED, TRANS_GREEN, TRANS_BLUE, P_PIC ) \
/* Main loop */
\
for (i_pic_y=0; i_pic_y < p_pic->i_height ; i_pic_y++) \
{ \
for (i_pic_x=0; i_pic_x< p_pic->i_width; i_pic_x+=2 ) \
{ \
/* First sample (complete) */
\
i_y = 76309 * *p_y++ - 1188177; \
i_u = *p_u++ - 128; \
i_v = *p_v++ - 128; \
*P_PIC++ = \
TRANS_RED [(i_y+i_crv*i_v) >>16] | \
TRANS_GREEN [(i_y-i_cgu*i_u-i_cgv*i_v) >>16] | \
TRANS_BLUE [(i_y+i_cbu*i_u) >>16]; \
i_y = 76309 * *p_y++ - 1188177; \
/* Second sample (partial) */
\
if( CHROMA == 444 ) \
{ \
i_u = *p_u++ - 128; \
i_v = *p_v++ - 128; \
} \
*P_PIC++ = \
TRANS_RED [(i_y+i_crv*i_v) >>16] | \
TRANS_GREEN [(i_y-i_cgu*i_u-i_cgv*i_v) >>16] | \
TRANS_BLUE [(i_y+i_cbu*i_u) >>16]; \
} \
if( (CHROMA == 420) && !(i_pic_y & 0x1) ) \
{ \
p_u -= i_chroma_width; \
p_v -= i_chroma_width; \
} \
/* Skip until beginning of next line */
\
P_PIC += i_eol_offset; \
}
/*******************************************************************************
* Constants
*******************************************************************************/
/* RGB/YUV inversion matrix (ISO/IEC 13818-2 section 6.3.6, table 6.9) */
const
int
MATRIX_COEFFICIENTS_TABLE
[
8
][
4
]
=
{
{
117504
,
138453
,
13954
,
34903
},
/* no sequence_display_extension */
{
117504
,
138453
,
13954
,
34903
},
/* ITU-R Rec. 709 (1990) */
{
104597
,
132201
,
25675
,
53279
},
/* unspecified */
{
104597
,
132201
,
25675
,
53279
},
/* reserved */
{
104448
,
132798
,
24759
,
53109
},
/* FCC */
{
104597
,
132201
,
25675
,
53279
},
/* ITU-R Rec. 624-4 System B, G */
{
104597
,
132201
,
25675
,
53279
},
/* SMPTE 170M */
{
117579
,
136230
,
16907
,
35559
}
/* SMPTE 240M (1987) */
};
/*******************************************************************************
* External prototypes
*******************************************************************************/
#ifdef HAVE_MMX
/* YUV transformations for MMX - in video_yuv_mmx.S
* p_y, p_u, p_v: Y U and V planes
* i_width, i_height: frames dimensions (pixels)
* i_ypitch, i_vpitch: Y and V lines sizes (bytes)
* i_aspect: vertical aspect factor
* p_pic: RGB frame
* i_dci_offset: ?? x offset for left image border
* i_offset_to_line_0: ?? x offset for left image border
* i_pitch: RGB line size (bytes)
* i_colortype: 0 for 565, 1 for 555 */
void
vout_YUV420_16_MMX
(
u8
*
p_y
,
u8
*
p_u
,
u8
*
p_v
,
unsigned
int
i_width
,
unsigned
int
i_height
,
unsigned
int
i_ypitch
,
unsigned
int
i_vpitch
,
unsigned
int
i_aspect
,
u8
*
p_pic
,
u32
i_dci_offset
,
u32
i_offset_to_line_0
,
int
CCOPitch
,
int
i_colortype
);
#endif
/* Optimized YUV functions: translations and tables building - in video_yuv_c.c
* ??? looks efficient, but does not work well - ask walken */
void
yuvToRgb16
(
unsigned
char
*
Y
,
unsigned
char
*
U
,
unsigned
char
*
V
,
short
*
dest
,
short
table
[
1935
],
int
width
);
int
rgbTable16
(
short
table
[
1935
],
int
redMask
,
int
greenMask
,
int
blueMask
,
unsigned
char
gamma
[
256
]);
/*******************************************************************************
* Local prototypes
*******************************************************************************/
...
...
@@ -169,11 +37,7 @@ static int InitThread ( vout_thread_t *p_vout );
static
void
RunThread
(
vout_thread_t
*
p_vout
);
static
void
ErrorThread
(
vout_thread_t
*
p_vout
);
static
void
EndThread
(
vout_thread_t
*
p_vout
);
static
void
BuildTables
(
vout_thread_t
*
p_vout
);
static
void
RenderPicture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
);
static
void
RenderYUVGrayPicture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
);
static
void
RenderYUV16Picture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
);
static
void
RenderYUV32Picture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
);
static
void
RenderPictureInfo
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
);
static
int
RenderIdle
(
vout_thread_t
*
p_vout
,
int
i_level
);
...
...
@@ -203,8 +67,15 @@ vout_thread_t * vout_CreateThread (
return
(
NULL
);
}
/* Initialize thread properties */
p_vout
->
b_die
=
0
;
p_vout
->
b_error
=
0
;
p_vout
->
b_active
=
0
;
p_vout
->
pi_status
=
(
pi_status
!=
NULL
)
?
pi_status
:
&
i_status
;
*
p_vout
->
pi_status
=
THREAD_CREATE
;
/* Initialize some fields used by the system-dependant method - these fields will
* probably be modified by the method */
* probably be modified by the method
, and are only preferences
*/
#ifdef DEBUG
p_vout
->
b_info
=
1
;
#else
...
...
@@ -240,21 +111,18 @@ vout_thread_t * vout_CreateThread (
p_vout
->
i_width
,
p_vout
->
i_height
,
p_vout
->
i_screen_depth
,
p_vout
->
i_bytes_per_pixel
,
p_vout
->
i_bytes_per_line
,
p_vout
->
f_x_ratio
,
p_vout
->
f_y_ratio
,
p_vout
->
b_grayscale
);
/* Terminate the initialization */
p_vout
->
b_die
=
0
;
p_vout
->
b_error
=
0
;
p_vout
->
b_active
=
0
;
p_vout
->
pi_status
=
(
pi_status
!=
NULL
)
?
pi_status
:
&
i_status
;
*
p_vout
->
pi_status
=
THREAD_CREATE
;
/* Initialize changement properties */
p_vout
->
b_gamma_change
=
0
;
p_vout
->
i_new_width
=
p_vout
->
i_width
;
p_vout
->
i_new_height
=
p_vout
->
i_height
;
#ifdef STATS
/* Initialize statistics fields */
p_vout
->
c_loops
=
0
;
p_vout
->
c_idle_loops
=
0
;
p_vout
->
c_fps_samples
=
0
;
#endif
p_vout
->
b_gamma_change
=
0
;
p_vout
->
i_new_width
=
p_vout
->
i_width
;
p_vout
->
i_new_height
=
p_vout
->
i_height
;
/* Create thread and set locks */
vlc_mutex_init
(
&
p_vout
->
lock
);
...
...
@@ -353,12 +221,13 @@ void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
* This function create a reserved image in the video output heap.
* A null pointer is returned if the function fails. This method provides an
* already allocated zone of memory in the picture data fields. It needs locking
* since several pictures can be created by several producers threads.
* since several pictures can be created by several producers threads.
*******************************************************************************/
picture_t
*
vout_CreatePicture
(
vout_thread_t
*
p_vout
,
int
i_type
,
int
i_width
,
int
i_height
,
int
i_bytes_per_line
)
int
i_width
,
int
i_height
)
{
int
i_picture
;
/* picture index */
int
i_chroma_width
;
/* chroma width */
picture_t
*
p_free_picture
=
NULL
;
/* first free picture */
picture_t
*
p_destroyed_picture
=
NULL
;
/* first destroyed picture */
...
...
@@ -374,15 +243,16 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
{
if
(
p_vout
->
p_picture
[
i_picture
].
i_status
==
DESTROYED_PICTURE
)
{
/* Picture is marked for destruction, but is still allocated */
/* Picture is marked for destruction, but is still allocated - note
* that if width and type are the same for two pictures, chroma_width
* should also be the same */
if
(
(
p_vout
->
p_picture
[
i_picture
].
i_type
==
i_type
)
&&
(
p_vout
->
p_picture
[
i_picture
].
i_height
==
i_height
)
&&
(
p_vout
->
p_picture
[
i_picture
].
i_
bytes_per_line
==
i_bytes_per_line
)
)
(
p_vout
->
p_picture
[
i_picture
].
i_
width
==
i_width
)
)
{
/* Memory size do match : memory will not be reallocated, and function
* can end immediately - this is the best possible case, since no
* memory allocation needs to be done */
p_vout
->
p_picture
[
i_picture
].
i_width
=
i_width
;
p_vout
->
p_picture
[
i_picture
].
i_status
=
RESERVED_PICTURE
;
#ifdef DEBUG_VIDEO
intf_DbgMsg
(
"picture %p (in destroyed picture slot)
\n
"
,
...
...
@@ -424,22 +294,25 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
switch
(
i_type
)
{
case
YUV_420_PICTURE
:
/* YUV 420: 1,1/4,1/4 samples per pixel */
p_free_picture
->
p_data
=
malloc
(
i_height
*
i_bytes_per_line
*
3
/
2
);
p_free_picture
->
p_y
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
;
p_free_picture
->
p_u
=
(
yuv_data_t
*
)(
p_free_picture
->
p_data
+
i_height
*
i_bytes_per_line
);
p_free_picture
->
p_v
=
(
yuv_data_t
*
)(
p_free_picture
->
p_data
+
i_height
*
i_bytes_per_line
*
5
/
4
);
i_chroma_width
=
i_width
/
4
;
p_free_picture
->
p_data
=
malloc
(
i_height
*
i_chroma_width
*
6
*
sizeof
(
yuv_data_t
)
);
p_free_picture
->
p_y
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
;
p_free_picture
->
p_u
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
+
i_height
*
i_chroma_width
*
4
;
p_free_picture
->
p_v
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
+
i_height
*
i_chroma_width
*
5
;
break
;
case
YUV_422_PICTURE
:
/* YUV 422: 1,1/2,1/2 samples per pixel */
p_free_picture
->
p_data
=
malloc
(
2
*
i_height
*
i_bytes_per_line
);
p_free_picture
->
p_y
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
;
p_free_picture
->
p_u
=
(
yuv_data_t
*
)(
p_free_picture
->
p_data
+
i_height
*
i_bytes_per_line
);
p_free_picture
->
p_v
=
(
yuv_data_t
*
)(
p_free_picture
->
p_data
+
i_height
*
i_bytes_per_line
*
3
/
2
);
i_chroma_width
=
i_width
/
2
;
p_free_picture
->
p_data
=
malloc
(
i_height
*
i_chroma_width
*
4
*
sizeof
(
yuv_data_t
)
);
p_free_picture
->
p_y
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
;
p_free_picture
->
p_u
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
+
i_height
*
i_chroma_width
*
2
;
p_free_picture
->
p_v
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
+
i_height
*
i_chroma_width
*
3
;
break
;
case
YUV_444_PICTURE
:
/* YUV 444: 1,1,1 samples per pixel */
p_free_picture
->
p_data
=
malloc
(
3
*
i_height
*
i_bytes_per_line
);
p_free_picture
->
p_y
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
;
p_free_picture
->
p_u
=
(
yuv_data_t
*
)(
p_free_picture
->
p_data
+
i_height
*
i_bytes_per_line
);
p_free_picture
->
p_v
=
(
yuv_data_t
*
)(
p_free_picture
->
p_data
+
i_height
*
i_bytes_per_line
*
2
);
i_chroma_width
=
i_width
;
p_free_picture
->
p_data
=
malloc
(
i_height
*
i_chroma_width
*
3
*
sizeof
(
yuv_data_t
)
);
p_free_picture
->
p_y
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
;
p_free_picture
->
p_u
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
+
i_height
*
i_chroma_width
;
p_free_picture
->
p_v
=
(
yuv_data_t
*
)
p_free_picture
->
p_data
+
i_height
*
i_chroma_width
*
2
;
break
;
#ifdef DEBUG
default:
...
...
@@ -451,14 +324,19 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
if
(
p_free_picture
->
p_data
!=
NULL
)
{
/* Copy picture informations */
/* Copy picture informations
, set some default values
*/
p_free_picture
->
i_type
=
i_type
;
p_free_picture
->
i_status
=
RESERVED_PICTURE
;
p_free_picture
->
i_matrix_coefficients
=
1
;
p_free_picture
->
i_width
=
i_width
;
p_free_picture
->
i_height
=
i_height
;
p_free_picture
->
i_bytes_per_line
=
i_bytes_per_line
;
p_free_picture
->
i_chroma_width
=
i_chroma_width
;
p_free_picture
->
i_display_horizontal_offset
=
0
;
p_free_picture
->
i_display_vertical_offset
=
0
;
p_free_picture
->
i_display_width
=
i_width
;
p_free_picture
->
i_display_height
=
i_height
;
p_free_picture
->
i_aspect_ratio
=
AR_SQUARE_PICTURE
;
p_free_picture
->
i_refcount
=
0
;
p_free_picture
->
i_matrix_coefficients
=
1
;
}
else
{
...
...
@@ -560,13 +438,6 @@ static int InitThread( vout_thread_t *p_vout )
/* Update status */
*
p_vout
->
pi_status
=
THREAD_START
;
/* Initialize pictures */
for
(
i_index
=
0
;
i_index
<
VOUT_MAX_PICTURES
;
i_index
++
)
{
p_vout
->
p_picture
[
i_index
].
i_type
=
EMPTY_PICTURE
;
p_vout
->
p_picture
[
i_index
].
i_status
=
FREE_PICTURE
;
}
/* Initialize output method - this function issues its own error messages */
if
(
vout_SysInit
(
p_vout
)
)
...
...
@@ -575,21 +446,19 @@ static int InitThread( vout_thread_t *p_vout )
return
(
1
);
}
/* Allocate translation tables */
p_vout
->
p_trans_base
=
malloc
(
(
4
*
1024
+
1935
)
*
p_vout
->
i_bytes_per_pixel
);
if
(
p_vout
->
p_trans_base
==
NULL
)
/* Initialize pictures */
for
(
i_index
=
0
;
i_index
<
VOUT_MAX_PICTURES
;
i_index
++
)
{
intf_ErrMsg
(
"error: %s
\n
"
,
strerror
(
ENOMEM
));
p_vout
->
p_picture
[
i_index
].
i_type
=
EMPTY_PICTURE
;
p_vout
->
p_picture
[
i_index
].
i_status
=
FREE_PICTURE
;
}
/* Initialize convertion tables and functions */
if
(
vout_InitTables
(
p_vout
)
)
{
intf_ErrMsg
(
"error: can't allocate translation tables
\n
"
);
return
(
1
);
}
p_vout
->
p_trans_red
=
p_vout
->
p_trans_base
+
384
*
p_vout
->
i_bytes_per_pixel
;
p_vout
->
p_trans_green
=
p_vout
->
p_trans_base
+
(
1024
+
384
)
*
p_vout
->
i_bytes_per_pixel
;
p_vout
->
p_trans_blue
=
p_vout
->
p_trans_base
+
(
2
*
1024
+
384
)
*
p_vout
->
i_bytes_per_pixel
;
p_vout
->
p_trans_gray
=
p_vout
->
p_trans_base
+
(
3
*
1024
+
384
)
*
p_vout
->
i_bytes_per_pixel
;
p_vout
->
p_trans_optimized
=
p_vout
->
p_trans_base
+
(
4
*
1024
)
*
p_vout
->
i_bytes_per_pixel
;
/* Build translation tables */
BuildTables
(
p_vout
);
/* Mark thread as running and return */
p_vout
->
b_active
=
1
;
...
...
@@ -631,19 +500,19 @@ static void RunThread( vout_thread_t *p_vout)
* initialization
*/
while
(
(
!
p_vout
->
b_die
)
&&
(
!
p_vout
->
b_error
)
)
{
{
/*
* Find the picture to display - this operation does not need lock,
* since only READY_PICTURES are handled
*/
p_pic
=
NULL
;
for
(
i_picture
=
0
;
i_picture
<
VOUT_MAX_PICTURES
;
i_picture
++
)
for
(
i_picture
=
0
;
i_picture
<
VOUT_MAX_PICTURES
;
i_picture
++
)
{
if
(
(
p_vout
->
p_picture
[
i_picture
].
i_status
==
READY_PICTURE
)
&&
(
(
p_pic
==
NULL
)
||
(
p_vout
->
p_picture
[
i_picture
].
date
<
pic_date
)
)
)
{
p_pic
=
&
p_vout
->
p_picture
[
i_picture
];
p_pic
=
&
p_vout
->
p_picture
[
i_picture
];
pic_date
=
p_pic
->
date
;
}
}
...
...
@@ -700,8 +569,9 @@ static void RunThread( vout_thread_t *p_vout)
*/
if
(
p_vout
->
b_gamma_change
)
{
//??
p_vout
->
b_gamma_change
=
0
;
Build
Tables
(
p_vout
);
vout_Reset
Tables
(
p_vout
);
// ?? test return value
}
/*
...
...
@@ -818,7 +688,7 @@ static void EndThread( vout_thread_t *p_vout )
}
/* Destroy translation tables */
free
(
p_vout
->
p_trans_base
);
vout_EndTables
(
p_vout
);
/* Destroy thread structures allocated by InitThread */
vout_SysEnd
(
p_vout
);
...
...
@@ -829,81 +699,6 @@ static void EndThread( vout_thread_t *p_vout )
*
pi_status
=
THREAD_OVER
;
}
/*******************************************************************************
* BuildTables: build YUV translation tables
*******************************************************************************
* This function will build translations tables according to pixel width and
* gamma.
*******************************************************************************/
static
void
BuildTables
(
vout_thread_t
*
p_vout
)
{
u16
*
p_trans16_red
=
(
u16
*
)
p_vout
->
p_trans_red
;
u16
*
p_trans16_green
=
(
u16
*
)
p_vout
->
p_trans_green
;