<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 9, 2021 at 12:35 PM Dakshinya T R S <<a href="mailto:dakshinya@multicorewareinc.com">dakshinya@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">From bf71142a6b22d33b2b2b8ebc8d80a019dbdf0a1d Mon Sep 17 00:00:00 2001<br>From: Dakshinya T R S <<a href="mailto:dakshinya@multicorewareinc.com" target="_blank">dakshinya@multicorewareinc.com</a>><br>Date: Wed, 7 Apr 2021 23:32:15 -0700<br>Subject: [PATCH] Fix VMAF exceptions<br><br>---<br> source/encoder/api.cpp | 38 ++++++++++++++++++++++++++++++---<br> source/encoder/frameencoder.cpp | 1 +<br> source/x265.h | 10 +++++----<br> 3 files changed, 42 insertions(+), 7 deletions(-)<br><br>diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp<br>index a986355e0..9374bbc38 100644<br>--- a/source/encoder/api.cpp<br>+++ b/source/encoder/api.cpp<br>@@ -1903,22 +1903,34 @@ double x265_calculate_vmafscore(x265_param *param, x265_vmaf_data *data)<br> data->width = param->sourceWidth;<br> data->height = param->sourceHeight;<br> data->internalBitDepth = param->internalBitDepth;<br>+ data->format = (char *)malloc(11 * sizeof(char));<br> [AM] Repeated malloc shall be avoided if the format is captured in encoder handle or in m_cliopt.vmafData after input file info parsing.<br> if (param->internalCsp == X265_CSP_I420)<br> {<br> if ((param->sourceWidth * param->sourceHeight) % 2 != 0)<br> x265_log(NULL, X265_LOG_ERROR, "Invalid file size\n");<br> data->offset = param->sourceWidth * param->sourceHeight / 2;<br>+ memcpy(data->format, "yuv420p", 7);<br> }<br> else if (param->internalCsp == X265_CSP_I422)<br>+ {<br> data->offset = param->sourceWidth * param->sourceHeight;<br>+ memcpy(data->format, "yuv422p", 7);<br>+ }<br> else if (param->internalCsp == X265_CSP_I444)<br>+ {<br> data->offset = param->sourceWidth * param->sourceHeight * 2;<br>+ memcpy(data->format, "yuv444p", 7);<br>+ }<br> else<br> x265_log(NULL, X265_LOG_ERROR, "Invalid format\n");<br>+ if (param->internalBitDepth == 10)<br>+ strcat(data->format, "10le");<br>+ else if (param->internalBitDepth == 12)<br>+ strcat(data->format, "12le");<br> <br>- compute_vmaf(&score, vcd->format, data->width, data->height, read_frame, data, vcd->model_path, vcd->log_path, vcd->log_fmt, vcd->disable_clip, vcd->disable_avx, vcd->enable_transform, vcd->phone_model, vcd->psnr, vcd->ssim, vcd->ms_ssim, vcd->pool, vcd->thread, vcd->subsample, vcd->enable_conf_interval);<br>-<br>+ compute_vmaf(&score, data->format, data->width, data->height, read_frame, data, vcd->model_path, vcd->log_path, vcd->log_fmt, vcd->disable_clip, vcd->disable_avx, vcd->enable_transform, vcd->phone_model, vcd->psnr, vcd->ssim, vcd->ms_ssim, vcd->pool, vcd->thread, vcd->subsample, vcd->enable_conf_interval);<br>+ free(data->format);<br> return score;<br> }<br> <br>@@ -2019,8 +2031,28 @@ double x265_calculate_vmaf_framelevelscore(x265_vmaf_framedata *vmafframedata)<br> read_frame = read_frame_8bit;<br> else<br> read_frame = read_frame_10bit;<br>- compute_vmaf(&score, vcd->format, vmafframedata->width, vmafframedata->height, read_frame, vmafframedata, vcd->model_path, vcd->log_path, vcd->log_fmt, vcd->disable_clip, vcd->disable_avx, vcd->enable_transform, vcd->phone_model, vcd->psnr, vcd->ssim, vcd->ms_ssim, vcd->pool, vcd->thread, vcd->subsample, vcd->enable_conf_interval);<br>+ vmafframedata->format = (char *)malloc(11 * sizeof(char));<br> <br>+ if (vmafframedata->internalCsp == X265_CSP_I420)<br>+ {<br>+ memcpy(vmafframedata->format, "yuv420p", 7);<br>+ }<br>+ else if (vmafframedata->internalCsp == X265_CSP_I422)<br>+ {<br>+ memcpy(vmafframedata->format, "yuv422p", 7);<br>+ }<br>+ else if (vmafframedata->internalCsp == X265_CSP_I444)<br>+ {<br>+ memcpy(vmafframedata->format, "yuv444p", 7);<br>+ }<br>+ else<br>+ x265_log(NULL, X265_LOG_ERROR, "Invalid format\n");<br>+ if (vmafframedata->internalBitDepth == 10)<br>+ strcat(vmafframedata->format, "10le");<br>+ else if (vmafframedata->internalBitDepth == 12)<br>+ strcat(vmafframedata->format, "12le");<br></div></blockquote><div>
[AM] Same comment as above.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">+ compute_vmaf(&score, vmafframedata->format, vmafframedata->width, vmafframedata->height, read_frame, vmafframedata, vcd->model_path, vcd->log_path, vcd->log_fmt, vcd->disable_clip, vcd->disable_avx, vcd->enable_transform, vcd->phone_model, vcd->psnr, vcd->ssim, vcd->ms_ssim, vcd->pool, vcd->thread, vcd->subsample, vcd->enable_conf_interval);<br>+ free(vmafframedata->format);<br> return score;<br> }<br> #endif<br>diff --git a/source/encoder/frameencoder.cpp b/source/encoder/frameencoder.cpp<br>index 2086a15a5..05c1d93a5 100644<br>--- a/source/encoder/frameencoder.cpp<br>+++ b/source/encoder/frameencoder.cpp<br>@@ -2143,6 +2143,7 @@ void FrameEncoder::vmafFrameLevelScore()<br> vmafframedata->internalBitDepth = m_param->internalBitDepth;<br> vmafframedata->reference_frame = fenc;<br> vmafframedata->distorted_frame = recon;<br>+ vmafframedata->internalCsp = m_param->internalCsp;<br> <br> fenc->m_vmafScore = x265_calculate_vmaf_framelevelscore(vmafframedata);<br> <br>diff --git a/source/x265.h b/source/x265.h<br>index f44040ba7..0e572e468 100644<br>--- a/source/x265.h<br>+++ b/source/x265.h<br>@@ -709,6 +709,7 @@ typedef struct x265_vmaf_data<br> int internalBitDepth;<br> FILE *reference_file; /* FILE pointer for input file */<br> FILE *distorted_file; /* FILE pointer for recon file generated*/<br>+ char *format;<br> }x265_vmaf_data;<br> [AM] Update X265_BUILD.<br> /* data to calculate frame level VMAF score */<br>@@ -716,16 +717,17 @@ typedef struct x265_vmaf_framedata<br> {<br> int width;<br> int height;<br>- int frame_set; <br>- int internalBitDepth; <br>+ int frame_set;<br>+ int internalBitDepth;<br> void *reference_frame; /* points to fenc of particular frame */<br> void *distorted_frame; /* points to recon of particular frame */<br>+ char *format;<br>+ int internalCsp;<br> }x265_vmaf_framedata;<br> <br> /* common data needed to calculate both frame level and video level VMAF scores */<br> typedef struct x265_vmaf_commondata<br> {<br>- char *format;<br> char *model_path;<br> char *log_path;<br> char *log_fmt;<br>@@ -742,7 +744,7 @@ typedef struct x265_vmaf_commondata<br> int enable_conf_interval;<br> }x265_vmaf_commondata;<br> <br>-static const x265_vmaf_commondata vcd[] = { { NULL, (char *)"/usr/local/share/model/vmaf_v0.6.1.pkl", NULL, NULL, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 1, 0 } };<br>+static const x265_vmaf_commondata vcd[] = { { (char *)"/usr/local/share/model/vmaf_v0.6.1.json", NULL, NULL, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 1, 0 } };<br> <br> /* x265 input parameters<br></div></blockquote><div>[AM] Please mention the VMAF version with the integration works fine in VMAF documentation.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> *<br>-- <br>2.17.1<br><br><div><br></div><div>Thanks & Regards,</div><div>Dakshinya T R S,</div><div>Intern at Multicoreware,</div><div>Bannari Amman Institute of Technology,</div><div>Sathyamangalam.</div><div>______________________________________</div><div><br></div><div><span style="color:rgb(136,136,136)">x265-devel mailing list</span><br></div><div><a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br style="color:rgb(136,136,136)"><a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br></div></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="georgia, serif">Regards,</font><div><b><font face="georgia, serif">Aruna Matheswaran,</font></b></div><div><font face="georgia, serif">Video Codec Engineer,</font></div><div><font face="georgia, serif">Media & AI analytics BU,</font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" width="96" height="36" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div></div></div></div></div></div></div></div></div></div>