Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(480070)

Unified Diff: tools/dump_ciede2000.py

Issue 1496: tools: Add 444, 444p10 support to dump_ciede2000.py
Patch Set: Created 2 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dump_ciede2000.py
diff --git a/tools/dump_ciede2000.py b/tools/dump_ciede2000.py
index ba91b303432f977cf37643990d26e7125baeb01a..20979fddde65b6e69178366b54b2923288fee62e 100755
--- a/tools/dump_ciede2000.py
+++ b/tools/dump_ciede2000.py
@@ -20,9 +20,14 @@ def decode_y4m_buffer(frame):
if C.endswith('p10'):
dtype, scale, A = 'uint16', 4., A * 2
Y = (np.ndarray((H, W), dtype, buf) - 16. * scale) / (219. * scale)
- Cb = (np.ndarray(div2, dtype, buf, A) - 128. * scale) / (224. * scale)
- Cr = (np.ndarray(div2, dtype, buf, A + A // 4) - 128. * scale) / (224. * scale)
- YCbCr444 = np.dstack((Y, np.kron(Cb, box2), np.kron(Cr, box2)))
+ if C.startswith('420'):
+ Cb = (np.ndarray(div2, dtype, buf, A) - 128. * scale) / (224. * scale)
+ Cr = (np.ndarray(div2, dtype, buf, A + A // 4) - 128. * scale) / (224. * scale)
luc.trudeau 2016/11/24 12:49:08 A // 4 != (H // 2) * (W //2) see https://review.x
+ YCbCr444 = np.dstack((Y, np.kron(Cb, box2), np.kron(Cr, box2)))
+ else:
+ Cb = (np.ndarray((H, W), dtype, buf, A) - 128. * scale) / (224. * scale)
+ Cr = (np.ndarray((H, W), dtype, buf, A * 2) - 128. * scale) / (224. * scale)
+ YCbCr444 = np.dstack((Y, Cb, Cr))
return np.dot(YCbCr444, yuv2rgb.T)
@@ -57,7 +62,14 @@ def process_recons(frame):
class Reader(y4m.Reader):
def _frame_size(self):
- pixels = super(Reader, self)._frame_size()
+ area = self._stream_headers['W'] * self._stream_headers['H']
+ C = self._stream_headers['C']
+ if C.startswith('420'):
+ pixels = area * 3 // 2
+ elif C.startswith('444'):
+ pixels = area * 3
+ else:
+ raise Exception('Unknown pixel format: %s' % C)
if self._stream_headers['C'].endswith('p10'):
return 2 * pixels
return pixels
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld