tor-browser

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

video_frame_metadata_unittest.cc (3604B)


      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 "api/video/video_frame_metadata.h"
     12 
     13 #include "modules/video_coding/codecs/h264/include/h264_globals.h"
     14 #include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
     15 #include "test/gtest.h"
     16 
     17 namespace webrtc {
     18 namespace {
     19 
     20 RTPVideoHeaderH264 ExampleHeaderH264() {
     21  NaluInfo nalu_info;
     22  nalu_info.type = 1;
     23  nalu_info.sps_id = 2;
     24  nalu_info.pps_id = 3;
     25 
     26  RTPVideoHeaderH264 header;
     27  header.nalu_type = 4;
     28  header.packetization_type = H264PacketizationTypes::kH264StapA;
     29  header.nalus = {nalu_info};
     30  header.packetization_mode = H264PacketizationMode::SingleNalUnit;
     31  return header;
     32 }
     33 
     34 RTPVideoHeaderVP9 ExampleHeaderVP9() {
     35  RTPVideoHeaderVP9 header;
     36  header.InitRTPVideoHeaderVP9();
     37  header.inter_pic_predicted = true;
     38  header.flexible_mode = true;
     39  header.beginning_of_frame = true;
     40  header.end_of_frame = true;
     41  header.ss_data_available = true;
     42  header.non_ref_for_inter_layer_pred = true;
     43  header.picture_id = 1;
     44  header.max_picture_id = 2;
     45  header.tl0_pic_idx = 3;
     46  header.temporal_idx = 4;
     47  header.spatial_idx = 5;
     48  header.temporal_up_switch = true;
     49  header.inter_layer_predicted = true;
     50  header.gof_idx = 6;
     51  header.num_ref_pics = 1;
     52  header.pid_diff[0] = 8;
     53  header.ref_picture_id[0] = 9;
     54  header.num_spatial_layers = 1;
     55  header.first_active_layer = 0;
     56  header.spatial_layer_resolution_present = true;
     57  header.width[0] = 12;
     58  header.height[0] = 13;
     59  header.end_of_picture = true;
     60  header.gof.SetGofInfoVP9(TemporalStructureMode::kTemporalStructureMode1);
     61  header.gof.pid_start = 14;
     62  return header;
     63 }
     64 
     65 TEST(VideoFrameMetadataTest, H264MetadataEquality) {
     66  RTPVideoHeaderH264 header = ExampleHeaderH264();
     67 
     68  VideoFrameMetadata metadata_lhs;
     69  metadata_lhs.SetRTPVideoHeaderCodecSpecifics(header);
     70 
     71  VideoFrameMetadata metadata_rhs;
     72  metadata_rhs.SetRTPVideoHeaderCodecSpecifics(header);
     73 
     74  EXPECT_TRUE(metadata_lhs == metadata_rhs);
     75  EXPECT_FALSE(metadata_lhs != metadata_rhs);
     76 }
     77 
     78 TEST(VideoFrameMetadataTest, H264MetadataInequality) {
     79  RTPVideoHeaderH264 header = ExampleHeaderH264();
     80 
     81  VideoFrameMetadata metadata_lhs;
     82  metadata_lhs.SetRTPVideoHeaderCodecSpecifics(header);
     83 
     84  VideoFrameMetadata metadata_rhs;
     85  header.nalus[0].type = 17;
     86  metadata_rhs.SetRTPVideoHeaderCodecSpecifics(header);
     87 
     88  EXPECT_FALSE(metadata_lhs == metadata_rhs);
     89  EXPECT_TRUE(metadata_lhs != metadata_rhs);
     90 }
     91 
     92 TEST(VideoFrameMetadataTest, VP9MetadataEquality) {
     93  RTPVideoHeaderVP9 header = ExampleHeaderVP9();
     94 
     95  VideoFrameMetadata metadata_lhs;
     96  metadata_lhs.SetRTPVideoHeaderCodecSpecifics(header);
     97 
     98  VideoFrameMetadata metadata_rhs;
     99  metadata_rhs.SetRTPVideoHeaderCodecSpecifics(header);
    100 
    101  EXPECT_TRUE(metadata_lhs == metadata_rhs);
    102  EXPECT_FALSE(metadata_lhs != metadata_rhs);
    103 }
    104 
    105 TEST(VideoFrameMetadataTest, VP9MetadataInequality) {
    106  RTPVideoHeaderVP9 header = ExampleHeaderVP9();
    107 
    108  VideoFrameMetadata metadata_lhs;
    109  metadata_lhs.SetRTPVideoHeaderCodecSpecifics(header);
    110 
    111  VideoFrameMetadata metadata_rhs;
    112  header.gof.pid_diff[0][0] = 42;
    113  metadata_rhs.SetRTPVideoHeaderCodecSpecifics(header);
    114 
    115  EXPECT_FALSE(metadata_lhs == metadata_rhs);
    116  EXPECT_TRUE(metadata_lhs != metadata_rhs);
    117 }
    118 
    119 }  // namespace
    120 }  // namespace webrtc