]> granicus.if.org Git - handbrake/commitdiff
New getters for video presets, tunes, profiles and levels.
authorRodeo <tdskywalker@gmail.com>
Fri, 8 Nov 2013 15:45:03 +0000 (15:45 +0000)
committerRodeo <tdskywalker@gmail.com>
Fri, 8 Nov 2013 15:45:03 +0000 (15:45 +0000)
x264 is no longer the only encoder with a built-in preset system; QSV has its own presets, and supports setting the H.264 profile and level, too.

Old getters still in place for compatibility with the old API..

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5883 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.c
libhb/common.h
libhb/qsv_common.c
libhb/qsv_common.h
test/test.c

index 9df282cbc9dfd7bae2b09e90bd3d34be1bb7dfaf..1b996e04aaf4930afa539a529de31072d8c01a00 100644 (file)
 #include <sys/time.h>
 
 #include "hb.h"
+#include "x264.h"
 #include "lang.h"
 #include "common.h"
+#include "h264_common.h"
 #ifdef USE_QSV
 #include "qsv_common.h"
 #endif
@@ -1142,6 +1144,61 @@ const char* hb_video_quality_get_name(uint32_t codec)
     }
 }
 
+const char* const* hb_video_encoder_get_presets(int encoder)
+{
+    switch (encoder)
+    {
+        case HB_VCODEC_X264:
+            return x264_preset_names;
+
+#ifdef USE_QSV
+        case HB_VCODEC_QSV_H264:
+            return hb_qsv_preset_get_names();
+#endif
+
+        default:
+            return NULL;
+    }
+}
+
+const char* const* hb_video_encoder_get_tunes(int encoder)
+{
+    switch (encoder)
+    {
+        case HB_VCODEC_X264:
+            return x264_tune_names;
+
+        default:
+            return NULL;
+    }
+}
+
+const char* const* hb_video_encoder_get_profiles(int encoder)
+{
+    switch (encoder)
+    {
+        case HB_VCODEC_X264:
+        case HB_VCODEC_QSV_H264:
+            return hb_h264_profile_names;
+
+        default:
+            return NULL;
+    }
+}
+
+const char* const* hb_video_encoder_get_levels(int encoder)
+{
+    switch (encoder)
+    {
+        case HB_VCODEC_X264:
+        case HB_VCODEC_QSV_H264:
+            return hb_h264_level_names;
+
+        default:
+            return NULL;
+    }
+}
+
 // Get limits and hints for the UIs.
 //
 // granularity sets the minimum step increments that should be used
index eed194cd7ed538f697421f7cb678595f0eadbe89..6a657465c4d4365fb8d740f406ef09a63c719a38 100644 (file)
@@ -292,6 +292,11 @@ const hb_rate_t* hb_audio_bitrate_get_next(const hb_rate_t *last);
 void        hb_video_quality_get_limits(uint32_t codec, float *low, float *high, float *granularity, int *direction);
 const char* hb_video_quality_get_name(uint32_t codec);
 
+const char* const* hb_video_encoder_get_presets (int encoder);
+const char* const* hb_video_encoder_get_tunes   (int encoder);
+const char* const* hb_video_encoder_get_profiles(int encoder);
+const char* const* hb_video_encoder_get_levels  (int encoder);
+
 void  hb_audio_quality_get_limits(uint32_t codec, float *low, float *high, float *granularity, int *direction);
 float hb_audio_quality_get_best(uint32_t codec, float quality);
 float hb_audio_quality_get_default(uint32_t codec);
@@ -1242,6 +1247,8 @@ char * hb_x264_param_unparse(const char *x264_preset,  const char *x264_tune,
                              const char *x264_encopts, const char *h264_profile,
                              const char *h264_level, int width, int height);
 
+#define HB_API_OLD_PRESET_GETTERS
+#ifdef  HB_API_OLD_PRESET_GETTERS
 // x264 preset/tune, qsv preset & h264 profile/level helpers
 const char * const * hb_x264_presets();
 const char * const * hb_x264_tunes();
