1 /* GStreamer Sub-Picture Unit - PGS 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_PGS_H__ 21 #define __GSTSPU_PGS_H__ 22 23 #include "gstspu-common.h" 24 25 typedef struct SpuPgsState SpuPgsState; 26 typedef enum PgsCompositionObjectFlags PgsCompositionObjectFlags; 27 typedef enum PgsPresentationSegmentFlags PgsPresentationSegmentFlags; 28 typedef enum PgsObjectUpdateFlags PgsObjectUpdateFlags; 29 30 typedef struct PgsPresentationSegment PgsPresentationSegment; 31 typedef struct PgsCompositionObject PgsCompositionObject; 32 33 enum PgsPresentationSegmentFlags 34 { 35 PGS_PRES_SEGMENT_FLAG_UPDATE_PALETTE = 0x80 36 }; 37 38 enum PgsCompositionObjectFlags 39 { 40 PGS_COMPOSITION_OBJECT_FLAG_CROPPED = 0x80, 41 PGS_COMPOSITION_OBJECT_FLAG_FORCED = 0x40 42 }; 43 44 enum PgsObjectUpdateFlags 45 { 46 /* Set in an object_update if this is the beginning of new RLE data. 47 * If not set, the data is a continuation to be appended */ 48 PGS_OBJECT_UPDATE_FLAG_START_RLE = 0x80, 49 PGS_OBJECT_UPDATE_FLAG_END_RLE = 0x40 /* This one is a guess */ 50 }; 51 52 struct PgsPresentationSegment 53 { 54 guint16 composition_no; 55 guint8 composition_state; 56 57 PgsPresentationSegmentFlags flags; 58 59 guint8 palette_id; 60 61 guint16 vid_w, vid_h; 62 guint8 vid_fps_code; 63 64 GArray *objects; 65 }; 66 67 struct PgsCompositionObject 68 { 69 guint16 id; 70 guint8 version; 71 PgsCompositionObjectFlags flags; 72 73 guint8 win_id; 74 75 guint8 rle_data_ver; 76 guint8 *rle_data; 77 guint32 rle_data_size; 78 guint32 rle_data_used; 79 80 /* Top left corner of this object */ 81 guint16 x, y; 82 83 /* Only valid if PGS_COMPOSITION_OBJECT_FLAG_CROPPED is set */ 84 guint16 crop_x, crop_y, crop_w, crop_h; 85 }; 86 87 struct SpuPgsState { 88 GstBuffer *pending_cmd; 89 90 gboolean in_presentation_segment; 91 gboolean have_presentation_segment; 92 93 PgsPresentationSegment pres_seg; 94 95 SpuColour palette[256]; 96 97 guint16 win_x, win_y, win_w, win_h; 98 }; 99 100 void gstspu_pgs_handle_new_buf (GstDVDSpu * dvdspu, GstClockTime event_ts, GstBuffer *buf); 101 gboolean gstspu_pgs_execute_event (GstDVDSpu *dvdspu); 102 void gstspu_pgs_render (GstDVDSpu *dvdspu, GstVideoFrame *frame); 103 gboolean gstspu_pgs_handle_dvd_event (GstDVDSpu *dvdspu, GstEvent *event); 104 void gstspu_pgs_flush (GstDVDSpu *dvdspu); 105 106 #endif 107