diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c
index 9129aae..b852007 100644
--- a/ext/x264/gstx264enc.c
+++ b/ext/x264/gstx264enc.c
@@ -1,4 +1,4 @@
-/* GStreamer H264 encoder plugin
+/* GStreamer H.264 encoder plugin
  * Copyright (C) 2005 Michal Benes <michal.benes@itonis.tv>
  * Copyright (C) 2005 Josef Zlomek <josef.zlomek@itonis.tv>
  * Copyright (C) 2008 Mark Nauwelaerts <mnauw@users.sf.net>
@@ -23,37 +23,46 @@
  * SECTION:element-x264enc
  * @see_also: faac
  *
- * This element encodes raw video into H264 compressed data,
- * also otherwise known as MPEG-4 AVC (Advanced Video Codec).
+ * This element encodes raw video into H.264 compressed data,
+ * also otherwise known as MPEG-4 AVC (Advanced Video Coding).
  *
- * The #GstX264Enc:pass property controls the type of encoding.  In case of Constant
- * Bitrate Encoding (actually ABR), the #GstX264Enc:bitrate will determine the quality
- * of the encoding.  This will similarly be the case if this target bitrate
- * is to obtained in multiple (2 or 3) pass encoding.
- * Alternatively, one may choose to perform Constant Quantizer or Quality encoding,
- * in which case the #GstX264Enc:quantizer property controls much of the outcome.
+ * The #GstX264Enc:rate-control property controls the image quality and
+ * number of bits used for each picture.  Setting this to #GstX264Enc:quality
+ * creates an encoded stream where each picture has the same quality, but
+ * the number of bits used ("bitrate") may change dramatically.  Setting
+ * #GstX264Enc:rate-control to #GstX264Enc:abr ("average bit rate") will
+ * cause the quality to vary somewhat, and number of bits per picture to
+ * be roughly constant and over a long time converge to #GstX264Enc:bitrate.
  *
- * The H264 profile that is eventually used depends on a few settings.
- * If #GstX264Enc:dct8x8 is enabled, then High profile is used.
- * Otherwise, if #GstX264Enc:cabac entropy coding is enabled or #GstX264Enc:bframes
- * are allowed, then Main Profile is in effect, and otherwise Baseline profile
- * applies.  As such, Main is presently the default profile, which is fine for
- * most players and settings, but in some cases (e.g. hardware platforms)
- * a more restricted profile/level may be necessary.
+ * A constant bit rate stream can be created by choosing ABR for rate control
+ * and setting #GstX264Enc:vbv_max_bitrate and #GstX264Enc:vbv_buf_size.
+ * Appropriate values for these would be vbv_max_bitrate=bitrate and
+ * vbv_buf_size=5*bitrate.
+ *
+ * To select multi-pass encoding, choose ABR for rate control and set
+ * the pass parameter.  The property multipass-cache-file specifies
+ * the name of the file to be used for temporary data storage between
+ * passes.
+ *
+ * The H.264 profile of the encoded stream may be selected by setting
+ * the profile parameter.  The default is High Profile, which is
+ * appropriate for most software players, but some hardware decoders
+ * may require Main or Baseline profile in order to play correctly.
  *
  * <refsect2>
  * <title>Example pipeline</title>
  * |[
- * gst-launch -v videotestsrc num-buffers=1000 ! x264enc qp-min=18 ! \
+ * gst-launch -v videotestsrc num-buffers=1000 ! x264enc ! \
  *   avimux ! filesink location=videotestsrc.avi
- * ]| This example pipeline will encode a test video source to H264 muxed in an
- * AVI container, while ensuring a sane minimum quantization factor to avoid
- * some (excessive) waste.
+ * ]| This example pipeline will encode a test video source to H.264 muxed in an
+ * AVI container.
  * |[
- * gst-launch -v videotestsrc num-buffers=1000 ! x264enc pass=quant ! \
- *   matroskamux ! filesink location=videotestsrc.avi
- * ]| This example pipeline will encode a test video source to H264 using fixed
- * quantization, and muxes it in a Matroska container.
+ * gst-launch -v videotestsrc num-buffers=1000 ! x264enc rate-control=abr \
+ *   bitrate=1000 vbv-buf-size=5000 vbv-max-bitrate=1000 profile=baseline ! \
+ *   matroskamux ! filesink location=videotestsrc.mkv
+ * ]| This example pipeline will encode a test video source to H.264 using
+ * constant bit rate and baseline profile, and muxes it in a Matroska
+ * container.
  * </refsect2>
  */
 
@@ -76,138 +85,115 @@ GST_DEBUG_CATEGORY_STATIC (x264_enc_debug);
 enum
 {
   ARG_0,
-  ARG_THREADS,
+  ARG_PROFILE,
+  ARG_PRESET,
+  ARG_TUNE,
+  ARG_RATE_CONTROL,
   ARG_PASS,
+  ARG_THREADS,
   ARG_QUANTIZER,
-  ARG_STATS_FILE,
   ARG_MULTIPASS_CACHE_FILE,
   ARG_BYTE_STREAM,
   ARG_BITRATE,
-  ARG_VBV_BUF_CAPACITY,
-  ARG_ME,
-  ARG_SUBME,
-  ARG_ANALYSE,
-  ARG_DCT8x8,
-  ARG_REF,
-  ARG_BFRAMES,
-  ARG_B_ADAPT,
-  ARG_B_PYRAMID,
-  ARG_WEIGHTB,
-  ARG_SPS_ID,
-  ARG_AU_NALU,
-  ARG_TRELLIS,
-  ARG_KEYINT_MAX,
-  ARG_CABAC,
-  ARG_QP_MIN,
-  ARG_QP_MAX,
-  ARG_QP_STEP,
-  ARG_IP_FACTOR,
-  ARG_PB_FACTOR,
-  ARG_NR,
-  ARG_INTERLACED
+  ARG_VBV_MAX_BITRATE,
+  ARG_VBV_BUF_SIZE,
+  ARG_KEYINT,
+  ARG_RC_LOOKAHEAD,
+  ARG_OPTIONS
 };
 