@@ -1250,6 +1257,7 @@ const char * const * hb_qsv_presets();
 #endif
 const char * const * hb_h264_profiles();
 const char * const * hb_h264_levels();
+#endif
 
 // x264 option name/synonym helper
 const char * hb_x264_encopt_name( const char * name );
index 542f03374877dbd6628d194a835f203bbc9130b0..44f11ffade2627fae9771690a8de53bbfc1172dc 100644 (file)
@@ -698,7 +698,7 @@ int hb_qsv_param_parse(hb_qsv_param_t *param,
     return error ? HB_QSV_PARAM_BAD_VALUE : HB_QSV_PARAM_OK;
 }
 
-const char* const* hb_qsv_presets()
+const char* const* hb_qsv_preset_get_names()
 {
     if (hb_get_cpu_platform() >= HB_CPU_PLATFORM_INTEL_HSW)
     {
@@ -710,6 +710,13 @@ const char* const* hb_qsv_presets()
     }
 }
 
+#ifdef HB_API_OLD_PRESET_GETTERS
+const char* const* hb_qsv_presets()
+{
+    return hb_qsv_preset_get_names();
+}
+#endif
+
 int hb_qsv_param_default_preset(hb_qsv_param_t *param,
                                 mfxVideoParam *videoParam, const char *preset)
 {
index 8b94fd0b4666e369518a1347956906e53e65c56b..31e1bb36b16f6fbb71c0771a0e335bd0e33acea8 100644 (file)
@@ -109,6 +109,7 @@ typedef struct
     mfxVideoParam *videoParam;
 } hb_qsv_param_t;
 
+const char* const* hb_qsv_preset_get_names();
 static const char* const hb_qsv_preset_names1[] = { "speed", "balanced",            NULL, };
 static const char* const hb_qsv_preset_names2[] = { "speed", "balanced", "quality", NULL, };
 
index 8265281728ada557e44c0dd77a5dcfad70401d62..1b1bb14ef6c0bbcadbd0a1026b07e65023e50b6c 100644 (file)
@@ -3143,7 +3143,7 @@ static void ShowHelp()
     fprintf( out,
     "        --x264-preset       When using x264, selects the x264 preset:\n"
     "          <string>          ");
-    x264_opts = hb_x264_presets();
+    x264_opts = hb_video_encoder_get_presets(HB_VCODEC_X264);
     tmp[0] = 0;
     len = 0;
     while( x264_opts && *x264_opts )
@@ -3164,7 +3164,7 @@ static void ShowHelp()
     fprintf( out,
     "        --x264-tune         When using x264, selects the x264 tuning:\n"
     "          <string>          ");
-    x264_opts = hb_x264_tunes();
+    x264_opts = hb_video_encoder_get_tunes(HB_VCODEC_X264);
     tmp[0] = 0;
     len = 0;
     while( x264_opts && *x264_opts )
@@ -3188,7 +3188,7 @@ if (hb_qsv_available())
     fprintf(out,
             "        --qsv-preset        When using QSV, selects the QSV preset:\n"
             "          <string>          ");
-    x264_opts = hb_qsv_presets();
+    x264_opts = hb_video_encoder_get_presets(HB_VCODEC_QSV_H264);
     tmp[0]    = 0;
     len       = 0;
     while (x264_opts != NULL && *x264_opts != NULL)
@@ -3232,7 +3232,7 @@ else
     "        --h264-profile      When using H.264, ensures compliance with the\n"
     "          <string>          specified H.264 profile:\n"
     "                            ");
-    x264_opts = hb_h264_profiles();
+    x264_opts = hb_video_encoder_get_profiles(HB_VCODEC_X264);
     tmp[0] = 0;
     len = 0;
     while( x264_opts && *x264_opts )
@@ -3254,7 +3254,7 @@ else
     "        --h264-level        When using H.264, ensures compliance with the\n"
     "          <string>          specified H.264 level:\n"
     "                            ");
-    x264_opts = hb_h264_levels();
+    x264_opts = hb_video_encoder_get_levels(HB_VCODEC_X264);
     tmp[0] = 0;
     len = 0;
     while( x264_opts && *x264_opts )