x264enc: Avoid format decision per frame
[platform/upstream/gst-plugins-ugly.git] / ext / x264 / gstx264enc.h
1 /* GStreamer H264 encoder plugin
2  * Copyright (C) 2005 Michal Benes <michal.benes@itonis.tv>
3  * Copyright (C) 2005 Josef Zlomek <josef.zlomek@itonis.tv>
4  * Copyright (C) 2016 Sebastian Dröge <sebastian@centricular.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 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  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef __GST_X264_ENC_H__
23 #define __GST_X264_ENC_H__
24
25 #include <gst/gst.h>
26 #include <gst/video/video.h>
27 #include <gst/video/gstvideoencoder.h>
28
29 #ifdef HAVE_STDINT_H
30 #include <stdint.h>
31 #endif
32
33 /* The x264.h header says this isn't needed with MinGW, but sometimes the
34  * compiler is unable to correctly do the pointer indirection for us, which
35  * leads to a segfault when you try to dereference any const values provided
36  * by x264.dll. See: https://bugzilla.gnome.org/show_bug.cgi?id=779249 */
37 #if defined(_WIN32) && !defined(X264_API_IMPORTS)
38 # define X264_API_IMPORTS
39 #endif
40 #include <x264.h>
41
42 G_BEGIN_DECLS
43
44 #define GST_TYPE_X264_ENC \
45   (gst_x264_enc_get_type())
46 #define GST_X264_ENC(obj) \
47   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_X264_ENC,GstX264Enc))
48 #define GST_X264_ENC_CLASS(klass) \
49   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_X264_ENC,GstX264EncClass))
50 #define GST_IS_X264_ENC(obj) \
51   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_X264_ENC))
52 #define GST_IS_X264_ENC_CLASS(klass) \
53   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_X264_ENC))
54
55 typedef struct _GstX264Enc GstX264Enc;
56 typedef struct _GstX264EncClass GstX264EncClass;
57 typedef struct _GstX264EncVTable GstX264EncVTable;
58
59 struct _GstX264Enc
60 {
61   GstVideoEncoder element;
62
63   /*< private >*/
64   GstX264EncVTable *vtable;
65   x264_t *x264enc;
66   x264_param_t x264param;
67   gint current_byte_stream;
68
69   /* List of frame/buffer mapping structs for
70    * pending frames */
71   GList *pending_frames;
72
73   /* properties */
74   guint threads;
75   gboolean sliced_threads;
76   gint sync_lookahead;
77   gint pass;
78   guint quantizer;
79   gchar *mp_cache_file;
80   gboolean byte_stream;
81   guint bitrate;
82   gboolean intra_refresh;
83   gint me;
84   guint subme;
85   guint analyse;
86   gboolean dct8x8;
87   guint ref;
88   guint bframes;
89   gboolean b_adapt;
90   gboolean b_pyramid;
91   gboolean weightb;
92   guint sps_id;
93   gboolean au_nalu;
94   gboolean trellis;
95   guint vbv_buf_capacity;
96   guint keyint_max;
97   gboolean cabac;
98   gfloat ip_factor;
99   gfloat pb_factor;
100   guint qp_min;
101   guint qp_max;
102   guint qp_step;
103   gboolean mb_tree;
104   gint rc_lookahead;
105   guint noise_reduction;
106   gboolean interlaced;
107   gint speed_preset;
108   gint psy_tune;
109   guint tune;
110   GString *tunings;
111   GString *option_string_prop; /* option-string property */
112   GString *option_string; /* used by set prop */
113   gint frame_packing;
114   gboolean insert_vui;
115
116   /* input description */
117   GstVideoCodecState *input_state;
118
119   /* configuration changed  while playing */
120   gboolean reconfig;
121
122   /* from the downstream caps */
123   const gchar *peer_profile;
124   gboolean peer_intra_profile;
125   gint peer_level_idc;
126
127   /* cached values to set x264_picture_t */
128   gint x264_nplanes;
129 };
130
131 struct _GstX264EncClass
132 {
133   GstVideoEncoderClass parent_class;
134 };
135
136 GType gst_x264_enc_get_type (void);
137
138 G_END_DECLS
139
140 #endif /* __GST_X264_ENC_H__ */