1 /* GStreamer Sub-Picture Unit - VobSub/DVD handling 2 * Copyright (C) 2009 Jan Schmidt <thaytan@noraisin.net> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef __GSTSPU_VOBSUB_H__ 21 #define __GSTSPU_VOBSUB_H__ 22 23 #include "gstspu-common.h" 24 25 typedef struct SpuVobsubState SpuVobsubState; 26 typedef struct SpuVobsubPixCtrlI SpuVobsubPixCtrlI; 27 typedef struct SpuVobsubLineCtrlI SpuVobsubLineCtrlI; 28 29 /* Pixel Control Info from a Change Color Contrast command */ 30 struct SpuVobsubPixCtrlI { 31 gint16 left; 32 guint32 palette; 33 34 /* Pre-multiplied palette values, updated as 35 * needed */ 36 SpuColour pal_cache[4]; 37 }; 38 39 struct SpuVobsubLineCtrlI { 40 guint8 n_changes; /* 1 to 8 */ 41 SpuVobsubPixCtrlI pix_ctrl_i[8]; 42 43 gint16 top; 44 gint16 bottom; 45 }; 46 47 struct SpuVobsubState { 48 GstClockTime base_ts; /* base TS for cmd blk delays in running time */ 49 GstBuffer *buf; /* Current SPU packet we're executing commands from */ 50 guint16 cur_cmd_blk; /* Offset into the buf for the current cmd block */ 51 52 /* Top + Bottom field offsets in the buffer. 0 = not set */ 53 guint16 pix_data[2]; 54 GstBuffer *pix_buf; /* Current SPU packet the pix_data references */ 55 GstMapInfo pix_buf_map; /* Mapped buffer info */ 56 57 SpuRect disp_rect; 58 SpuRect clip_rect; 59 SpuRect hl_rect; 60 61 guint32 current_clut[16]; /* Colour lookup table from incoming events */ 62 63 guint8 main_idx[4]; /* Indices for current main palette */ 64 guint8 main_alpha[4]; /* Alpha values for main palette */ 65 66 guint8 hl_idx[4]; /* Indices for current highlight palette */ 67 guint8 hl_alpha[4]; /* Alpha values for highlight palette */ 68 69 /* Pre-multiplied colour palette for the main palette */ 70 SpuColour main_pal[4]; 71 gboolean main_pal_dirty; 72 73 /* Line control info for rendering the highlight palette */ 74 SpuVobsubLineCtrlI hl_ctrl_i; 75 gboolean hl_pal_dirty; /* Indicates that the HL palette info needs refreshing */ 76 77 /* LineCtrlI Info from a Change Color & Contrast command */ 78 SpuVobsubLineCtrlI *line_ctrl_i; 79 gint16 n_line_ctrl_i; 80 gboolean line_ctrl_i_pal_dirty; /* Indicates that the palettes for the line_ctrl_i 81 * need recalculating */ 82 83 /* Rendering state vars below */ 84 gint16 comp_last_x[2]; /* Maximum X values we rendered into the comp buffer (odd & even) */ 85 gint16 *comp_last_x_ptr; /* Ptr to the current comp_last_x value to be updated by the render */ 86 87 /* Current Y Position */ 88 gint16 cur_Y; 89 90 /* Current offset in nibbles into the pix_data */ 91 guint16 cur_offsets[2]; 92 guint16 max_offset; 93 94 /* current ChgColCon Line Info */ 95 SpuVobsubLineCtrlI *cur_chg_col; 96 SpuVobsubLineCtrlI *cur_chg_col_end; 97 98 /* Output position tracking */ 99 guint8 *out_Y; 100 guint32 *out_U; 101 guint32 *out_V; 102 guint32 *out_A; 103 }; 104 105 void gstspu_vobsub_handle_new_buf (GstDVDSpu * dvdspu, GstClockTime event_ts, GstBuffer *buf); 106 gboolean gstspu_vobsub_execute_event (GstDVDSpu *dvdspu); 107 void gstspu_vobsub_render (GstDVDSpu *dvdspu, GstVideoFrame *frame); 108 gboolean gstspu_vobsub_handle_dvd_event (GstDVDSpu *dvdspu, GstEvent *event); 109 void gstspu_vobsub_flush (GstDVDSpu *dvdspu); 110 111 #endif 112