Fixed compile errors caused by combining plugins
[gst-davinci.git] / ti_plugins / davinci / src / gstgdecoder.h
blob72987ef8798c2f3f8da24d25c915f57720cb531c
1 /*
2 * Plugin Name : gstgdecoder.h
3 * Description : Header file for Video Decoder for for TI Davinci DM644x
5 * Copyright (C) 2007 Texas Instruments, Inc.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation version 2.1 of the License.
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
12 * whether express or implied; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 #ifndef __GST_GDECODER_H__
17 #define __GST_GDECODER_H__
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
23 #include <stdio.h>
24 #include <string.h>
25 #include <stdlib.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <unistd.h>
30 #include <pthread.h>
31 #include <getopt.h>
32 #include <errno.h>
33 #include <glib.h>
34 #include <gst/gst.h>
35 #include <gst/base/gstadapter.h>
37 //#define DEBUG_OUT
38 #define IDMA3_USEFULLPACKAGEPATH
39 #define MdUns UInt16
40 #define SmUns UInt8
42 #include <xdc/std.h>
43 #include <ti/sdo/ce/video/viddec.h>
44 #include <ti/sdo/ce/CERuntime.h>
45 #include <ti/sdo/ce/Engine.h>
46 #include <ti/sdo/ce/trace/gt.h>
47 #include <ti/sdo/ce/osal/Memory.h>
48 #include <ti/sdo/fc/acpy3/idma3.h>
50 #include <ti/sdo/ivc1dec.h>
52 #define CLOCK_BASE 9LL
53 #define CLOCK_FREQ CLOCK_BASE * 10000
55 #define MPEGTIME_TO_GSTTIME(time) (((time) * (GST_MSECOND/10)) / CLOCK_BASE)
56 #define GSTTIME_TO_MPEGTIME(time) (((time) * CLOCK_BASE) / (GST_MSECOND/10))
58 #define MAX_FRAME_WIDTH 720
59 #define MAX_FRAME_HEIGHT 480
60 #define PREROLL_TIME 180000000
61 #define FRAME_DURATION 33366666 //We can't hardcode this, get it from demuxer
63 #define GDECODER_INIT_STATE 0
64 #define GDECODER_PROCESS_STATE 1
66 /* Begin Declaration */
67 G_BEGIN_DECLS
69 #define GST_TYPE_GDECODER (gst_gdecoder_get_type())
70 #define GST_TYPE_GDECODER_ENGINE (gst_gdecoder_get_engine_type())
71 #define GST_TYPE_GDECODER_CODEC (gst_gdecoder_get_codec_type())
72 #define GST_GDECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GDECODER,GstGDecoder))
73 #define GST_GDECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GDECODER,GstGDecoderClass))
74 #define GST_GDECODER_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((klass),GST_TYPE_GDECODER,GstGDecoderClass))
75 #define GST_IS_GDECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDECODER))
76 #define GST_IS_GDECODER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDECODER))
78 typedef struct _GstGDecoder GstGDecoder;
79 typedef struct _GstGDecoderClass GstGDecoderClass;
81 struct _GstGDecoder {
82 GstElement parent;
84 GstPad *sinkpad;
85 GstPad *srcpad;
87 gboolean decReady;
88 guint8 codec;
89 guint8 engine;
91 gboolean isCodecPropSet;
92 guint64 pts32;
93 gboolean bit33;
95 XDAS_Int8 *outbuf;
96 XDAS_Int8 *inbuf;
97 XDM_BufDesc outBufDesc;
98 XDM_BufDesc inBufDesc;
99 guint32 readOffset; //File read offset
100 XDAS_Int32 inBufSize; //For free
101 guint32 curInBufStartOffset;
102 guint64 ptsNoDemux;
103 guint32 state;
104 void *decoder;
105 Engine_Handle ce;
106 GstSegment segment;
107 GstBuffer *srcbuf;
108 gboolean streaming;
109 guint32 width;
110 guint32 height;
111 GSList *inbuf_pool;
112 GSList *displaybuf_pool;
113 guint64 lastdispts;
114 gboolean isRcv;
115 gboolean isEof;
116 GMutex *pool_lock;
117 GMutex *inbuf_lock;
118 guint64 bytesConsumed;
119 gboolean onlyonce;
120 guint32 preroll_buflen;
122 gboolean enable_processing;
123 GMutex *process_lock;
126 struct _GstGDecoderClass {
127 GstElementClass parent_class;
128 GstPadTemplate *sink_template;
129 GstPadTemplate *src_template;
132 GType gst_gdecoder_get_type(void);
133 gboolean gst_gdecoder_plugin_init(GstPlugin * plugin);
134 static void gst_gdecoder_base_init(GstGDecoderClass * klass);
135 static void gst_gdecoder_class_init(GstGDecoderClass * klass);
136 static void gst_gdecoder_init(GstGDecoder * gdecoder);
137 static GstFlowReturn gst_gdecoder_chain(GstPad * pad,GstBuffer * buffer);
138 static GstStateChangeReturn gst_gdecoder_change_state(GstElement *
139 element,
140 GstStateChange
141 transition);
143 static gboolean gst_gdecoder_decoder_initialize(GstGDecoder *
144 gdecoder);
145 static GstCaps *gst_gdecoder_sink_getcaps(GstPad * pad);
146 static gboolean gst_gdecoder_sink_setcaps(GstPad * pad,
147 GstCaps * caps);
149 static gboolean gst_gdecoder_src_event(GstPad * pad, GstEvent * event);
150 static gboolean gst_gdecoder_sink_event(GstPad * pad,
151 GstEvent * event);
153 static gboolean gst_gdecoder_sink_activate(GstPad * sinkpad);
154 static gboolean gst_gdecoder_sink_activate_pull(GstPad * sinkpad,
155 gboolean active);
156 static void gst_gdecoder_loop(GstPad * pad);
157 static void gst_gdecoder_set_property(GObject * object, guint prop_id,
158 const GValue * value,
159 GParamSpec * pspec);
160 static gboolean gst_gdecoder_open_engine(GstGDecoder * gdecoder);
161 void gst_gdecoder_reset(GstGDecoder * gdecoder);
162 void gst_gdecoder_cleanup(GstGDecoder * gdecoder);
164 G_END_DECLS
166 #endif /* __GST_GDECODER_H__ */