]> git.sesse.net Git - vlc/blob - modules/codec/spudec/spudec.h
* modules/codec/spudec/*: modified the spu decoder to handle text subtitles.
[vlc] / modules / codec / spudec / spudec.h
1 /*****************************************************************************
2  * spudec.h : sub picture unit decoder thread interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: spudec.h,v 1.4 2002/11/06 21:48:24 gbazin Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 typedef struct spudec_thread_t spudec_thread_t;
25
26 struct subpicture_sys_t
27 {
28     mtime_t i_pts;                                 /* presentation timestamp */
29
30     int   pi_offset[2];                              /* byte offsets to data */
31     void *p_data;
32
33     /* Color information */
34     vlc_bool_t b_palette;
35     uint8_t    pi_alpha[4];
36     uint8_t    pi_yuv[4][3];
37
38     /* Link to our input */
39     vlc_object_t * p_input;
40
41     /* Cropping properties */
42     vlc_mutex_t  lock;
43     vlc_bool_t   b_crop;
44     int          i_x_start, i_y_start, i_x_end, i_y_end;
45 };
46
47 /*****************************************************************************
48  * subtitler_font_t : proportional font
49  *****************************************************************************/
50 typedef struct subtitler_font_s
51 {
52     int                 i_height;              /* character height in pixels */
53     int                 i_width[256];          /* character widths in pixels */
54     int                 i_memory[256]; /* amount of memory used by character */
55     int *               p_length[256];                   /* line byte widths */
56     u16 **              p_offset[256];                /* pointer to RLE data */
57 } subtitler_font_t;
58
59 /*****************************************************************************
60  * spudec_thread_t : sub picture unit decoder thread descriptor
61  *****************************************************************************/
62 struct spudec_thread_t
63 {
64     /*
65      * Thread properties and locks
66      */
67     vlc_thread_t        thread_id;                /* id for thread functions */
68
69     /*
70      * Input properties
71      */
72     decoder_fifo_t *    p_fifo;                /* stores the PES stream data */
73     /* The bit stream structure handles the PES stream at the bit level */
74     bit_stream_t        bit_stream;
75
76     /*
77      * Output properties
78      */
79     vout_thread_t *     p_vout;          /* needed to create the spu objects */
80
81     /*
82      * Private properties
83      */
84     int                 i_spu_size;            /* size of current SPU packet */
85     int                 i_rle_size;                  /* size of the RLE part */
86 };
87
88 /*****************************************************************************
89  * Amount of bytes we GetChunk() in one go
90  *****************************************************************************/
91 #define SPU_CHUNK_SIZE              0x200
92
93 /*****************************************************************************
94  * SPU commands
95  *****************************************************************************/
96 #define SPU_CMD_FORCE_DISPLAY       0x00
97 #define SPU_CMD_START_DISPLAY       0x01
98 #define SPU_CMD_STOP_DISPLAY        0x02
99 #define SPU_CMD_SET_PALETTE         0x03
100 #define SPU_CMD_SET_ALPHACHANNEL    0x04
101 #define SPU_CMD_SET_COORDINATES     0x05
102 #define SPU_CMD_SET_OFFSETS         0x06
103 #define SPU_CMD_END                 0xff
104
105 /*****************************************************************************
106  * Prototypes
107  *****************************************************************************/
108 int  E_(SyncPacket)           ( spudec_thread_t * );
109 void E_(ParsePacket)          ( spudec_thread_t * );
110
111 void E_(RenderSPU)            ( vout_thread_t *, picture_t *,
112                                 const subpicture_t * );
113
114 void E_(ParseText)            ( spudec_thread_t *, subtitler_font_t * );
115
116 subtitler_font_t *E_(subtitler_LoadFont) ( vout_thread_t *, const char * );
117 void E_(subtitler_UnloadFont)   ( vout_thread_t *, subtitler_font_t * );
118 void E_(subtitler_PlotSubtitle) ( vout_thread_t *, char *, subtitler_font_t *,
119                                   mtime_t, mtime_t );