mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
[MOVED FROM BAD 12/28] configure.ac: Check for sufficiently up-to-date x264 API.
Original commit message from CVS: * configure.ac: Check for sufficiently up-to-date x264 API. * ext/x264/gstx264enc.c: (gst_x264_enc_pass_get_type), (gst_x264_enc_base_init), (gst_x264_enc_class_init), (gst_x264_enc_init), (gst_x264_enc_init_encoder), (gst_x264_enc_set_property), (gst_x264_enc_get_property): * ext/x264/gstx264enc.h: Expose some more parameters of the x264 encoder as properties.
This commit is contained in:
parent
1b4c1fead0
commit
a2ff3c6fde
2 changed files with 285 additions and 60 deletions
|
@ -1,6 +1,7 @@
|
||||||
/* GStreamer H264 encoder plugin
|
/* GStreamer H264 encoder plugin
|
||||||
* Copyright (C) 2005 Michal Benes <michal.benes@itonis.tv>
|
* Copyright (C) 2005 Michal Benes <michal.benes@itonis.tv>
|
||||||
* Copyright (C) 2005 Josef Zlomek <josef.zlomek@itonis.tv>
|
* Copyright (C) 2005 Josef Zlomek <josef.zlomek@itonis.tv>
|
||||||
|
* Copyright (C) 2008 Mark Nauwelaerts <mnauw@users.sf.net>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
@ -35,6 +36,8 @@ enum
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_THREADS,
|
ARG_THREADS,
|
||||||
ARG_PASS,
|
ARG_PASS,
|
||||||
|
ARG_PASS_NEW,
|
||||||
|
ARG_QUANTIZER,
|
||||||
ARG_STATS_FILE,
|
ARG_STATS_FILE,
|
||||||
ARG_BYTE_STREAM,
|
ARG_BYTE_STREAM,
|
||||||
ARG_BITRATE,
|
ARG_BITRATE,
|
||||||
|
@ -45,16 +48,26 @@ enum
|
||||||
ARG_DCT8x8,
|
ARG_DCT8x8,
|
||||||
ARG_REF,
|
ARG_REF,
|
||||||
ARG_BFRAMES,
|
ARG_BFRAMES,
|
||||||
|
ARG_B_ADAPT,
|
||||||
ARG_B_PYRAMID,
|
ARG_B_PYRAMID,
|
||||||
ARG_WEIGHTB,
|
ARG_WEIGHTB,
|
||||||
ARG_SPS_ID,
|
ARG_SPS_ID,
|
||||||
ARG_TRELLIS,
|
ARG_TRELLIS,
|
||||||
ARG_KEYINT_MAX,
|
ARG_KEYINT_MAX,
|
||||||
ARG_CABAC
|
ARG_CABAC,
|
||||||
|
ARG_QP_MIN,
|
||||||
|
ARG_QP_MAX,
|
||||||
|
ARG_QP_STEP,
|
||||||
|
ARG_IP_FACTOR,
|
||||||
|
ARG_PB_FACTOR,
|
||||||
|
ARG_NR,
|
||||||
|
ARG_INTERLACED
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ARG_THREADS_DEFAULT 1
|
#define ARG_THREADS_DEFAULT 1
|
||||||
#define ARG_PASS_DEFAULT 0
|
#define ARG_PASS_DEFAULT 0
|
||||||
|
#define ARG_PASS_NEW_DEFAULT 0
|
||||||
|
#define ARG_QUANTIZER_DEFAULT 21
|
||||||
#define ARG_STATS_FILE_DEFAULT "x264.log"
|
#define ARG_STATS_FILE_DEFAULT "x264.log"
|
||||||
#define ARG_BYTE_STREAM_DEFAULT FALSE
|
#define ARG_BYTE_STREAM_DEFAULT FALSE
|
||||||
#define ARG_BITRATE_DEFAULT (2 * 1024)
|
#define ARG_BITRATE_DEFAULT (2 * 1024)
|
||||||
|
@ -65,12 +78,52 @@ enum
|
||||||
#define ARG_DCT8x8_DEFAULT FALSE
|
#define ARG_DCT8x8_DEFAULT FALSE
|
||||||
#define ARG_REF_DEFAULT 1
|
#define ARG_REF_DEFAULT 1
|
||||||
#define ARG_BFRAMES_DEFAULT 0
|
#define ARG_BFRAMES_DEFAULT 0
|
||||||
|
#define ARG_B_ADAPT_DEFAULT TRUE
|
||||||
#define ARG_B_PYRAMID_DEFAULT FALSE
|
#define ARG_B_PYRAMID_DEFAULT FALSE
|
||||||
#define ARG_WEIGHTB_DEFAULT FALSE
|
#define ARG_WEIGHTB_DEFAULT FALSE
|
||||||
#define ARG_SPS_ID_DEFAULT 0
|
#define ARG_SPS_ID_DEFAULT 0
|
||||||
#define ARG_TRELLIS_DEFAULT TRUE
|
#define ARG_TRELLIS_DEFAULT TRUE
|
||||||
#define ARG_KEYINT_MAX_DEFAULT 0
|
#define ARG_KEYINT_MAX_DEFAULT 0
|
||||||
#define ARG_CABAC_DEFAULT TRUE
|
#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
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GST_X264_ENC_PASS_CBR = 0,
|
||||||
|
GST_X264_ENC_PASS_QUANT,
|
||||||
|
GST_X264_ENC_PASS_QUAL,
|
||||||
|
GST_X264_ENC_PASS_PASS1 = 0x11,
|
||||||
|
GST_X264_ENC_PASS_PASS2,
|
||||||
|
GST_X264_ENC_PASS_PASS3
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GST_X264_ENC_PASS_TYPE (gst_x264_enc_pass_get_type())
|
||||||
|
static GType
|
||||||
|
gst_x264_enc_pass_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}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!pass_type) {
|
||||||
|
pass_type = g_enum_register_static ("GstX264EncPass", pass_types);
|
||||||
|
}
|
||||||
|
return pass_type;
|
||||||
|
}
|
||||||
|
|
||||||
#define GST_X264_ENC_ME_TYPE (gst_x264_enc_me_get_type())
|
#define GST_X264_ENC_ME_TYPE (gst_x264_enc_me_get_type())
|
||||||
static GType
|
static GType
|
||||||
|
@ -155,7 +208,8 @@ gst_x264_enc_base_init (gpointer g_class)
|
||||||
|
|
||||||
gst_element_class_set_details_simple (element_class,
|
gst_element_class_set_details_simple (element_class,
|
||||||
"x264enc", "Codec/Encoder/Video", "H264 Encoder",
|
"x264enc", "Codec/Encoder/Video", "H264 Encoder",
|
||||||
"Josef Zlomek <josef.zlomek@itonis.tv>");
|
"Josef Zlomek <josef.zlomek@itonis.tv>, "
|
||||||
|
"Mark Nauwelaerts <mnauw@users.sf.net>");
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&src_factory));
|
gst_static_pad_template_get (&src_factory));
|
||||||
|
@ -181,27 +235,36 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, ARG_THREADS,
|
g_object_class_install_property (gobject_class, ARG_THREADS,
|
||||||
g_param_spec_uint ("threads", "Threads",
|
g_param_spec_uint ("threads", "Threads",
|
||||||
"Number of threads used by the codec", 1, 4, ARG_THREADS_DEFAULT,
|
"Number of threads used by the codec (0 for automatic)",
|
||||||
G_PARAM_READWRITE));
|
0, 4, ARG_THREADS_DEFAULT, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_PASS_NEW,
|
||||||
|
g_param_spec_enum ("pass-new", "Encoding pass/type",
|
||||||
|
"Encoding pass/type", GST_X264_ENC_PASS_TYPE,
|
||||||
|
ARG_PASS_NEW_DEFAULT, G_PARAM_READWRITE));
|
||||||
|
/* FIXME 0.11: remove pass property and use the one above */
|
||||||
g_object_class_install_property (gobject_class, ARG_PASS,
|
g_object_class_install_property (gobject_class, ARG_PASS,
|
||||||
g_param_spec_uint ("pass", "Pass",
|
g_param_spec_uint ("pass", "Pass",
|
||||||
"Pass of multipass encoding (0=single pass; 1=first pass, 2=middle pass, 3=last pass)",
|
"Pass of multipass encoding (0=single pass; 1=first pass, 2=middle pass, 3=last pass)",
|
||||||
0, 3, ARG_PASS_DEFAULT, G_PARAM_READWRITE));
|
0, 3, ARG_PASS_DEFAULT, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_QUANTIZER,
|
||||||
|
g_param_spec_uint ("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_object_class_install_property (gobject_class, ARG_STATS_FILE,
|
||||||
g_param_spec_string ("stats_file", "Stats File",
|
g_param_spec_string ("stats-file", "Stats File",
|
||||||
"Filename for multipass statistics", ARG_STATS_FILE_DEFAULT,
|
"Filename for multipass statistics",
|
||||||
G_PARAM_READWRITE));
|
ARG_STATS_FILE_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_BYTE_STREAM,
|
g_object_class_install_property (gobject_class, ARG_BYTE_STREAM,
|
||||||
g_param_spec_boolean ("byte_stream", "Byte Stream",
|
g_param_spec_boolean ("byte-stream", "Byte Stream",
|
||||||
"Generate byte stream format of NALU", ARG_BYTE_STREAM_DEFAULT,
|
"Generate byte stream format of NALU",
|
||||||
G_PARAM_READWRITE));
|
ARG_BYTE_STREAM_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_BITRATE,
|
g_object_class_install_property (gobject_class, ARG_BITRATE,
|
||||||
g_param_spec_uint ("bitrate", "Bitrate", "Bitrate in kbit/sec", 1,
|
g_param_spec_uint ("bitrate", "Bitrate", "Bitrate in kbit/sec", 1,
|
||||||
100 * 1024, ARG_BITRATE_DEFAULT, G_PARAM_READWRITE));
|
100 * 1024, ARG_BITRATE_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_VBV_BUF_CAPACITY,
|
g_object_class_install_property (gobject_class, ARG_VBV_BUF_CAPACITY,
|
||||||
g_param_spec_uint ("vbv_buf_capacity", "VBV buffer capacity",
|
g_param_spec_uint ("vbv-buf-capacity", "VBV buffer capacity",
|
||||||
"Size of the VBV buffer in milliseconds", 300,
|
"Size of the VBV buffer in milliseconds",
|
||||||
10000, ARG_VBV_BUF_CAPACITY_DEFAULT, G_PARAM_READWRITE));
|
300, 10000, ARG_VBV_BUF_CAPACITY_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_ME,
|
g_object_class_install_property (gobject_class, ARG_ME,
|
||||||
g_param_spec_enum ("me", "Motion Estimation",
|
g_param_spec_enum ("me", "Motion Estimation",
|
||||||
"Integer pixel motion estimation method", GST_X264_ENC_ME_TYPE,
|
"Integer pixel motion estimation method", GST_X264_ENC_ME_TYPE,
|
||||||
|
@ -215,18 +278,22 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
|
||||||
GST_X264_ENC_ANALYSE_TYPE, ARG_ANALYSE_DEFAULT, G_PARAM_READWRITE));
|
GST_X264_ENC_ANALYSE_TYPE, ARG_ANALYSE_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_DCT8x8,
|
g_object_class_install_property (gobject_class, ARG_DCT8x8,
|
||||||
g_param_spec_boolean ("dct8x8", "DCT8x8",
|
g_param_spec_boolean ("dct8x8", "DCT8x8",
|
||||||
"Adaptive spatial transform size", ARG_DCT8x8_DEFAULT,
|
"Adaptive spatial transform size",
|
||||||
G_PARAM_READWRITE));
|
ARG_DCT8x8_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_REF,
|
g_object_class_install_property (gobject_class, ARG_REF,
|
||||||
g_param_spec_uint ("ref", "Reference Frames",
|
g_param_spec_uint ("ref", "Reference Frames",
|
||||||
"Number of reference frames", 1, 12, ARG_REF_DEFAULT,
|
"Number of reference frames",
|
||||||
G_PARAM_READWRITE));
|
1, 12, ARG_REF_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_BFRAMES,
|
g_object_class_install_property (gobject_class, ARG_BFRAMES,
|
||||||
g_param_spec_uint ("bframes", "B-Frames",
|
g_param_spec_uint ("bframes", "B-Frames",
|
||||||
"Number of B-frames between I and P", 0, 4, ARG_BFRAMES_DEFAULT,
|
"Number of B-frames between I and P",
|
||||||
G_PARAM_READWRITE));
|
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_object_class_install_property (gobject_class, ARG_B_PYRAMID,
|
||||||
g_param_spec_boolean ("b_pyramid", "B-Pyramid",
|
g_param_spec_boolean ("b-pyramid", "B-Pyramid",
|
||||||
"Keep some B-frames as references", ARG_B_PYRAMID_DEFAULT,
|
"Keep some B-frames as references", ARG_B_PYRAMID_DEFAULT,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_WEIGHTB,
|
g_object_class_install_property (gobject_class, ARG_WEIGHTB,
|
||||||
|
@ -234,20 +301,45 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
|
||||||
"Weighted prediction for B-frames", ARG_WEIGHTB_DEFAULT,
|
"Weighted prediction for B-frames", ARG_WEIGHTB_DEFAULT,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_SPS_ID,
|
g_object_class_install_property (gobject_class, ARG_SPS_ID,
|
||||||
g_param_spec_uint ("sps_id", "SPS ID",
|
g_param_spec_uint ("sps-id", "SPS ID",
|
||||||
"SPS and PPS ID number", 0, 31, ARG_SPS_ID_DEFAULT,
|
"SPS and PPS ID number",
|
||||||
G_PARAM_READWRITE));
|
0, 31, ARG_SPS_ID_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_TRELLIS,
|
g_object_class_install_property (gobject_class, ARG_TRELLIS,
|
||||||
g_param_spec_boolean ("trellis", "Trellis quantization",
|
g_param_spec_boolean ("trellis", "Trellis quantization",
|
||||||
"Enable trellis searched quantization", ARG_TRELLIS_DEFAULT,
|
"Enable trellis searched quantization", ARG_TRELLIS_DEFAULT,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_KEYINT_MAX,
|
g_object_class_install_property (gobject_class, ARG_KEYINT_MAX,
|
||||||
g_param_spec_uint ("key_int_max", "Key-frame maximal interval",
|
g_param_spec_uint ("key_int_max", "Key-frame maximal interval",
|
||||||
"Maximal distance between two key-frames (0 for automatic)", 0,
|
"Maximal distance between two key-frames (0 for automatic)",
|
||||||
G_MAXINT, ARG_KEYINT_MAX_DEFAULT, G_PARAM_READWRITE));
|
0, G_MAXINT, ARG_KEYINT_MAX_DEFAULT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (gobject_class, ARG_CABAC,
|
g_object_class_install_property (gobject_class, ARG_CABAC,
|
||||||
g_param_spec_boolean ("cabac", "Use CABAC",
|
g_param_spec_boolean ("cabac", "Use CABAC",
|
||||||
"Enable CABAC entropy coding", ARG_CABAC_DEFAULT, G_PARAM_READWRITE));
|
"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));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -303,7 +395,8 @@ gst_x264_enc_init (GstX264Enc * encoder, GstX264EncClass * klass)
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
encoder->threads = ARG_THREADS_DEFAULT;
|
encoder->threads = ARG_THREADS_DEFAULT;
|
||||||
encoder->pass = ARG_PASS_DEFAULT;
|
encoder->pass = ARG_PASS_NEW_DEFAULT;
|
||||||
|
encoder->quantizer = ARG_QUANTIZER_DEFAULT;
|
||||||
encoder->stats_file = g_strdup (ARG_STATS_FILE_DEFAULT);
|
encoder->stats_file = g_strdup (ARG_STATS_FILE_DEFAULT);
|
||||||
encoder->byte_stream = ARG_BYTE_STREAM_DEFAULT;
|
encoder->byte_stream = ARG_BYTE_STREAM_DEFAULT;
|
||||||
encoder->bitrate = ARG_BITRATE_DEFAULT;
|
encoder->bitrate = ARG_BITRATE_DEFAULT;
|
||||||
|
@ -314,12 +407,20 @@ gst_x264_enc_init (GstX264Enc * encoder, GstX264EncClass * klass)
|
||||||
encoder->dct8x8 = ARG_DCT8x8_DEFAULT;
|
encoder->dct8x8 = ARG_DCT8x8_DEFAULT;
|
||||||
encoder->ref = ARG_REF_DEFAULT;
|
encoder->ref = ARG_REF_DEFAULT;
|
||||||
encoder->bframes = ARG_BFRAMES_DEFAULT;
|
encoder->bframes = ARG_BFRAMES_DEFAULT;
|
||||||
|
encoder->b_adapt = ARG_B_ADAPT_DEFAULT;
|
||||||
encoder->b_pyramid = ARG_B_PYRAMID_DEFAULT;
|
encoder->b_pyramid = ARG_B_PYRAMID_DEFAULT;
|
||||||
encoder->weightb = ARG_WEIGHTB_DEFAULT;
|
encoder->weightb = ARG_WEIGHTB_DEFAULT;
|
||||||
encoder->sps_id = ARG_SPS_ID_DEFAULT;
|
encoder->sps_id = ARG_SPS_ID_DEFAULT;
|
||||||
encoder->trellis = ARG_TRELLIS_DEFAULT;
|
encoder->trellis = ARG_TRELLIS_DEFAULT;
|
||||||
encoder->keyint_max = ARG_KEYINT_MAX_DEFAULT;
|
encoder->keyint_max = ARG_KEYINT_MAX_DEFAULT;
|
||||||
encoder->cabac = ARG_CABAC_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;
|
||||||
|
|
||||||
/* resources */
|
/* resources */
|
||||||
encoder->delay = g_queue_new ();
|
encoder->delay = g_queue_new ();
|
||||||
|
@ -372,9 +473,13 @@ gst_x264_enc_finalize (GObject * object)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_x264_enc_init_encoder (GstX264Enc * encoder)
|
gst_x264_enc_init_encoder (GstX264Enc * encoder)
|
||||||
{
|
{
|
||||||
|
guint pass = 0;
|
||||||
|
|
||||||
/* make sure that the encoder is closed */
|
/* make sure that the encoder is closed */
|
||||||
gst_x264_enc_close_encoder (encoder);
|
gst_x264_enc_close_encoder (encoder);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (encoder);
|
||||||
|
|
||||||
/* set up encoder parameters */
|
/* set up encoder parameters */
|
||||||
encoder->x264param.i_threads = encoder->threads;
|
encoder->x264param.i_threads = encoder->threads;
|
||||||
encoder->x264param.i_fps_num = encoder->fps_num;
|
encoder->x264param.i_fps_num = encoder->fps_num;
|
||||||
|
@ -405,30 +510,51 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder)
|
||||||
encoder->x264param.vui.i_vidformat = 5; /* unspecified */
|
encoder->x264param.vui.i_vidformat = 5; /* unspecified */
|
||||||
encoder->x264param.analyse.i_trellis = encoder->trellis ? 1 : 0;
|
encoder->x264param.analyse.i_trellis = encoder->trellis ? 1 : 0;
|
||||||
encoder->x264param.analyse.b_psnr = 0;
|
encoder->x264param.analyse.b_psnr = 0;
|
||||||
/*encoder->x264param.analyse.b_ssim = 0; */
|
|
||||||
encoder->x264param.analyse.i_me_method = encoder->me;
|
encoder->x264param.analyse.i_me_method = encoder->me;
|
||||||
encoder->x264param.analyse.i_subpel_refine = encoder->subme;
|
encoder->x264param.analyse.i_subpel_refine = encoder->subme;
|
||||||
encoder->x264param.analyse.inter = encoder->analyse;
|
encoder->x264param.analyse.inter = encoder->analyse;
|
||||||
encoder->x264param.analyse.b_transform_8x8 = encoder->dct8x8;
|
encoder->x264param.analyse.b_transform_8x8 = encoder->dct8x8;
|
||||||
encoder->x264param.analyse.b_weighted_bipred = encoder->weightb;
|
encoder->x264param.analyse.b_weighted_bipred = encoder->weightb;
|
||||||
/*encoder->x264param.analyse.i_noise_reduction = 600; */
|
encoder->x264param.analyse.i_noise_reduction = encoder->noise_reduction;
|
||||||
encoder->x264param.i_frame_reference = encoder->ref;
|
encoder->x264param.i_frame_reference = encoder->ref;
|
||||||
encoder->x264param.i_bframe = encoder->bframes;
|
encoder->x264param.i_bframe = encoder->bframes;
|
||||||
encoder->x264param.b_bframe_pyramid = encoder->b_pyramid;
|
encoder->x264param.b_bframe_pyramid = encoder->b_pyramid;
|
||||||
encoder->x264param.b_bframe_adaptive = 0;
|
encoder->x264param.b_bframe_adaptive = encoder->b_adapt;
|
||||||
|
encoder->x264param.b_interlaced = encoder->interlaced;
|
||||||
encoder->x264param.b_deblocking_filter = 1;
|
encoder->x264param.b_deblocking_filter = 1;
|
||||||
encoder->x264param.i_deblocking_filter_alphac0 = 0;
|
encoder->x264param.i_deblocking_filter_alphac0 = 0;
|
||||||
encoder->x264param.i_deblocking_filter_beta = 0;
|
encoder->x264param.i_deblocking_filter_beta = 0;
|
||||||
#ifdef X264_RC_ABR
|
encoder->x264param.rc.f_ip_factor = encoder->ip_factor;
|
||||||
|
encoder->x264param.rc.f_pb_factor = encoder->pb_factor;
|
||||||
|
|
||||||
|
switch (encoder->pass) {
|
||||||
|
case GST_X264_ENC_PASS_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:
|
||||||
|
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:
|
||||||
encoder->x264param.rc.i_rc_method = X264_RC_ABR;
|
encoder->x264param.rc.i_rc_method = X264_RC_ABR;
|
||||||
#endif
|
|
||||||
encoder->x264param.rc.i_bitrate = encoder->bitrate;
|
encoder->x264param.rc.i_bitrate = encoder->bitrate;
|
||||||
encoder->x264param.rc.i_vbv_max_bitrate = encoder->bitrate;
|
encoder->x264param.rc.i_vbv_max_bitrate = encoder->bitrate;
|
||||||
encoder->x264param.rc.i_vbv_buffer_size
|
encoder->x264param.rc.i_vbv_buffer_size
|
||||||
= encoder->x264param.rc.i_vbv_max_bitrate
|
= encoder->x264param.rc.i_vbv_max_bitrate
|
||||||
* encoder->vbv_buf_capacity / 1000;
|
* 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;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (encoder->pass) {
|
switch (pass) {
|
||||||
case 0:
|
case 0:
|
||||||
encoder->x264param.rc.b_stat_read = 0;
|
encoder->x264param.rc.b_stat_read = 0;
|
||||||
encoder->x264param.rc.b_stat_write = 0;
|
encoder->x264param.rc.b_stat_write = 0;
|
||||||
|
@ -445,6 +571,7 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder)
|
||||||
encoder->x264param.rc.b_stat_read = 0;
|
encoder->x264param.rc.b_stat_read = 0;
|
||||||
encoder->x264param.rc.b_stat_write = 1;
|
encoder->x264param.rc.b_stat_write = 1;
|
||||||
break;
|
break;
|
||||||
|
/* FIXME 0.11: settings for these passes must be swapped; 2: ro, 3: r/w */
|
||||||
case 2:
|
case 2:
|
||||||
encoder->x264param.rc.b_stat_read = 1;
|
encoder->x264param.rc.b_stat_read = 1;
|
||||||
encoder->x264param.rc.b_stat_write = 1;
|
encoder->x264param.rc.b_stat_write = 1;
|
||||||
|
@ -457,6 +584,8 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder)
|
||||||
encoder->x264param.rc.psz_stat_in = encoder->stats_file;
|
encoder->x264param.rc.psz_stat_in = encoder->stats_file;
|
||||||
encoder->x264param.rc.psz_stat_out = encoder->stats_file;
|
encoder->x264param.rc.psz_stat_out = encoder->stats_file;
|
||||||
|
|
||||||
|
GST_OBJECT_UNLOCK (encoder);
|
||||||
|
|
||||||
encoder->x264enc = x264_encoder_open (&encoder->x264param);
|
encoder->x264enc = x264_encoder_open (&encoder->x264param);
|
||||||
if (!encoder->x264enc) {
|
if (!encoder->x264enc) {
|
||||||
GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
|
GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
|
||||||
|
@ -883,16 +1012,36 @@ gst_x264_enc_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstX264Enc *encoder;
|
GstX264Enc *encoder;
|
||||||
|
GstState state;
|
||||||
|
|
||||||
encoder = GST_X264_ENC (object);
|
encoder = GST_X264_ENC (object);
|
||||||
|
|
||||||
/* FIXME: should probably do locking or check state */
|
GST_OBJECT_LOCK (encoder);
|
||||||
|
/* state at least matters for sps, bytestream, pass,
|
||||||
|
* and so by extension ... */
|
||||||
|
state = GST_STATE (encoder);
|
||||||
|
if (state != GST_STATE_READY && state != GST_STATE_NULL)
|
||||||
|
goto wrong_state;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_THREADS:
|
case ARG_THREADS:
|
||||||
encoder->threads = g_value_get_uint (value);
|
encoder->threads = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
case ARG_PASS:
|
case ARG_PASS:
|
||||||
encoder->pass = g_value_get_uint (value);
|
{
|
||||||
|
guint pass = g_value_get_uint (value);
|
||||||
|
|
||||||
|
if (pass)
|
||||||
|
encoder->pass = GST_X264_ENC_PASS_PASS1 + (pass - 1);
|
||||||
|
else
|
||||||
|
encoder->pass = GST_X264_ENC_PASS_CBR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ARG_PASS_NEW:
|
||||||
|
encoder->pass = g_value_get_enum (value);
|
||||||
|
break;
|
||||||
|
case ARG_QUANTIZER:
|
||||||
|
encoder->quantizer = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
case ARG_STATS_FILE:
|
case ARG_STATS_FILE:
|
||||||
if (encoder->stats_file)
|
if (encoder->stats_file)
|
||||||
|
@ -926,6 +1075,9 @@ gst_x264_enc_set_property (GObject * object, guint prop_id,
|
||||||
case ARG_BFRAMES:
|
case ARG_BFRAMES:
|
||||||
encoder->bframes = g_value_get_uint (value);
|
encoder->bframes = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
|
case ARG_B_ADAPT:
|
||||||
|
encoder->b_adapt = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
case ARG_B_PYRAMID:
|
case ARG_B_PYRAMID:
|
||||||
encoder->b_pyramid = g_value_get_boolean (value);
|
encoder->b_pyramid = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
@ -944,10 +1096,40 @@ gst_x264_enc_set_property (GObject * object, guint prop_id,
|
||||||
case ARG_CABAC:
|
case ARG_CABAC:
|
||||||
encoder->cabac = g_value_get_boolean (value);
|
encoder->cabac = g_value_get_boolean (value);
|
||||||
break;
|
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);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
GST_OBJECT_UNLOCK (encoder);
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* ERROR */
|
||||||
|
wrong_state:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (encoder, "setting property in wrong state");
|
||||||
|
GST_OBJECT_UNLOCK (encoder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -958,13 +1140,22 @@ gst_x264_enc_get_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
encoder = GST_X264_ENC (object);
|
encoder = GST_X264_ENC (object);
|
||||||
|
|
||||||
/* FIXME: should probably do locking or check state */
|
GST_OBJECT_LOCK (encoder);
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_THREADS:
|
case ARG_THREADS:
|
||||||
g_value_set_uint (value, encoder->threads);
|
g_value_set_uint (value, encoder->threads);
|
||||||
break;
|
break;
|
||||||
case ARG_PASS:
|
case ARG_PASS:
|
||||||
g_value_set_uint (value, encoder->pass);
|
if (encoder->pass < GST_X264_ENC_PASS_PASS1)
|
||||||
|
g_value_set_uint (value, 0);
|
||||||
|
else
|
||||||
|
g_value_set_uint (value, encoder->pass - GST_X264_ENC_PASS_PASS1 + 1);
|
||||||
|
break;
|
||||||
|
case ARG_PASS_NEW:
|
||||||
|
g_value_set_enum (value, encoder->pass);
|
||||||
|
break;
|
||||||
|
case ARG_QUANTIZER:
|
||||||
|
g_value_set_uint (value, encoder->quantizer);
|
||||||
break;
|
break;
|
||||||
case ARG_STATS_FILE:
|
case ARG_STATS_FILE:
|
||||||
g_value_set_string (value, encoder->stats_file);
|
g_value_set_string (value, encoder->stats_file);
|
||||||
|
@ -996,6 +1187,9 @@ gst_x264_enc_get_property (GObject * object, guint prop_id,
|
||||||
case ARG_BFRAMES:
|
case ARG_BFRAMES:
|
||||||
g_value_set_uint (value, encoder->bframes);
|
g_value_set_uint (value, encoder->bframes);
|
||||||
break;
|
break;
|
||||||
|
case ARG_B_ADAPT:
|
||||||
|
g_value_set_boolean (value, encoder->b_adapt);
|
||||||
|
break;
|
||||||
case ARG_B_PYRAMID:
|
case ARG_B_PYRAMID:
|
||||||
g_value_set_boolean (value, encoder->b_pyramid);
|
g_value_set_boolean (value, encoder->b_pyramid);
|
||||||
break;
|
break;
|
||||||
|
@ -1011,13 +1205,35 @@ gst_x264_enc_get_property (GObject * object, guint prop_id,
|
||||||
case ARG_KEYINT_MAX:
|
case ARG_KEYINT_MAX:
|
||||||
g_value_set_uint (value, encoder->keyint_max);
|
g_value_set_uint (value, encoder->keyint_max);
|
||||||
break;
|
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);
|
||||||
|
break;
|
||||||
case ARG_CABAC:
|
case ARG_CABAC:
|
||||||
g_value_set_boolean (value, encoder->cabac);
|
g_value_set_boolean (value, encoder->cabac);
|
||||||
break;
|
break;
|
||||||
|
case ARG_IP_FACTOR:
|
||||||
|
g_value_set_float (value, encoder->ip_factor);
|
||||||
|
break;
|
||||||
|
case ARG_PB_FACTOR:
|
||||||
|
g_value_set_float (value, encoder->pb_factor);
|
||||||
|
break;
|
||||||
|
case ARG_NR:
|
||||||
|
g_value_set_uint (value, encoder->noise_reduction);
|
||||||
|
break;
|
||||||
|
case ARG_INTERLACED:
|
||||||
|
g_value_set_boolean (value, encoder->interlaced);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
GST_OBJECT_UNLOCK (encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -55,7 +55,8 @@ struct _GstX264Enc
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
guint threads;
|
guint threads;
|
||||||
guint pass;
|
gint pass;
|
||||||
|
guint quantizer;
|
||||||
gchar *stats_file;
|
gchar *stats_file;
|
||||||
gboolean byte_stream;
|
gboolean byte_stream;
|
||||||
guint bitrate;
|
guint bitrate;
|
||||||
|
@ -65,6 +66,7 @@ struct _GstX264Enc
|
||||||
gboolean dct8x8;
|
gboolean dct8x8;
|
||||||
guint ref;
|
guint ref;
|
||||||
guint bframes;
|
guint bframes;
|
||||||
|
gboolean b_adapt;
|
||||||
gboolean b_pyramid;
|
gboolean b_pyramid;
|
||||||
gboolean weightb;
|
gboolean weightb;
|
||||||
guint sps_id;
|
guint sps_id;
|
||||||
|
@ -72,6 +74,13 @@ struct _GstX264Enc
|
||||||
guint vbv_buf_capacity;
|
guint vbv_buf_capacity;
|
||||||
guint keyint_max;
|
guint keyint_max;
|
||||||
gboolean cabac;
|
gboolean cabac;
|
||||||
|
gfloat ip_factor;
|
||||||
|
gfloat pb_factor;
|
||||||
|
guint qp_min;
|
||||||
|
guint qp_max;
|
||||||
|
guint qp_step;
|
||||||
|
guint noise_reduction;
|
||||||
|
gboolean interlaced;
|
||||||
|
|
||||||
/* input description */
|
/* input description */
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
|
|
Loading…
Reference in a new issue