<div dir="ltr">From 2d2893653fef764f30c987f0b341bcaf6fd0d7a2 Mon Sep 17 00:00:00 2001<br>From: AnusuyaKumarasamy <<a href="mailto:anusuya.kumarasamy@multicorewareinc.com">anusuya.kumarasamy@multicorewareinc.com</a>><br>Date: Mon, 19 Aug 2024 14:42:27 +0530<br>Subject: [PATCH 2/7] Extend the multiview parsing support for y4m input<br><br>---<br> source/input/input.cpp |  2 +-<br> source/input/y4m.cpp   | 14 ++++++++------<br> source/input/y4m.h     |  2 +-<br> 3 files changed, 10 insertions(+), 8 deletions(-)<br><br>diff --git a/source/input/input.cpp b/source/input/input.cpp<br>index 43734c978..2f52718a8 100644<br>--- a/source/input/input.cpp<br>+++ b/source/input/input.cpp<br>@@ -32,7 +32,7 @@ InputFile* InputFile::open(InputFileInfo& info, bool bForceY4m, bool alpha, int<br>     const char * s = strrchr(info.filename, '.');<br> <br>     if (bForceY4m || (s && !strcmp(s, ".y4m")))<br>-        return new Y4MInput(info, alpha);<br>+        return new Y4MInput(info, alpha, format);<br>     else<br>         return new YUVInput(info, alpha, format);<br> }<br>diff --git a/source/input/y4m.cpp b/source/input/y4m.cpp<br>index 0fe0cc43e..186499bd1 100644<br>--- a/source/input/y4m.cpp<br>+++ b/source/input/y4m.cpp<br>@@ -40,7 +40,7 @@<br> using namespace X265_NS;<br> using namespace std;<br> static const char header[] = {'F','R','A','M','E'};<br>-Y4MInput::Y4MInput(InputFileInfo& info, bool alpha)<br>+Y4MInput::Y4MInput(InputFileInfo& info, bool alpha, int format)<br> {<br>     for (int i = 0; i < QUEUE_SIZE; i++)<br>         buf[i] = NULL;<br>@@ -69,11 +69,13 @@ Y4MInput::Y4MInput(InputFileInfo& info, bool alpha)<br>         ifs = x265_fopen(info.filename, "rb");<br>     if (ifs && !ferror(ifs) && parseHeader())<br>     {<br>+        if (format == 1) width /= 2;<br>+        if (format == 2) height /= 2;<br>         int pixelbytes = depth > 8 ? 2 : 1;<br>         for (int i = 0; i < x265_cli_csps[colorSpace].planes + alphaAvailable; i++)<br>         {<br>-            int stride = (width >> x265_cli_csps[colorSpace].width[i]) * pixelbytes;<br>-            framesize += (stride * (height >> x265_cli_csps[colorSpace].height[i]));<br>+            int stride = ((width * (format == 1 ? 2 : 1)) >> x265_cli_csps[colorSpace].width[i]) * pixelbytes;<br>+            framesize += (stride * ((height * (format == 2 ? 2 : 1)) >> x265_cli_csps[colorSpace].height[i]));<br>         }<br> <br>         threadActive = true;<br>@@ -391,12 +393,12 @@ bool Y4MInput::readPicture(x265_picture& pic)<br>         pic.height = height;<br>         pic.width = width;<br>         pic.colorSpace = colorSpace;<br>-        pic.stride[0] = width * pixelbytes;<br>+        pic.stride[0] = width * pixelbytes * (pic.format == 1 ? 2 : 1);<br>         pic.stride[1] = pic.stride[0] >> x265_cli_csps[colorSpace].width[1];<br>         pic.stride[2] = pic.stride[0] >> x265_cli_csps[colorSpace].width[2];<br>         pic.planes[0] = buf[read % QUEUE_SIZE];<br>-        pic.planes[1] = (char*)pic.planes[0] + pic.stride[0] * height;<br>-        pic.planes[2] = (char*)pic.planes[1] + pic.stride[1] * (height >> x265_cli_csps[colorSpace].height[1]);<br>+        pic.planes[1] = (char*)pic.planes[0] + pic.stride[0] * (height * (pic.format == 2 ? 2 : 1));<br>+        pic.planes[2] = (char*)pic.planes[1] + pic.stride[1] * ((height * (pic.format == 2 ? 2 : 1)) >> x265_cli_csps[colorSpace].height[1]);<br> #if ENABLE_ALPHA<br>         if (alphaAvailable)<br>         {<br>diff --git a/source/input/y4m.h b/source/input/y4m.h<br>index 37992bb66..16d2d0401 100644<br>--- a/source/input/y4m.h<br>+++ b/source/input/y4m.h<br>@@ -71,7 +71,7 @@ protected:<br> <br> public:<br> <br>-    Y4MInput(InputFileInfo& info, bool alpha);<br>+    Y4MInput(InputFileInfo& info, bool alpha, int format);<br> <br>     virtual ~Y4MInput();<br>     void release();<br>-- <br>2.36.0.windows.1<br><br></div>