summaryrefslogtreecommitdiff
path: root/gst/dvdspu/gstdvdspu.h
blob: aa8ae77ca7b726c6cc2e60a24fc9bac77cc93c5f (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* GStreamer DVD Sub-Picture Unit
 * Copyright (C) 2007 Fluendo S.A. <info@fluendo.com>
 *
 * 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 __GST_DVD_SPU_H__
#define __GST_DVD_SPU_H__

#include <gst/gst.h>

#include "gstspu-common.h"
#include "gstspu-vobsub.h"
#include "gstspu-pgs.h"

G_BEGIN_DECLS

#define GST_TYPE_DVD_SPU \
  (gst_dvd_spu_get_type())
#define GST_DVD_SPU(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVD_SPU,GstDVDSpu))
#define GST_DVD_SPU_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVD_SPU,GstDVDSpuClass))
#define GST_IS_DVD_SPU(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVD_SPU))
#define GST_IS_DVD_SPU_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVD_SPU))

#define DVD_SPU_LOCK(s) g_mutex_lock (&(s)->spu_lock);
#define DVD_SPU_UNLOCK(s) g_mutex_unlock (&(s)->spu_lock);

typedef struct _GstDVDSpuClass GstDVDSpuClass;

typedef enum SpuStateFlags SpuStateFlags;
typedef enum SpuInputType SpuInputType;
typedef struct SpuPacket SpuPacket;

enum SpuInputType {
  SPU_INPUT_TYPE_NONE   = 0x00,
  SPU_INPUT_TYPE_VOBSUB = 0x01,
  SPU_INPUT_TYPE_PGS    = 0x02
};

enum SpuStateFlags {
  SPU_STATE_NONE        = 0x00,
  /* Flags cleared on a flush */
  SPU_STATE_DISPLAY     = 0x01,
  SPU_STATE_FORCED_DSP  = 0x02,
  SPU_STATE_STILL_FRAME = 0x04,
  /* Persistent flags */
  SPU_STATE_FORCED_ONLY = 0x100
};

#define SPU_STATE_FLAGS_MASK (0xff)

struct SpuState {
  GstClockTime next_ts; /* Next event TS in running time */
  SpuStateFlags flags;

  GstVideoInfo info;

  guint32 *comp_bufs[3]; /* Compositing buffers for U+V & A */
  guint16 comp_left;
  guint16 comp_right;

  SpuVobsubState vobsub;
  SpuPgsState pgs;
};

/* Structure used to store the queue of pending SPU packets. The start_ts is
 * stored in running time... 
 * Also used to carry in-band events so they remain serialised properly */
struct SpuPacket {
  GstClockTime event_ts;
  GstBuffer *buf;
  GstEvent *event;
};

struct _GstDVDSpu {
  GstElement element;

  GstPad *videosinkpad;
  GstPad *subpic_sinkpad;
  GstPad *srcpad;

  /* Mutex to protect state we access from different chain funcs */
  GMutex spu_lock;

  GstSegment video_seg;
  GstSegment subp_seg;

  SpuState spu_state;
  SpuInputType spu_input_type;

  /* GQueue of SpuBuf structures */
  GQueue *pending_spus;

  /* Accumulator for collecting partial SPU buffers until they're complete */
  GstBuffer *partial_spu;

  /* Store either a reference or a copy of the last video frame for duplication
   * during still-frame conditions */
  GstBuffer *ref_frame;

  /* Buffer to push after handling a DVD event, if any */
  GstBuffer *pending_frame;
};

struct _GstDVDSpuClass {
  GstElementClass parent_class;
};

GType gst_dvd_spu_get_type (void);

typedef enum {
  GST_DVD_SPU_DEBUG_RENDER_RECTANGLE = (1 << 0),
  GST_DVD_SPU_DEBUG_HIGHLIGHT_RECTANGLE = (1 << 1)
} GstDVDSPUDebugFlags;

extern GstDVDSPUDebugFlags dvdspu_debug_flags;


G_END_DECLS

#endif /* __GST_DVD_SPU_H__ */