a7027ae913fd30c1b93e09a8a7f42e257ffa7626
[platform/upstream/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapiencoder_h264_priv.h
1 /*
2  *  gstvaapiencoder_h264_priv.h - H.264 encoder (private definitions)
3  *
4  *  Copyright (C) 2013 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_PRIV_H
23 #define GST_VAAPI_ENCODER_H264_PRIV_H
24
25 #include <glib.h>
26 #include <gst/base/gstbitwriter.h>
27 #include <gst/vaapi/gstvaapiencoder.h>
28 #include <gst/vaapi/gstvaapiencoder_priv.h>
29
30 G_BEGIN_DECLS
31
32 #define GST_VAAPI_ENCODER_H264(encoder) \
33     ((GstVaapiEncoderH264 *)(encoder))
34 #define GST_VAAPI_ENCODER_H264_CAST(encoder) \
35     ((GstVaapiEncoderH264 *)(encoder))
36 #define GST_VAAPI_ENCODER_H264_CLASS(klass) \
37     ((GstVaapiEncoderH264Class *)(klass))
38 #define GST_IS_VAAPI_ENCODER_H264_CLASS(klass) \
39     ((klass) != NULL)
40 #define GST_VAAPI_ENCODER_H264_GET_CLASS(obj) \
41     GST_VAAPI_ENCODER_H264_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(obj))
42
43 typedef struct _GstVaapiEncoderH264Class GstVaapiEncoderH264Class;
44
45 typedef enum
46 {
47   GST_VAAPI_ENCODER_H264_LEVEL_10 = 10, /* QCIF format, < 380160 samples/sec */
48   GST_VAAPI_ENCODER_H264_LEVEL_11 = 11, /* CIF format,   < 768000 samples/sec */
49   GST_VAAPI_ENCODER_H264_LEVEL_12 = 12, /* CIF format,   < 1536000  samples/sec */
50   GST_VAAPI_ENCODER_H264_LEVEL_13 = 13, /* CIF format,   < 3041280  samples/sec */
51   GST_VAAPI_ENCODER_H264_LEVEL_20 = 20, /* CIF format,   < 3041280  samples/sec */
52   GST_VAAPI_ENCODER_H264_LEVEL_21 = 21, /* HHR format,  < 5068800  samples/sec */
53   GST_VAAPI_ENCODER_H264_LEVEL_22 = 22, /* SD/4CIF format,     < 5184000      samples/sec */
54   GST_VAAPI_ENCODER_H264_LEVEL_30 = 30, /* SD/4CIF format,     < 10368000    samples/sec */
55   GST_VAAPI_ENCODER_H264_LEVEL_31 = 31, /* 720pHD format,      < 27648000    samples/sec */
56   GST_VAAPI_ENCODER_H264_LEVEL_32 = 32, /* SXGA  format,         < 55296000    samples/sec */
57   GST_VAAPI_ENCODER_H264_LEVEL_40 = 40, /* 2Kx1K format,         < 62914560    samples/sec */
58   GST_VAAPI_ENCODER_H264_LEVEL_41 = 41, /* 2Kx1K format,         < 62914560    samples/sec */
59   GST_VAAPI_ENCODER_H264_LEVEL_42 = 42, /* 2Kx1K format,         < 125829120  samples/sec */
60   GST_VAAPI_ENCODER_H264_LEVEL_50 = 50, /* 3672x1536 format,  < 150994944  samples/sec */
61   GST_VAAPI_ENCODER_H264_LEVEL_51 = 51, /* 4096x2304 format,  < 251658240  samples/sec */
62 } GstVaapiEncoderH264Level;
63
64 #define GST_VAAPI_ENCODER_H264_DEFAULT_PROFILE      GST_VAAPI_PROFILE_H264_BASELINE
65 #define GST_VAAPI_ENCODER_H264_DEFAULT_LEVEL        GST_VAAPI_ENCODER_H264_LEVEL_31
66 #define GST_VAAPI_ENCODER_H264_DEFAULT_INIT_QP      26
67 #define GST_VAAPI_ENCODER_H264_DEFAULT_MIN_QP       1
68 #define GST_VAAPI_ENCODER_H264_DEFAULT_INTRA_PERIOD 30
69 #define GST_VAAPI_ENCODER_H264_MAX_INTRA_PERIOD     512
70 #define GST_VAAPI_ENCODER_H264_MAX_IDR_PERIOD       512
71
72 #define GST_VAAPI_ENCODER_H264_DEFAULT_SLICE_NUM    1
73
74 struct _GstVaapiEncoderH264
75 {
76   GstVaapiEncoder parent;
77
78   /* public */
79   guint32 profile;
80   guint32 level;
81   guint32 bitrate;              /*kbps */
82   guint32 intra_period;
83   guint32 idr_period;
84   guint32 init_qp;              /*default 24 */
85   guint32 min_qp;               /*default 1 */
86   guint32 slice_num;
87   guint32 b_frame_num;
88
89   /* private */
90   gboolean is_avc;              /* avc or bytestream */
91   /* re-ordering */
92   GQueue reorder_frame_list;
93   guint reorder_state;
94   guint frame_index;
95   guint cur_frame_num;
96   guint cur_present_index;
97   GstClockTime cts_offset;
98
99   /* reference list */
100   GQueue ref_list;
101   guint max_ref_num;
102   /* max reflist count */
103   guint max_reflist0_count;
104   guint max_reflist1_count;
105
106   /* frame, poc */
107   guint32 max_frame_num;
108   guint32 log2_max_frame_num;
109   guint32 max_pic_order_cnt;
110   guint32 log2_max_pic_order_cnt;
111   guint32 idr_num;
112
113   GstBuffer *sps_data;
114   GstBuffer *pps_data;
115
116 };
117
118 struct _GstVaapiEncoderH264Class
119 {
120   /*< private > */
121   GstVaapiEncoderClass parent_class;
122 };
123
124 G_END_DECLS
125
126 #endif /*GST_VAAPI_ENCODER_H264_PRIV_H */