// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/40285824): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif // For some sample vp9 test videos, $filename, there is a file of golden value // of frame entropy, named $filename.context. These values are dumped from // libvpx. // // The syntax of these context dump is described as follows. For every // frame, there are corresponding data in context file, // 1. [initial] [current] [should_update=0], or // 2. [initial] [current] [should_update=1] [update] // The first two are expected frame entropy, fhdr->initial_frame_context and // fhdr->frame_context. // If |should_update| is true, it follows by the frame context to update. #include "media/parsers/vp9_parser.h" #include <stdint.h> #include <string.h> #include <memory> #include <utility> #include <vector> #include "base/files/memory_mapped_file.h" #include "base/logging.h" #include "media/base/test_data_util.h" #include "media/parsers/ivf_parser.h" #include "testing/gtest/include/gtest/gtest.h" TestWithParam; namespace media { namespace { struct TestParams { … }; const struct TestParams kTestParams[] = …; const char kInitialIV[] = …; const char kIVIncrementOne[] = …; const char kIVIncrementTwo[] = …; const char kKeyID[] = …; } // anonymous namespace class Vp9ParserTest : public TestWithParam<TestParams> { … }; Vp9Parser::Result Vp9ParserTest::ParseNextFrame(Vp9FrameHeader* fhdr) { … } void Vp9ParserTest::CheckSubsampleValues( const uint8_t* superframe, size_t framesize, std::unique_ptr<DecryptConfig> config, std::vector<std::unique_ptr<DecryptConfig>>& expected_split) { … } uint8_t make_marker_byte(bool is_superframe, const uint8_t frame_count) { … } // ┌───────────────────┬────────────────────┐ // │ frame 1 │ frame 2 │ // ┝━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━┥ // │ clear1 | cipher 1 │ clear 2 | cipher 2 │ // └───────────────────┴────────────────────┘ TEST_F(Vp9ParserTest, AlignedFrameSubsampleParsing) { … } // ┌───────────────────┬────────────────────┐ // │ frame 1 │ frame 2 │ // ┝━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┥ // │ clear1 | cipher 1 │ // └────────────────────────────────────────┘ TEST_F(Vp9ParserTest, UnalignedFrameSubsampleParsing) { … } // ┌─────────────────────────┬────────────────────┐ // │ frame 1 │ frame 2 │ // ┝━━━━━━━━━━━━━━━━━━━┯━━━━━┷━━━━━━━━━━━━━━━━━━━━┥ // │ clear1 | cipher 1 │ clear 2 | cipher 2 │ // └───────────────────┴──────────────────────────┘ TEST_F(Vp9ParserTest, ClearSectionRollsOverSubsampleParsing) { … } // ┌────────────────────────────────────────┬────────────────────┐ // │ frame 1 │ frame 2 │ // ┝━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━┥ // │ clear1 | cipher 1 │ clear 2 | cipher 2 │ clear 3 | cipher 3 │ // └───────────────────┴────────────────────┴────────────────────┘ TEST_F(Vp9ParserTest, FirstFrame2xSubsampleParsing) { … } // ┌─────────────────────────────────────────────┬───────────────┐ // │ frame 1 │ frame 2 │ // ┝━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━┷━━━━━━━━━━━━━━━┥ // │ clear1 | cipher 1 │ clear 2 | cipher 2 │ clear 3 | cipher 3 │ // └───────────────────┴────────────────────┴────────────────────┘ TEST_F(Vp9ParserTest, UnalignedBigFrameSubsampleParsing) { … } // ┌───────────────────┬────────────────────┐ // │ frame 1 │ frame 2 │ // ┝━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┥ // │ clear1 | cipher 1 │ // └────────────────────────────────────────┘ TEST_F(Vp9ParserTest, UnalignedInvalidSubsampleParsing) { … } // ┌─────────────────────────────────────┬─────────┐ // │ single frame in superframe │ marker │ // ┝━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┥ // │ clear1 = 0 | cipher 1 │ // └───────────────────────────────────────────────┘ TEST_F(Vp9ParserTest, CipherBytesCoverSuperframeMarkerSubsampleParsing) { … } // ┌─────────────────────────────────────┬─────────┐ // │ single frame in superframe │ marker │ // ┝━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┥ // │ clear1 │ // └───────────────────────────────────────────────┘ TEST_F(Vp9ParserTest, ClearBytesCoverSuperframeMarkerSubsampleParsing) { … } // ┌─────────────────────────────────────┬─────────┐ // │ single frame in superframe │ marker │ // ┝━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┷━━━━━━━━━┥ // │ clear 1 | cipher 1 │ clear 2 │ // └────────────────────┴──────────────────────────┘ TEST_F(Vp9ParserTest, SecondClearSubsampleSuperframeMarkerSubsampleParsing) { … } TEST_F(Vp9ParserTest, TestIncrementIV) { … } TEST_F(Vp9ParserTest, StreamFileParsingWithoutCompressedHeader) { … } TEST_P(Vp9ParserTest, VerifyFirstFrame) { … } INSTANTIATE_TEST_SUITE_P(…); TEST_F(Vp9ParserTest, CheckColorSpace) { … } } // namespace media