From ac6b656ed31129b6810b9fbd757f6f6238902c31 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Wed, 21 Jul 2010 16:32:11 +0200 Subject: [PATCH] x264enc: Update available me types Use the x264_motion_est_names[] array to populate the enum of ME types. This is now self-maintaining. --- ext/x264/gstx264enc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c index 4174a66..5a09f32 100644 --- a/ext/x264/gstx264enc.c +++ b/ext/x264/gstx264enc.c @@ -204,17 +204,26 @@ static GType gst_x264_enc_me_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 GEnumValue *me_types; + int n, i; + + if (me_type != 0) + return me_type; + + n = 0; + while (x264_motion_est_names[n] != NULL) + n++; + + me_types = g_new0 (GEnumValue, n + 1); - if (!me_type) { - me_type = g_enum_register_static ("GstX264EncMe", me_types); + for (i = 0; i < n; i++) { + me_types[i].value = i; + me_types[i].value_name = x264_motion_est_names[i]; + me_types[i].value_nick = x264_motion_est_names[i]; } + + me_type = g_enum_register_static ("GstX264EncMe", me_types); + return me_type; } -- 2.7.4