<!--
Copyright (c) 2019 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<script src="../../../js/js-test-pre.js"></script>
<script src="../../../js/webgl-test-utils.js"></script>
<script src="../../../js/tests/tex-image-and-sub-image-utils.js"></script>
<script src="../../../js/tests/texture-corner-case-videos.js"></script>
</head>
<body>
<canvas id="example" width="32" height="32"></canvas>
<canvas id="c2d" width="32" height="32"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
function testPrologue(gl) {
    return true;
}

generateTest(
    'Verify uploading various corner-case videos to 2D textures',
    "RGBA", "RGBA", "UNSIGNED_BYTE", testPrologue, "", 1,
    [
        // Regression test for http://crbug.com/701060.
        // Generated with the following command line:
        // ffmpeg -r 25 -i red-green-480-272.png -vframes 10 -vcodec h264 -vf setsar=136:135,setdar=16:9 -pix_fmt yuv420p ...
        {
            comment: "Video whose natural size is larger than coded size due to uncommon pixel shape (Sample Aspect Ratio)",
            src: "../../../resources/red-green-480x272-sar-136x135-dar-16x9.mp4",
            type: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',
            // A fairly high tolerance is used because colorspace conversion seems to differ widely between
            // hardware-accelerated video decoders. At least on Windows / NVIDIA, this test was seen to convert
            // (0,255,0) to (13,238,14), and (255,0,0) to (238,14,14).
            tolerance: 18,
        }
    ])();
</script>
</body>
</html>
