Skip to content

Commit 63a91b0

Browse files
committed
Fix support for y4m files with odd dimensions
This fixes the Y4M parser, though yuview eventually refused to read the file. Error before: "Error parsing the Y4M header: Could not locate the next 'FRAME' indicator". Note that the parser cannot deal correctly with the odd-dimensions. Error after: "With the given settings, the YUV data can not be converted to RGB: The item width 9 must be divisible by the horizontal subsampling factor 2. The item height 9 must be divisible by the horizontal subsampling factor 2." Now the problem is that yuview does not seem to support odd dimensions for subsampled files.
1 parent f7a6683 commit 63a91b0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

YUViewLib/src/playlistitem/playlistItemRawFile.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,13 @@ bool playlistItemRawFile::parseY4MFile()
447447
// parameters is also terminated by 0x0A.
448448

449449
// The offset in bytes to the next frame
450-
auto stride = width * height * 3 / 2;
450+
auto ypixels = width * height;
451+
auto cpixels = ((width + 1) / 2) * ((height + 1) / 2);
451452
if (format.getSubsampling() == video::yuv::Subsampling::YUV_422)
452-
stride = width * height * 2;
453+
cpixels = ((width + 1) / 2) * height;
453454
else if (format.getSubsampling() == video::yuv::Subsampling::YUV_444)
454-
stride = width * height * 3;
455+
cpixels = width * height;
456+
auto stride = ypixels + 2 * cpixels;
455457
if (format.getBitsPerSample() > 8)
456458
stride *= 2;
457459

0 commit comments

Comments
 (0)