• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 Collabora Ltd.
3  *     Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 #ifndef __GST_OPENJPEG_DEC_H__
23 #define __GST_OPENJPEG_DEC_H__
24 
25 #include <gst/gst.h>
26 #include <gst/video/video.h>
27 #include <gst/codecparsers/gstjpeg2000sampling.h>
28 
29 #include "gstopenjpeg.h"
30 
31 G_BEGIN_DECLS
32 
33 #define GST_TYPE_OPENJPEG_DEC \
34   (gst_openjpeg_dec_get_type())
35 #define GST_OPENJPEG_DEC(obj) \
36   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPENJPEG_DEC,GstOpenJPEGDec))
37 #define GST_OPENJPEG_DEC_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OPENJPEG_DEC,GstOpenJPEGDecClass))
39 #define GST_IS_OPENJPEG_DEC(obj) \
40   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OPENJPEG_DEC))
41 #define GST_IS_OPENJPEG_DEC_CLASS(obj) \
42   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPENJPEG_DEC))
43 
44 typedef struct _GstOpenJPEGDec GstOpenJPEGDec;
45 typedef struct _GstOpenJPEGDecClass GstOpenJPEGDecClass;
46 
47 struct _GstOpenJPEGDec
48 {
49   GstVideoDecoder parent;
50 
51   /* < private > */
52   GstVideoCodecState *input_state;
53   GstVideoCodecState *output_state;
54 
55   OPJ_CODEC_FORMAT codec_format;
56   gboolean is_jp2c;
57   OPJ_COLOR_SPACE color_space;
58   GstJPEG2000Sampling sampling;
59   gint ncomps;
60   gint max_threads;  /* atomic */
61   gint max_slice_threads; /* internal openjpeg threading system */
62   gint num_procs;
63   gint num_stripes;
64   gboolean drop_subframes;
65 
66   void (*fill_frame) (GstOpenJPEGDec *self,
67                       GstVideoFrame *frame, opj_image_t * image);
68 
69   gboolean (*decode_frame) (GstVideoDecoder * decoder, GstVideoCodecFrame *frame);
70 
71   opj_dparameters_t params;
72 
73   guint available_threads;
74   GQueue messages;
75 
76   GCond messages_cond;
77   GMutex messages_lock;
78   GMutex decoding_lock;
79   GstFlowReturn downstream_flow_ret;
80   gboolean flushing;
81 
82   /* Draining state */
83   GMutex drain_lock;
84   GCond drain_cond;
85   /* TRUE if EOS buffers shouldn't be forwarded */
86   gboolean draining; /* protected by drain_lock */
87 
88   int last_error;
89 
90   gboolean started;
91 };
92 
93 struct _GstOpenJPEGDecClass
94 {
95   GstVideoDecoderClass parent_class;
96 };
97 
98 GType gst_openjpeg_dec_get_type (void);
99 
100 GST_ELEMENT_REGISTER_DECLARE (openjpegdec);
101 
102 G_END_DECLS
103 
104 #endif /* __GST_OPENJPEG_DEC_H__ */
105