summaryrefslogtreecommitdiff
path: root/gst/dvdspu/gstspu-pgs.h
blob: 68429c441da40ac1ccf85233efc6a3e78f545b7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* GStreamer Sub-Picture Unit - PGS handling
 * Copyright (C) 2009 Jan Schmidt <thaytan@noraisin.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __GSTSPU_PGS_H__
#define __GSTSPU_PGS_H__

#include "gstspu-common.h"

typedef struct SpuPgsState SpuPgsState;
typedef enum PgsCompositionObjectFlags PgsCompositionObjectFlags;
typedef enum PgsPresentationSegmentFlags PgsPresentationSegmentFlags;
typedef enum PgsObjectUpdateFlags PgsObjectUpdateFlags;

typedef struct PgsPresentationSegment PgsPresentationSegment;
typedef struct PgsCompositionObject PgsCompositionObject;

enum PgsPresentationSegmentFlags
{
  PGS_PRES_SEGMENT_FLAG_UPDATE_PALETTE = 0x80
};

enum PgsCompositionObjectFlags
{
  PGS_COMPOSITION_OBJECT_FLAG_CROPPED = 0x80,
  PGS_COMPOSITION_OBJECT_FLAG_FORCED = 0x40
};

enum PgsObjectUpdateFlags
{
  /* Set in an object_update if this is the beginning of new RLE data.
   * If not set, the data is a continuation to be appended */
  PGS_OBJECT_UPDATE_FLAG_START_RLE = 0x80,
  PGS_OBJECT_UPDATE_FLAG_END_RLE = 0x40 /* This one is a guess */
};

struct PgsPresentationSegment
{
  guint16 composition_no;
  guint8 composition_state;

  PgsPresentationSegmentFlags flags;

  guint8 palette_id;

  guint16 vid_w, vid_h;
  guint8  vid_fps_code;

  GArray *objects;
};

struct PgsCompositionObject
{
  guint16 id;
  guint8 version;
  PgsCompositionObjectFlags flags;

  guint8 win_id;

  guint8 rle_data_ver;
  guint8 *rle_data;
  guint32 rle_data_size;
  guint32 rle_data_used;

  /* Top left corner of this object */
  guint16 x, y;

  /* Only valid if PGS_COMPOSITION_OBJECT_FLAG_CROPPED is set */
  guint16 crop_x, crop_y, crop_w, crop_h;
};

struct SpuPgsState {
  GstBuffer *pending_cmd;

  gboolean in_presentation_segment;
  gboolean have_presentation_segment;

  PgsPresentationSegment pres_seg;

  SpuColour palette[256];

  guint16 win_x, win_y, win_w, win_h;
};

void gstspu_pgs_handle_new_buf (GstDVDSpu * dvdspu, GstClockTime event_ts, GstBuffer *buf);
gboolean gstspu_pgs_execute_event (GstDVDSpu *dvdspu);
void gstspu_pgs_render (GstDVDSpu *dvdspu, GstVideoFrame *frame);
gboolean gstspu_pgs_handle_dvd_event (GstDVDSpu *dvdspu, GstEvent *event);
void gstspu_pgs_flush (GstDVDSpu *dvdspu);

#endif