]> granicus.if.org Git - handbrake/commitdiff
Fix previous commit again. This is not my day.
authorRodeo <tdskywalker@gmail.com>
Sun, 6 Apr 2014 17:10:57 +0000 (17:10 +0000)
committerRodeo <tdskywalker@gmail.com>
Sun, 6 Apr 2014 17:10:57 +0000 (17:10 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6155 b64f7644-9d1e-0410-96f1-a4d463321fa5

contrib/x265/A01-x265-multiple-inclusion.patch [new file with mode: 0644]
contrib/x265/module.defs
libhb/encx265.c

diff --git a/contrib/x265/A01-x265-multiple-inclusion.patch b/contrib/x265/A01-x265-multiple-inclusion.patch
new file mode 100644 (file)
index 0000000..b88a7e0
--- /dev/null
@@ -0,0 +1,12 @@
+diff -r 527d03c56d68 source/x265.h
+--- a/source/x265.h    Tue Mar 04 03:13:00 2014 +0530
++++ b/source/x265.h    Fri Mar 14 16:08:12 2014 +0100
+@@ -240,7 +240,7 @@
+     int height[3];
+ } x265_cli_csp;
+-const x265_cli_csp x265_cli_csps[] =
++static const x265_cli_csp x265_cli_csps[] =
+ {
+     { 1, { 0, 0, 0 }, { 0, 0, 0 } }, /* i400 */
+     { 3, { 0, 1, 1 }, { 0, 1, 1 } }, /* i420 */
index 1606c962947953ca84e43d086efaf94c931782eb..e744549a87819d397eeb0e3d652213d368b00db1 100644 (file)
@@ -1,7 +1,7 @@
 $(eval $(call import.MODULE.defs,X265,x265,YASM))
 $(eval $(call import.CONTRIB.defs,X265))
 
-X265.FETCH.url = http://download.handbrake.fr/contrib/x265-6657-82bbd2bf3b49-0.9.tar.bz2
+X265.FETCH.url = http://download.handbrake.fr/contrib/x265-6356-527d03c56d68-0.8.tar.bz2
 
 X265.CONFIGURE.exe         = cmake
 X265.CONFIGURE.args.prefix = -DCMAKE_INSTALL_PREFIX="$(X265.CONFIGURE.prefix)"
index 37f4a2a4e380976e0613ac2bbfd64486094773ad..7ed2803715a527b541bfb874759a93a23457a91f 100644 (file)
@@ -76,7 +76,7 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
     pv->delayed_chapters  = hb_list_init();
     pv->job               = job;
     w->private_data       = pv;
-    int ret, vrate, vrate_base;
+    int i, vrate, vrate_base;
     x265_nal *nal;
     uint32_t nnal;
 
@@ -85,7 +85,9 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
     if (x265_param_default_preset(param,
                                   job->encoder_preset, job->encoder_tune) < 0)
     {
-        goto fail;
+        free(pv);
+        pv = NULL;
+        return 1;
     }
 
     /* If the PSNR or SSIM tunes are in use, enable the relevant metric */
@@ -121,56 +123,13 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
     param->keyframeMin = (int)((double)vrate / (double)vrate_base + 0.5);
     param->keyframeMax = param->keyframeMin * 10;
 
-    /*
-     * Video Signal Type (color description only).
-     *
-     * Use x265_param_parse (let x265 determine which bEnable
-     * flags, if any, should be set in the x264_param struct).
-     */
-    char colorprim[11], transfer[11], colormatrix[11];
-    switch (job->color_matrix_code)
-    {
-        case 1: // ITU BT.601 DVD or SD TV content (NTSC)
-            strcpy(colorprim,   "smpte170m");
-            strcpy(transfer,        "bt709");
-            strcpy(colormatrix, "smpte170m");
-            break;
-        case 2: // ITU BT.601 DVD or SD TV content (PAL)
-            strcpy(colorprim,     "bt470bg");
-            strcpy(transfer,        "bt709");
-            strcpy(colormatrix, "smpte170m");
-            break;
-        case 3: // ITU BT.709 HD content
-            strcpy(colorprim,   "bt709");
-            strcpy(transfer,    "bt709");
-            strcpy(colormatrix, "bt709");
-            break;
-        case 4: // custom
-            snprintf(colorprim,   sizeof(colorprim),   "%d", job->color_prim);
-            snprintf(transfer,    sizeof(transfer),    "%d", job->color_transfer);
-            snprintf(colormatrix, sizeof(colormatrix), "%d", job->color_matrix);
-            break;
-        default: // detected during scan
-            snprintf(colorprim,   sizeof(colorprim),   "%d", job->title->color_prim);
-            snprintf(transfer,    sizeof(transfer),    "%d", job->title->color_transfer);
-            snprintf(colormatrix, sizeof(colormatrix), "%d", job->title->color_matrix);
-            break;
-    }
-    if (x265_param_parse(param, "colorprim",   colorprim)   ||
-        x265_param_parse(param, "transfer",    transfer)    ||
-        x265_param_parse(param, "colormatrix", colormatrix))
-    {
-        hb_error("encx265: failed to set VUI color description");
-        goto fail;
-    }
-
     /* iterate through x265_opts and parse the options */
     hb_dict_entry_t *entry = NULL;
     hb_dict_t *x265_opts = hb_encopts_to_dict(job->encoder_options, job->vcodec);
     while ((entry = hb_dict_next(x265_opts, entry)) != NULL)
     {
         // here's where the strings are passed to libx265 for parsing
-        ret = x265_param_parse(param, entry->key, entry->value);
+        int ret = x265_param_parse(param, entry->key, entry->value);
         // let x265 sanity check the options for us
         switch (ret)
         {
@@ -187,37 +146,12 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
     }
     hb_dict_free(&x265_opts);
 
-    /*
-     * Reload colorimetry settings in case custom
-     * values were set in the encoder_options string.
-     */
-    job->color_matrix_code = 4;
-    job->color_prim        = param->vui.colorPrimaries;
-    job->color_transfer    = param->vui.transferCharacteristics;
-    job->color_matrix      = param->vui.matrixCoeffs;
-
     /*
      * Settings which can't be overriden in the encodeer_options string
      * (muxer-specific settings, resolution, ratecontrol, etc.).
      */
-    param->bRepeatHeaders = 0;
-    param->sourceWidth    = job->width;
-    param->sourceHeight   = job->height;
-    if (job->anamorphic.mode)
-    {
-        /*
-         * Let x265 determnine whether to use an aspect ratio
-         * index vs. the extended SAR index + SAR width/height.
-         */
-        char sar[22];
-        snprintf(sar, sizeof(sar), "%d:%d",
-                 job->anamorphic.par_width, job->anamorphic.par_height);
-        if (x265_param_parse(param, "sar", sar))
-        {
-            hb_error("encx265: failed to set SAR");
-            goto fail;
-        }
-    }
+    param->sourceWidth  = job->width;
+    param->sourceHeight = job->height;
 
     if (job->vquality > 0)
     {
@@ -248,7 +182,9 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
     /* Apply profile and level settings last. */
     if (x265_param_apply_profile(param, job->encoder_profile) < 0)
     {
-        goto fail;
+        free(pv);
+        pv = NULL;
+        return 1;
     }
 
     /* we should now know whether B-frames are enabled */
@@ -259,7 +195,17 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
     if (pv->x265 == NULL)
     {
         hb_error("encx265: x265_encoder_open failed.");
-        goto fail;
+        free(pv);
+        pv = NULL;
+        return 1;
+    }
+
+    if (x265_encoder_headers(pv->x265, &nal, &nnal) < 0)
+    {
+        hb_error("encx265: x265_encoder_headers failed.");
+        free(pv);
+        pv = NULL;
+        return 1;
     }
 
     /*
@@ -268,26 +214,24 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
      * Write the header as is, and let the muxer reformat
      * the extradata and output bitstream properly for us.
      */
-    ret = x265_encoder_headers(pv->x265, &nal, &nnal);
-    if (ret < 0)
-    {
-        hb_error("encx265: x265_encoder_headers failed (%d)", ret);
-        goto fail;
-    }
-    if (ret > sizeof(w->config->h265.headers))
+    w->config->h265.headers_length = 0;
+    for (i = 0; i < nnal; i++)
     {
-        hb_error("encx265: bitstream headers too large (%d)", ret);
-        goto fail;
+        if (w->config->h265.headers_length +
+            nal[i].sizeBytes > HB_CONFIG_MAX_SIZE)
+        {
+            hb_error("encx265: bitstream headers too large");
+            free(pv);
+            pv = NULL;
+            return 1;
+        }
+        memcpy(w->config->h265.headers +
+               w->config->h265.headers_length,
+               nal[i].payload, nal[i].sizeBytes);
+        w->config->h265.headers_length += nal[i].sizeBytes;
     }
-    memcpy(w->config->h265.headers, nal->payload, ret);
-    w->config->h265.headers_length = ret;
 
     return 0;
-
-fail:
-    w->private_data = NULL;
-    free(pv);
-    return 1;
 }
 
 void encx265Close(hb_work_object_t *w)