1#!/bin/bash 2# 3# Any copyright is dedicated to the Public Domain. 4# http://creativecommons.org/publicdomain/zero/1.0/ 5# 6# Script to generate <video src> reftest files, from corresponding reftest 7# files that use <video poster>. 8# 9# This script expects to be run from this working directory: 10# mozilla-central/layout/reftests/w3c-css/submitted/images3 11# 12# It requires that the tools png2yuv and vpxenc be available, from the 13# Ubuntu packages 'mjpegtools' and 'vpx-tools'. More info here: 14# http://wiki.webmproject.org/howtos/convert-png-frames-to-webm-video 15 16VIDEO_REFTEST_PATH="../../../webm-video" 17 18imageFileArr=("colors-16x8.png" "colors-8x16.png") 19numImageFiles=${#imageFileArr[@]} 20 21# Copy image files, and generate webm files: 22for ((i = 0; i < $numImageFiles; i++)); do 23 imageFileName=${imageFileArr[$i]} 24 imageDest=$VIDEO_REFTEST_PATH/$imageFileName 25 26 echo "Copying $imageDest." 27 hg cp support/$imageFileName $imageDest 28 29 videoDest=`echo $imageDest | sed "s/png/webm/"` 30 echo "Generating $videoDest." 31 png2yuv -f 1 -I p -b 1 -n 1 -j $imageDest \ 32 | vpxenc --passes=1 --pass=1 --codec=vp9 --lossless=1 --max-q=0 -o $videoDest - 33 hg add $videoDest 34done 35 36# Add comment to reftest.list in dest directory: 37reftestListFileName="$VIDEO_REFTEST_PATH/reftest.list" 38echo " 39# Tests for <video src> with 'object-fit' & 'object-position': 40# These tests should be very similar to tests in our w3c-css/submitted/images3 41# reftest directory. They live here because they use WebM video (VP9), and it 42# wouldn't be fair of us to make a W3C testsuite implicitly depend on any 43# particular (non-spec-mandated) video codec."\ 44 >> $reftestListFileName 45 46# Loop across all <video poster> tests: 47for origTestName in object*p.html; do 48 # Find the corresponding reference case: 49 origReferenceName=$(echo $origTestName | 50 sed "s/p.html/-ref.html/") 51 52 # The generated testcase will have "-webm" instead of "-png", and unlike 53 # the original png test, it won't have a single-letter suffix to indicate the 54 # particular container element. (since it's unnecessary -- there's only one 55 # possible container element for webm, "<video>") 56 videoTestName=$(echo $origTestName | 57 sed "s/png/webm/" | 58 sed "s/p.html/.html/") 59 60 videoReferenceName=$(echo $videoTestName | 61 sed "s/.html/-ref.html/") 62 63 # Generate reference file (dropping "support" subdir from image paths): 64 echo "Copying $origReferenceName to $VIDEO_REFTEST_PATH." 65 videoReferenceFullPath=$VIDEO_REFTEST_PATH/$videoReferenceName 66 hg cp $origReferenceName $videoReferenceFullPath 67 sed -i "s,support/,," $videoReferenceFullPath 68 69 # Generate testcase 70 # (converting <video poster="support/foo.png"> to <video src="foo.webm">): 71 echo "Generating $videoTestName from $origTestName." 72 videoTestFullPath=$VIDEO_REFTEST_PATH/$videoTestName 73 hg cp $origTestName $videoTestFullPath 74 sed -i "s/PNG image/WebM video/" $videoTestFullPath 75 sed -i "s/poster/src/" $videoTestFullPath 76 sed -i "s,support/,," $videoTestFullPath 77 sed -i "s/png/webm/" $videoTestFullPath 78 sed -i "s/$origReferenceName/$videoReferenceName/" $videoTestFullPath 79 80 # Update reftest manifest: 81 annotation="fails-if(layersGPUAccelerated) skip-if(Android||B2G)" 82 comment="# Bug 1083516 for layersGPUAccelerated failures, Bug 1084564 for Android/B2G failures" 83 echo "$annotation == $videoTestName $videoReferenceName $comment" \ 84 >> $reftestListFileName 85 86done 87