OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [image/] [color/] [ycbcr_test.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package color
6
 
7
import (
8
        "testing"
9
)
10
 
11
func delta(x, y uint8) uint8 {
12
        if x >= y {
13
                return x - y
14
        }
15
        return y - x
16
}
17
 
18
// Test that a subset of RGB space can be converted to YCbCr and back to within
19
// 1/256 tolerance.
20
func TestRoundtrip(t *testing.T) {
21
        for r := 0; r < 255; r += 7 {
22
                for g := 0; g < 255; g += 5 {
23
                        for b := 0; b < 255; b += 3 {
24
                                r0, g0, b0 := uint8(r), uint8(g), uint8(b)
25
                                y, cb, cr := RGBToYCbCr(r0, g0, b0)
26
                                r1, g1, b1 := YCbCrToRGB(y, cb, cr)
27
                                if delta(r0, r1) > 1 || delta(g0, g1) > 1 || delta(b0, b1) > 1 {
28
                                        t.Fatalf("r0, g0, b0 = %d, %d, %d   r1, g1, b1 = %d, %d, %d", r0, g0, b0, r1, g1, b1)
29
                                }
30
                        }
31
                }
32
        }
33
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.