[x265] [PATCH] Extend the multiview parsing support for y4m input

Anusuya Kumarasamy anusuya.kumarasamy at multicorewareinc.com
Mon Sep 9 08:33:28 UTC 2024


>From 2d2893653fef764f30c987f0b341bcaf6fd0d7a2 Mon Sep 17 00:00:00 2001
From: AnusuyaKumarasamy <anusuya.kumarasamy at multicorewareinc.com>
Date: Mon, 19 Aug 2024 14:42:27 +0530
Subject: [PATCH 2/7] Extend the multiview parsing support for y4m input

---
 source/input/input.cpp |  2 +-
 source/input/y4m.cpp   | 14 ++++++++------
 source/input/y4m.h     |  2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/source/input/input.cpp b/source/input/input.cpp
index 43734c978..2f52718a8 100644
--- a/source/input/input.cpp
+++ b/source/input/input.cpp
@@ -32,7 +32,7 @@ InputFile* InputFile::open(InputFileInfo& info, bool
bForceY4m, bool alpha, int
     const char * s = strrchr(info.filename, '.');

     if (bForceY4m || (s && !strcmp(s, ".y4m")))
-        return new Y4MInput(info, alpha);
+        return new Y4MInput(info, alpha, format);
     else
         return new YUVInput(info, alpha, format);
 }
diff --git a/source/input/y4m.cpp b/source/input/y4m.cpp
index 0fe0cc43e..186499bd1 100644
--- a/source/input/y4m.cpp
+++ b/source/input/y4m.cpp
@@ -40,7 +40,7 @@
 using namespace X265_NS;
 using namespace std;
 static const char header[] = {'F','R','A','M','E'};
-Y4MInput::Y4MInput(InputFileInfo& info, bool alpha)
+Y4MInput::Y4MInput(InputFileInfo& info, bool alpha, int format)
 {
     for (int i = 0; i < QUEUE_SIZE; i++)
         buf[i] = NULL;
@@ -69,11 +69,13 @@ Y4MInput::Y4MInput(InputFileInfo& info, bool alpha)
         ifs = x265_fopen(info.filename, "rb");
     if (ifs && !ferror(ifs) && parseHeader())
     {
+        if (format == 1) width /= 2;
+        if (format == 2) height /= 2;
         int pixelbytes = depth > 8 ? 2 : 1;
         for (int i = 0; i < x265_cli_csps[colorSpace].planes +
alphaAvailable; i++)
         {
-            int stride = (width >> x265_cli_csps[colorSpace].width[i]) *
pixelbytes;
-            framesize += (stride * (height >>
x265_cli_csps[colorSpace].height[i]));
+            int stride = ((width * (format == 1 ? 2 : 1)) >>
x265_cli_csps[colorSpace].width[i]) * pixelbytes;
+            framesize += (stride * ((height * (format == 2 ? 2 : 1)) >>
x265_cli_csps[colorSpace].height[i]));
         }

         threadActive = true;
@@ -391,12 +393,12 @@ bool Y4MInput::readPicture(x265_picture& pic)
         pic.height = height;
         pic.width = width;
         pic.colorSpace = colorSpace;
-        pic.stride[0] = width * pixelbytes;
+        pic.stride[0] = width * pixelbytes * (pic.format == 1 ? 2 : 1);
         pic.stride[1] = pic.stride[0] >>
x265_cli_csps[colorSpace].width[1];
         pic.stride[2] = pic.stride[0] >>
x265_cli_csps[colorSpace].width[2];
         pic.planes[0] = buf[read % QUEUE_SIZE];
-        pic.planes[1] = (char*)pic.planes[0] + pic.stride[0] * height;
-        pic.planes[2] = (char*)pic.planes[1] + pic.stride[1] * (height >>
x265_cli_csps[colorSpace].height[1]);
+        pic.planes[1] = (char*)pic.planes[0] + pic.stride[0] * (height *
(pic.format == 2 ? 2 : 1));
+        pic.planes[2] = (char*)pic.planes[1] + pic.stride[1] * ((height *
(pic.format == 2 ? 2 : 1)) >> x265_cli_csps[colorSpace].height[1]);
 #if ENABLE_ALPHA
         if (alphaAvailable)
         {
diff --git a/source/input/y4m.h b/source/input/y4m.h
index 37992bb66..16d2d0401 100644
--- a/source/input/y4m.h
+++ b/source/input/y4m.h
@@ -71,7 +71,7 @@ protected:

 public:

-    Y4MInput(InputFileInfo& info, bool alpha);
+    Y4MInput(InputFileInfo& info, bool alpha, int format);

     virtual ~Y4MInput();
     void release();
-- 
2.36.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240909/2ce3a863/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Extend-the-multiview-parsing-support-for-y4m-input.patch
Type: application/octet-stream
Size: 3538 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240909/2ce3a863/attachment-0001.obj>


More information about the x265-devel mailing list