Skip to content

Commit

Permalink
Increase video-rotation test tolerance, add vp9 version. (KhronosGrou…
Browse files Browse the repository at this point in the history
…p#3262)

Speed focused software yuv conversion libraries may be off by more
than 5 points in a channel for values near the channel maximum.

There's also no reason we can't have a vp9 version of this test, so
add encodes for clients who want to test w/o proprietary codecs.

Run both h264 and vp9 tests if supported.
  • Loading branch information
dalecurtis authored Mar 18, 2021
1 parent 4aad270 commit 9174c56
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
56 changes: 37 additions & 19 deletions sdk/tests/conformance/textures/misc/video-rotation.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
let gl = wtu.create3DContext(canvas);
let program = tiu.setupTexturedQuad(gl, gl.RGBA);
const resourcePath = "../../../resources/";
const tolerance = 5;
const tolerance = 6;

const expectedColors = {
top: { location: [0.5, 0.25], color: [255, 0, 0] },
Expand Down Expand Up @@ -89,11 +89,12 @@
return;
}

const type = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"';
if (!video.canPlayType(type).replace(/no/, '')) {
debug(type + " unsupported");
let supports_h264 = !!video.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/no/, '');
let supports_vp9 = !!video.canPlayType('video/mp4; codecs="vp09.00.10.08"').replace(/no/, '');
if (!supports_h264 && !supports_vp9) {
testFailed("No supported video types.");
return;
};
}

let tex = gl.createTexture();
// Bind the texture to the default texture unit 0
Expand All @@ -107,27 +108,44 @@
// These files were created by converting exif-orientation-test-1-normal.jpg to mp4
// files, rotating them using the transpose filter, and adding rotate metadata, all
// using the ffmpeg command-line tool.
//
// From sdk/tests/resources/ directory:
//
// 0:
// ffmpeg -noautorotate -i sdk/tests/resources/exif-orientation-test-1-normal.jpg -pix_fmt yuv420p temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=0 sdk/tests/resources/video-rotation-0.mp
// ffmpeg -noautorotate -i exif-orientation-test-1-normal.jpg -pix_fmt yuv420p -y temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=0 video-rotation-0.mp4
// ffmpeg -noautorotate -i exif-orientation-test-1-normal.jpg -pix_fmt yuv420p -crf 0 -vcodec libvpx-vp9 -y temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=0 video-rotation-0.vp9.mp4
// 90:
// ffmpeg -noautorotate -i sdk/tests/resources/exif-orientation-test-1-normal.jpg -vf "transpose=2" -pix_fmt yuv420p temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=270 sdk/tests/resources/video-rotation-90.mp4
// ffmpeg -noautorotate -i exif-orientation-test-1-normal.jpg -vf "transpose=2" -pix_fmt yuv420p -y temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=270 video-rotation-90.mp4
// ffmpeg -noautorotate -i exif-orientation-test-1-normal.jpg -vf "transpose=2" -pix_fmt yuv420p -crf 0 -vcodec libvpx-vp9 -y temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=270 video-rotation-90.vp9.mp4
// 180:
// ffmpeg -noautorotate -i sdk/tests/resources/exif-orientation-test-1-normal.jpg -vf "transpose=2,transpose=2" -pix_fmt yuv420p temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=180 sdk/tests/resources/video-rotation-180.mp4
// ffmpeg -noautorotate -i exif-orientation-test-1-normal.jpg -vf "transpose=2,transpose=2" -pix_fmt yuv420p -y temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=180 video-rotation-180.mp4
// ffmpeg -noautorotate -i exif-orientation-test-1-normal.jpg -vf "transpose=2,transpose=2" -pix_fmt yuv420p -crf 0 -vcodec libvpx-vp9 -y temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=180 video-rotation-180.vp9.mp4
// 270:
// ffmpeg -noautorotate -i sdk/tests/resources/exif-orientation-test-1-normal.jpg -vf "transpose=1" -pix_fmt yuv420p temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=90 sdk/tests/resources/video-rotation-270.mp4
// ffmpeg -noautorotate -i exif-orientation-test-1-normal.jpg -vf "transpose=1" -pix_fmt yuv420p -y temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=90 video-rotation-270.mp4
// ffmpeg -noautorotate -i exif-orientation-test-1-normal.jpg -vf "transpose=1" -pix_fmt yuv420p -crf 0 -vcodec libvpx-vp9 -y temp.mp4 &&
// ffmpeg -i temp.mp4 -c copy -metadata:s:v:0 rotate=90 video-rotation-270.vp9.mp4
const filenames = [
"video-rotation-0.mp4",
"video-rotation-90.mp4",
"video-rotation-180.mp4",
"video-rotation-270.mp4",
"video-rotation-0",
"video-rotation-90",
"video-rotation-180",
"video-rotation-270",
];

for (let fn of filenames) {
await testVideoElement(fn);
if (supports_h264) {
for (let fn of filenames)
await testVideoElement(fn + ".mp4");
}

if (supports_vp9) {
for (let fn of filenames)
await testVideoElement(fn + ".vp9.mp4");
}

finishTest();
Expand Down
Binary file added sdk/tests/resources/video-rotation-0.vp9.mp4
Binary file not shown.
Binary file added sdk/tests/resources/video-rotation-180.vp9.mp4
Binary file not shown.
Binary file added sdk/tests/resources/video-rotation-270.vp9.mp4
Binary file not shown.
Binary file added sdk/tests/resources/video-rotation-90.vp9.mp4
Binary file not shown.

0 comments on commit 9174c56

Please sign in to comment.