[x265] [PATCH] output: use 64bit file offsets to prevent overflow with 4k video

Gopu Govindaswamy gopu at multicorewareinc.com
Thu Oct 24 11:00:49 CEST 2013


# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1382605225 -19800
# Node ID 7443339bdc9b3bf10dd159ce01468b1cd2f61b6a
# Parent  0cb0692d6c69dbf6c5b49c51f6f528e29674baa9
output: use 64bit file offsets to prevent overflow with 4k video

diff -r 0cb0692d6c69 -r 7443339bdc9b source/output/y4m.cpp
--- a/source/output/y4m.cpp	Wed Oct 23 20:09:33 2013 +0800
+++ b/source/output/y4m.cpp	Thu Oct 24 14:30:25 2013 +0530
@@ -50,9 +50,8 @@
 bool Y4MOutput::writePicture(const x265_picture_t& pic)
 {
     PPAStartCpuEventFunc(write_yuv);
-    std::ofstream::pos_type outPicPos = header;
-    outPicPos += pic.poc * (6 + 3 * (width * height) / 2);
-    ofs.seekp(outPicPos);
+    std::ofstream::pos_type frameSize = (6 + 3 * (width * height) / 2);
+    ofs.seekp(header + frameSize * pic.poc); 
     ofs << "FRAME\n";
 
     if (pic.bitDepth > 8)
diff -r 0cb0692d6c69 -r 7443339bdc9b source/output/yuv.cpp
--- a/source/output/yuv.cpp	Wed Oct 23 20:09:33 2013 +0800
+++ b/source/output/yuv.cpp	Thu Oct 24 14:30:25 2013 +0530
@@ -47,7 +47,10 @@
 {
     PPAStartCpuEventFunc(write_yuv);
     int pixelbytes = (depth > 8) ? 2 : 1;
-    ofs.seekp(pic.poc * 3 * (width * height * pixelbytes) / 2);
+    uint64_t size = (pic.poc * 3);
+    size *= (width * height * pixelbytes);
+    size /= 2;
+    ofs.seekp(size);
 
     if (pic.bitDepth > 8 && depth == 8)
     {


More information about the x265-devel mailing list