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

Unified Diff: tools/dump_ciede2000.py

Issue 1543: 4:2:2 support in dump_ciede2000.py
Patch Set: 4:2:2 support in dump_ciede2000.py Created 1 year, 6 months 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 388882c86b560b66ada08a5d9212a8458c1adfe2..80b6b6ad3e308443aa8c49130f31fa08b5d6802f 100755
--- a/tools/dump_ciede2000.py
+++ b/tools/dump_ciede2000.py
@@ -14,6 +14,7 @@ yuv2rgb = np.array([
# Simple box filter
box2 = np.ones((2, 2))
+box1 = np.ones((1, 2))
def usage():
print("Usage: %s <video1> <video2>\n"
@@ -23,15 +24,22 @@ def decode_y4m_buffer(frame):
W, H = frame.headers['W'], frame.headers['H']
Wdiv2, Hdiv2 = W // 2, H // 2
C, buf = frame.headers['C'], frame.buffer
- A, Adiv2, div2 = W * H, Hdiv2 * Wdiv2, (Hdiv2, Wdiv2)
+ A = W * H
dtype, scale = 'uint8', 1.
if C.endswith('p10'):
+ # TODO 420p10 and 422p10
dtype, scale, A = 'uint16', 4., A * 2
Y = (np.ndarray((H, W), dtype, buf) - 16. * scale) / (219. * scale)
if C.startswith('420'):
- Cb = (np.ndarray(div2, dtype, buf, A) - 128. * scale) / (224. * scale)
- Cr = (np.ndarray(div2, dtype, buf, A + Adiv2) - 128. * scale) / (224. * scale)
+ A_420 = Hdiv2 * Wdiv2
+ Cb = (np.ndarray((Hdiv2, Wdiv2), dtype, buf, A) - 128. * scale) / (224. * scale)
+ Cr = (np.ndarray((Hdiv2, Wdiv2), dtype, buf, A + A_420) - 128. * scale) / (224. * scale)
YCbCr444 = np.dstack((Y, np.kron(Cb, box2), np.kron(Cr, box2)))
+ elif C.startswith('422'):
+ A_422 = H * Wdiv2
+ Cb = (np.ndarray((H, Wdiv2), dtype, buf, A) - 128. * scale) / (224. * scale)
+ Cr = (np.ndarray((H, Wdiv2), dtype, buf, A + A_422) - 128. * scale) / (224. * scale)
+ YCbCr444 = np.dstack((Y, np.kron(Cb, box1), np.kron(Cr, box1)))
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)
@@ -74,6 +82,8 @@ class Reader(y4m.Reader):
C = self._stream_headers['C']
if C.startswith('420'):
pixels = area * 3 // 2
+ elif C.startswith('422'):
+ pixels = area * 2
elif C.startswith('444'):
pixels = area * 3
else:
« 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