Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / ext / jpeg / gstjpegdec.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #ifndef __GST_JPEG_DEC_H__
22 #define __GST_JPEG_DEC_H__
23
24
25 #include <setjmp.h>
26 #include <gst/gst.h>
27 #include <gst/video/video.h>
28 #include <gst/base/gstadapter.h>
29
30 /* this is a hack hack hack to get around jpeglib header bugs... */
31 #ifdef HAVE_STDLIB_H
32 # undef HAVE_STDLIB_H
33 #endif
34 #include <stdio.h>
35 #include <jpeglib.h>
36
37 G_BEGIN_DECLS
38
39 #define GST_TYPE_JPEG_DEC \
40   (gst_jpeg_dec_get_type())
41 #define GST_JPEG_DEC(obj) \
42   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JPEG_DEC,GstJpegDec))
43 #define GST_JPEG_DEC_CLASS(klass) \
44   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JPEG_DEC,GstJpegDecClass))
45 #define GST_IS_JPEG_DEC(obj) \
46   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JPEG_DEC))
47 #define GST_IS_JPEG_DEC_CLASS(klass) \
48   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JPEG_DEC))
49
50 typedef struct _GstJpegDec           GstJpegDec;
51 typedef struct _GstJpegDecClass      GstJpegDecClass;
52
53 struct GstJpegDecErrorMgr {
54   struct jpeg_error_mgr    pub;   /* public fields */
55   jmp_buf                  setjmp_buffer;
56 };
57
58 struct GstJpegDecSourceMgr {
59   struct jpeg_source_mgr   pub;   /* public fields */
60   GstJpegDec              *dec;
61 };
62
63 /* Can't use GstBaseTransform, because GstBaseTransform
64  * doesn't handle the N buffers in, 1 buffer out case,
65  * but only the 1-in 1-out case */
66 struct _GstJpegDec {
67   GstElement element;
68
69   /* pads */
70   GstPad  *sinkpad;
71   GstPad  *srcpad;
72
73   GstAdapter *adapter;
74
75   guint8     *cur_buf;
76
77   /* TRUE if each input buffer contains a whole jpeg image */
78   gboolean packetized;
79
80   /* the (expected) timestamp of the next frame */
81   guint64  next_ts;
82
83   GstSegment segment;
84
85   /* TRUE if the next output buffer should have the DISCONT flag set */
86   gboolean discont;
87
88   /* QoS stuff *//* with LOCK */
89   gdouble proportion;
90   GstClockTime earliest_time;
91   GstClockTime qos_duration;
92
93   /* video state */
94   gint framerate_numerator;
95   gint framerate_denominator;
96
97   /* negotiated state */
98   gint     caps_framerate_numerator;
99   gint     caps_framerate_denominator;
100   gint     caps_width;
101   gint     caps_height;
102   gint     outsize;
103   gint     clrspc;
104
105   gint     offset[3];
106   gint     stride;
107   gint     inc;
108
109   /* parse state */
110   gint     parse_offset;
111   gint     parse_entropy_len;
112   gint     parse_resync;
113
114   /* properties */
115   gint     idct_method;
116   gint     max_errors;  /* ATOMIC */
117
118   /* current error (the message is the debug message) */
119   gchar       *error_msg;
120   int          error_line;
121   const gchar *error_func;
122
123   /* number of errors since start or last successfully decoded image */
124   guint     error_count;
125
126   /* number of successfully decoded images since start */
127   guint     good_count;
128
129   struct jpeg_decompress_struct cinfo;
130   struct GstJpegDecErrorMgr     jerr;
131   struct GstJpegDecSourceMgr    jsrc;
132
133   /* arrays for indirect decoding */
134   gboolean idr_width_allocated;
135   guchar *idr_y[16],*idr_u[16],*idr_v[16];
136   /* current (parsed) image size */
137   guint    rem_img_len;
138 };
139
140 struct _GstJpegDecClass {
141   GstElementClass  parent_class;
142 };
143
144 GType gst_jpeg_dec_get_type(void);
145
146
147 G_END_DECLS
148
149
150 #endif /* __GST_JPEG_DEC_H__ */