omxvideodec: support interlace-mode=interleaved input
[platform/upstream/gstreamer.git] / omx / gstomxvideoenc.h
1 /*
2  * Copyright (C) 2011, Hewlett-Packard Development Company, L.P.
3  *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>, Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation
8  * version 2.1 of the License.
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  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
18  *
19  */
20
21 #ifndef __GST_OMX_VIDEO_ENC_H__
22 #define __GST_OMX_VIDEO_ENC_H__
23
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26 #include <gst/video/gstvideoencoder.h>
27
28 #include "gstomx.h"
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_OMX_VIDEO_ENC \
33   (gst_omx_video_enc_get_type())
34 #define GST_OMX_VIDEO_ENC(obj) \
35   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEnc))
36 #define GST_OMX_VIDEO_ENC_CLASS(klass) \
37   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEncClass))
38 #define GST_OMX_VIDEO_ENC_GET_CLASS(obj) \
39   (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEncClass))
40 #define GST_IS_OMX_VIDEO_ENC(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_VIDEO_ENC))
42 #define GST_IS_OMX_VIDEO_ENC_CLASS(obj) \
43   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_VIDEO_ENC))
44
45 typedef struct _GstOMXVideoEnc GstOMXVideoEnc;
46 typedef struct _GstOMXVideoEncClass GstOMXVideoEncClass;
47
48 struct _GstOMXVideoEnc
49 {
50   GstVideoEncoder parent;
51
52   /* < protected > */
53   GstOMXComponent *enc;
54   GstOMXPort *enc_in_port, *enc_out_port;
55
56   /* < private > */
57   GstVideoCodecState *input_state;
58   /* TRUE if the component is configured and saw
59    * the first buffer */
60   gboolean started;
61    /* TRUE if the ports where disabled after being activated the first time. */
62   gboolean disabled;
63
64   GstClockTime last_upstream_ts;
65
66   /* Draining state */
67   GMutex drain_lock;
68   GCond drain_cond;
69   /* TRUE if EOS buffers shouldn't be forwarded */
70   gboolean draining; /* protected by drain_lock */
71
72   /* properties */
73   guint32 control_rate;
74   guint32 target_bitrate; /* protected by object lock */
75   guint32 quant_i_frames;
76   guint32 quant_p_frames;
77   guint32 quant_b_frames;
78 #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
79   guint32 qp_mode;
80   guint32 min_qp;
81   guint32 max_qp;
82   guint32 gop_mode;
83   guint32 gdr_mode;
84   guint32 initial_delay;
85   guint32 cpb_size;
86   guint32 scaling_list;
87   gboolean low_bandwidth;
88   guint32 max_bitrate;
89   guint32 aspect_ratio;
90   gboolean filler_data;
91   guint32 num_slices;
92   guint32 slice_size;
93   gboolean dependent_slice;
94   gint default_roi_quality;
95   gboolean long_term_ref;
96   guint32 long_term_freq;
97   guint32 look_ahead;
98 #endif
99
100   guint32 default_target_bitrate;
101
102   GstFlowReturn downstream_flow_ret;
103
104   GstOMXBufferAllocation input_allocation;
105   /* TRUE if encoder is passing dmabuf's fd directly to the OMX component */
106   gboolean input_dmabuf;
107   /* Number of buffers requested downstream */
108   guint nb_downstream_buffers;
109
110   /* TRUE if input buffers are from the pool we proposed to upstream */
111   gboolean in_pool_used;
112
113 #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
114   GEnumClass *alg_roi_quality_enum_class;
115 #endif
116 };
117
118 struct _GstOMXVideoEncClass
119 {
120   GstVideoEncoderClass parent_class;
121
122   GstOMXClassData cdata;
123
124   gboolean            (*set_format)          (GstOMXVideoEnc * self, GstOMXPort * port, GstVideoCodecState * state);
125   GstCaps            *(*get_caps)           (GstOMXVideoEnc * self, GstOMXPort * port, GstVideoCodecState * state);
126   GstFlowReturn       (*handle_output_frame) (GstOMXVideoEnc * self, GstOMXPort * port, GstOMXBuffer * buffer, GstVideoCodecFrame * frame);
127 };
128
129 GType gst_omx_video_enc_get_type (void);
130
131 G_END_DECLS
132
133 #endif /* __GST_OMX_VIDEO_ENC_H__ */