A dump tool for VP8 files
Change-Id: Ia7523ddcd7ee73c4a77432435360596e1df425d6
diff --git a/bin/vpxdump b/bin/vpxdump
new file mode 100755
index 0000000..949b803
--- /dev/null
+++ b/bin/vpxdump
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Dump stats from a VP8 encoded file.
+# The VP8 file is a Matroska file; data is extracted using vpxdec with a patch
+# to write to decodestats.stt for each frame.
+#
+set -e
+
+FILE=$1
+DIR=$PWD
+BINDIR=$(dirname $(realpath $0))
+
+if [ ! -f $DIR/$FILE ]; then
+ echo "No such file: $DIR/$FILE"
+ exit 1
+fi
+
+WORKDIR=$(mktemp -d)
+
+cd $WORKDIR
+
+# Dump info to decodestats.stt
+$BINDIR/vpxdec-dumper $DIR/$FILE -o /dev/null
+mkvinfo -v --size $DIR/$FILE > mkvinfo.log
+grep 'Frame with' mkvinfo.log > mkvinfo.frames
+
+paste decodestats.stt mkvinfo.frames
+
+rm -r $WORKDIR
+
+
+
diff --git a/enable-decodestats.patch b/enable-decodestats.patch
new file mode 100644
index 0000000..4146c11
--- /dev/null
+++ b/enable-decodestats.patch
@@ -0,0 +1,13 @@
+diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c
+index 4632118..cb000d0 100644
+--- a/vp8/decoder/decodframe.c
++++ b/vp8/decoder/decodframe.c
+@@ -1278,7 +1278,7 @@ int vp8_decode_frame(VP8D_COMP *pbi)
+ pc->refresh_last_frame = 1;
+ #endif
+
+- if (0)
++ if (1)
+ {
+ FILE *z = fopen("decodestats.stt", "a");
+ fprintf(z, "%6d F:%d,G:%d,A:%d,L:%d,Q:%d\n",
diff --git a/install_software.sh b/install_software.sh
index a07ab41..6980739 100755
--- a/install_software.sh
+++ b/install_software.sh
@@ -33,8 +33,15 @@
patch -p1 < ../vp8_fixed_q.patch
make
cp vpxenc ../bin/vpxenc-mpeg
+
+# Build a patched version of vpxdec that dumps decode data
+patch -p1 < ../enable-decodestats.patch
+make
+cp vpxdec ../bin/vpxdec-dumper
+
cd ..
+
# Build the x264 binary
if [ ! -d x264 ]; then
git clone git://git.videolan.org/x264.git