-#define ARG_THREADS_DEFAULT            1
-#define ARG_PASS_DEFAULT               0
-#define ARG_QUANTIZER_DEFAULT          21
-#define ARG_MULTIPASS_CACHE_FILE_DEFAULT "x264.log"
-#define ARG_STATS_FILE_DEFAULT         ARG_MULTIPASS_CACHE_FILE_DEFAULT
-#define ARG_BYTE_STREAM_DEFAULT        FALSE
-#define ARG_BITRATE_DEFAULT            (2 * 1024)
-#define ARG_VBV_BUF_CAPACITY_DEFAULT   600
-#define ARG_ME_DEFAULT                 X264_ME_HEX
-#define ARG_SUBME_DEFAULT              1
-#define ARG_ANALYSE_DEFAULT            0
-#define ARG_DCT8x8_DEFAULT             FALSE
-#define ARG_REF_DEFAULT                1
-#define ARG_BFRAMES_DEFAULT            0
-#define ARG_B_ADAPT_DEFAULT            TRUE
-#define ARG_B_PYRAMID_DEFAULT          FALSE
-#define ARG_WEIGHTB_DEFAULT            FALSE
-#define ARG_SPS_ID_DEFAULT             0
-#define ARG_AU_NALU_DEFAULT            TRUE
-#define ARG_TRELLIS_DEFAULT            TRUE
-#define ARG_KEYINT_MAX_DEFAULT         0
-#define ARG_CABAC_DEFAULT              TRUE
-#define ARG_QP_MIN_DEFAULT             10
-#define ARG_QP_MAX_DEFAULT             51
-#define ARG_QP_STEP_DEFAULT            4
-#define ARG_IP_FACTOR_DEFAULT          1.4
-#define ARG_PB_FACTOR_DEFAULT          1.3
-#define ARG_NR_DEFAULT                 0
-#define ARG_INTERLACED_DEFAULT         FALSE
+#define GST_X264_ENC_PROFILE_HIGH 2
+#define GST_X264_ENC_PRESET_MEDIUM 5
 
-enum
-{
-  GST_X264_ENC_PASS_CBR = 0,
-  GST_X264_ENC_PASS_QUANT = 0x04,
-  GST_X264_ENC_PASS_QUAL,
-  GST_X264_ENC_PASS_PASS1 = 0x11,
-  GST_X264_ENC_PASS_PASS2,
-  GST_X264_ENC_PASS_PASS3
-};
+#define DEFAULT_PROFILE               GST_X264_ENC_PROFILE_HIGH
+#define DEFAULT_PRESET                GST_X264_ENC_PRESET_MEDIUM
+#define DEFAULT_TUNE                  ""
+#define DEFAULT_RATE_CONTROL          GST_X264_ENC_RATE_CONTROL_QUALITY
+#define DEFAULT_PASS                  1
+#define DEFAULT_THREADS               0
+#define DEFAULT_MULTIPASS_CACHE_FILE  "x264.log"
+#define DEFAULT_BYTE_STREAM           FALSE
+#define DEFAULT_OPTIONS               ""
 
-#define GST_X264_ENC_PASS_TYPE (gst_x264_enc_pass_get_type())
+#define GST_X264_ENC_PROFILE_TYPE (gst_x264_enc_profile_get_type())
 static GType
