Tizen 2.0 Release
[framework/multimedia/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapiencoder_h264.h
1 /*
2  *  gstvaapiencoder_h264.h -  H.264 encoder
3  *
4  *  Copyright (C) 2011 Intel Corporation
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Lesser General Public License
8  *  as published by the Free Software Foundation; either version 2.1
9  *  of the License, or (at your option) any later version.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; 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.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with this library; if not, write to the Free
18  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  *  Boston, MA 02110-1301 USA
20  */
21
22 #ifndef GST_VAAPI_ENCODER_H264_H
23 #define GST_VAAPI_ENCODER_H264_H
24
25 #include "gst/vaapi/gstvaapisurfacepool.h"
26 #include "gst/vaapi/gstvaapibaseencoder.h"
27
28 G_BEGIN_DECLS
29
30 typedef struct _GstVaapiEncoderH264              GstVaapiEncoderH264;
31 typedef struct _GstVaapiEncoderH264Private       GstVaapiEncoderH264Private;
32 typedef struct _GstVaapiEncoderH264Class         GstVaapiEncoderH264Class;
33
34 #define GST_TYPE_VAAPI_ENCODER_H264 \
35     (gst_vaapi_encoder_h264_get_type())
36
37 #define GST_IS_VAAPI_ENCODER_H264(obj) \
38     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_ENCODER_H264))
39
40 #define GST_IS_VAAPI_ENCODER_H264_CLASS(klass) \
41     (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPI_ENCODER_H264))
42
43 #define GST_VAAPI_ENCODER_H264_GET_CLASS(obj)                  \
44     (G_TYPE_INSTANCE_GET_CLASS ((obj),                         \
45                                 GST_TYPE_VAAPI_ENCODER_H264,   \
46                                 GstVaapiEncoderH264Class))
47
48 #define GST_VAAPI_ENCODER_H264(obj)                            \
49     (G_TYPE_CHECK_INSTANCE_CAST ((obj),                        \
50                                  GST_TYPE_VAAPI_ENCODER_H264,  \
51                                  GstVaapiEncoderH264))
52
53 #define GST_VAAPI_ENCODER_H264_CLASS(klass)                    \
54     (G_TYPE_CHECK_CLASS_CAST ((klass),                         \
55                               GST_TYPE_VAAPI_ENCODER_H264,     \
56                               GstVaapiEncoderH264Class))
57
58 #define GST_VAAPI_ENCODER_H264_GET_PRIVATE(obj)                \
59     (G_TYPE_INSTANCE_GET_PRIVATE((obj),                        \
60                                  GST_TYPE_VAAPI_ENCODER_H264,  \
61                                  GstVaapiEncoderH264Private))
62
63 typedef enum {
64   H264_PROFILE_BASELINE = 66,
65   H264_PROFILE_MAIN     = 77,
66   H264_PROFILE_EXTENDED = 88,
67   H264_PROFILE_HIGH    = 100,
68   H264_PROFILE_HIGH10  = 110,
69   H264_PROFILE_HIGH422 = 122,
70   H264_PROFILE_HIGH444 = 144,
71   H264_PROFILE_HIGH444_PREDICTIVE = 244,
72 } H264_Profile;
73
74 typedef enum {
75   H264_LEVEL_10 = 10,  /* QCIF format, < 380160 samples/sec */
76   H264_LEVEL_11 = 11,  /* CIF format,   < 768000 samples/sec */
77   H264_LEVEL_12 = 12,  /* CIF format,   < 1536000  samples/sec */
78   H264_LEVEL_13 = 13,  /* CIF format,   < 3041280  samples/sec */
79   H264_LEVEL_20 = 20,  /* CIF format,   < 3041280  samples/sec */
80   H264_LEVEL_21 = 21,  /* HHR format,  < 5068800  samples/sec */
81   H264_LEVEL_22 = 22,  /* SD/4CIF format,     < 5184000      samples/sec */
82   H264_LEVEL_30 = 30,  /* SD/4CIF format,     < 10368000    samples/sec */
83   H264_LEVEL_31 = 31,  /* 720pHD format,      < 27648000    samples/sec */
84   H264_LEVEL_32 = 32,  /* SXGA  format,         < 55296000    samples/sec */
85   H264_LEVEL_40 = 40,  /* 2Kx1K format,         < 62914560    samples/sec */
86   H264_LEVEL_41 = 41,  /* 2Kx1K format,         < 62914560    samples/sec */
87   H264_LEVEL_42 = 42,  /* 2Kx1K format,         < 125829120  samples/sec */
88   H264_LEVEL_50 = 50,  /* 3672x1536 format,  < 150994944  samples/sec */
89   H264_LEVEL_51 = 51,  /* 4096x2304 format,  < 251658240  samples/sec */
90 } H264_Level;
91
92 #define H264_DEFAULT_PROFILE      H264_PROFILE_BASELINE
93 #define H264_DEFAULT_LEVEL        H264_LEVEL_30
94 #define H264_DEFAULT_INIT_QP      26
95 #define H264_DEFAULT_MIN_QP       1
96 #define H264_DEFAULT_INTRA_PERIOD 30
97 #define H264_DEFAULT_FPS          30
98 #define H264_DEFAULT_SLICE_NUM    1
99
100 struct _GstVaapiEncoderH264 {
101   GstVaapiBaseEncoder parent;   /*based on gobject*/
102
103   GstVaapiEncoderH264Private *priv;
104
105   guint32         profile;
106   guint32         level;
107   guint32         bitrate;  /*kbps*/
108   guint32         intra_period;
109   guint32         init_qp;  /*default 24*/
110   guint32         min_qp;   /*default 1*/
111   guint32         slice_num;
112   guint32         b_frame_num;
113 };
114
115 struct _GstVaapiEncoderH264Class {
116     GstVaapiBaseEncoderClass parent_class;
117 };
118
119
120 GType
121 gst_vaapi_encoder_h264_get_type(void);
122
123 GstVaapiEncoderH264 *
124 gst_vaapi_encoder_h264_new(void);
125
126 static inline void
127 gst_vaapi_encoder_h264_unref (GstVaapiEncoderH264 * encoder)
128 {
129   g_object_unref (encoder);
130 }
131
132 void
133 gst_vaapi_encoder_h264_set_avc_flag(
134     GstVaapiEncoderH264* encoder,
135     gboolean avc
136 );
137
138 gboolean
139 gst_vaapi_encoder_h264_get_avc_flag(GstVaapiEncoderH264* encoder);
140
141 G_END_DECLS
142
143 #endif /*GST_VAAPI_ENCODER_H264_H */