From bc4c511ad49a97293ea30f95f13984eef0d14675 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Fri, 24 Mar 2017 10:21:05 -0700 Subject: [PATCH] Fix Windows build break (#217) Change-Id: Id0a00c01077adb97f294c68357b629441321e6c7 --- .../media/codecs/nal_unit_to_byte_stream_converter.cc | 8 +++++--- packager/media/formats/mp4/fragmenter.cc | 4 ++-- packager/media/formats/webm/encryptor_unittest.cc | 5 ++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packager/media/codecs/nal_unit_to_byte_stream_converter.cc b/packager/media/codecs/nal_unit_to_byte_stream_converter.cc index a2cdc37cd4..42903183d6 100644 --- a/packager/media/codecs/nal_unit_to_byte_stream_converter.cc +++ b/packager/media/codecs/nal_unit_to_byte_stream_converter.cc @@ -190,6 +190,8 @@ bool NalUnitToByteStreamConverter::ConvertUnitToByteStreamWithSubsamples( buffer_writer.AppendVector(decoder_configuration_in_byte_stream_); int adjustment = static_cast(buffer_writer.Size()); + const int start_code_size_adjustment = + arraysize(kNaluStartCode) - nalu_length_size_; size_t subsample_id = 0; NaluReader nalu_reader(Nalu::kH264, nalu_length_size_, sample, sample_size); @@ -237,15 +239,15 @@ bool NalUnitToByteStreamConverter::ConvertUnitToByteStreamWithSubsamples( DCHECK_LT(old_nalu_size, subsamples->at(subsample_id).clear_bytes); subsamples->at(subsample_id).clear_bytes -= static_cast(old_nalu_size); - adjustment += static_cast(old_nalu_size) + - arraysize(kNaluStartCode) - nalu_length_size_; + adjustment += + static_cast(old_nalu_size) + start_code_size_adjustment; } else { if (escape_encrypted_nalu) escape_data = subsamples->at(subsample_id).cipher_bytes != 0; // Apply the adjustment on the current subsample, reset the // adjustment and move to the next subsample. subsamples->at(subsample_id).clear_bytes += - adjustment + arraysize(kNaluStartCode) - nalu_length_size_; + adjustment + start_code_size_adjustment; subsample_id++; adjustment = 0; } diff --git a/packager/media/formats/mp4/fragmenter.cc b/packager/media/formats/mp4/fragmenter.cc index 94675c2be2..85fcf5044f 100644 --- a/packager/media/formats/mp4/fragmenter.cc +++ b/packager/media/formats/mp4/fragmenter.cc @@ -239,8 +239,8 @@ Status Fragmenter::FinalizeFragmentForEncryption() { !sample_encryption_entry.subsamples.empty(); if (use_subsample_encryption) traf_->sample_encryption.flags |= SampleEncryption::kUseSubsampleEncryption; - traf_->sample_encryption.iv_size = - sample_encryption_entry.initialization_vector.size(); + traf_->sample_encryption.iv_size = static_cast( + sample_encryption_entry.initialization_vector.size()); // The offset will be adjusted in Segmenter after knowing moof size. traf_->auxiliary_offset.offsets.push_back(0); diff --git a/packager/media/formats/webm/encryptor_unittest.cc b/packager/media/formats/webm/encryptor_unittest.cc index 24c23770b7..42155450f1 100644 --- a/packager/media/formats/webm/encryptor_unittest.cc +++ b/packager/media/formats/webm/encryptor_unittest.cc @@ -38,11 +38,10 @@ TEST(EncryptionUtilTest, UpdateTrack) { } TEST(EncryptionUtilTest, UpdateTrackWithEmptyKeyId) { - const uint8_t kKeyId[] = {}; unsigned int seed = 0; mkvmuxer::VideoTrack video_track(&seed); - Status status = UpdateTrackForEncryption( - std::vector(kKeyId, kKeyId + sizeof(kKeyId)), &video_track); + const std::vector empty_key_id; + Status status = UpdateTrackForEncryption(empty_key_id, &video_track); EXPECT_EQ(error::INTERNAL_ERROR, status.error_code()); }