f79de0eaa73d18c832d8d332fa84ed68b56b54e4
[profile/ivi/gstreamer-vaapi.git] / gst / vaapiencode / h264encoder.h
1
2 #ifndef _GST_H264_ENCODER_H_
3 #define _GST_H264_ENCODER_H_
4
5 #include <stdio.h>
6 #include <stdint.h>
7
8 #include "gst/gstbuffer.h"
9 #include "gst/vaapi/gstvaapidisplay.h"
10 #include "gst/vaapi/gstvaapisurfacepool.h"
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #ifdef DEBUG
17 #include <assert.h>
18 #define H264_ASSERT(exp) assert(exp)
19 #else
20 #define H264_ASSERT(exp)
21 #endif
22
23 #define H264_NO_ERROR       0
24 #define H264_MEM_ERR       -1
25 #define H264_DISPLAY_ERR   -2
26 #define H264_CONFIG_ERR    -3
27 #define H264_CONTEXT_ERR    -3
28 #define H264_STATE_ERR     -4
29 #define H264_ENC_RES_ERR   -5
30 #define H264_PICTURE_ERR   -6
31 #define H264_SURFACE_ERR   -7
32 #define H264_QUERY_STATUS_ERR -8
33 #define H264_DATA_NOT_READY   -9
34 #define H264_DATA_ERR      -10
35
36
37
38 #define H264_LOG_ERROR(...) fprintf(stdout, ## __VA_ARGS__)
39 #define H264_LOG_DEBUG(...) fprintf(stdout, ## __VA_ARGS__)
40 #define H264_LOG_INFO(...)  fprintf(stdout, ## __VA_ARGS__)
41
42
43 typedef int                                 H264Status;
44 typedef void*                               VADisplay;
45 typedef struct _GstH264Encoder              GstH264Encoder;
46 typedef struct _GstH264EncoderPrivate       GstH264EncoderPrivate;
47 typedef struct _GstH264EncoderClass         GstH264EncoderClass;
48
49
50 #define GST_TYPE_H264_ENCODER             (gst_h264_encoder_get_type())
51 #define GST_IS_H264_ENCODER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_H264_ENCODER))
52 #define GST_IS_H264_ENCODER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_H264_ENCODER))
53 #define GST_H264_ENCODER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_H264_ENCODER, GstH264EncoderClass))
54 #define GST_H264_ENCODER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_H264_ENCODER, GstH264Encoder))
55 #define GST_H264_ENCODER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_H264_ENCODER, GstH264EncoderClass))
56 #define GST_H264_ENCODER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj),GST_TYPE_H264_ENCODER,GstH264EncoderPrivate))
57
58 typedef enum {
59   H264_ENC_NULL,
60   H264_ENC_INIT,
61   H264_ENC_OPENED,
62   H264_ENC_ENCODING,
63 } H264_Encode_State;
64
65 typedef enum {
66   H264_PROFILE_BASELINE = 66,
67   H264_PROFILE_MAIN     = 77,
68   H264_PROFILE_EXTENDED = 88,
69   H264_PROFILE_HIGH    = 100,
70   H264_PROFILE_HIGH10  = 110,
71   H264_PROFILE_HIGH422 = 122,
72   H264_PROFILE_HIGH444 = 144,
73   H264_PROFILE_HIGH444_PREDICTIVE = 244,
74 } H264_Profile;
75
76 #define H264_DEFAULT_INIT_QP 26
77
78 struct _GstH264Encoder {
79   GObject parent;   /*based on gobject*/
80
81   uint32_t profile;
82   uint32_t level;
83   uint32_t width;
84   uint32_t height;
85   uint32_t frame_rate;
86   uint32_t bitrate;
87   uint32_t intra_period;
88   int32_t  init_qp;  /*default 26*/
89   /* private data; */
90 };
91
92 struct _GstH264EncoderClass {
93     GObjectClass parent_class;
94 };
95
96
97 GType    gst_h264_encoder_get_type(void);
98
99 GstH264Encoder *gst_h264_encoder_new(void);
100 static inline void gst_h264_encoder_unref (GstH264Encoder * encoder)
101 {
102   g_object_unref (encoder);
103 }
104
105 void     gst_h264_encoder_set_input_format(GstH264Encoder* encoder, uint32_t format);
106 void     gst_h264_encoder_set_es_flag(GstH264Encoder* encoder, gboolean es);
107 gboolean gst_h264_encoder_set_display(GstH264Encoder* encoder, GstVaapiDisplay *display);
108 GstVaapiDisplay *gst_h264_encoder_get_display(GstH264Encoder* encoder);
109
110
111 H264Status gst_h264_encoder_initialize(GstH264Encoder* encoder);
112 H264Status gst_h264_encoder_uninitialize(GstH264Encoder* encoder);
113
114 /*
115  set attributes here
116 */
117 void       gst_h264_encoder_set_default_values(GstH264Encoder* encoder);
118
119
120 /**/
121 #ifdef _MRST_
122 H264Status gst_h264_encoder_open(GstH264Encoder* encoder, GstVaapiSurfacePool *surfaces_pool);
123 #else
124 H264Status gst_h264_encoder_open(GstH264Encoder* encoder);
125 #endif
126
127 H264Status gst_h264_encoder_close(GstH264Encoder* encoder);
128
129
130 H264Status gst_h264_encoder_encode(GstH264Encoder* encoder, GstBuffer *raw_pic, GList **coded_pics);
131 H264Status gst_h264_encoder_flush(GstH264Encoder* encoder, GList *coded_pics);
132
133 H264_Encode_State gst_h264_encoder_get_state(GstH264Encoder* encoder);
134
135 /*other functions*/
136 char      *h264_dump_bytes(const uint8_t *buf, uint32_t num);
137 H264Status gst_h264_encoder_get_avcC_codec_data(GstH264Encoder* encoder, GstBuffer **buffer);
138 H264Status gst_h264_encoder_get_nal_codec_data(GstH264Encoder* encoder, GstBuffer **buffer);
139
140
141 #ifdef __cplusplus
142 }
143 #endif
144
145 #endif /*_GST_H264_ENCODER_H_ */
146