mkvmuxer: Fix hard-coded data size in EbmlElementSize

EbmlElementSize for char* assumes that the varint encoding of
payload size is always 1-byte. Fix that by using the correct
number of bytes.

mkvinfo of the new gold file: http://pastebin.com/ncR7DqEf

Change-Id: I2d10708de77b2b8089900a8719ee3797dfb6994c
This commit is contained in:
Vignesh Venkatasubramanian 2017-03-07 11:34:39 -08:00
parent c36112caa0
commit a0d67d081c
4 changed files with 21 additions and 2 deletions

View File

@ -75,7 +75,7 @@ The tests rely upon the LIBWEBM_TEST_DATA_PATH environment variable to locate
test input. The following example demonstrates running the muxer tests from the
build directory:
$ LIBWEBM_TEST_DATA_PATH=path/to/libwebm/testing/testdata ./muxer_tests
$ LIBWEBM_TEST_DATA_PATH=path/to/libwebm/testing/testdata ./mkvmuxer_tests
Note: Libwebm Googletest integration was built with googletest from
https://github.com/google/googletest.git at git revision

View File

@ -288,7 +288,7 @@ uint64 EbmlElementSize(uint64 type, const char* value) {
ebml_size += strlen(value);
// Size of Datasize
ebml_size++;
ebml_size += GetCodedUIntSize(strlen(value));
return ebml_size;
}

View File

@ -30,6 +30,7 @@ using mkvmuxer::Frame;
using mkvmuxer::MkvWriter;
using mkvmuxer::Segment;
using mkvmuxer::SegmentInfo;
using mkvmuxer::Tag;
using mkvmuxer::Track;
using mkvmuxer::VideoTrack;
@ -996,6 +997,24 @@ TEST_F(MuxerTest, SetPixelWidthPixelHeight) {
filename_));
}
TEST_F(MuxerTest, LongTagString) {
EXPECT_TRUE(SegmentInit(false, false, false));
segment_.set_estimate_file_duration(false);
AddVideoTrack();
Tag* const tag = segment_.AddTag();
// 160 needs two bytes when varint encoded.
const std::string dummy_string(160, '0');
tag->add_simple_tag("long_tag", dummy_string.c_str());
EXPECT_TRUE(segment_.AddFrame(dummy_data_, kFrameLength, kVideoTrackNumber, 0,
false));
segment_.Finalize();
CloseWriter();
EXPECT_TRUE(CompareFiles(GetTestFilePath("long_tag_string.webm"), filename_));
}
} // namespace test
int main(int argc, char* argv[]) {

BIN
testing/testdata/long_tag_string.webm vendored Normal file

Binary file not shown.