]> granicus.if.org Git - handbrake/commitdiff
encx265: set level
authorJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 10 Jun 2019 15:43:45 +0000 (08:43 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Thu, 11 Jul 2019 20:22:57 +0000 (13:22 -0700)
It seems the encoder level has been supported in x265 since May 2014,
just a few months after initial support for x265 was added to
HandBrake :\

libhb/encx265.c
libhb/work.c

index 30bde6565d8f6ac23f4c85c4f0e614a2ad8feb7d..6e196eafd4116564f23706f7ced42233ede20311 100644 (file)
@@ -81,6 +81,29 @@ static int param_parse(hb_work_private_t *pv, x265_param *param,
     return ret;
 }
 
+int apply_h265_level(hb_work_private_t *pv,  x265_param *param,
+                     const char *h265_level)
+{
+    if (h265_level == NULL ||
+        !strcasecmp(h265_level, hb_h265_level_names[0]))
+    {
+        return 0;
+    }
+    // Verify that level is valid
+    int i;
+    for (i = 1; hb_h265_level_values[i]; i++)
+    {
+        if (!strcmp(hb_h265_level_names[i], h265_level))
+        {
+            return param_parse(pv, param, "level-idc", h265_level);
+        }
+    }
+
+    // error (invalid or unsupported level), abort
+    hb_error("apply_h265_level: invalid level %s", h265_level);
+    return X265_PARAM_BAD_VALUE;
+}
+
 /***********************************************************************
  * hb_work_encx265_init
  ***********************************************************************
@@ -273,6 +296,10 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
     {
         goto fail;
     }
+    if (apply_h265_level(pv, param, job->encoder_level) < 0)
+    {
+        goto fail;
+    }
 
     /* we should now know whether B-frames are enabled */
     job->areBframes = (param->bframes > 0) + (param->bframes   > 0 &&
index acd2750538416133b882786bd00dc7f15e82014c..3565290dc7c0bc18c20fa7cad59dce544b100784 100644 (file)
@@ -546,6 +546,9 @@ void hb_display_job_info(hb_job_t *job)
             {
                 case HB_VCODEC_X264_8BIT:
                 case HB_VCODEC_X264_10BIT:
+                case HB_VCODEC_X265_8BIT:
+                case HB_VCODEC_X265_10BIT:
+                case HB_VCODEC_X265_12BIT:
                 case HB_VCODEC_QSV_H264:
                 case HB_VCODEC_QSV_H265:
                 case HB_VCODEC_QSV_H265_10BIT: