Bug 1224363 - Added vp8/ivf test case - r=rillian
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 03 Dec 2015 14:14:45 +1100
changeset 309513 9f6b527b5e1377940474a7086965d2e1717270ec
parent 309512 945a33faaac9662015f00be3ba56cac2f8f63dbd
child 309514 f0cc92be4cd8cb1a55f2a029a102ec2d079eafef
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs1224363
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1224363 - Added vp8/ivf test case - r=rillian
dom/media/gtest/TestVPXDecoding.cpp
dom/media/gtest/moz.build
dom/media/gtest/test_case_1224363.vp8.ivf
new file mode 100644
--- /dev/null
+++ b/dom/media/gtest/TestVPXDecoding.cpp
@@ -0,0 +1,90 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "gtest/gtest.h"
+#include "mozilla/ArrayUtils.h"
+#include "nsTArray.h"
+#include "VPXDecoder.h"
+
+#include <stdio.h>
+
+using namespace mozilla;
+
+static void
+ReadVPXFile(const char* aPath, nsTArray<uint8_t>& aBuffer)
+{
+  FILE* f = fopen(aPath, "rb");
+  ASSERT_NE(f, (FILE *) nullptr);
+
+  int r = fseek(f, 0, SEEK_END);
+  ASSERT_EQ(r, 0);
+
+  long size = ftell(f);
+  ASSERT_NE(size, -1);
+  aBuffer.SetLength(size);
+
+  r = fseek(f, 0, SEEK_SET);
+  ASSERT_EQ(r, 0);
+
+  size_t got = fread(aBuffer.Elements(), 1, size, f);
+  ASSERT_EQ(got, size_t(size));
+
+  r = fclose(f);
+  ASSERT_EQ(r, 0);
+}
+
+static
+vpx_codec_iface_t*
+ParseIVFConfig(nsTArray<uint8_t>& data, vpx_codec_dec_cfg_t& config)
+{
+  if (data.Length() < 32 + 12) {
+    // Not enough data for file & first frame headers.
+    return nullptr;
+  }
+  if (data[0] != 'D' || data[1] != 'K' || data[2] != 'I' || data[3] != 'F') {
+    // Expect 'DKIP'
+    return nullptr;
+  }
+  if (data[4] != 0 || data[5] != 0) {
+    // Expect version==0.
+    return nullptr;
+  }
+  if (data[8] != 'V' || data[9] != 'P'
+      || (data[10] != '8' && data[10] != '9')
+      || data[11] != '0') {
+    // Expect 'VP80' or 'VP90'.
+    return nullptr;
+  }
+  config.w = uint32_t(data[12]) || (uint32_t(data[13]) << 8);
+  config.h = uint32_t(data[14]) || (uint32_t(data[15]) << 8);
+  vpx_codec_iface_t* codec = (data[10] == '8')
+                             ? vpx_codec_vp8_dx()
+                             : vpx_codec_vp9_dx();
+  // Remove headers, to just leave raw VPx data to be decoded.
+  data.RemoveElementsAt(0, 32 + 12);
+  return codec;
+}
+
+TEST(libvpx, test_case_1224363)
+{
+  nsTArray<uint8_t> data;
+  ReadVPXFile("test_case_1224363.vp8.ivf", data);
+
+  vpx_codec_dec_cfg_t config;
+  vpx_codec_iface_t* dx = ParseIVFConfig(data, config);
+  ASSERT_TRUE(dx);
+  config.threads = 2;
+
+  vpx_codec_ctx_t ctx;
+  PodZero(&ctx);
+  vpx_codec_err_t r = vpx_codec_dec_init(&ctx, dx, &config, 0);
+  ASSERT_EQ(VPX_CODEC_OK, r);
+
+  r = vpx_codec_decode(&ctx, data.Elements(), data.Length(), nullptr, 0);
+  // This test case is known to be corrupt.
+  EXPECT_EQ(VPX_CODEC_CORRUPT_FRAME, r);
+
+  r = vpx_codec_destroy(&ctx);
+  EXPECT_EQ(VPX_CODEC_OK, r);
+}
--- a/dom/media/gtest/moz.build
+++ b/dom/media/gtest/moz.build
@@ -14,16 +14,17 @@ UNIFIED_SOURCES += [
     'TestMediaEventSource.cpp',
     'TestMediaFormatReader.cpp',
     'TestMozPromise.cpp',
     'TestMP3Demuxer.cpp',
     'TestMP4Demuxer.cpp',
     # 'TestMP4Reader.cpp', disabled so we can turn check tests back on (bug 1175752)
     'TestTrackEncoder.cpp',
     'TestVideoSegment.cpp',
+    'TestVPXDecoding.cpp',
     'TestWebMBuffered.cpp',
 ]
 
 if CONFIG['MOZ_EME']:
     UNIFIED_SOURCES += [
         'TestEME.cpp',
     ]
 
@@ -45,16 +46,17 @@ TEST_HARNESS_FILES.gtest += [
     'dash_dashinit.mp4',
     'id3v2header.mp3',
     'mediasource_test.mp4',
     'noise.mp3',
     'noise_vbr.mp3',
     'short-zero-in-moov.mp4',
     'small-shot.mp3',
     'test.webm',
+    'test_case_1224363.vp8.ivf',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/dom/media',
     '/dom/media/eme',
     '/dom/media/encoder',
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6d2e4e02063b750d7ee9a349acedc517e7e8a83d
GIT binary patch
literal 1388
zc$@)j1(W(jOG!om03ZNXP&hC^03-k&0000100003000000000z1poj5000000002+
z7yz9CDnI}v?EeP{g@wweE?!g2#&y-kjh#J+g@lL#0s_Q*Ukg6v`2o*Q5_dFyPZakW
z^)>m6{f|s%tMAuuQa`AF;y<~2!TKrxJ-*541Lc4F0q~*wm+4z`!|DUozZ-tmlEuLN
zF8r^|2gbkRyf63_{HKy%?Z1>im44FuN%BAX{x|z(IQAoh{pY8T{N7srq4oy-RR3|<
z>(MXvSK9Rc5%*Vle4kir)KBJah|gC4uKuKdQNO@{U9_{oU~!)xGN|-mc0fg8XZ=47
z;Q#;tWO%W4J*{I7F!K!ipXza;dELXcp;q=*k8HDe#Co~9!0^`V`JlV5I?mr9f8hFU
z=I*U2tmSX=DT0kV{r4Kue#Rd0UaA_pk3B<5m%*f0pWf#gQr~`@yJ@k5?Ixw)|7alH
z-~VU2{mjTQ^TK0P%hZ{-^o8EE|Kd+K>+8h8v;R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