encoder: fix subclassing process.
[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
37 typedef enum
38 {
39   GST_VAAPI_ENCODER_H264_LEVEL_10 = 10, /* QCIF format, < 380160 samples/sec */
40   GST_VAAPI_ENCODER_H264_LEVEL_11 = 11, /* CIF format,   < 768000 samples/sec */
41   GST_VAAPI_ENCODER_H264_LEVEL_12 = 12, /* CIF format,   < 1536000  samples/sec */
42   GST_VAAPI_ENCODER_H264_LEVEL_13 = 13, /* CIF format,   < 3041280  samples/sec */
43   GST_VAAPI_ENCODER_H264_LEVEL_20 = 20, /* CIF format,   < 3041280  samples/sec */
44   GST_VAAPI_ENCODER_H264_LEVEL_21 = 21, /* HHR format,  < 5068800  samples/sec */
45   GST_VAAPI_ENCODER_H264_LEVEL_22 = 22, /* SD/4CIF format,     < 5184000      samples/sec */
46   GST_VAAPI_ENCODER_H264_LEVEL_30 = 30, /* SD/4CIF format,     < 10368000    samples/sec */
47   GST_VAAPI_ENCODER_H264_LEVEL_31 = 31, /* 720pHD format,      < 27648000    samples/sec */
48   GST_VAAPI_ENCODER_H264_LEVEL_32 = 32, /* SXGA  format,         < 55296000    samples/sec */
49   GST_VAAPI_ENCODER_H264_LEVEL_40 = 40, /* 2Kx1K format,         < 62914560    samples/sec */
50   GST_VAAPI_ENCODER_H264_LEVEL_41 = 41, /* 2Kx1K format,         < 62914560    samples/sec */
51   GST_VAAPI_ENCODER_H264_LEVEL_42 = 42, /* 2Kx1K format,         < 125829120  samples/sec */
52   GST_VAAPI_ENCODER_H264_LEVEL_50 = 50, /* 3672x1536 format,  < 150994944  samples/sec */
53   GST_VAAPI_ENCODER_H264_LEVEL_51 = 51, /* 4096x2304 format,  < 251658240  samples/sec */
54 } GstVaapiEncoderH264Level;
55
56 #define GST_VAAPI_ENCODER_H264_DEFAULT_PROFILE      GST_VAAPI_PROFILE_H264_BASELINE
57 #define GST_VAAPI_ENCODER_H264_DEFAULT_LEVEL        GST_VAAPI_ENCODER_H264_LEVEL_31
58 #define GST_VAAPI_ENCODER_H264_DEFAULT_INIT_QP      26
59 #define GST_VAAPI_ENCODER_H264_DEFAULT_MIN_QP       1
60 #define GST_VAAPI_ENCODER_H264_DEFAULT_INTRA_PERIOD 30
61 #define GST_VAAPI_ENCODER_H264_MAX_INTRA_PERIOD     512
62 #define GST_VAAPI_ENCODER_H264_MAX_IDR_PERIOD       512
63
64 #define GST_VAAPI_ENCODER_H264_DEFAULT_SLICE_NUM    1
65
66 struct _GstVaapiEncoderH264
67 {
68   GstVaapiEncoder parent;
69
70   /* public */
71   guint32 profile;
72   guint32 level;
73   guint32 bitrate;              /*kbps */
74   guint32 intra_period;
75   guint32 idr_period;
76   guint32 init_qp;              /*default 24 */
77   guint32 min_qp;               /*default 1 */
78   guint32 slice_num;
79   guint32 b_frame_num;
80
81   /* private */
82   gboolean is_avc;              /* avc or bytestream */
83   /* re-ordering */
84   GQueue reorder_frame_list;
85   guint reorder_state;
86   guint frame_index;
87   guint cur_frame_num;
88   guint cur_present_index;
89   GstClockTime cts_offset;
90
91   /* reference list */
92   GQueue ref_list;
93   guint max_ref_num;
94   /* max reflist count */
95   guint max_reflist0_count;
96   guint max_reflist1_count;
97
98   /* frame, poc */
99   guint32 max_frame_num;
100   guint32 log2_max_frame_num;
101   guint32 max_pic_order_cnt;
102   guint32 log2_max_pic_order_cnt;
103   guint32 idr_num;
104
105   GstBuffer *sps_data;
106   GstBuffer *pps_data;
107
108 };
109
110 G_END_DECLS
111
112 #endif /*GST_VAAPI_ENCODER_H264_PRIV_H */