-gst_x264_enc_pass_get_type (void)
+gst_x264_enc_profile_get_type (void)
 {
-  static GType pass_type = 0;
-
-  static const GEnumValue pass_types[] = {
-    {GST_X264_ENC_PASS_CBR, "Constant Bitrate Encoding", "cbr"},
-    {GST_X264_ENC_PASS_QUANT, "Constant Quantizer", "quant"},
-    {GST_X264_ENC_PASS_QUAL, "Constant Quality", "qual"},
-    {GST_X264_ENC_PASS_PASS1, "VBR Encoding - Pass 1", "pass1"},
-    {GST_X264_ENC_PASS_PASS2, "VBR Encoding - Pass 2", "pass2"},
-    {GST_X264_ENC_PASS_PASS3, "VBR Encoding - Pass 3", "pass3"},
-    {0, NULL, NULL}
-  };
+  static GType profile_type = 0;
+  static GEnumValue *profile_types;
+  int n;
+  int i;
+
+  if (profile_type != 0) return profile_type;
 
-  if (!pass_type) {
-    pass_type = g_enum_register_static ("GstX264EncPass", pass_types);
+  n = 0;
+  while (x264_profile_names[n] != NULL) n++;
+
+  profile_types = g_malloc0 ((n + 1) * sizeof (GEnumValue));
+  for (i = 0; i < n; i++) {
+    profile_types[i].value = i;
+    profile_types[i].value_name = x264_profile_names[i];
+    profile_types[i].value_nick = x264_profile_names[i];
   }
-  return pass_type;
+
+  profile_type = g_enum_register_static ("GstX264EncProfile", profile_types);
+
+  return profile_type;
 }
 
-#define GST_X264_ENC_ME_TYPE (gst_x264_enc_me_get_type())
+#define GST_X264_ENC_PRESET_TYPE (gst_x264_enc_preset_get_type())
 static GType
-gst_x264_enc_me_get_type (void)
+gst_x264_enc_preset_get_type (void)
 {
-  static GType me_type = 0;
-  static const GEnumValue me_types[] = {
-    {X264_ME_DIA, "diamond search, radius 1 (fast)", "dia"},
-    {X264_ME_HEX, "hexagonal search, radius 2", "hex"},
-    {X264_ME_UMH, "uneven multi-hexagon search", "umh"},
-    {X264_ME_ESA, "exhaustive search (slow)", "esa"},
-    {0, NULL, NULL}
-  };
+  static GType preset_type = 0;
+  static GEnumValue *preset_types;
+  int n;
+  int i;
+
+  if (preset_type != 0) return preset_type;
 
-  if (!me_type) {
-    me_type = g_enum_register_static ("GstX264EncMe", me_types);
+  n = 0;
+  while (x264_preset_names[n] != NULL) n++;
+
+  preset_types = g_malloc0 ((n + 1) * sizeof (GEnumValue));
+  for (i = 0; i < n; i++) {
+    preset_types[i].value = i;
+    preset_types[i].value_name = x264_preset_names[i];
+    preset_types[i].value_nick = x264_preset_names[i];
   }
-  return me_type;
+
+  preset_type = g_enum_register_static ("GstX264EncPreset", preset_types);
+
+  return preset_type;
 }
 
-#define GST_X264_ENC_ANALYSE_TYPE (gst_x264_enc_analyse_get_type())
+enum
+{
+  GST_X264_ENC_RATE_CONTROL_QUANT,
+  GST_X264_ENC_RATE_CONTROL_QUALITY,
+  GST_X264_ENC_RATE_CONTROL_ABR
+};
+
+#define GST_X264_ENC_RATE_CONTROL_TYPE (gst_x264_enc_rate_control_get_type())
 static GType
-gst_x264_enc_analyse_get_type (void)
+gst_x264_enc_rate_control_get_type (void)
 {
-  static GType analyse_type = 0;
-  static const GFlagsValue analyse_types[] = {
-    {X264_ANALYSE_I4x4, "i4x4", "i4x4"},
-    {X264_ANALYSE_I8x8, "i8x8", "i8x8"},
-    {X264_ANALYSE_PSUB16x16, "p8x8", "p8x8"},
-    {X264_ANALYSE_PSUB8x8, "p4x4", "p4x4"},
-    {X264_ANALYSE_BSUB16x16, "b8x8", "b8x8"},
-    {0, NULL, NULL},
+  static GType rate_control_type = 0;
+
+  static const GEnumValue rate_control_types[] = {
+    {GST_X264_ENC_RATE_CONTROL_QUANT, "Constant Quantizer", "quant"},
+    {GST_X264_ENC_RATE_CONTROL_QUALITY, "Constant Quality", "quality"},
+    {GST_X264_ENC_RATE_CONTROL_ABR, "Average or constant bit rate", "abr"},
+    {0, NULL, NULL}
   };
 
-  if (!analyse_type) {
-    analyse_type = g_flags_register_static ("GstX264EncAnalyse", analyse_types);
+  if (!rate_control_type) {
+    rate_control_type = g_enum_register_static ("GstX264EncRateControl", rate_control_types);
   }
-  return analyse_type;
+  return rate_control_type;
 }
 
+
 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
@@ -269,7 +255,7 @@ gst_x264_enc_base_init (gpointer g_class)
   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
 
   gst_element_class_set_details_simple (element_class,
-      "x264enc", "Codec/Encoder/Video", "H264 Encoder",
+      "x264enc", "Codec/Encoder/Video", "H.264 Encoder",
       "Josef Zlomek <josef.zlomek@itonis.tv>, "
       "Mark Nauwelaerts <mnauw@users.sf.net>");
 
@@ -284,6 +270,7 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
+  x264_param_t defaults;
 
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
@@ -295,116 +282,67 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_x264_enc_change_state);
 
-  g_object_class_install_property (gobject_class, ARG_THREADS,
-      g_param_spec_uint ("threads", "Threads",
-          "Number of threads used by the codec (0 for automatic)",
-          0, 4, ARG_THREADS_DEFAULT, G_PARAM_READWRITE));
+  x264_param_default(&defaults);
+
+  g_object_class_install_property (gobject_class, ARG_PROFILE,
+      g_param_spec_enum ("profile", "H.264 profile",
+          "Encoding to H.264 profile", GST_X264_ENC_PROFILE_TYPE,
+          DEFAULT_PROFILE, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_PRESET,
+      g_param_spec_enum ("preset", "x264 preset",
+          "x264 preset", GST_X264_ENC_PRESET_TYPE,
+          DEFAULT_PRESET, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_TUNE,
+      g_param_spec_string ("tune", "x264 tuning",
+          "x264 tuning", DEFAULT_TUNE, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_RATE_CONTROL,
+      g_param_spec_enum ("rate-control", "Rate Control",
+          "Rate Control", GST_X264_ENC_RATE_CONTROL_TYPE,
+          DEFAULT_RATE_CONTROL, G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class, ARG_PASS,
-      g_param_spec_enum ("pass", "Encoding pass/type",
-          "Encoding pass/type", GST_X264_ENC_PASS_TYPE,
-          ARG_PASS_DEFAULT, G_PARAM_READWRITE));
+      g_param_spec_int ("pass", "Encoding pass",
+          "Encoding pass (Only useful when rate-control=abr)", 1, 3,
+          DEFAULT_PASS, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_THREADS,
+      g_param_spec_int ("threads", "Encoding Threads",
+          "Number of encoding threads (0=automatic)", 0, 100,
+          DEFAULT_THREADS, G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class, ARG_QUANTIZER,
-      g_param_spec_uint ("quantizer", "Constant Quantizer",
+      g_param_spec_int ("quantizer", "Constant Quantizer",
           "Constant quantizer or quality to apply",
-          1, 50, ARG_QUANTIZER_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_STATS_FILE,
-      g_param_spec_string ("stats-file", "Stats File",
-          "Filename for multipass statistics (deprecated, use multipass-stats-file)",
-          ARG_STATS_FILE_DEFAULT, G_PARAM_READWRITE));
+          1, 50, defaults.rc.i_qp_constant, G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class, ARG_MULTIPASS_CACHE_FILE,
       g_param_spec_string ("multipass-cache-file", "Multipass Cache File",
           "Filename for multipass cache file",
-          ARG_MULTIPASS_CACHE_FILE_DEFAULT, G_PARAM_READWRITE));
+          DEFAULT_MULTIPASS_CACHE_FILE, G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class, ARG_BYTE_STREAM,
       g_param_spec_boolean ("byte-stream", "Byte Stream",
           "Generate byte stream format of NALU",
-          ARG_BYTE_STREAM_DEFAULT, G_PARAM_READWRITE));
+          DEFAULT_BYTE_STREAM, G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class, ARG_BITRATE,
-      g_param_spec_uint ("bitrate", "Bitrate", "Bitrate in kbit/sec", 1,
-          100 * 1024, ARG_BITRATE_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_VBV_BUF_CAPACITY,
-      g_param_spec_uint ("vbv-buf-capacity", "VBV buffer capacity",
-          "Size of the VBV buffer in milliseconds",
-          300, 10000, ARG_VBV_BUF_CAPACITY_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_ME,
-      g_param_spec_enum ("me", "Motion Estimation",
-          "Integer pixel motion estimation method", GST_X264_ENC_ME_TYPE,
-          ARG_ME_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_SUBME,
-      g_param_spec_uint ("subme", "Subpixel Motion Estimation",
-          "Subpixel motion estimation and partition decision quality: 1=fast, 6=best",
-          1, 6, ARG_SUBME_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_ANALYSE,
-      g_param_spec_flags ("analyse", "Analyse", "Partitions to consider",
-          GST_X264_ENC_ANALYSE_TYPE, ARG_ANALYSE_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_DCT8x8,
-      g_param_spec_boolean ("dct8x8", "DCT8x8",
-          "Adaptive spatial transform size",
-          ARG_DCT8x8_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_REF,
-      g_param_spec_uint ("ref", "Reference Frames",
-          "Number of reference frames",
-          1, 12, ARG_REF_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_BFRAMES,
-      g_param_spec_uint ("bframes", "B-Frames",
-          "Number of B-frames between I and P",
-          0, 4, ARG_BFRAMES_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_B_ADAPT,
-      g_param_spec_boolean ("b-adapt", "B-Adapt",
-          "Automatically decide how many B-frames to use",
-          ARG_B_ADAPT_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_B_PYRAMID,
-      g_param_spec_boolean ("b-pyramid", "B-Pyramid",
-          "Keep some B-frames as references", ARG_B_PYRAMID_DEFAULT,
-          G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_WEIGHTB,
-      g_param_spec_boolean ("weightb", "Weighted B-Frames",
-          "Weighted prediction for B-frames", ARG_WEIGHTB_DEFAULT,
-          G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_SPS_ID,
-      g_param_spec_uint ("sps-id", "SPS ID",
-          "SPS and PPS ID number",
-          0, 31, ARG_SPS_ID_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_AU_NALU,
-      g_param_spec_boolean ("aud", "AUD",
-          "Use AU (Access Unit) delimiter", ARG_AU_NALU_DEFAULT,
-          G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_TRELLIS,
-      g_param_spec_boolean ("trellis", "Trellis quantization",
-          "Enable trellis searched quantization", ARG_TRELLIS_DEFAULT,
-          G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_KEYINT_MAX,
-      g_param_spec_uint ("key-int-max", "Key-frame maximal interval",
-          "Maximal distance between two key-frames (0 for automatic)",
-          0, G_MAXINT, ARG_KEYINT_MAX_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_CABAC,
-      g_param_spec_boolean ("cabac", "Use CABAC",
-          "Enable CABAC entropy coding", ARG_CABAC_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_QP_MIN,
-      g_param_spec_uint ("qp-min", "Minimum Quantizer",
-          "Minimum quantizer", 1, 51, ARG_QP_MIN_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_QP_MAX,
-      g_param_spec_uint ("qp-max", "Maximum Quantizer",
-          "Maximum quantizer", 1, 51, ARG_QP_MAX_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_QP_STEP,
-      g_param_spec_uint ("qp-step", "Maximum Quantizer Difference",
-          "Maximum quantizer difference between frames",
-          1, 50, ARG_QP_STEP_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_IP_FACTOR,
-      g_param_spec_float ("ip-factor", "IP-Factor",
-          "Quantizer factor between I- and P-frames",
-          0, 2, ARG_IP_FACTOR_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_PB_FACTOR,
-      g_param_spec_float ("pb-factor", "PB-Factor",
-          "Quantizer factor between P- and B-frames",
-          0, 2, ARG_PB_FACTOR_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_NR,
-      g_param_spec_uint ("noise-reduction", "Noise Reducation",
-          "Noise reduction strength",
-          0, 100000, ARG_NR_DEFAULT, G_PARAM_READWRITE));
-  g_object_class_install_property (gobject_class, ARG_INTERLACED,
-      g_param_spec_boolean ("interlaced", "Interlaced",
-          "Interlaced material", ARG_INTERLACED_DEFAULT, G_PARAM_READWRITE));
+      g_param_spec_int ("bitrate", "Bitrate", "Bitrate in kbit/sec", 0,
+          1000000, defaults.rc.i_bitrate, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_VBV_MAX_BITRATE,
+      g_param_spec_int ("vbv-max-bitrate", "VBV max bitrate",
+          "Maximum VBV rate",
+          0, 1000000, defaults.rc.i_vbv_max_bitrate, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_VBV_BUF_SIZE,
+      g_param_spec_int ("vbv-buf-size", "VBV buffer size",
+          "Size of the VBV buffer in kbits",
+          0, 1000000, defaults.rc.i_vbv_buffer_size, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_KEYINT,
+      g_param_spec_int ("keyint", "Keyframe interval",
+          "Maximum interval between key frames",
+          0, 100000, defaults.i_keyint_max, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_RC_LOOKAHEAD,
+      g_param_spec_int ("rc-lookahead", "rc lookahead",
+          "Number of frames for frametype lookahead",
+          0, 100, defaults.rc.i_lookahead, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_OPTIONS,
+      g_param_spec_string ("options", "x264 options",
+          "Extra x264 options",
+          DEFAULT_OPTIONS, G_PARAM_READWRITE));
+
 }
 
 static void
@@ -447,6 +385,8 @@ gst_x264_enc_log_callback (gpointer private, gint level, const char *format,
 static void
 gst_x264_enc_init (GstX264Enc * encoder, GstX264EncClass * klass)
 {
+  x264_param_t defaults;
+
   encoder->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
   gst_pad_set_setcaps_function (encoder->sinkpad,
       GST_DEBUG_FUNCPTR (gst_x264_enc_sink_set_caps));
@@ -463,35 +403,24 @@ gst_x264_enc_init (GstX264Enc * encoder, GstX264EncClass * klass)
   gst_pad_set_event_function (encoder->srcpad,
       GST_DEBUG_FUNCPTR (gst_x264_enc_src_event));
 
+  x264_param_default(&defaults);
+
   /* properties */
-  encoder->threads = ARG_THREADS_DEFAULT;
-  encoder->pass = ARG_PASS_DEFAULT;
-  encoder->quantizer = ARG_QUANTIZER_DEFAULT;
-  encoder->mp_cache_file = g_strdup (ARG_MULTIPASS_CACHE_FILE_DEFAULT);
-  encoder->byte_stream = ARG_BYTE_STREAM_DEFAULT;
-  encoder->bitrate = ARG_BITRATE_DEFAULT;
-  encoder->vbv_buf_capacity = ARG_VBV_BUF_CAPACITY_DEFAULT;
-  encoder->me = ARG_ME_DEFAULT;
-  encoder->subme = ARG_SUBME_DEFAULT;
-  encoder->analyse = ARG_ANALYSE_DEFAULT;
-  encoder->dct8x8 = ARG_DCT8x8_DEFAULT;
-  encoder->ref = ARG_REF_DEFAULT;
-  encoder->bframes = ARG_BFRAMES_DEFAULT;
-  encoder->b_adapt = ARG_B_ADAPT_DEFAULT;
-  encoder->b_pyramid = ARG_B_PYRAMID_DEFAULT;
-  encoder->weightb = ARG_WEIGHTB_DEFAULT;
-  encoder->sps_id = ARG_SPS_ID_DEFAULT;
-  encoder->au_nalu = ARG_AU_NALU_DEFAULT;
-  encoder->trellis = ARG_TRELLIS_DEFAULT;
-  encoder->keyint_max = ARG_KEYINT_MAX_DEFAULT;
-  encoder->cabac = ARG_CABAC_DEFAULT;
-  encoder->qp_min = ARG_QP_MIN_DEFAULT;
-  encoder->qp_max = ARG_QP_MAX_DEFAULT;
-  encoder->qp_step = ARG_QP_STEP_DEFAULT;
-  encoder->ip_factor = ARG_IP_FACTOR_DEFAULT;
-  encoder->pb_factor = ARG_PB_FACTOR_DEFAULT;
-  encoder->noise_reduction = ARG_NR_DEFAULT;
-  encoder->interlaced = ARG_INTERLACED_DEFAULT;
+  encoder->profile = DEFAULT_PROFILE;
+  encoder->preset = DEFAULT_PRESET;
+  encoder->tune = g_strdup(DEFAULT_TUNE);
+  encoder->rate_control = DEFAULT_RATE_CONTROL;
+  encoder->pass = DEFAULT_PASS;
+  encoder->threads = DEFAULT_THREADS;
+  encoder->quantizer = defaults.rc.i_qp_constant;
+  encoder->mp_cache_file = g_strdup (DEFAULT_MULTIPASS_CACHE_FILE);
+  encoder->byte_stream = DEFAULT_BYTE_STREAM;
+  encoder->bitrate = defaults.rc.i_bitrate;
+  encoder->vbv_buf_size = defaults.rc.i_vbv_buffer_size;
+  encoder->vbv_max_bitrate = defaults.rc.i_vbv_max_bitrate;
+  encoder->keyint = defaults.i_keyint_max;
+  encoder->rc_lookahead = defaults.rc.i_lookahead;
+  encoder->options = g_strdup(DEFAULT_OPTIONS);
 
   /* resources */
   encoder->delay = g_queue_new ();
@@ -500,11 +429,6 @@ gst_x264_enc_init (GstX264Enc * encoder, GstX264EncClass * klass)
 
   x264_param_default (&encoder->x264param);
 
-  /* log callback setup; part of parameters */
-  encoder->x264param.pf_log = gst_x264_enc_log_callback;
-  encoder->x264param.p_log_private = encoder;
-  encoder->x264param.i_log_level = X264_LOG_DEBUG;
-
   gst_x264_enc_reset (encoder);
 }
 
@@ -550,13 +474,20 @@ gst_x264_enc_finalize (GObject * object)
 static gboolean
 gst_x264_enc_init_encoder (GstX264Enc * encoder)
 {
-  guint pass = 0;
-
   /* make sure that the encoder is closed */
   gst_x264_enc_close_encoder (encoder);
 
   GST_OBJECT_LOCK (encoder);
 
+  x264_param_default (&encoder->x264param);
+  x264_param_default_preset (&encoder->x264param,
+      x264_preset_names[encoder->preset], encoder->tune);
+
+  /* log callback setup; part of parameters */
+  encoder->x264param.pf_log = gst_x264_enc_log_callback;
+  encoder->x264param.p_log_private = encoder;
+  encoder->x264param.i_log_level = X264_LOG_DEBUG;
+
   /* set up encoder parameters */
   encoder->x264param.i_threads = encoder->threads;
   encoder->x264param.i_fps_num = encoder->fps_num;
@@ -567,113 +498,82 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder)
     encoder->x264param.vui.i_sar_width = encoder->par_num;
     encoder->x264param.vui.i_sar_height = encoder->par_den;
   }
-  /* FIXME 0.11 : 2s default keyframe interval seems excessive
-   * (10s is x264 default) */
-  encoder->x264param.i_keyint_max = encoder->keyint_max ? encoder->keyint_max :
-      (2 * encoder->fps_num / encoder->fps_den);
-  encoder->x264param.b_cabac = encoder->cabac;
-  encoder->x264param.b_aud = encoder->au_nalu;
-  encoder->x264param.i_sps_id = encoder->sps_id;
-  if ((((encoder->height == 576) && ((encoder->width == 720)
-                  || (encoder->width == 704) || (encoder->width == 352)))
-          || ((encoder->height == 288) && (encoder->width == 352)))
-      && (encoder->fps_den == 1) && (encoder->fps_num == 25)) {
-    encoder->x264param.vui.i_vidformat = 1;     /* PAL */
-  } else if ((((encoder->height == 480) && ((encoder->width == 720)
-                  || (encoder->width == 704) || (encoder->width == 352)))
-          || ((encoder->height == 240) && (encoder->width == 352)))
-      && (encoder->fps_den == 1001) && ((encoder->fps_num == 30000)
-          || (encoder->fps_num == 24000))) {
-    encoder->x264param.vui.i_vidformat = 2;     /* NTSC */
-  } else
-    encoder->x264param.vui.i_vidformat = 5;     /* unspecified */
-  encoder->x264param.analyse.i_trellis = encoder->trellis ? 1 : 0;
-  encoder->x264param.analyse.b_psnr = 0;
-  encoder->x264param.analyse.i_me_method = encoder->me;
-  encoder->x264param.analyse.i_subpel_refine = encoder->subme;
-  encoder->x264param.analyse.inter = encoder->analyse;
-  encoder->x264param.analyse.b_transform_8x8 = encoder->dct8x8;
-  encoder->x264param.analyse.b_weighted_bipred = encoder->weightb;
-  encoder->x264param.analyse.i_noise_reduction = encoder->noise_reduction;
-  encoder->x264param.i_frame_reference = encoder->ref;
-  encoder->x264param.i_bframe = encoder->bframes;
-#if X264_BUILD < 78
-  encoder->x264param.b_bframe_pyramid = encoder->b_pyramid;
-#else
-  encoder->x264param.i_bframe_pyramid =
-      encoder->b_pyramid ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE;
-#endif
-#if X264_BUILD < 63
-  encoder->x264param.b_bframe_adaptive = encoder->b_adapt;
-#else
-  encoder->x264param.i_bframe_adaptive =
-      encoder->b_adapt ? X264_B_ADAPT_FAST : X264_B_ADAPT_NONE;
-#endif
-  encoder->x264param.b_interlaced = encoder->interlaced;
-  encoder->x264param.b_deblocking_filter = 1;
-  encoder->x264param.i_deblocking_filter_alphac0 = 0;
-  encoder->x264param.i_deblocking_filter_beta = 0;
-  encoder->x264param.rc.f_ip_factor = encoder->ip_factor;
-  encoder->x264param.rc.f_pb_factor = encoder->pb_factor;
+  encoder->x264param.i_keyint_max = encoder->keyint;
 #ifdef X264_ENC_NALS
   encoder->x264param.b_annexb = encoder->byte_stream;
 #endif
+  encoder->x264param.vui.i_chroma_loc = encoder->chroma_site;
+  encoder->x264param.vui.i_colmatrix = encoder->color_matrix;
+  encoder->x264param.b_interlaced = encoder->interlaced;
 
-  switch (encoder->pass) {
-    case GST_X264_ENC_PASS_QUANT:
+  switch (encoder->rate_control) {
+    case GST_X264_ENC_RATE_CONTROL_QUANT:
       encoder->x264param.rc.i_rc_method = X264_RC_CQP;
       encoder->x264param.rc.i_qp_constant = encoder->quantizer;
       break;
-    case GST_X264_ENC_PASS_QUAL:
+    case GST_X264_ENC_RATE_CONTROL_QUALITY:
       encoder->x264param.rc.i_rc_method = X264_RC_CRF;
       encoder->x264param.rc.f_rf_constant = encoder->quantizer;
       break;
-    case GST_X264_ENC_PASS_CBR:
-    case GST_X264_ENC_PASS_PASS1:
-    case GST_X264_ENC_PASS_PASS2:
-    case GST_X264_ENC_PASS_PASS3:
-    default:
+    case GST_X264_ENC_RATE_CONTROL_ABR:
       encoder->x264param.rc.i_rc_method = X264_RC_ABR;
       encoder->x264param.rc.i_bitrate = encoder->bitrate;
-      encoder->x264param.rc.i_vbv_max_bitrate = encoder->bitrate;
-      encoder->x264param.rc.i_vbv_buffer_size
-          = encoder->x264param.rc.i_vbv_max_bitrate
-          * encoder->vbv_buf_capacity / 1000;
-      encoder->x264param.rc.i_qp_min = encoder->qp_min;
-      encoder->x264param.rc.i_qp_max = encoder->qp_max;
-      encoder->x264param.rc.i_qp_step = encoder->qp_step;
-      pass = encoder->pass & 0xF;
+      encoder->x264param.rc.i_vbv_max_bitrate = encoder->vbv_max_bitrate;
+      encoder->x264param.rc.i_vbv_buffer_size = encoder->vbv_buf_size;
+      switch (encoder->pass) {
+        case 1:
+          x264_param_apply_fastfirstpass (&encoder->x264param);
+          encoder->x264param.rc.b_stat_read = 0;
+          encoder->x264param.rc.b_stat_write = 1;
+          break;
+        case 2:
+          encoder->x264param.rc.b_stat_read = 1;
+          encoder->x264param.rc.b_stat_write = 0;
+          break;
+        case 3:
+          encoder->x264param.rc.b_stat_read = 1;
+          encoder->x264param.rc.b_stat_write = 1;
+          break;
+      }
+      encoder->x264param.rc.psz_stat_in = encoder->mp_cache_file;
+      encoder->x264param.rc.psz_stat_out = encoder->mp_cache_file;
       break;
+    default:
+      g_assert_not_reached();
   }
+  encoder->x264param.rc.i_lookahead = encoder->rc_lookahead;
 
-  switch (pass) {
-    case 0:
-      encoder->x264param.rc.b_stat_read = 0;
-      encoder->x264param.rc.b_stat_write = 0;
-      break;
-    case 1:
-      /* Turbo mode parameters. */
-      encoder->x264param.i_frame_reference = (encoder->ref + 1) >> 1;
-      encoder->x264param.analyse.i_subpel_refine =
-          CLAMP (encoder->subme - 1, 1, 3);
-      encoder->x264param.analyse.inter &= ~X264_ANALYSE_PSUB8x8;
-      encoder->x264param.analyse.inter &= ~X264_ANALYSE_BSUB16x16;
-      encoder->x264param.analyse.i_trellis = 0;
-
-      encoder->x264param.rc.b_stat_read = 0;
-      encoder->x264param.rc.b_stat_write = 1;
-      break;
-    case 2:
-      encoder->x264param.rc.b_stat_read = 1;
-      encoder->x264param.rc.b_stat_write = 0;
-      break;
-    case 3:
-      encoder->x264param.rc.b_stat_read = 1;
-      encoder->x264param.rc.b_stat_write = 1;
-      break;
+
+  {
+    gchar **list;
+    int i;
+
+    list = g_strsplit (encoder->options, ",", 0);
+    i = 0;
+    while (list[i]) {
+      gchar **nameval;
+
+      GST_ERROR("option string %s", list[i]);
+
+      nameval = g_strsplit (list[i], "=", 2);
+      GST_ERROR("nameval %s %s", nameval[0], nameval[1]);
+
+      if (nameval[0]) {
+        int ret;
+
+        ret = x264_param_parse (&encoder->x264param, nameval[0], nameval[1]);
+
+        GST_ERROR("parsing %s returned %d", nameval[0], ret);
+      }
+
+      i++;
+    }
+
+    g_strfreev (list);
   }
-  encoder->x264param.rc.psz_stat_in = encoder->mp_cache_file;
-  encoder->x264param.rc.psz_stat_out = encoder->mp_cache_file;
+
+  x264_param_apply_profile (&encoder->x264param,
+      x264_profile_names[encoder->profile]);
 
   GST_OBJECT_UNLOCK (encoder);
 
@@ -853,6 +753,10 @@ gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps)
   gint fps_num, fps_den;
   gint par_num, par_den;
   gint i;
+  gint chroma_site;
+  gint color_matrix;
+  gboolean interlaced;
+  const char *s;
 
   /* get info from caps */
   /* only I420 supported for now; so apparently claims x264enc ? */
@@ -865,6 +769,26 @@ gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps)
     par_num = 1;
     par_den = 1;
   }
+  if (!gst_video_format_parse_caps_interlaced (caps, &interlaced)) {
+    interlaced = FALSE;
+  }
+
+  s = gst_video_parse_caps_chroma_site (caps);
+  /* See H.264 Annex E "chroma_sample_loc_type_top_field" for details */
+  chroma_site = 0;
+  if (s && g_str_equal (s, "jpeg")) {
+    chroma_site = 1;
+  }
+
+  /* See H.264 Annex E "matrix_coefficients" for details */
+  s = gst_video_parse_caps_color_matrix (caps);
+  color_matrix = 5;
+  if (s && g_str_equal (s, "hdtv")) {
+    color_matrix = 1;
+  }
+  if (s && g_str_equal (s, "sdtv")) {
+    color_matrix = 5;
+  }
 
   /* If the encoder is initialized, do not
      reinitialize it again if not necessary */
@@ -887,6 +811,9 @@ gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps)
   encoder->fps_den = fps_den;
   encoder->par_num = par_num;
   encoder->par_den = par_den;
+  encoder->chroma_site = chroma_site;
+  encoder->color_matrix = color_matrix;
+  encoder->interlaced = interlaced;
 
   /* prepare a cached image description  */
   encoder->image_size = gst_video_format_get_size (encoder->format, width,
@@ -1066,6 +993,8 @@ gst_x264_enc_encode_frame (GstX264Enc * encoder, x264_picture_t * pic_in,
   if (G_UNLIKELY (encoder->x264enc == NULL))
     return GST_FLOW_NOT_NEGOTIATED;
 
+  GST_ERROR("encoding %p", pic_in);
+
   encoder_return = x264_encoder_encode (encoder->x264enc,
       &nal, i_nal, pic_in, &pic_out);
 
@@ -1160,14 +1089,16 @@ gst_x264_enc_flush_frames (GstX264Enc * encoder, gboolean send)
   gint i_nal;
 
   /* first send the remaining frames */
-  if (encoder->x264enc)
-    do {
+  if (encoder->x264enc) {
+    while (x264_encoder_delayed_frames (encoder->x264enc)) {
       flow_ret = gst_x264_enc_encode_frame (encoder, NULL, &i_nal, send);
-    } while (flow_ret == GST_FLOW_OK && i_nal > 0);
+    }
+  }
 
   /* in any case, make sure the delay queue is emptied */
-  while (!g_queue_is_empty (encoder->delay))
+  while (!g_queue_is_empty (encoder->delay)) {
     gst_buffer_unref (g_queue_pop_head (encoder->delay));
+  }
 }
 
 static GstStateChangeReturn
@@ -1211,16 +1142,28 @@ gst_x264_enc_set_property (GObject * object, guint prop_id,
     goto wrong_state;
 
   switch (prop_id) {
-    case ARG_THREADS:
-      encoder->threads = g_value_get_uint (value);
+    case ARG_PROFILE:
+      encoder->profile = g_value_get_enum (value);
+      break;
+    case ARG_PRESET:
+      encoder->preset = g_value_get_enum (value);
+      break;
+    case ARG_TUNE:
+      if (encoder->tune) g_free (encoder->tune);
+      encoder->tune = g_value_dup_string (value);
+      break;
+    case ARG_RATE_CONTROL:
+      encoder->rate_control = g_value_get_enum (value);
       break;
     case ARG_PASS:
-      encoder->pass = g_value_get_enum (value);
+      encoder->pass = g_value_get_int (value);
+      break;
+    case ARG_THREADS:
+      encoder->threads = g_value_get_int (value);
       break;
     case ARG_QUANTIZER:
-      encoder->quantizer = g_value_get_uint (value);
+      encoder->quantizer = g_value_get_int (value);
       break;
-    case ARG_STATS_FILE:
     case ARG_MULTIPASS_CACHE_FILE:
       if (encoder->mp_cache_file)
         g_free (encoder->mp_cache_file);
@@ -1230,73 +1173,24 @@ gst_x264_enc_set_property (GObject * object, guint prop_id,
       encoder->byte_stream = g_value_get_boolean (value);
       break;
     case ARG_BITRATE:
-      encoder->bitrate = g_value_get_uint (value);
-      break;
-    case ARG_VBV_BUF_CAPACITY:
-      encoder->vbv_buf_capacity = g_value_get_uint (value);
-      break;
-    case ARG_ME:
-      encoder->me = g_value_get_enum (value);
-      break;
-    case ARG_SUBME:
-      encoder->subme = g_value_get_uint (value);
-      break;
-    case ARG_ANALYSE:
-      encoder->analyse = g_value_get_flags (value);
-      break;
-    case ARG_DCT8x8:
-      encoder->dct8x8 = g_value_get_boolean (value);
-      break;
-    case ARG_REF:
-      encoder->ref = g_value_get_uint (value);
-      break;
-    case ARG_BFRAMES:
-      encoder->bframes = g_value_get_uint (value);
-      break;
-    case ARG_B_ADAPT:
-      encoder->b_adapt = g_value_get_boolean (value);
-      break;
-    case ARG_B_PYRAMID:
-      encoder->b_pyramid = g_value_get_boolean (value);
+      encoder->bitrate = g_value_get_int (value);
       break;
-    case ARG_WEIGHTB:
-      encoder->weightb = g_value_get_boolean (value);
+    case ARG_VBV_MAX_BITRATE:
+      encoder->vbv_max_bitrate = g_value_get_int (value);
       break;
-    case ARG_SPS_ID:
-      encoder->sps_id = g_value_get_uint (value);
+    case ARG_VBV_BUF_SIZE:
+      encoder->vbv_buf_size = g_value_get_int (value);
       break;
-    case ARG_AU_NALU:
-      encoder->au_nalu = g_value_get_boolean (value);
+    case ARG_KEYINT:
+      encoder->keyint = g_value_get_int (value);
       break;
-    case ARG_TRELLIS:
-      encoder->trellis = g_value_get_boolean (value);
+    case ARG_RC_LOOKAHEAD:
+      encoder->rc_lookahead = g_value_get_int (value);
       break;
-    case ARG_KEYINT_MAX:
-      encoder->keyint_max = g_value_get_uint (value);
-      break;
-    case ARG_CABAC:
-      encoder->cabac = g_value_get_boolean (value);
-      break;
-    case ARG_QP_MIN:
-      encoder->qp_min = g_value_get_uint (value);
-      break;
-    case ARG_QP_MAX:
-      encoder->qp_max = g_value_get_uint (value);
-      break;
-    case ARG_QP_STEP:
-      encoder->qp_step = g_value_get_uint (value);
-      break;
-    case ARG_IP_FACTOR:
-      encoder->ip_factor = g_value_get_float (value);
-      break;
-    case ARG_PB_FACTOR:
-      encoder->pb_factor = g_value_get_float (value);
-      break;
-    case ARG_NR:
-      encoder->noise_reduction = g_value_get_uint (value);
-      break;
-    case ARG_INTERLACED:
-      encoder->interlaced = g_value_get_boolean (value);
+    case ARG_OPTIONS:
+      if (encoder->options)
+        g_free (encoder->options);
+      encoder->options = g_value_dup_string (value);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1323,16 +1217,27 @@ gst_x264_enc_get_property (GObject * object, guint prop_id,
 
   GST_OBJECT_LOCK (encoder);
   switch (prop_id) {
-    case ARG_THREADS:
-      g_value_set_uint (value, encoder->threads);
+    case ARG_PROFILE:
+      g_value_set_enum (value, encoder->profile);
+      break;
+    case ARG_PRESET:
+      g_value_set_enum (value, encoder->preset);
+      break;
+    case ARG_TUNE:
+      g_value_set_string (value, encoder->tune);
+      break;
+    case ARG_RATE_CONTROL:
+      g_value_set_enum (value, encoder->rate_control);
       break;
     case ARG_PASS:
-      g_value_set_enum (value, encoder->pass);
+      g_value_set_int (value, encoder->pass);
+      break;
+    case ARG_THREADS:
+      g_value_set_int (value, encoder->threads);
       break;
     case ARG_QUANTIZER:
-      g_value_set_uint (value, encoder->quantizer);
+      g_value_set_int (value, encoder->quantizer);
       break;
-    case ARG_STATS_FILE:
     case ARG_MULTIPASS_CACHE_FILE:
       g_value_set_string (value, encoder->mp_cache_file);
       break;
@@ -1340,73 +1245,22 @@ gst_x264_enc_get_property (GObject * object, guint prop_id,
       g_value_set_boolean (value, encoder->byte_stream);
       break;
     case ARG_BITRATE:
-      g_value_set_uint (value, encoder->bitrate);
-      break;
-    case ARG_VBV_BUF_CAPACITY:
-      g_value_set_uint (value, encoder->vbv_buf_capacity);
-      break;
-    case ARG_ME:
-      g_value_set_enum (value, encoder->me);
-      break;
-    case ARG_SUBME:
-      g_value_set_uint (value, encoder->subme);
-      break;
-    case ARG_ANALYSE:
-      g_value_set_flags (value, encoder->analyse);
-      break;
-    case ARG_DCT8x8:
-      g_value_set_boolean (value, encoder->dct8x8);
-      break;
-    case ARG_REF:
-      g_value_set_uint (value, encoder->ref);
-      break;
-    case ARG_BFRAMES:
-      g_value_set_uint (value, encoder->bframes);
-      break;
-    case ARG_B_ADAPT:
-      g_value_set_boolean (value, encoder->b_adapt);
-      break;
-    case ARG_B_PYRAMID:
-      g_value_set_boolean (value, encoder->b_pyramid);
-      break;
-    case ARG_WEIGHTB:
-      g_value_set_boolean (value, encoder->weightb);
-      break;
-    case ARG_SPS_ID:
-      g_value_set_uint (value, encoder->sps_id);
-      break;
-    case ARG_AU_NALU:
-      g_value_set_boolean (value, encoder->au_nalu);
-      break;
-    case ARG_TRELLIS:
-      g_value_set_boolean (value, encoder->trellis);
-      break;
-    case ARG_KEYINT_MAX:
-      g_value_set_uint (value, encoder->keyint_max);
-      break;
-    case ARG_QP_MIN:
-      g_value_set_uint (value, encoder->qp_min);
-      break;
-    case ARG_QP_MAX:
-      g_value_set_uint (value, encoder->qp_max);
-      break;
-    case ARG_QP_STEP:
-      g_value_set_uint (value, encoder->qp_step);
+      g_value_set_int (value, encoder->bitrate);
       break;
-    case ARG_CABAC:
-      g_value_set_boolean (value, encoder->cabac);
+    case ARG_VBV_MAX_BITRATE:
+      g_value_set_int (value, encoder->vbv_max_bitrate);
       break;
-    case ARG_IP_FACTOR:
-      g_value_set_float (value, encoder->ip_factor);
+    case ARG_VBV_BUF_SIZE:
+      g_value_set_int (value, encoder->vbv_buf_size);
       break;
-    case ARG_PB_FACTOR:
-      g_value_set_float (value, encoder->pb_factor);
+    case ARG_KEYINT:
+      g_value_set_int (value, encoder->keyint);
       break;
-    case ARG_NR:
-      g_value_set_uint (value, encoder->noise_reduction);
+    case ARG_RC_LOOKAHEAD:
+      g_value_set_int (value, encoder->rc_lookahead);
       break;
-    case ARG_INTERLACED:
-      g_value_set_boolean (value, encoder->interlaced);
+    case ARG_OPTIONS:
+      g_value_set_string (value, encoder->options);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1428,5 +1282,5 @@ plugin_init (GstPlugin * plugin)
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
     GST_VERSION_MINOR,
     "x264",
-    "libx264-based H264 plugins",
+    "libx264-based H.264 plugins",
     plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/ext/x264/gstx264enc.h b/ext/x264/gstx264enc.h
index 340067a..f51ccbc 100644
--- a/ext/x264/gstx264enc.h
+++ b/ext/x264/gstx264enc.h
@@ -54,40 +54,32 @@ struct _GstX264Enc
   x264_param_t x264param;
 
   /* properties */
-  guint threads;
-  gint pass;
-  guint quantizer;
+  int profile;
+  int preset;
+  char *tune;
+  int rate_control;
+  int pass;
+  int threads;
+  int quantizer;
   gchar *mp_cache_file;
   gboolean byte_stream;
-  guint bitrate;
-  gint me;
-  guint subme;
-  guint analyse;
-  gboolean dct8x8;
-  guint ref;
-  guint bframes;
-  gboolean b_adapt;
-  gboolean b_pyramid;
-  gboolean weightb;
+  int bitrate;
+  int vbv_max_bitrate;
+  int vbv_buf_size;
+  int keyint;
+  int rc_lookahead;
+  gchar *options;
+
   guint sps_id;
-  gboolean au_nalu;
-  gboolean trellis;
-  guint vbv_buf_capacity;
-  guint keyint_max;
-  gboolean cabac;
-  gfloat ip_factor;
-  gfloat pb_factor;
-  guint qp_min;
-  guint qp_max;
-  guint qp_step;
-  guint noise_reduction;
-  gboolean interlaced;
 
   /* input description */
   GstVideoFormat format;
   gint width, height;
   gint fps_num, fps_den;
   gint par_num, par_den;
+  gboolean interlaced;
+  gint chroma_site;
+  gint color_matrix;
   /* cache some format properties */
   gint stride[4], offset[4];
   gint image_size;
