tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

h265_vps_parser_unittest.cc (1530B)


      1 /*
      2 *  Copyright (c) 2023 The WebRTC project authors. All Rights Reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #include "common_video/h265/h265_vps_parser.h"
     12 
     13 #include <cstdint>
     14 #include <optional>
     15 
     16 #include "test/gtest.h"
     17 
     18 namespace webrtc {
     19 
     20 // Example VPS can be generated with ffmpeg. Here's an example set of commands,
     21 // runnable on Linux:
     22 // 1) Generate a video, from the camera:
     23 // ffmpeg -i /dev/video0 -r 30 -c:v libx265 -s 1280x720 camera.h265
     24 //
     25 // 2) Open camera.h265 and find the VPS, generally everything between the first
     26 // and second start codes (0 0 0 1 or 0 0 1). The first two bytes should be 0x40
     27 // and 0x01, which should be stripped out before being passed to the parser.
     28 
     29 class H265VpsParserTest : public ::testing::Test {
     30 public:
     31  H265VpsParserTest() {}
     32  ~H265VpsParserTest() override {}
     33 
     34  std::optional<H265VpsParser::VpsState> vps_;
     35 };
     36 
     37 TEST_F(H265VpsParserTest, TestSampleVPSId) {
     38  // VPS id 1
     39  const uint8_t buffer[] = {
     40      0x1c, 0x01, 0xff, 0xff, 0x04, 0x08, 0x00, 0x00, 0x03, 0x00, 0x9d,
     41      0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78, 0x95, 0x98, 0x09,
     42  };
     43  EXPECT_TRUE(static_cast<bool>(vps_ = H265VpsParser::ParseVps(buffer)));
     44  EXPECT_EQ(1u, vps_->id);
     45 }
     46 
     47 }  // namespace webrtc