feat: port media/codecs to CMake (#1143)
Issue #1047 (CMake port) Issue #346 (absl port)
This commit is contained in:
parent
41a50962ac
commit
e9bf0c6de4
|
@ -14,3 +14,4 @@
|
|||
.settings
|
||||
build/
|
||||
/packager/docs/
|
||||
.vscode/
|
||||
|
|
|
@ -9,3 +9,4 @@ add_subdirectory(base)
|
|||
add_subdirectory(origin)
|
||||
add_subdirectory(replicator)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(codecs)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "glog/logging.h"
|
||||
#include "packager/media/base/aes_decryptor.h"
|
||||
#include "packager/media/base/aes_encryptor.h"
|
||||
#include "packager/utils/bytes_to_string_view.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -203,7 +204,7 @@ TEST_F(AesCtrEncryptorTest, GenerateRandomIv) {
|
|||
ASSERT_TRUE(AesCryptor::GenerateRandomIv(FOURCC_cenc, &iv));
|
||||
ASSERT_EQ(kCencIvSize, iv.size());
|
||||
LOG(INFO) << "Random IV: "
|
||||
<< absl::BytesToHexString(std::string(iv.begin(), iv.end()));
|
||||
<< absl::BytesToHexString(byte_vector_to_string_view(iv));
|
||||
}
|
||||
|
||||
TEST_F(AesCtrEncryptorTest, UnsupportedKeySize) {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef FALLTHROUGH_INTENDED
|
||||
#define FALLTHROUGH_INTENDED
|
||||
#define FALLTHROUGH_INTENDED [[fallthrough]]
|
||||
#endif
|
||||
|
||||
#endif // PACKAGER_MEDIA_BASE_MACROS_H_
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "glog/logging.h"
|
||||
#include "packager/media/base/key_source.h"
|
||||
#include "packager/status/status_macros.h"
|
||||
#include "packager/utils/bytes_to_string_view.h"
|
||||
|
||||
namespace {
|
||||
const char kEmptyDrmLabel[] = "";
|
||||
|
@ -56,9 +57,9 @@ Status RawKeySource::GetKey(const std::vector<uint8_t>& key_id,
|
|||
return Status::OK;
|
||||
}
|
||||
}
|
||||
std::string key_id_str(key_id.begin(), key_id.end());
|
||||
return Status(error::INTERNAL_ERROR,
|
||||
"Key for key_id=" + absl::BytesToHexString(key_id_str) +
|
||||
"Key for key_id=" +
|
||||
absl::BytesToHexString(byte_vector_to_string_view(key_id)) +
|
||||
" was not found.");
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
# Copyright 2022 Google LLC. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file or at
|
||||
# https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
add_library(codecs STATIC
|
||||
aac_audio_specific_config.cc
|
||||
ac3_audio_util.cc
|
||||
av1_codec_configuration_record.cc
|
||||
av1_parser.cc
|
||||
avc_decoder_configuration_record.cc
|
||||
decoder_configuration_record.cc
|
||||
dovi_decoder_configuration_record.cc
|
||||
ec3_audio_util.cc
|
||||
ac4_audio_util.cc
|
||||
es_descriptor.cc
|
||||
h264_byte_to_unit_stream_converter.cc
|
||||
h264_parser.cc
|
||||
h265_byte_to_unit_stream_converter.cc
|
||||
h265_parser.cc
|
||||
h26x_bit_reader.cc
|
||||
h26x_byte_to_unit_stream_converter.cc
|
||||
hevc_decoder_configuration_record.cc
|
||||
hls_audio_util.cc
|
||||
nal_unit_to_byte_stream_converter.cc
|
||||
nalu_reader.cc
|
||||
video_slice_header_parser.cc
|
||||
vp_codec_configuration_record.cc
|
||||
vp8_parser.cc
|
||||
vp9_parser.cc
|
||||
)
|
||||
|
||||
target_link_libraries(codecs
|
||||
media_base)
|
||||
|
||||
add_executable(codecs_unittest
|
||||
aac_audio_specific_config_unittest.cc
|
||||
ac3_audio_util_unittest.cc
|
||||
av1_codec_configuration_record_unittest.cc
|
||||
av1_parser_unittest.cc
|
||||
avc_decoder_configuration_record_unittest.cc
|
||||
dovi_decoder_configuration_record_unittest.cc
|
||||
ec3_audio_util_unittest.cc
|
||||
ac4_audio_util_unittest.cc
|
||||
es_descriptor_unittest.cc
|
||||
h264_byte_to_unit_stream_converter_unittest.cc
|
||||
h264_parser_unittest.cc
|
||||
h265_byte_to_unit_stream_converter_unittest.cc
|
||||
h265_parser_unittest.cc
|
||||
h26x_bit_reader_unittest.cc
|
||||
hevc_decoder_configuration_record_unittest.cc
|
||||
hls_audio_util_unittest.cc
|
||||
nal_unit_to_byte_stream_converter_unittest.cc
|
||||
nalu_reader_unittest.cc
|
||||
video_slice_header_parser_unittest.cc
|
||||
vp_codec_configuration_record_unittest.cc
|
||||
vp8_parser_unittest.cc
|
||||
vp9_parser_unittest.cc
|
||||
)
|
||||
|
||||
target_link_libraries(codecs_unittest
|
||||
codecs
|
||||
gmock
|
||||
gtest
|
||||
gtest_main
|
||||
test_data_util)
|
||||
|
||||
add_test(NAME codecs_unittest COMMAND codecs_unittest)
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
|
||||
|
@ -70,7 +70,7 @@ bool AACAudioSpecificConfig::Parse(const std::vector<uint8_t>& data) {
|
|||
RCHECK(reader.ReadBits(24, &frequency_));
|
||||
RCHECK(reader.ReadBits(4, &channel_config_));
|
||||
|
||||
RCHECK(channel_config_ < arraysize(kChannelConfigs));
|
||||
RCHECK(channel_config_ < std::size(kChannelConfigs));
|
||||
num_channels_ = kChannelConfigs[channel_config_];
|
||||
|
||||
// Read extension configuration.
|
||||
|
@ -120,12 +120,12 @@ bool AACAudioSpecificConfig::Parse(const std::vector<uint8_t>& data) {
|
|||
}
|
||||
|
||||
if (frequency_ == 0) {
|
||||
RCHECK(frequency_index_ < arraysize(kSampleRates));
|
||||
RCHECK(frequency_index_ < std::size(kSampleRates));
|
||||
frequency_ = kSampleRates[frequency_index_];
|
||||
}
|
||||
|
||||
if (extension_frequency_ == 0 && extension_frequency_index != 0xff) {
|
||||
RCHECK(extension_frequency_index < arraysize(kSampleRates));
|
||||
RCHECK(extension_frequency_index < std::size(kSampleRates));
|
||||
extension_frequency_ = kSampleRates[extension_frequency_index];
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
#include "packager/media/codecs/ac3_audio_util.h"
|
||||
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
#include "packager/utils/bytes_to_string_view.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
@ -42,7 +43,8 @@ size_t GetAc3NumChannels(const std::vector<uint8_t>& ac3_data) {
|
|||
bool lfe_channel_on;
|
||||
if (!ExtractAc3Data(ac3_data, &audio_coding_mode, &lfe_channel_on)) {
|
||||
LOG(WARNING) << "Seeing invalid AC3 data: "
|
||||
<< base::HexEncode(ac3_data.data(), ac3_data.size());
|
||||
<< absl::BytesToHexString(
|
||||
byte_vector_to_string_view(ac3_data));
|
||||
return 0;
|
||||
}
|
||||
return kAc3NumChannelsTable[audio_coding_mode] + (lfe_channel_on ? 1 : 0);
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
#include "packager/media/codecs/ac4_audio_util.h"
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
#include "packager/utils/bytes_to_string_view.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
@ -442,7 +444,8 @@ bool CalculateAC4ChannelMask(const std::vector<uint8_t>& ac4_data,
|
|||
&mdcompat, &pre_channel_mask, &dolby_ims_indicator,
|
||||
&dolby_cbi_indicator)) {
|
||||
LOG(WARNING) << "Seeing invalid AC4 data: "
|
||||
<< base::HexEncode(ac4_data.data(), ac4_data.size());
|
||||
<< absl::BytesToHexString(
|
||||
byte_vector_to_string_view(ac4_data));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -467,7 +470,8 @@ bool CalculateAC4ChannelMPEGValue(const std::vector<uint8_t>& ac4_data,
|
|||
&mdcompat, &pre_channel_mask, &dolby_ims_indicator,
|
||||
&dolby_cbi_indicator)) {
|
||||
LOG(WARNING) << "Seeing invalid AC4 data: "
|
||||
<< base::HexEncode(ac4_data.data(), ac4_data.size());
|
||||
<< absl::BytesToHexString(
|
||||
byte_vector_to_string_view(ac4_data));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -488,7 +492,8 @@ bool GetAc4CodecInfo(const std::vector<uint8_t>& ac4_data,
|
|||
&mdcompat, &pre_channel_mask, &dolby_ims_indicator,
|
||||
&dolby_cbi_indicator)) {
|
||||
LOG(WARNING) << "Seeing invalid AC4 data: "
|
||||
<< base::HexEncode(ac4_data.data(), ac4_data.size());
|
||||
<< absl::BytesToHexString(
|
||||
byte_vector_to_string_view(ac4_data));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -517,7 +522,8 @@ bool GetAc4ImmersiveInfo(const std::vector<uint8_t>& ac4_data,
|
|||
&mdcompat, &pre_channel_mask, ac4_ims_flag,
|
||||
ac4_cbi_flag)) {
|
||||
LOG(WARNING) << "Seeing invalid AC4 data: "
|
||||
<< base::HexEncode(ac4_data.data(), ac4_data.size());
|
||||
<< absl::BytesToHexString(
|
||||
byte_vector_to_string_view(ac4_data));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "packager/media/codecs/av1_codec_configuration_record.h"
|
||||
|
||||
#include "packager/base/strings/stringprintf.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
|
||||
|
@ -84,7 +84,7 @@ bool AV1CodecConfigurationRecord::Parse(const uint8_t* data, size_t data_size) {
|
|||
// Since some of the optional fields (e.g. colorPrimaries) are not present in
|
||||
// AV1CodecConfigurationRecord, we omit all the optional fields.
|
||||
std::string AV1CodecConfigurationRecord::GetCodecString() const {
|
||||
return base::StringPrintf("av01.%d.%02d%c.%02d", profile_, level_,
|
||||
return absl::StrFormat("av01.%d.%02d%c.%02d", profile_, level_,
|
||||
tier_ ? 'H' : 'M', bit_depth_);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
|
||||
|
@ -1481,7 +1481,7 @@ bool AV1Parser::SkipGlobalMotionParams(bool frame_is_intra,
|
|||
|
||||
// 5.9.25. Global param syntax.
|
||||
bool AV1Parser::SkipGlobalParam(int type,
|
||||
int ref,
|
||||
int /*ref*/,
|
||||
int idx,
|
||||
bool allow_high_precision_mv,
|
||||
BitReader* reader) {
|
||||
|
@ -1810,7 +1810,7 @@ bool AV1Parser::SetFrameRefs(int last_frame_idx, int gold_frame_idx) {
|
|||
static const int kRefFrameList[] = {
|
||||
LAST2_FRAME, LAST3_FRAME, BWDREF_FRAME, ALTREF2_FRAME, ALTREF_FRAME,
|
||||
};
|
||||
static_assert(arraysize(kRefFrameList) == kRefsPerFrame - 2,
|
||||
static_assert(std::size(kRefFrameList) == kRefsPerFrame - 2,
|
||||
"Unexpected kRefFrameList size.");
|
||||
for (const int ref_frame : kRefFrameList) {
|
||||
if (frame_header_.ref_frame_idx[ref_frame - LAST_FRAME] < 0) {
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
|
||||
#include "packager/media/codecs/avc_decoder_configuration_record.h"
|
||||
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/string_util.h"
|
||||
#include "absl/strings/ascii.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/base/buffer_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
#include "packager/media/codecs/h264_parser.h"
|
||||
#include "packager/utils/bytes_to_string_view.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
@ -123,7 +125,8 @@ std::string AVCDecoderConfigurationRecord::GetCodecString(
|
|||
const uint8_t bytes[] = {profile_indication, profile_compatibility,
|
||||
avc_level};
|
||||
return FourCCToString(codec_fourcc) + "." +
|
||||
base::ToLowerASCII(base::HexEncode(bytes, arraysize(bytes)));
|
||||
absl::AsciiStrToLower(absl::BytesToHexString(
|
||||
byte_array_to_string_view(bytes, std::size(bytes))));
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
#define PACKAGER_MEDIA_CODECS_AVC_DECODER_CONFIGURATION_RECORD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/base/fourccs.h"
|
||||
#include "packager/media/codecs/decoder_configuration_record.h"
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST(AVCDecoderConfigurationRecordTest, Success) {
|
|||
|
||||
AVCDecoderConfigurationRecord avc_config;
|
||||
ASSERT_TRUE(avc_config.Parse(kAvcDecoderConfigurationData,
|
||||
arraysize(kAvcDecoderConfigurationData)));
|
||||
std::size(kAvcDecoderConfigurationData)));
|
||||
|
||||
EXPECT_EQ(1u, avc_config.version());
|
||||
EXPECT_EQ(0x64, avc_config.profile_indication());
|
||||
|
@ -81,7 +81,7 @@ TEST(AVCDecoderConfigurationRecordTest, SuccessWithSPSExtension) {
|
|||
|
||||
AVCDecoderConfigurationRecord avc_config;
|
||||
ASSERT_TRUE(avc_config.Parse(kAvcDecoderConfigurationData,
|
||||
arraysize(kAvcDecoderConfigurationData)));
|
||||
std::size(kAvcDecoderConfigurationData)));
|
||||
|
||||
EXPECT_EQ(1u, avc_config.version());
|
||||
EXPECT_EQ(0x64, avc_config.profile_indication());
|
||||
|
@ -121,7 +121,7 @@ TEST(AVCDecoderConfigurationRecordTest, SuccessWithTransferCharacteristics) {
|
|||
|
||||
AVCDecoderConfigurationRecord avc_config;
|
||||
ASSERT_TRUE(avc_config.Parse(kAvcDecoderConfigurationData,
|
||||
arraysize(kAvcDecoderConfigurationData)));
|
||||
std::size(kAvcDecoderConfigurationData)));
|
||||
|
||||
EXPECT_EQ(1u, avc_config.version());
|
||||
EXPECT_EQ(0x64, avc_config.profile_indication());
|
||||
|
@ -153,7 +153,7 @@ TEST(AVCDecoderConfigurationRecordTest, SuccessWithNoParameterSets) {
|
|||
|
||||
AVCDecoderConfigurationRecord avc_config;
|
||||
ASSERT_TRUE(avc_config.Parse(kAvcDecoderConfigurationData,
|
||||
arraysize(kAvcDecoderConfigurationData)));
|
||||
std::size(kAvcDecoderConfigurationData)));
|
||||
|
||||
EXPECT_EQ(1u, avc_config.version());
|
||||
EXPECT_EQ(0x64, avc_config.profile_indication());
|
||||
|
@ -191,7 +191,7 @@ TEST(AVCDecoderConfigurationRecordTest, FailsOnInvalidNaluLengthSize) {
|
|||
|
||||
AVCDecoderConfigurationRecord avc_config;
|
||||
ASSERT_FALSE(avc_config.Parse(kAvcDecoderConfigurationData,
|
||||
arraysize(kAvcDecoderConfigurationData)));
|
||||
std::size(kAvcDecoderConfigurationData)));
|
||||
}
|
||||
|
||||
TEST(AVCDecoderConfigurationRecordTest, FailOnInsufficientData) {
|
||||
|
@ -199,7 +199,7 @@ TEST(AVCDecoderConfigurationRecordTest, FailOnInsufficientData) {
|
|||
|
||||
AVCDecoderConfigurationRecord avc_config;
|
||||
ASSERT_FALSE(avc_config.Parse(kAvcDecoderConfigurationData,
|
||||
arraysize(kAvcDecoderConfigurationData)));
|
||||
std::size(kAvcDecoderConfigurationData)));
|
||||
}
|
||||
|
||||
TEST(AVCDecoderConfigurationRecordTest, GetCodecString) {
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
# Copyright 2014 Google LLC. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file or at
|
||||
# https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
{
|
||||
'variables': {
|
||||
'shaka_code': 1,
|
||||
},
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'codecs',
|
||||
'type': '<(component)',
|
||||
'sources': [
|
||||
'aac_audio_specific_config.cc',
|
||||
'aac_audio_specific_config.h',
|
||||
'ac3_audio_util.cc',
|
||||
'ac3_audio_util.h',
|
||||
'av1_codec_configuration_record.cc',
|
||||
'av1_codec_configuration_record.h',
|
||||
'av1_parser.cc',
|
||||
'av1_parser.h',
|
||||
'avc_decoder_configuration_record.cc',
|
||||
'avc_decoder_configuration_record.h',
|
||||
'decoder_configuration_record.cc',
|
||||
'decoder_configuration_record.h',
|
||||
'dovi_decoder_configuration_record.cc',
|
||||
'dovi_decoder_configuration_record.h',
|
||||
'ec3_audio_util.cc',
|
||||
'ec3_audio_util.h',
|
||||
'ac4_audio_util.cc',
|
||||
'ac4_audio_util.h',
|
||||
'es_descriptor.cc',
|
||||
'es_descriptor.h',
|
||||
'h264_byte_to_unit_stream_converter.cc',
|
||||
'h264_byte_to_unit_stream_converter.h',
|
||||
'h264_parser.cc',
|
||||
'h264_parser.h',
|
||||
'h265_byte_to_unit_stream_converter.cc',
|
||||
'h265_byte_to_unit_stream_converter.h',
|
||||
'h265_parser.cc',
|
||||
'h265_parser.h',
|
||||
'h26x_bit_reader.cc',
|
||||
'h26x_bit_reader.h',
|
||||
'h26x_byte_to_unit_stream_converter.cc',
|
||||
'h26x_byte_to_unit_stream_converter.h',
|
||||
'hevc_decoder_configuration_record.cc',
|
||||
'hevc_decoder_configuration_record.h',
|
||||
'hls_audio_util.cc',
|
||||
'hls_audio_util.h',
|
||||
'nal_unit_to_byte_stream_converter.cc',
|
||||
'nal_unit_to_byte_stream_converter.h',
|
||||
'nalu_reader.cc',
|
||||
'nalu_reader.h',
|
||||
'video_slice_header_parser.cc',
|
||||
'video_slice_header_parser.h',
|
||||
'vp_codec_configuration_record.cc',
|
||||
'vp_codec_configuration_record.h',
|
||||
'vp8_parser.cc',
|
||||
'vp8_parser.h',
|
||||
'vp9_parser.cc',
|
||||
'vp9_parser.h',
|
||||
'vpx_parser.h',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../base/base.gyp:base',
|
||||
'../../third_party/gflags/gflags.gyp:gflags',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'codecs_unittest',
|
||||
'type': '<(gtest_target_type)',
|
||||
'sources': [
|
||||
'aac_audio_specific_config_unittest.cc',
|
||||
'ac3_audio_util_unittest.cc',
|
||||
'av1_codec_configuration_record_unittest.cc',
|
||||
'av1_parser_unittest.cc',
|
||||
'avc_decoder_configuration_record_unittest.cc',
|
||||
'dovi_decoder_configuration_record_unittest.cc',
|
||||
'ec3_audio_util_unittest.cc',
|
||||
'ac4_audio_util_unittest.cc',
|
||||
'es_descriptor_unittest.cc',
|
||||
'h264_byte_to_unit_stream_converter_unittest.cc',
|
||||
'h264_parser_unittest.cc',
|
||||
'h265_byte_to_unit_stream_converter_unittest.cc',
|
||||
'h265_parser_unittest.cc',
|
||||
'h26x_bit_reader_unittest.cc',
|
||||
'hevc_decoder_configuration_record_unittest.cc',
|
||||
'hls_audio_util_unittest.cc',
|
||||
'nal_unit_to_byte_stream_converter_unittest.cc',
|
||||
'nalu_reader_unittest.cc',
|
||||
'video_slice_header_parser_unittest.cc',
|
||||
'vp_codec_configuration_record_unittest.cc',
|
||||
'vp8_parser_unittest.cc',
|
||||
'vp9_parser_unittest.cc',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../media/base/media_base.gyp:media_base',
|
||||
'../../testing/gmock.gyp:gmock',
|
||||
'../../testing/gtest.gyp:gtest',
|
||||
'../test/media_test.gyp:media_test_support',
|
||||
'codecs',
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/macros.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/codecs/nalu_reader.h"
|
||||
|
||||
namespace shaka {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "packager/media/codecs/dovi_decoder_configuration_record.h"
|
||||
|
||||
#include "packager/base/strings/stringprintf.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
|
||||
|
@ -30,8 +30,8 @@ std::string DOVIDecoderConfigurationRecord::GetCodecString(
|
|||
FourCC codec_fourcc) const {
|
||||
// Dolby Vision Streams within the HTTP Live Streaming format Version 2.0:
|
||||
// https://www.dolby.com/us/en/technologies/dolby-vision/dolby-vision-streams-within-the-http-live-streaming-format-v2.0.pdf
|
||||
return base::StringPrintf(
|
||||
"%s.%02d.%02d", FourCCToString(codec_fourcc).c_str(), profile_, level_);
|
||||
return absl::StrFormat("%s.%02d.%02d", FourCCToString(codec_fourcc).c_str(),
|
||||
profile_, level_);
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
#include "packager/media/codecs/ec3_audio_util.h"
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
#include "packager/utils/bytes_to_string_view.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
@ -57,7 +58,7 @@ enum kEC3AudioChannelMap {
|
|||
const size_t kChannelCountArray[] = {
|
||||
1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 1, 1,
|
||||
};
|
||||
static_assert(arraysize(kChannelCountArray) == 16u,
|
||||
static_assert(std::size(kChannelCountArray) == 16u,
|
||||
"Channel count array should have 16 entries.");
|
||||
|
||||
// EC3 Audio coding mode map (acmod) to determine EC3 audio channel layout. The
|
||||
|
@ -216,7 +217,8 @@ bool CalculateEC3ChannelMap(const std::vector<uint8_t>& ec3_data,
|
|||
if (!ExtractEc3Data(ec3_data, &audio_coding_mode, &lfe_channel_on,
|
||||
&dependent_substreams_layout, &ec3_joc_complexity)) {
|
||||
LOG(WARNING) << "Seeing invalid EC3 data: "
|
||||
<< base::HexEncode(ec3_data.data(), ec3_data.size());
|
||||
<< absl::BytesToHexString(
|
||||
byte_vector_to_string_view(ec3_data));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -279,7 +281,8 @@ bool GetEc3JocComplexity(const std::vector<uint8_t>& ec3_data,
|
|||
if (!ExtractEc3Data(ec3_data, &audio_coding_mode, &lfe_channel_on,
|
||||
&dependent_substreams_layout, ec3_joc_complexity)) {
|
||||
LOG(WARNING) << "Seeing invalid EC3 data: "
|
||||
<< base::HexEncode(ec3_data.data(), ec3_data.size());
|
||||
<< absl::BytesToHexString(
|
||||
byte_vector_to_string_view(ec3_data));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -182,7 +182,7 @@ size_t DecoderConfigDescriptor::ComputeDataSize() {
|
|||
decoder_specific_info_descriptor_.ComputeSize();
|
||||
}
|
||||
|
||||
bool SLConfigDescriptor::ReadData(BitReader* reader) {
|
||||
bool SLConfigDescriptor::ReadData(BitReader*) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <limits>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/buffer_writer.h"
|
||||
#include "packager/media/codecs/h264_parser.h"
|
||||
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/codecs/h264_byte_to_unit_stream_converter.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/media/codecs/h264_byte_to_unit_stream_converter.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "packager/media/test/test_data_util.h"
|
||||
|
||||
namespace {
|
||||
|
@ -37,9 +38,11 @@ TEST(H264ByteToUnitStreamConverter, StripParameterSetsNalu) {
|
|||
&output_frame));
|
||||
EXPECT_EQ(expected_output_frame, output_frame);
|
||||
|
||||
std::vector<uint8_t> expected_decoder_config;
|
||||
ASSERT_TRUE(base::HexStringToBytes(kExpectedConfigRecord,
|
||||
&expected_decoder_config));
|
||||
auto expected_decoder_config_str =
|
||||
absl::HexStringToBytes(kExpectedConfigRecord);
|
||||
ASSERT_FALSE(expected_decoder_config_str.empty());
|
||||
std::vector<uint8_t> expected_decoder_config(
|
||||
expected_decoder_config_str.begin(), expected_decoder_config_str.end());
|
||||
std::vector<uint8_t> decoder_config;
|
||||
ASSERT_TRUE(converter.GetDecoderConfigurationRecord(&decoder_config));
|
||||
EXPECT_EQ(expected_decoder_config, decoder_config);
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#include "packager/media/codecs/h264_parser.h"
|
||||
|
||||
#include <memory>
|
||||
#include "packager/base/logging.h"
|
||||
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/buffer_reader.h"
|
||||
|
||||
#define LOG_ERROR_ONCE(msg) \
|
||||
|
@ -180,7 +181,7 @@ static const int kTableSarWidth[] = {
|
|||
static const int kTableSarHeight[] = {
|
||||
0, 1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1
|
||||
};
|
||||
static_assert(arraysize(kTableSarWidth) == arraysize(kTableSarHeight),
|
||||
static_assert(std::size(kTableSarWidth) == std::size(kTableSarHeight),
|
||||
"sar_tables_must_have_same_size");
|
||||
|
||||
H264Parser::H264Parser() {}
|
||||
|
@ -272,7 +273,7 @@ static void FallbackScalingList4x4(
|
|||
break;
|
||||
|
||||
default:
|
||||
NOTREACHED();
|
||||
NOTIMPLEMENTED() << "index out of range [0,5]: " << i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +314,7 @@ static void FallbackScalingList8x8(
|
|||
break;
|
||||
|
||||
default:
|
||||
NOTREACHED();
|
||||
NOTIMPLEMENTED() << "index out of range [0,5]: " << i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -360,10 +361,8 @@ H264Parser::Result H264Parser::ParseSpsScalingLists(H26xBitReader* br,
|
|||
READ_BOOL_OR_RETURN(&seq_scaling_list_present_flag);
|
||||
|
||||
if (seq_scaling_list_present_flag) {
|
||||
res = ParseScalingList(br,
|
||||
arraysize(sps->scaling_list4x4[i]),
|
||||
sps->scaling_list4x4[i],
|
||||
&use_default);
|
||||
res = ParseScalingList(br, std::size(sps->scaling_list4x4[i]),
|
||||
sps->scaling_list4x4[i], &use_default);
|
||||
if (res != kOk)
|
||||
return res;
|
||||
|
||||
|
@ -381,10 +380,8 @@ H264Parser::Result H264Parser::ParseSpsScalingLists(H26xBitReader* br,
|
|||
READ_BOOL_OR_RETURN(&seq_scaling_list_present_flag);
|
||||
|
||||
if (seq_scaling_list_present_flag) {
|
||||
res = ParseScalingList(br,
|
||||
arraysize(sps->scaling_list8x8[i]),
|
||||
sps->scaling_list8x8[i],
|
||||
&use_default);
|
||||
res = ParseScalingList(br, std::size(sps->scaling_list8x8[i]),
|
||||
sps->scaling_list8x8[i], &use_default);
|
||||
if (res != kOk)
|
||||
return res;
|
||||
|
||||
|
@ -412,10 +409,8 @@ H264Parser::Result H264Parser::ParsePpsScalingLists(H26xBitReader* br,
|
|||
READ_BOOL_OR_RETURN(&pic_scaling_list_present_flag);
|
||||
|
||||
if (pic_scaling_list_present_flag) {
|
||||
res = ParseScalingList(br,
|
||||
arraysize(pps->scaling_list4x4[i]),
|
||||
pps->scaling_list4x4[i],
|
||||
&use_default);
|
||||
res = ParseScalingList(br, std::size(pps->scaling_list4x4[i]),
|
||||
pps->scaling_list4x4[i], &use_default);
|
||||
if (res != kOk)
|
||||
return res;
|
||||
|
||||
|
@ -442,10 +437,8 @@ H264Parser::Result H264Parser::ParsePpsScalingLists(H26xBitReader* br,
|
|||
READ_BOOL_OR_RETURN(&pic_scaling_list_present_flag);
|
||||
|
||||
if (pic_scaling_list_present_flag) {
|
||||
res = ParseScalingList(br,
|
||||
arraysize(pps->scaling_list8x8[i]),
|
||||
pps->scaling_list8x8[i],
|
||||
&use_default);
|
||||
res = ParseScalingList(br, std::size(pps->scaling_list8x8[i]),
|
||||
pps->scaling_list8x8[i], &use_default);
|
||||
if (res != kOk)
|
||||
return res;
|
||||
|
||||
|
@ -504,7 +497,7 @@ H264Parser::Result H264Parser::ParseVUIParameters(H26xBitReader* br,
|
|||
READ_BITS_OR_RETURN(16, &sps->sar_width);
|
||||
READ_BITS_OR_RETURN(16, &sps->sar_height);
|
||||
} else {
|
||||
const int max_aspect_ratio_idc = arraysize(kTableSarWidth) - 1;
|
||||
const int max_aspect_ratio_idc = std::size(kTableSarWidth) - 1;
|
||||
IN_RANGE_OR_RETURN(aspect_ratio_idc, 0, max_aspect_ratio_idc);
|
||||
sps->sar_width = kTableSarWidth[aspect_ratio_idc];
|
||||
sps->sar_height = kTableSarHeight[aspect_ratio_idc];
|
||||
|
@ -939,7 +932,7 @@ H264Parser::Result H264Parser::ParseDecRefPicMarking(H26xBitReader* br,
|
|||
H264DecRefPicMarking* marking;
|
||||
if (shdr->adaptive_ref_pic_marking_mode_flag) {
|
||||
size_t i;
|
||||
for (i = 0; i < arraysize(shdr->ref_pic_marking); ++i) {
|
||||
for (i = 0; i < std::size(shdr->ref_pic_marking); ++i) {
|
||||
marking = &shdr->ref_pic_marking[i];
|
||||
|
||||
READ_UE_OR_RETURN(&marking->memory_mgmnt_control_operation);
|
||||
|
@ -964,7 +957,7 @@ H264Parser::Result H264Parser::ParseDecRefPicMarking(H26xBitReader* br,
|
|||
return kInvalidStream;
|
||||
}
|
||||
|
||||
if (i == arraysize(shdr->ref_pic_marking)) {
|
||||
if (i == std::size(shdr->ref_pic_marking)) {
|
||||
LOG_ERROR_ONCE("Ran out of dec ref pic marking fields");
|
||||
return kUnsupportedStream;
|
||||
}
|
||||
|
|
|
@ -2,24 +2,17 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "packager/media/codecs/h264_parser.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/media/codecs/h264_parser.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/test/test_data_util.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
namespace {
|
||||
// SPS, PPS (for first slice), slice header from test-25fps.h264 file.
|
||||
const uint8_t kSps[] = {
|
||||
0x27, 0x4D, 0x40, 0x0D, 0xA9, 0x18, 0x28, 0x3E, 0x60, 0x0D,
|
||||
0x41, 0x80, 0x41, 0xAD, 0xB0, 0xAD, 0x7B, 0xDF, 0x01,
|
||||
};
|
||||
const uint8_t kPps[] = {
|
||||
0x28, 0xDE, 0x9, 0x88,
|
||||
};
|
||||
// This is the prefix of a video slice (including the nalu header) that only has
|
||||
// the slice header. The actual slice header size is 30 bits (not including the
|
||||
// nalu header).
|
||||
|
@ -108,15 +101,26 @@ TEST(H264ParserTest, StreamFileParsing) {
|
|||
// Verify that SliceHeader::nalu_data points to the beginning of nal unit.
|
||||
// Also verify that header_bit_size is set correctly.
|
||||
TEST(H264ParserTest, SliceHeaderSize) {
|
||||
const uint8_t kSps[] = {
|
||||
0x27, 0x4D, 0x40, 0x0D, 0xA9, 0x18, 0x28, 0x3E, 0x60, 0x0D,
|
||||
0x41, 0x80, 0x41, 0xAD, 0xB0, 0xAD, 0x7B, 0xDF, 0x01,
|
||||
};
|
||||
const uint8_t kPps[] = {
|
||||
0x28,
|
||||
0xDE,
|
||||
0x9,
|
||||
0x88,
|
||||
};
|
||||
|
||||
H264Parser parser;
|
||||
int unused_id;
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, arraysize(kSps)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, std::size(kSps)));
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &unused_id));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kPps, arraysize(kPps)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kPps, std::size(kPps)));
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParsePps(nalu, &unused_id));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kVideoSliceTrimmed,
|
||||
arraysize(kVideoSliceTrimmed)));
|
||||
std::size(kVideoSliceTrimmed)));
|
||||
|
||||
H264SliceHeader slice_header;
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParseSliceHeader(nalu, &slice_header));
|
||||
|
@ -128,13 +132,13 @@ TEST(H264ParserTest, PredWeightTable) {
|
|||
H264Parser parser;
|
||||
int unused_id;
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps2, arraysize(kSps2)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps2, std::size(kSps2)));
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &unused_id));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kPps2, arraysize(kPps2)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kPps2, std::size(kPps2)));
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParsePps(nalu, &unused_id));
|
||||
ASSERT_TRUE(
|
||||
nalu.Initialize(Nalu::kH264, kVideoSliceTrimmedMultipleLumaWeights,
|
||||
arraysize(kVideoSliceTrimmedMultipleLumaWeights)));
|
||||
std::size(kVideoSliceTrimmedMultipleLumaWeights)));
|
||||
|
||||
H264SliceHeader slice_header;
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParseSliceHeader(nalu, &slice_header));
|
||||
|
@ -196,7 +200,7 @@ TEST(H264ParserTest, ParseSps) {
|
|||
H264Parser parser;
|
||||
int sps_id = 0;
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, arraysize(kSps)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, std::size(kSps)));
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id));
|
||||
|
||||
const H264Sps* sps = parser.GetSps(sps_id);
|
||||
|
@ -217,7 +221,7 @@ TEST(H264ParserTest, ParseSpsWithTransferCharacteristics) {
|
|||
H264Parser parser;
|
||||
int sps_id = 0;
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, arraysize(kSps)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, std::size(kSps)));
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id));
|
||||
|
||||
const H264Sps* sps = parser.GetSps(sps_id);
|
||||
|
@ -237,7 +241,7 @@ TEST(H264ParserTest, ExtractResolutionFromSpsData) {
|
|||
H264Parser parser;
|
||||
int sps_id = 0;
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, arraysize(kSps)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, std::size(kSps)));
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id));
|
||||
|
||||
uint32_t coded_width = 0;
|
||||
|
@ -262,7 +266,7 @@ TEST(H264ParserTest, ExtractResolutionFromSpsDataWithCropping) {
|
|||
H264Parser parser;
|
||||
int sps_id = 0;
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, arraysize(kSps)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kSps, std::size(kSps)));
|
||||
ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id));
|
||||
|
||||
uint32_t coded_width = 0;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <limits>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/buffer_writer.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
#include "packager/media/codecs/h265_parser.h"
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/codecs/h265_byte_to_unit_stream_converter.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/media/codecs/h265_byte_to_unit_stream_converter.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "packager/media/codecs/hevc_decoder_configuration_record.h"
|
||||
#include "packager/media/test/test_data_util.h"
|
||||
|
||||
|
@ -40,9 +41,11 @@ TEST(H265ByteToUnitStreamConverter, StripParameterSetsNalu) {
|
|||
&output_frame));
|
||||
EXPECT_EQ(expected_output_frame, output_frame);
|
||||
|
||||
std::vector<uint8_t> expected_decoder_config;
|
||||
ASSERT_TRUE(base::HexStringToBytes(kExpectedConfigRecord,
|
||||
&expected_decoder_config));
|
||||
auto expected_decoder_config_str =
|
||||
absl::HexStringToBytes(kExpectedConfigRecord);
|
||||
ASSERT_FALSE(expected_decoder_config_str.empty());
|
||||
std::vector<uint8_t> expected_decoder_config(
|
||||
expected_decoder_config_str.begin(), expected_decoder_config_str.end());
|
||||
std::vector<uint8_t> decoder_config;
|
||||
ASSERT_TRUE(converter.GetDecoderConfigurationRecord(&decoder_config));
|
||||
EXPECT_EQ(expected_decoder_config, decoder_config);
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include "packager/media/codecs/h265_parser.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/macros.h"
|
||||
#include "packager/media/codecs/nalu_reader.h"
|
||||
|
||||
|
@ -884,7 +885,7 @@ H265Parser::Result H265Parser::ParseReferencePictureSet(
|
|||
|
||||
H265Parser::Result H265Parser::SkipReferencePictureListModification(
|
||||
const H265SliceHeader& slice_header,
|
||||
const H265Pps& pps,
|
||||
const H265Pps&,
|
||||
int num_pic_total_curr,
|
||||
H26xBitReader* br) {
|
||||
// Reads whole element but ignores it all.
|
||||
|
|
|
@ -245,7 +245,7 @@ struct H265SliceHeader {
|
|||
int slice_pic_order_cnt_lsb = 0;
|
||||
|
||||
bool short_term_ref_pic_set_sps_flag = false;
|
||||
H265ReferencePictureSet st_ref_pic_set;
|
||||
H265ReferencePictureSet st_ref_pic_set{};
|
||||
int short_term_ref_pic_set_idx = 0;
|
||||
|
||||
int num_long_term_sps = 0;
|
||||
|
|
|
@ -42,13 +42,13 @@ TEST(H265ParserTest, ParseSliceHeader) {
|
|||
int id;
|
||||
Nalu nalu;
|
||||
H265Parser parser;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, arraysize(kSpsData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, std::size(kSpsData)));
|
||||
ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &id));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, arraysize(kPpsData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, std::size(kPpsData)));
|
||||
ASSERT_EQ(H265Parser::kOk, parser.ParsePps(nalu, &id));
|
||||
|
||||
// Parse the slice header.
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSliceData, arraysize(kSliceData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSliceData, std::size(kSliceData)));
|
||||
ASSERT_EQ(Nalu::H265_IDR_W_RADL, nalu.type());
|
||||
|
||||
H265SliceHeader header;
|
||||
|
@ -69,14 +69,14 @@ TEST(H265ParserTest, ParseSliceHeader_NonIDR) {
|
|||
int id;
|
||||
Nalu nalu;
|
||||
H265Parser parser;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, arraysize(kSpsData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, std::size(kSpsData)));
|
||||
ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &id));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, arraysize(kPpsData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, std::size(kPpsData)));
|
||||
ASSERT_EQ(H265Parser::kOk, parser.ParsePps(nalu, &id));
|
||||
|
||||
// Parse the slice header.
|
||||
ASSERT_TRUE(
|
||||
nalu.Initialize(Nalu::kH265, kSliceData2, arraysize(kSliceData2)));
|
||||
nalu.Initialize(Nalu::kH265, kSliceData2, std::size(kSliceData2)));
|
||||
ASSERT_EQ(1 /* TRAIL_R */, nalu.type());
|
||||
|
||||
H265SliceHeader header;
|
||||
|
@ -92,7 +92,7 @@ TEST(H265ParserTest, ParseSliceHeader_NonIDR) {
|
|||
|
||||
TEST(H265ParserTest, ParseSps) {
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, arraysize(kSpsData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, std::size(kSpsData)));
|
||||
ASSERT_EQ(Nalu::H265_SPS, nalu.type());
|
||||
|
||||
int id = 12;
|
||||
|
@ -117,7 +117,7 @@ TEST(H265ParserTest, ParseSps) {
|
|||
TEST(H265ParserTest, ParseSpsWithTransferCharacteristics) {
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsDataWithTransferCharacteristics,
|
||||
arraysize(kSpsDataWithTransferCharacteristics)));
|
||||
std::size(kSpsDataWithTransferCharacteristics)));
|
||||
ASSERT_EQ(Nalu::H265_SPS, nalu.type());
|
||||
|
||||
int id = 12;
|
||||
|
@ -141,7 +141,7 @@ TEST(H265ParserTest, ParseSpsWithTransferCharacteristics) {
|
|||
|
||||
TEST(H265ParserTest, ParsePps) {
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, arraysize(kPpsData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kPpsData, std::size(kPpsData)));
|
||||
ASSERT_EQ(Nalu::H265_PPS, nalu.type());
|
||||
|
||||
int id = 12;
|
||||
|
@ -162,7 +162,7 @@ TEST(H265ParserTest, ExtractResolutionFromSpsData) {
|
|||
H265Parser parser;
|
||||
int sps_id = 0;
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, arraysize(kSpsData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH265, kSpsData, std::size(kSpsData)));
|
||||
ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &sps_id));
|
||||
|
||||
uint32_t coded_width = 0;
|
||||
|
@ -189,7 +189,7 @@ TEST(H265ParserTest, ExtractResolutionFromSpsDataWithCrop) {
|
|||
int sps_id = 0;
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(
|
||||
nalu.Initialize(Nalu::kH265, kSpsCropData, arraysize(kSpsCropData)));
|
||||
nalu.Initialize(Nalu::kH265, kSpsCropData, std::size(kSpsCropData)));
|
||||
ASSERT_EQ(H265Parser::kOk, parser.ParseSps(nalu, &sps_id));
|
||||
|
||||
uint32_t coded_width = 0;
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/media/codecs/h26x_bit_reader.h"
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
namespace {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
|
|
@ -6,16 +6,18 @@
|
|||
|
||||
#include "packager/media/codecs/h26x_byte_to_unit_stream_converter.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
#include <limits>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/buffer_writer.h"
|
||||
#include "packager/utils/bytes_to_string_view.h"
|
||||
|
||||
// TODO(kqyang): Move byte to unit stream convertion to muxer and make it a
|
||||
// muxer option.
|
||||
DEFINE_bool(strip_parameter_set_nalus,
|
||||
ABSL_FLAG(bool,
|
||||
strip_parameter_set_nalus,
|
||||
true,
|
||||
"When converting from NAL byte stream (AnnexB stream) to NAL unit "
|
||||
"stream, this flag determines whether to strip parameter sets NAL "
|
||||
|
@ -30,13 +32,13 @@ namespace {
|
|||
// Additional space to reserve for output frame. This value ought to be enough
|
||||
// to acommodate frames consisting of 100 NAL units with 3-byte start codes.
|
||||
const size_t kStreamConversionOverhead = 100;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
H26xByteToUnitStreamConverter::H26xByteToUnitStreamConverter(
|
||||
Nalu::CodecType type)
|
||||
: type_(type),
|
||||
stream_format_(
|
||||
FLAGS_strip_parameter_set_nalus
|
||||
absl::GetFlag(FLAGS_strip_parameter_set_nalus)
|
||||
? H26xStreamFormat::kNalUnitStreamWithoutParameterSetNalus
|
||||
: H26xStreamFormat::kNalUnitStreamWithParameterSetNalus) {}
|
||||
|
||||
|
@ -91,8 +93,11 @@ void H26xByteToUnitStreamConverter::WarnIfNotMatch(
|
|||
LOG(WARNING) << "Seeing varying NAL unit of type " << nalu_type
|
||||
<< ". You may need to set --strip_parameter_set_nalus=false "
|
||||
"during packaging to generate a playable stream.";
|
||||
VLOG(1) << "Old: " << base::HexEncode(vector.data(), vector.size());
|
||||
VLOG(1) << "New: " << base::HexEncode(nalu_ptr, nalu_size);
|
||||
VLOG(1) << "Old: "
|
||||
<< absl::BytesToHexString(byte_vector_to_string_view(vector));
|
||||
VLOG(1) << "New: "
|
||||
<< absl::BytesToHexString(
|
||||
byte_array_to_string_view(nalu_ptr, nalu_size));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
|
||||
#include "packager/media/codecs/hevc_decoder_configuration_record.h"
|
||||
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/string_util.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/str_join.h"
|
||||
#include "packager/media/base/buffer_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
#include "packager/media/codecs/h265_parser.h"
|
||||
#include "packager/utils/bytes_to_string_view.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
@ -57,7 +59,8 @@ std::string ReverseBitsAndHexEncode(uint32_t x) {
|
|||
static_cast<uint8_t>((x >> 8) & 0xFF),
|
||||
static_cast<uint8_t>((x >> 16) & 0xFF),
|
||||
static_cast<uint8_t>((x >> 24) & 0xFF)};
|
||||
return TrimLeadingZeros(base::HexEncode(bytes, arraysize(bytes)));
|
||||
return TrimLeadingZeros(absl::BytesToHexString(
|
||||
byte_array_to_string_view(bytes, std::size(bytes))));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -129,11 +132,11 @@ std::string HEVCDecoderConfigurationRecord::GetCodecString(
|
|||
std::vector<std::string> fields;
|
||||
fields.push_back(FourCCToString(codec_fourcc));
|
||||
fields.push_back(GeneralProfileSpaceAsString(general_profile_space_) +
|
||||
base::IntToString(general_profile_idc_));
|
||||
absl::StrFormat("%d", general_profile_idc_));
|
||||
fields.push_back(
|
||||
ReverseBitsAndHexEncode(general_profile_compatibility_flags_));
|
||||
fields.push_back((general_tier_flag_ ? "H" : "L") +
|
||||
base::IntToString(general_level_idc_));
|
||||
absl::StrFormat("%d", general_level_idc_));
|
||||
|
||||
// Remove trailing bytes that are zero.
|
||||
std::vector<uint8_t> constraints = general_constraint_indicator_flags_;
|
||||
|
@ -143,9 +146,10 @@ std::string HEVCDecoderConfigurationRecord::GetCodecString(
|
|||
}
|
||||
constraints.resize(size);
|
||||
for (uint8_t constraint : constraints)
|
||||
fields.push_back(TrimLeadingZeros(base::HexEncode(&constraint, 1)));
|
||||
fields.push_back(TrimLeadingZeros(
|
||||
absl::BytesToHexString(byte_array_to_string_view(&constraint, 1))));
|
||||
|
||||
return base::JoinString(fields, ".");
|
||||
return absl::StrJoin(fields, ".");
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
#define PACKAGER_MEDIA_CODECS_HEVC_DECODER_CONFIGURATION_RECORD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/base/fourccs.h"
|
||||
#include "packager/media/base/video_stream_info.h"
|
||||
#include "packager/media/codecs/decoder_configuration_record.h"
|
||||
|
|
|
@ -44,7 +44,7 @@ TEST(HEVCDecoderConfigurationRecordTest, Success) {
|
|||
// clang-format on
|
||||
HEVCDecoderConfigurationRecord hevc_config;
|
||||
ASSERT_TRUE(hevc_config.Parse(kHevcDecoderConfigurationData,
|
||||
arraysize(kHevcDecoderConfigurationData)));
|
||||
std::size(kHevcDecoderConfigurationData)));
|
||||
EXPECT_EQ(4u, hevc_config.nalu_length_size());
|
||||
EXPECT_EQ("hev1.2.4.L63.90", hevc_config.GetCodecString(FOURCC_hev1));
|
||||
EXPECT_EQ("hvc1.2.4.L63.90", hevc_config.GetCodecString(FOURCC_hvc1));
|
||||
|
@ -92,7 +92,7 @@ TEST(HEVCDecoderConfigurationRecordTest, SuccessWithTransferCharacteristics) {
|
|||
|
||||
HEVCDecoderConfigurationRecord hevc_config;
|
||||
ASSERT_TRUE(hevc_config.Parse(kHevcDecoderConfigurationData,
|
||||
arraysize(kHevcDecoderConfigurationData)));
|
||||
std::size(kHevcDecoderConfigurationData)));
|
||||
|
||||
EXPECT_EQ(4u, hevc_config.nalu_length_size());
|
||||
|
||||
|
@ -111,7 +111,7 @@ TEST(HEVCDecoderConfigurationRecordTest, FailOnInsufficientData) {
|
|||
|
||||
HEVCDecoderConfigurationRecord hevc_config;
|
||||
ASSERT_FALSE(hevc_config.Parse(kHevcDecoderConfigurationData,
|
||||
arraysize(kHevcDecoderConfigurationData)));
|
||||
std::size(kHevcDecoderConfigurationData)));
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <list>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/buffer_reader.h"
|
||||
#include "packager/media/base/buffer_writer.h"
|
||||
|
@ -38,7 +38,7 @@ bool IsNaluEqual(const Nalu& left, const Nalu& right) {
|
|||
}
|
||||
|
||||
void AppendNalu(const Nalu& nalu,
|
||||
int nalu_length_size,
|
||||
int /*nalu_length_size*/,
|
||||
bool escape_data,
|
||||
BufferWriter* buffer_writer) {
|
||||
if (escape_data) {
|
||||
|
@ -235,15 +235,15 @@ bool NalUnitToByteStreamConverter::Initialize(
|
|||
for (uint32_t i = 0; i < decoder_config_.nalu_count(); ++i) {
|
||||
const Nalu& nalu = decoder_config_.nalu(i);
|
||||
if (nalu.type() == Nalu::H264NaluType::H264_SPS) {
|
||||
buffer_writer.AppendArray(kNaluStartCode, arraysize(kNaluStartCode));
|
||||
buffer_writer.AppendArray(kNaluStartCode, std::size(kNaluStartCode));
|
||||
AppendNalu(nalu, nalu_length_size_, !kEscapeData, &buffer_writer);
|
||||
found_sps = true;
|
||||
} else if (nalu.type() == Nalu::H264NaluType::H264_PPS) {
|
||||
buffer_writer.AppendArray(kNaluStartCode, arraysize(kNaluStartCode));
|
||||
buffer_writer.AppendArray(kNaluStartCode, std::size(kNaluStartCode));
|
||||
AppendNalu(nalu, nalu_length_size_, !kEscapeData, &buffer_writer);
|
||||
found_pps = true;
|
||||
} else if (nalu.type() == Nalu::H264NaluType::H264_SPSExtension) {
|
||||
buffer_writer.AppendArray(kNaluStartCode, arraysize(kNaluStartCode));
|
||||
buffer_writer.AppendArray(kNaluStartCode, std::size(kNaluStartCode));
|
||||
AppendNalu(nalu, nalu_length_size_, !kEscapeData, &buffer_writer);
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ bool NalUnitToByteStreamConverter::ConvertUnitToByteStreamWithSubsamples(
|
|||
std::vector<SubsampleEntry> temp_subsamples;
|
||||
|
||||
BufferWriter buffer_writer(sample_size);
|
||||
buffer_writer.AppendArray(kNaluStartCode, arraysize(kNaluStartCode));
|
||||
buffer_writer.AppendArray(kNaluStartCode, std::size(kNaluStartCode));
|
||||
AddAccessUnitDelimiter(&buffer_writer);
|
||||
if (is_key_frame)
|
||||
buffer_writer.AppendVector(decoder_configuration_in_byte_stream_);
|
||||
|
@ -351,12 +351,12 @@ bool NalUnitToByteStreamConverter::ConvertUnitToByteStreamWithSubsamples(
|
|||
}
|
||||
}
|
||||
}
|
||||
buffer_writer.AppendArray(kNaluStartCode, arraysize(kNaluStartCode));
|
||||
buffer_writer.AppendArray(kNaluStartCode, std::size(kNaluStartCode));
|
||||
AppendNalu(nalu, nalu_length_size_, escape_data, &buffer_writer);
|
||||
|
||||
if (subsamples && !subsamples->empty()) {
|
||||
temp_subsamples.emplace_back(
|
||||
static_cast<uint16_t>(arraysize(kNaluStartCode)), 0u);
|
||||
static_cast<uint16_t>(std::size(kNaluStartCode)), 0u);
|
||||
// Update the first subsample of each NAL unit, which replaces NAL
|
||||
// unit length field with start code. Note that if the escape_data is
|
||||
// true, the total data size and the cipher_bytes may be changed.
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
#define PACKAGER_MEDIA_CODECS_NAL_UNIT_TO_BYTE_STREAM_CONVERTER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/base/decrypt_config.h"
|
||||
#include "packager/media/codecs/avc_decoder_configuration_record.h"
|
||||
|
||||
|
|
|
@ -68,10 +68,10 @@ TEST(NalUnitToByteStreamConverterTest, ParseAVCDecoderConfigurationRecord) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
}
|
||||
|
||||
// Empty AVCDecoderConfigurationRecord should return false.
|
||||
|
@ -97,7 +97,7 @@ TEST(NalUnitToByteStreamConverterTest, NoSps) {
|
|||
0x68, 0xFE, 0xFD, 0xFC, 0xFB, 0x11, 0x12, 0x13, 0x14, 0x15,
|
||||
};
|
||||
|
||||
EXPECT_FALSE(converter.Initialize(kNoSps, arraysize(kNoSps)));
|
||||
EXPECT_FALSE(converter.Initialize(kNoSps, std::size(kNoSps)));
|
||||
}
|
||||
|
||||
// If there is no PPS, Initialize() should fail.
|
||||
|
@ -119,7 +119,7 @@ TEST(NalUnitToByteStreamConverterTest, NoPps) {
|
|||
0x00, // 0 pps.
|
||||
};
|
||||
|
||||
EXPECT_FALSE(converter.Initialize(kNoPps, arraysize(kNoPps)));
|
||||
EXPECT_FALSE(converter.Initialize(kNoPps, std::size(kNoPps)));
|
||||
}
|
||||
|
||||
// If the length of SPS is 0 then Initialize() should fail.
|
||||
|
@ -138,7 +138,7 @@ TEST(NalUnitToByteStreamConverterTest, ZeroLengthSps) {
|
|||
0x68, 0xFE, 0xFD, 0xFC, 0xFB, 0x11, 0x12, 0x13, 0x14, 0x15,
|
||||
};
|
||||
|
||||
EXPECT_FALSE(converter.Initialize(kZeroLengthSps, arraysize(kZeroLengthSps)));
|
||||
EXPECT_FALSE(converter.Initialize(kZeroLengthSps, std::size(kZeroLengthSps)));
|
||||
}
|
||||
|
||||
// If the length of PPS is 0 then Initialize() should fail.
|
||||
|
@ -157,7 +157,7 @@ TEST(NalUnitToByteStreamConverterTest, ZeroLengthPps) {
|
|||
0x00, 0x00, // PPS length == 0
|
||||
};
|
||||
|
||||
EXPECT_FALSE(converter.Initialize(kZeroLengthPps, arraysize(kZeroLengthPps)));
|
||||
EXPECT_FALSE(converter.Initialize(kZeroLengthPps, std::size(kZeroLengthPps)));
|
||||
}
|
||||
|
||||
TEST(NalUnitToByteStreamConverterTest, ConvertUnitToByteStream) {
|
||||
|
@ -171,11 +171,11 @@ TEST(NalUnitToByteStreamConverterTest, ConvertUnitToByteStream) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStream(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, &output));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -197,7 +197,7 @@ TEST(NalUnitToByteStreamConverterTest, ConvertUnitToByteStream) {
|
|||
};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
}
|
||||
|
||||
|
@ -258,12 +258,12 @@ TEST(NalUnitToByteStreamConverterTest, ConvertUnitToByteStreamWithSPSExtension)
|
|||
0xFD, 0x78, 0xA4, 0xC3, 0x82, 0x62, 0x11, 0x29, 0x77,
|
||||
};
|
||||
EXPECT_TRUE(converter.Initialize(kDecoderConfigWithSpsExt,
|
||||
arraysize(kDecoderConfigWithSpsExt)));
|
||||
std::size(kDecoderConfigWithSpsExt)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStream(
|
||||
kUnitStreamLikeMediaSample,
|
||||
arraysize(kUnitStreamLikeMediaSample), kIsKeyFrame, &output));
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, &output));
|
||||
EXPECT_EQ(std::vector<uint8_t>(std::begin(kByteStreamWithSpsExtension),
|
||||
std::end(kByteStreamWithSpsExtension)),
|
||||
output);
|
||||
|
@ -280,11 +280,11 @@ TEST(NalUnitToByteStreamConverterTest, NonKeyFrameSample) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStream(kNonKeyFrameStream,
|
||||
arraysize(kNonKeyFrameStream),
|
||||
std::size(kNonKeyFrameStream),
|
||||
!kIsKeyFrame, &output));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -298,7 +298,7 @@ TEST(NalUnitToByteStreamConverterTest, NonKeyFrameSample) {
|
|||
};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
}
|
||||
|
||||
|
@ -316,11 +316,11 @@ TEST(NalUnitToByteStreamConverterTest, DispersedZeros) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStream(
|
||||
kDispersedZeros, arraysize(kDispersedZeros), !kIsKeyFrame, &output));
|
||||
kDispersedZeros, std::size(kDispersedZeros), !kIsKeyFrame, &output));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
0x00, 0x00, 0x00, 0x01, // Start code.
|
||||
|
@ -333,7 +333,7 @@ TEST(NalUnitToByteStreamConverterTest, DispersedZeros) {
|
|||
};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
}
|
||||
|
||||
|
@ -349,11 +349,11 @@ TEST(NalUnitToByteStreamConverterTest, DoNotEscape) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStream(
|
||||
kNotEscaped, arraysize(kNotEscaped), !kIsKeyFrame, &output));
|
||||
kNotEscaped, std::size(kNotEscaped), !kIsKeyFrame, &output));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
0x00, 0x00, 0x00, 0x01, // Start code.
|
||||
|
@ -366,7 +366,7 @@ TEST(NalUnitToByteStreamConverterTest, DoNotEscape) {
|
|||
};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
}
|
||||
|
||||
|
@ -389,11 +389,11 @@ TEST(NalUnitToByteStreamConverterTest, NoClearNAL) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, !kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -422,7 +422,7 @@ TEST(NalUnitToByteStreamConverterTest, NoClearNAL) {
|
|||
SubsampleEntry(58, 9), SubsampleEntry(5, 7)};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
EXPECT_EQ(kExpectedOutputSubsamples, subsamples);
|
||||
}
|
||||
|
@ -445,11 +445,11 @@ TEST(NalUnitToByteStreamConverterTest, WithSomeClearNAL) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, !kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -478,7 +478,7 @@ TEST(NalUnitToByteStreamConverterTest, WithSomeClearNAL) {
|
|||
SubsampleEntry(72, 7)};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
EXPECT_EQ(kExpectedOutputSubsamples, subsamples);
|
||||
}
|
||||
|
@ -501,11 +501,11 @@ TEST(NalUnitToByteStreamConverterTest, WithSomeClearNALAndNaluLengthSize2) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(converter.Initialize(
|
||||
kTestAVCDecoderConfigurationRecordNaluLengthSize2,
|
||||
arraysize(kTestAVCDecoderConfigurationRecordNaluLengthSize2)));
|
||||
std::size(kTestAVCDecoderConfigurationRecordNaluLengthSize2)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, !kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -532,7 +532,7 @@ TEST(NalUnitToByteStreamConverterTest, WithSomeClearNALAndNaluLengthSize2) {
|
|||
SubsampleEntry(72, 7)};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
EXPECT_EQ(kExpectedOutputSubsamples, subsamples);
|
||||
}
|
||||
|
@ -562,11 +562,11 @@ TEST(NalUnitToByteStreamConverterTest, EscapeEncryptedNalu) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
ASSERT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
!kIsKeyFrame, kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -609,11 +609,11 @@ TEST(NalUnitToByteStreamConverterTest, EncryptedNaluEndingWithZero) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
ASSERT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
!kIsKeyFrame, kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -655,11 +655,11 @@ TEST(NalUnitToByteStreamConverterTest, EncryptedPps) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, !kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
// clang-format off
|
||||
|
@ -693,7 +693,7 @@ TEST(NalUnitToByteStreamConverterTest, EncryptedPps) {
|
|||
SubsampleEntry(72, 10), SubsampleEntry(5, 7)};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
EXPECT_THAT(kExpectedOutputSubsamples, subsamples);
|
||||
}
|
||||
|
@ -722,11 +722,11 @@ TEST(NalUnitToByteStreamConverterTest, ClearPpsSame) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, !kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
// clang-format off
|
||||
|
@ -757,7 +757,7 @@ TEST(NalUnitToByteStreamConverterTest, ClearPpsSame) {
|
|||
SubsampleEntry(73, 7)};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
EXPECT_EQ(kExpectedOutputSubsamples, subsamples);
|
||||
}
|
||||
|
@ -785,11 +785,11 @@ TEST(NalUnitToByteStreamConverterTest, ClearPpsDifferent) {
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, !kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
// clang-format off
|
||||
|
@ -823,7 +823,7 @@ TEST(NalUnitToByteStreamConverterTest, ClearPpsDifferent) {
|
|||
SubsampleEntry(87, 7)};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
EXPECT_EQ(kExpectedOutputSubsamples, subsamples);
|
||||
}
|
||||
|
@ -851,11 +851,11 @@ TEST(NalUnitToByteStreamConverterTest,
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, !kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -882,7 +882,7 @@ TEST(NalUnitToByteStreamConverterTest,
|
|||
SubsampleEntry(72, 7)};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
EXPECT_EQ(kExpectedOutputSubsamples, subsamples);
|
||||
}
|
||||
|
@ -913,11 +913,11 @@ TEST(NalUnitToByteStreamConverterTest,
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
kUnitStreamLikeMediaSample, arraysize(kUnitStreamLikeMediaSample),
|
||||
kUnitStreamLikeMediaSample, std::size(kUnitStreamLikeMediaSample),
|
||||
kIsKeyFrame, !kEscapeEncryptedNalu, &output, &subsamples));
|
||||
|
||||
const uint8_t kExpectedOutput[] = {
|
||||
|
@ -947,7 +947,7 @@ TEST(NalUnitToByteStreamConverterTest,
|
|||
SubsampleEntry(72, 5), SubsampleEntry(6, 4)};
|
||||
|
||||
EXPECT_EQ(std::vector<uint8_t>(kExpectedOutput,
|
||||
kExpectedOutput + arraysize(kExpectedOutput)),
|
||||
kExpectedOutput + std::size(kExpectedOutput)),
|
||||
output);
|
||||
EXPECT_EQ(kExpectedOutputSubsamples, subsamples);
|
||||
}
|
||||
|
@ -997,7 +997,7 @@ TEST(NalUnitToByteStreamConverterTest,
|
|||
NalUnitToByteStreamConverter converter;
|
||||
EXPECT_TRUE(
|
||||
converter.Initialize(kTestAVCDecoderConfigurationRecord,
|
||||
arraysize(kTestAVCDecoderConfigurationRecord)));
|
||||
std::size(kTestAVCDecoderConfigurationRecord)));
|
||||
|
||||
std::vector<uint8_t> output;
|
||||
EXPECT_TRUE(converter.ConvertUnitToByteStreamWithSubsamples(
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/buffer_reader.h"
|
||||
#include "packager/media/codecs/h264_parser.h"
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "packager/base/compiler_specific.h"
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/base/decrypt_config.h"
|
||||
|
||||
namespace shaka {
|
||||
|
@ -89,9 +88,9 @@ class Nalu {
|
|||
|
||||
Nalu();
|
||||
|
||||
bool Initialize(CodecType type,
|
||||
[[nodiscard]] bool Initialize(CodecType type,
|
||||
const uint8_t* data,
|
||||
uint64_t size) WARN_UNUSED_RESULT;
|
||||
uint64_t size);
|
||||
|
||||
/// This is the pointer to the Nalu data, pointing to the header.
|
||||
const uint8_t* data() const { return data_; }
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packager/media/codecs/nalu_reader.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
|
@ -21,7 +21,7 @@ TEST(NaluReaderTest, StartCodeSearch) {
|
|||
};
|
||||
|
||||
NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, kNaluData,
|
||||
arraysize(kNaluData));
|
||||
std::size(kNaluData));
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -55,7 +55,7 @@ TEST(NaluReaderTest, StartCodeSearchWithStartCodeInsideNalUnit) {
|
|||
};
|
||||
|
||||
NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, kNaluData,
|
||||
arraysize(kNaluData));
|
||||
std::size(kNaluData));
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -83,7 +83,7 @@ TEST(NaluReaderTest, OneByteNaluLength) {
|
|||
0x06, 0x67, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
|
||||
};
|
||||
|
||||
NaluReader reader(Nalu::kH264, 1, kNaluData, arraysize(kNaluData));
|
||||
NaluReader reader(Nalu::kH264, 1, kNaluData, std::size(kNaluData));
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -111,7 +111,7 @@ TEST(NaluReaderTest, FourByteNaluLength) {
|
|||
0x00, 0x00, 0x00, 0x03, 0x67, 0x0a, 0x0b,
|
||||
};
|
||||
|
||||
NaluReader reader(Nalu::kH264, 4, kNaluData, arraysize(kNaluData));
|
||||
NaluReader reader(Nalu::kH264, 4, kNaluData, std::size(kNaluData));
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -137,7 +137,7 @@ TEST(NaluReaderTest, ErrorForNotEnoughForNaluLength) {
|
|||
0x00,
|
||||
};
|
||||
|
||||
NaluReader reader(Nalu::kH264, 3, kNaluData, arraysize(kNaluData));
|
||||
NaluReader reader(Nalu::kH264, 3, kNaluData, std::size(kNaluData));
|
||||
|
||||
Nalu nalu;
|
||||
EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu));
|
||||
|
@ -149,7 +149,7 @@ TEST(NaluReaderTest, ErrorForNaluLengthExceedsRemainingData) {
|
|||
0xFF, 0x08, 0x00,
|
||||
};
|
||||
|
||||
NaluReader reader(Nalu::kH264, 1, kNaluData, arraysize(kNaluData));
|
||||
NaluReader reader(Nalu::kH264, 1, kNaluData, std::size(kNaluData));
|
||||
|
||||
Nalu nalu;
|
||||
EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu));
|
||||
|
@ -160,7 +160,7 @@ TEST(NaluReaderTest, ErrorForNaluLengthExceedsRemainingData) {
|
|||
0x04, 0x08, 0x00, 0x00,
|
||||
};
|
||||
|
||||
NaluReader reader2(Nalu::kH264, 1, kNaluData2, arraysize(kNaluData2));
|
||||
NaluReader reader2(Nalu::kH264, 1, kNaluData2, std::size(kNaluData2));
|
||||
EXPECT_EQ(NaluReader::kInvalidStream, reader2.Advance(&nalu));
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ TEST(NaluReaderTest, ErrorForForbiddenBitSet) {
|
|||
0x03, 0x80, 0x00, 0x00,
|
||||
};
|
||||
|
||||
NaluReader reader(Nalu::kH264, 1, kNaluData, arraysize(kNaluData));
|
||||
NaluReader reader(Nalu::kH264, 1, kNaluData, std::size(kNaluData));
|
||||
|
||||
Nalu nalu;
|
||||
EXPECT_EQ(NaluReader::kInvalidStream, reader.Advance(&nalu));
|
||||
|
@ -199,7 +199,7 @@ TEST(NaluReaderTest, SubsamplesAnnexB) {
|
|||
std::vector<SubsampleEntry> subsamples;
|
||||
subsamples.emplace_back(SubsampleEntry(4, 9));
|
||||
NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, kNaluData,
|
||||
arraysize(kNaluData), subsamples);
|
||||
std::size(kNaluData), subsamples);
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -225,7 +225,7 @@ TEST(NaluReaderTest, MultiSubsamplesAnnexB) {
|
|||
subsamples.emplace_back(SubsampleEntry(1, 3));
|
||||
subsamples.emplace_back(SubsampleEntry(4, 5));
|
||||
NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, kNaluData,
|
||||
arraysize(kNaluData), subsamples);
|
||||
std::size(kNaluData), subsamples);
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -251,7 +251,7 @@ TEST(NaluReaderTest, BufferBiggerThanSubsamplesAnnexB) {
|
|||
std::vector<SubsampleEntry> subsamples;
|
||||
subsamples.emplace_back(SubsampleEntry(4, 9));
|
||||
NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, kNaluData,
|
||||
arraysize(kNaluData), subsamples);
|
||||
std::size(kNaluData), subsamples);
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -299,7 +299,7 @@ TEST(NaluReaderTest, SubsamplesWithInvalidNalu) {
|
|||
subsamples.emplace_back(SubsampleEntry(4, 4));
|
||||
|
||||
NaluReader reader(Nalu::kH264, kIsAnnexbByteStream, kNaluData,
|
||||
arraysize(kNaluData), subsamples);
|
||||
std::size(kNaluData), subsamples);
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -324,7 +324,7 @@ TEST(NaluReaderTest, FindStartCodeInClearRangeNoNalu) {
|
|||
uint64_t offset = 0;
|
||||
uint8_t start_code_size = 0;
|
||||
EXPECT_FALSE(NaluReader::FindStartCodeInClearRange(
|
||||
kNaluData, arraysize(kNaluData), &offset, &start_code_size, subsamples));
|
||||
kNaluData, std::size(kNaluData), &offset, &start_code_size, subsamples));
|
||||
EXPECT_GT(offset, 4u)
|
||||
<< "Expect at least the subsample region should be consumed.";
|
||||
}
|
||||
|
@ -343,8 +343,8 @@ TEST(NaluReaderTest, FindStartCodeInClearRangeSubsamplesBiggerThanBuffer) {
|
|||
uint64_t offset;
|
||||
uint8_t start_code_size;
|
||||
EXPECT_FALSE(NaluReader::FindStartCodeInClearRange(
|
||||
kNaluData, arraysize(kNaluData), &offset, &start_code_size, subsamples));
|
||||
EXPECT_LE(offset, arraysize(kNaluData));
|
||||
kNaluData, std::size(kNaluData), &offset, &start_code_size, subsamples));
|
||||
EXPECT_LE(offset, std::size(kNaluData));
|
||||
}
|
||||
|
||||
// Verify that it doesn't affect the Nalu stream mode too much.
|
||||
|
@ -358,8 +358,8 @@ TEST(NaluReaderTest, SubsamplesNaluStream) {
|
|||
};
|
||||
std::vector<SubsampleEntry> subsamples;
|
||||
subsamples.emplace_back(SubsampleEntry(2, 9));
|
||||
NaluReader reader(Nalu::kH264, 1, kNaluData,
|
||||
arraysize(kNaluData), subsamples);
|
||||
NaluReader reader(Nalu::kH264, 1, kNaluData, std::size(kNaluData),
|
||||
subsamples);
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
@ -386,8 +386,8 @@ TEST(NaluReaderTest, EncryptedNaluLengthNaluStream) {
|
|||
std::vector<SubsampleEntry> subsamples;
|
||||
subsamples.emplace_back(SubsampleEntry(3, 9));
|
||||
subsamples.emplace_back(SubsampleEntry(1, 2));
|
||||
NaluReader reader(Nalu::kH264, 2, kNaluData,
|
||||
arraysize(kNaluData), subsamples);
|
||||
NaluReader reader(Nalu::kH264, 2, kNaluData, std::size(kNaluData),
|
||||
subsamples);
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_EQ(NaluReader::kOk, reader.Advance(&nalu));
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packager/media/codecs/video_slice_header_parser.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
|
@ -36,13 +36,13 @@ TEST(H264VideoSliceHeaderParserTest, BasicSupport) {
|
|||
0xc8, 0xc3, 0xa5, 0xcb, 0x77, 0x60, 0x50, 0x85, 0xd9, 0xfc
|
||||
};
|
||||
const std::vector<uint8_t> extra_data(kExtraData,
|
||||
kExtraData + arraysize(kExtraData));
|
||||
kExtraData + std::size(kExtraData));
|
||||
|
||||
H264VideoSliceHeaderParser parser;
|
||||
ASSERT_TRUE(parser.Initialize(extra_data));
|
||||
|
||||
Nalu nalu;
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kData, arraysize(kData)));
|
||||
ASSERT_TRUE(nalu.Initialize(Nalu::kH264, kData, std::size(kData)));
|
||||
// Real header size is 34 bits, but we round up to 5 bytes.
|
||||
EXPECT_EQ(5, parser.GetHeaderSize(nalu));
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ TEST(H264VideoSliceHeaderParserTest, SupportsMultipleEntriesInExtraData) {
|
|||
0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0
|
||||
};
|
||||
const std::vector<uint8_t> extra_data(kExtraData,
|
||||
kExtraData + arraysize(kExtraData));
|
||||
kExtraData + std::size(kExtraData));
|
||||
|
||||
H264VideoSliceHeaderParser parser;
|
||||
EXPECT_TRUE(parser.Initialize(extra_data));
|
||||
|
@ -108,7 +108,7 @@ TEST(H264VideoSliceHeaderParserTest, IgnoresExtraDataAtEnd) {
|
|||
0x00, 0x19, 0x67, 0x64, 0x00
|
||||
};
|
||||
const std::vector<uint8_t> extra_data(kExtraData,
|
||||
kExtraData + arraysize(kExtraData));
|
||||
kExtraData + std::size(kExtraData));
|
||||
|
||||
H264VideoSliceHeaderParser parser;
|
||||
EXPECT_TRUE(parser.Initialize(extra_data));
|
||||
|
@ -128,7 +128,7 @@ TEST(H264VideoSliceHeaderParserTest, ErrorsForEOSAfterEntry) {
|
|||
0x96,
|
||||
};
|
||||
const std::vector<uint8_t> extra_data(kExtraData,
|
||||
kExtraData + arraysize(kExtraData));
|
||||
kExtraData + std::size(kExtraData));
|
||||
|
||||
H264VideoSliceHeaderParser parser;
|
||||
EXPECT_FALSE(parser.Initialize(extra_data));
|
||||
|
@ -145,7 +145,7 @@ TEST(H264VideoSliceHeaderParserTest, ErrorsForEOSWithinEntry) {
|
|||
0x67, 0x64, 0x00, 0x1e, 0xac, 0xd9, 0x40, 0xa0,
|
||||
};
|
||||
const std::vector<uint8_t> extra_data(kExtraData,
|
||||
kExtraData + arraysize(kExtraData));
|
||||
kExtraData + std::size(kExtraData));
|
||||
|
||||
H264VideoSliceHeaderParser parser;
|
||||
EXPECT_FALSE(parser.Initialize(extra_data));
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "packager/media/codecs/vp8_parser.h"
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/codecs/vpx_parser.h"
|
||||
|
||||
namespace shaka {
|
||||
|
|
|
@ -38,14 +38,14 @@ TEST(VP8ParserTest, Keyframe) {
|
|||
0x63, 0x3f, 0xbb, 0xe5, 0xcf, 0x9b, 0x7d, 0x53, 0xec, 0x67, 0xa2, 0xcf,
|
||||
};
|
||||
|
||||
EXPECT_TRUE(VP8Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_TRUE(VP8Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP8Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_EQ("vp08.02.10.08.01.02.02.02.00",
|
||||
parser.codec_config().GetCodecString(kCodecVP8));
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(arraysize(kData), 22u, true,
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(std::size(kData), 22u, true,
|
||||
320u, 240u)));
|
||||
}
|
||||
|
||||
|
@ -56,21 +56,21 @@ TEST(VP8ParserTest, NonKeyframe) {
|
|||
0x34, 0x7b, 0x47, 0xfc, 0x2d, 0xaa, 0x0b, 0xbb, 0xc6, 0xc3, 0xc1, 0x12,
|
||||
};
|
||||
|
||||
EXPECT_FALSE(VP8Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_FALSE(VP8Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP8Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_THAT(frames,
|
||||
ElementsAre(EqualVPxFrame(arraysize(kData), 8u, false, 0u, 0u)));
|
||||
ElementsAre(EqualVPxFrame(std::size(kData), 8u, false, 0u, 0u)));
|
||||
}
|
||||
|
||||
TEST(VP8ParserTest, InsufficientData) {
|
||||
const uint8_t kData[] = {0x00, 0x0a};
|
||||
EXPECT_FALSE(VP8Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_FALSE(VP8Parser::IsKeyframe(kData, std::size(kData)));
|
||||
VP8Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_FALSE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_FALSE(parser.Parse(kData, std::size(kData), &frames));
|
||||
}
|
||||
|
||||
TEST(VP8ParserTest, CorruptedSynccode) {
|
||||
|
@ -79,10 +79,10 @@ TEST(VP8ParserTest, CorruptedSynccode) {
|
|||
0x08, 0x85, 0x85, 0x88, 0x85, 0x84, 0x88, 0x01, 0x24, 0x10, 0x17, 0x67,
|
||||
0x63, 0x3f, 0xbb, 0xe5, 0xcf, 0x9b, 0x7d, 0x53, 0xec, 0x67, 0xa2, 0xcf,
|
||||
};
|
||||
EXPECT_FALSE(VP8Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_FALSE(VP8Parser::IsKeyframe(kData, std::size(kData)));
|
||||
VP8Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_FALSE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_FALSE(parser.Parse(kData, std::size(kData), &frames));
|
||||
}
|
||||
|
||||
TEST(VP8ParserTest, NotEnoughBytesForHeaderSize) {
|
||||
|
@ -94,11 +94,11 @@ TEST(VP8ParserTest, NotEnoughBytesForHeaderSize) {
|
|||
|
||||
// IsKeyframe only parses the bytes that is necessary to determine whether it
|
||||
// is a keyframe.
|
||||
EXPECT_TRUE(VP8Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_TRUE(VP8Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP8Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
EXPECT_FALSE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
EXPECT_FALSE(parser.Parse(kData, std::size(kData), &frames));
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "packager/media/codecs/vp9_parser.h"
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "glog/logging.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
|
||||
|
@ -122,7 +122,7 @@ bool ParseIfSuperframeIndex(const uint8_t* data,
|
|||
|
||||
data += data_size - index_size + 1;
|
||||
size_t total_frame_sizes = 0;
|
||||
for (size_t i = 0; i < num_frames; ++i) {
|
||||
for (size_t frame = 0; frame < num_frames; ++frame) {
|
||||
vpx_frame.frame_size = 0;
|
||||
for (size_t i = 0; i < frame_size_length; ++i) {
|
||||
vpx_frame.frame_size |= *data << (i * 8);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/codecs/vpx_parser.h"
|
||||
|
||||
namespace shaka {
|
||||
|
|
|
@ -47,17 +47,17 @@ TEST(VP9ParserTest, Superframe) {
|
|||
0xc9, 0x3c, 0x00, 0x48, 0x00, 0xc9,
|
||||
};
|
||||
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(data, arraysize(data)));
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(data, std::size(data)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(data, arraysize(data), &frames));
|
||||
ASSERT_TRUE(parser.Parse(data, std::size(data), &frames));
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(60u, 13u, false, 0u, 0u),
|
||||
EqualVPxFrame(72u, 13u, false, 0u, 0u)));
|
||||
|
||||
// Corrupt super frame marker.
|
||||
data[arraysize(data) - 6] = 0xc0;
|
||||
ASSERT_FALSE(parser.Parse(data, arraysize(data), &frames));
|
||||
data[std::size(data) - 6] = 0xc0;
|
||||
ASSERT_FALSE(parser.Parse(data, std::size(data), &frames));
|
||||
}
|
||||
|
||||
TEST(VP9ParserTest, KeyframeChroma420) {
|
||||
|
@ -71,15 +71,15 @@ TEST(VP9ParserTest, KeyframeChroma420) {
|
|||
0x35, 0x7a, 0x88, 0x69, 0xf7, 0x1f, 0x26, 0x8b,
|
||||
};
|
||||
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_EQ("vp09.00.10.08.01.02.02.02.00",
|
||||
parser.codec_config().GetCodecString(kCodecVP9));
|
||||
EXPECT_THAT(frames,
|
||||
ElementsAre(EqualVPxFrame(arraysize(kData), 18u, true, 32u, 8u)));
|
||||
ElementsAre(EqualVPxFrame(std::size(kData), 18u, true, 32u, 8u)));
|
||||
}
|
||||
|
||||
TEST(VP9ParserTest, KeyframeProfile1Chroma422) {
|
||||
|
@ -93,14 +93,14 @@ TEST(VP9ParserTest, KeyframeProfile1Chroma422) {
|
|||
0xa0, 0x96, 0xa7, 0xb8, 0xf4, 0xb4, 0x65, 0xff,
|
||||
};
|
||||
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_EQ("vp09.01.10.08.02.02.02.02.00",
|
||||
parser.codec_config().GetCodecString(kCodecVP9));
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(arraysize(kData), 18u, true,
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(std::size(kData), 18u, true,
|
||||
160u, 90u)));
|
||||
}
|
||||
|
||||
|
@ -115,14 +115,14 @@ TEST(VP9ParserTest, KeyframeProfile2Chroma420) {
|
|||
0xa4, 0xdf, 0x05, 0xaf, 0x6f, 0xff, 0xd1, 0x74,
|
||||
};
|
||||
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_EQ("vp09.02.10.10.01.02.02.02.00",
|
||||
parser.codec_config().GetCodecString(kCodecVP9));
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(arraysize(kData), 18u, true,
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(std::size(kData), 18u, true,
|
||||
160u, 90u)));
|
||||
}
|
||||
|
||||
|
@ -137,14 +137,15 @@ TEST(VP9ParserTest, KeyframeProfile3Chroma444) {
|
|||
0xe1, 0xe6, 0xef, 0xff, 0xfd, 0xf7, 0x4f, 0x0f,
|
||||
};
|
||||
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_EQ("vp09.03.10.12.03.02.02.02.00",
|
||||
parser.codec_config().GetCodecString(kCodecVP9));
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(arraysize(kData), 19u, true, 160u, 90u)));
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(std::size(kData), 19u, true,
|
||||
160u, 90u)));
|
||||
}
|
||||
|
||||
TEST(VP9ParserTest, Intra) {
|
||||
|
@ -159,25 +160,25 @@ TEST(VP9ParserTest, Intra) {
|
|||
|
||||
};
|
||||
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_EQ("vp09.00.10.08.01.02.02.02.00",
|
||||
parser.codec_config().GetCodecString(kCodecVP9));
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(arraysize(kData), 19u, false,
|
||||
EXPECT_THAT(frames, ElementsAre(EqualVPxFrame(std::size(kData), 19u, false,
|
||||
352u, 288u)));
|
||||
}
|
||||
|
||||
TEST(VP9ParserTest, ShowExisting) {
|
||||
const uint8_t kData[] = {0x88};
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_THAT(frames,
|
||||
ElementsAre(EqualVPxFrame(arraysize(kData), 1u, false, 0u, 0u)));
|
||||
ElementsAre(EqualVPxFrame(std::size(kData), 1u, false, 0u, 0u)));
|
||||
}
|
||||
|
||||
TEST(VP9ParserTest, Interframe) {
|
||||
|
@ -191,21 +192,21 @@ TEST(VP9ParserTest, Interframe) {
|
|||
0x90, 0xeb, 0x8c, 0xad, 0x5f, 0x69, 0xb7, 0x9b,
|
||||
};
|
||||
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_TRUE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_TRUE(parser.Parse(kData, std::size(kData), &frames));
|
||||
EXPECT_THAT(frames,
|
||||
ElementsAre(EqualVPxFrame(arraysize(kData), 10u, false, 0u, 0u)));
|
||||
ElementsAre(EqualVPxFrame(std::size(kData), 10u, false, 0u, 0u)));
|
||||
}
|
||||
|
||||
TEST(VP9ParserTest, CorruptedFrameMarker) {
|
||||
const uint8_t kData[] = {0xc8};
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_FALSE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_FALSE(parser.Parse(kData, std::size(kData), &frames));
|
||||
}
|
||||
|
||||
TEST(VP9ParserTest, CorruptedSynccode) {
|
||||
|
@ -219,11 +220,11 @@ TEST(VP9ParserTest, CorruptedSynccode) {
|
|||
0x35, 0x7a, 0x88, 0x69, 0xf7, 0x1f, 0x26, 0x8b,
|
||||
};
|
||||
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_FALSE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
ASSERT_FALSE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
ASSERT_FALSE(parser.Parse(kData, std::size(kData), &frames));
|
||||
}
|
||||
|
||||
TEST(VP9ParserTest, NotEnoughBytesForHeaderSize) {
|
||||
|
@ -239,11 +240,11 @@ TEST(VP9ParserTest, NotEnoughBytesForHeaderSize) {
|
|||
|
||||
// IsKeyframe only parses the bytes that is necessary to determine whether it
|
||||
// is a keyframe.
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, arraysize(kData)));
|
||||
EXPECT_TRUE(VP9Parser::IsKeyframe(kData, std::size(kData)));
|
||||
|
||||
VP9Parser parser;
|
||||
std::vector<VPxFrameInfo> frames;
|
||||
EXPECT_FALSE(parser.Parse(kData, arraysize(kData), &frames));
|
||||
EXPECT_FALSE(parser.Parse(kData, std::size(kData), &frames));
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
|
||||
#include "packager/media/codecs/vp_codec_configuration_record.h"
|
||||
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/string_util.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/str_replace.h"
|
||||
#include "packager/media/base/bit_reader.h"
|
||||
#include "packager/media/base/buffer_reader.h"
|
||||
#include "packager/media/base/buffer_writer.h"
|
||||
#include "packager/media/base/rcheck.h"
|
||||
#include "packager/base/strings/stringprintf.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
@ -38,8 +37,8 @@ std::string VPCodecAsString(Codec codec) {
|
|||
|
||||
template <typename T>
|
||||
void MergeField(const std::string& name,
|
||||
const base::Optional<T>& source_value,
|
||||
base::Optional<T>* dest_value) {
|
||||
const std::optional<T>& source_value,
|
||||
std::optional<T>* dest_value) {
|
||||
if (*dest_value) {
|
||||
if (source_value && *source_value != **dest_value) {
|
||||
LOG(WARNING) << "VPx " << name << " is inconsistent, "
|
||||
|
@ -295,13 +294,13 @@ void VPCodecConfigurationRecord::WriteWebM(std::vector<uint8_t>* data) const {
|
|||
|
||||
std::string VPCodecConfigurationRecord::GetCodecString(Codec codec) const {
|
||||
const std::string fields[] = {
|
||||
base::IntToString(profile()),
|
||||
base::IntToString(level()),
|
||||
base::IntToString(bit_depth()),
|
||||
base::IntToString(chroma_subsampling()),
|
||||
base::IntToString(color_primaries()),
|
||||
base::IntToString(transfer_characteristics()),
|
||||
base::IntToString(matrix_coefficients()),
|
||||
absl::StrFormat("%d", profile()),
|
||||
absl::StrFormat("%d", level()),
|
||||
absl::StrFormat("%d", bit_depth()),
|
||||
absl::StrFormat("%d", chroma_subsampling()),
|
||||
absl::StrFormat("%d", color_primaries()),
|
||||
absl::StrFormat("%d", transfer_characteristics()),
|
||||
absl::StrFormat("%d", matrix_coefficients()),
|
||||
(video_full_range_flag_ && *video_full_range_flag_) ? "01" : "00",
|
||||
};
|
||||
|
||||
|
@ -309,9 +308,9 @@ std::string VPCodecConfigurationRecord::GetCodecString(Codec codec) const {
|
|||
for (const std::string& field : fields) {
|
||||
// Make sure every field is at least 2-chars wide. The space will be
|
||||
// replaced with '0' afterwards.
|
||||
base::StringAppendF(&codec_string, ".%2s", field.c_str());
|
||||
absl::StrAppendFormat(&codec_string, ".%2s", field.c_str());
|
||||
}
|
||||
base::ReplaceChars(codec_string, " ", "0", &codec_string);
|
||||
absl::StrReplaceAll({{" ", "0"}}, &codec_string);
|
||||
return codec_string;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
#define PACKAGER_MEDIA_CODECS_VP_CODEC_CONFIGURATION_RECORD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/base/optional.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/base/video_stream_info.h"
|
||||
|
||||
namespace shaka {
|
||||
|
@ -268,25 +269,25 @@ class VPCodecConfigurationRecord {
|
|||
return matrix_coefficients_.value_or(AVCOL_SPC_UNSPECIFIED);
|
||||
}
|
||||
uint8_t chroma_location() const {
|
||||
return chroma_location_ ? *chroma_location_ : AVCHROMA_LOC_UNSPECIFIED;
|
||||
return chroma_location_.value_or(AVCHROMA_LOC_UNSPECIFIED);
|
||||
}
|
||||
|
||||
private:
|
||||
void UpdateChromaSubsamplingIfNeeded();
|
||||
|
||||
base::Optional<uint8_t> profile_;
|
||||
base::Optional<uint8_t> level_;
|
||||
base::Optional<uint8_t> bit_depth_;
|
||||
base::Optional<uint8_t> chroma_subsampling_;
|
||||
base::Optional<bool> video_full_range_flag_;
|
||||
base::Optional<uint8_t> color_primaries_;
|
||||
base::Optional<uint8_t> transfer_characteristics_;
|
||||
base::Optional<uint8_t> matrix_coefficients_;
|
||||
std::optional<uint8_t> profile_;
|
||||
std::optional<uint8_t> level_;
|
||||
std::optional<uint8_t> bit_depth_;
|
||||
std::optional<uint8_t> chroma_subsampling_;
|
||||
std::optional<bool> video_full_range_flag_;
|
||||
std::optional<uint8_t> color_primaries_;
|
||||
std::optional<uint8_t> transfer_characteristics_;
|
||||
std::optional<uint8_t> matrix_coefficients_;
|
||||
std::vector<uint8_t> codec_initialization_data_;
|
||||
|
||||
// Not in the decoder config. It is there to help determine chroma subsampling
|
||||
// format.
|
||||
base::Optional<uint8_t> chroma_location_;
|
||||
std::optional<uint8_t> chroma_location_;
|
||||
// Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
|
||||
// generated copy constructor and assignment operator. Since the internal data
|
||||
// is small, the performance impact is minimal.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "packager/base/macros.h"
|
||||
#include "packager/macros.h"
|
||||
#include "packager/media/codecs/vp_codec_configuration_record.h"
|
||||
|
||||
namespace shaka {
|
||||
|
|
|
@ -346,8 +346,8 @@ inline bool operator==(const SoundMediaHeader& lhs,
|
|||
return lhs.balance == rhs.balance;
|
||||
}
|
||||
|
||||
inline bool operator==(const SubtitleMediaHeader& lhs,
|
||||
const SubtitleMediaHeader& rhs) {
|
||||
inline bool operator==(const SubtitleMediaHeader& /*lhs*/,
|
||||
const SubtitleMediaHeader& /*rhs*/) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,8 @@ inline bool operator==(const CuePayloadBox& lhs,
|
|||
return lhs.cue_text == rhs.cue_text;
|
||||
}
|
||||
|
||||
inline bool operator==(const VTTEmptyCueBox& lhs, const VTTEmptyCueBox& rhs) {
|
||||
inline bool operator==(const VTTEmptyCueBox& /*lhs*/,
|
||||
const VTTEmptyCueBox& /*rhs*/) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2022 Google LLC. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#ifndef PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_
|
||||
#define PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace shaka {
|
||||
|
||||
/// Convert byte array to string_view
|
||||
inline std::string_view byte_array_to_string_view(const uint8_t* bytes,
|
||||
size_t bytes_size) {
|
||||
return {reinterpret_cast<const char*>(bytes), bytes_size};
|
||||
}
|
||||
|
||||
/// Convert byte vector to string_view
|
||||
inline std::string_view byte_vector_to_string_view(
|
||||
const std::vector<uint8_t>& bytes) {
|
||||
return byte_array_to_string_view(bytes.data(), bytes.size());
|
||||
}
|
||||
|
||||
} // namespace shaka
|
||||
#endif // PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_
|
Loading…
Reference in New Issue