1 /* 2 * Copyright (C) 2002, 2003 Jan Panteltje <panteltje@yahoo.com> 3 * With many changes by Scott Smith (trckjunky@users.sourceforge.net) 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or (at 8 * your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 18 * MA 02110-1301 USA. 19 */ 20 21 typedef struct { /* representation of a raster image read from a file on disk */ 22 char *fname; /* name of file to read image from */ 23 unsigned char *img; /* one byte per pixel, index into pal */ 24 colorspec pal[256]; /* image colour table */ 25 int numpal; /* nr used entries in pal */ 26 int width,height; /* dimensions of image (will be even) */ 27 } pict; 28 29 typedef struct { 30 int x0,y0,x1,y1; 31 } rectangle; 32 33 typedef struct { /* representation of a menu button */ 34 char *name; 35 bool autoaction; 36 rectangle r; /* bounds of button */ 37 char *up,*down,*left,*right; /* pointers to other buttons in corresponding directions, if any */ 38 int grp; /* which group button belongs to */ 39 } button; 40 41 typedef struct { /* representation of a subpicture and associated buttons */ 42 unsigned int x0, y0; /* top-left coords of pixels actually present */ 43 unsigned int xd, yd; 44 int spts, sd; // start pts, subtitle duration in 90kHz clock units 45 int forced; 46 int numbuttons; /* nr entries in buttons */ 47 int numpal; /* nr entries used in masterpal */ 48 bool autooutline,autoorder; 49 int outlinewidth; 50 pict img; /* button image in "normal" state */ 51 pict hlt; /* button image in "highlighted" state (user has moved to button with remote) */ 52 pict sel; /* button image in "selected" state (user has hit OK key with button highlighted) */ 53 unsigned char *fimg; /* combined menu subpicture image built here */ 54 colorspec pal[4]; /* palette for fimg */ 55 colorspec masterpal[16]; 56 colorspec transparentc; 57 int numgroups; /* how many button groups */ 58 int groupmap[3][4]; /* colour table for each button group, -1 for unused entries in each group */ 59 button *buttons; /* array of buttons */ 60 subtitle_elt *sub_title; /* subtitle text to be rendered */ 61 } stinfo; 62 63 #define SUB_BUFFER_MAX 53220 64 #define SUB_BUFFER_HEADROOM 1024 65 66 extern unsigned char *sub; 67 extern int debug; 68 extern bool have_textsub; /* whether a <textsub> tag has been seen */ 69 70 extern stinfo **spus; 71 extern int numspus; 72 73 extern int nr_subtitles_skipped; 74 75 int calcY(const colorspec *p); 76 int calcCr(const colorspec *p); 77 int calcCb(const colorspec *p); 78 79 int findmasterpal(stinfo *s, const colorspec *p); 80 /* returns the index in s->masterpal corresponding to colour p, allocating a 81 new palette entry if not there already. */ 82 83 // subgen-parse-xml 84 85 int spumux_parse(const char *fname); 86 87 // subgen-encode 88 89 int dvd_encode(stinfo *s); 90 int svcd_encode(stinfo *s); 91 int cvd_encode(stinfo *s); 92 93 // subgen-image 94 95 bool process_subtitle(stinfo *s); 96 void image_init(); 97 void image_shutdown(); 98