Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1095)

Unified Diff: media/formats/mp4/avc_unittest.cc

Issue 591713002: Fix inserting SPS/PPS after AUD NALU (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback fixes Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/mp4/avc.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/mp4/avc_unittest.cc
diff --git a/media/formats/mp4/avc_unittest.cc b/media/formats/mp4/avc_unittest.cc
index ba538c88162d3ca9921de67cccd42dae7f000725..b0aa976a51564488ba0237b87d45ccbd749900cc 100644
--- a/media/formats/mp4/avc_unittest.cc
+++ b/media/formats/mp4/avc_unittest.cc
@@ -170,25 +170,6 @@ void StringToAnnexB(const std::string& str, std::vector<uint8>* buffer,
}
}
-int FindSubsampleIndex(const std::vector<uint8>& buffer,
- const std::vector<SubsampleEntry>* subsamples,
- const uint8* ptr) {
- DCHECK(ptr >= &buffer[0]);
- DCHECK(ptr <= &buffer[buffer.size()-1]);
- if (!subsamples || subsamples->empty())
- return 0;
-
- const uint8* p = &buffer[0];
- for (size_t i = 0; i < subsamples->size(); ++i) {
- p += (*subsamples)[i].clear_bytes + (*subsamples)[i].cypher_bytes;
- if (p > ptr) {
- return i;
- }
- }
- NOTREACHED();
- return 0;
-}
-
std::string AnnexBToString(const std::vector<uint8>& buffer,
const std::vector<SubsampleEntry>& subsamples) {
std::stringstream ss;
@@ -200,7 +181,8 @@ std::string AnnexBToString(const std::vector<uint8>& buffer,
bool first = true;
size_t current_subsample_index = 0;
while (parser.AdvanceToNextNALU(&nalu) == H264Parser::kOk) {
- size_t subsample_index = FindSubsampleIndex(buffer, &subsamples, nalu.data);
+ size_t subsample_index = AVC::FindSubsampleIndex(buffer, &subsamples,
+ nalu.data);
if (!first) {
ss << (subsample_index == current_subsample_index ? "," : " ");
} else {
@@ -309,10 +291,10 @@ TEST_F(AVCConversionTest, ConvertConfigToAnnexB) {
std::vector<uint8> buf;
std::vector<SubsampleEntry> subsamples;
- EXPECT_TRUE(AVC::ConvertConfigToAnnexB(avc_config, &buf, &subsamples));
+ EXPECT_TRUE(AVC::ConvertConfigToAnnexB(avc_config, &buf));
EXPECT_EQ(0, memcmp(kExpectedParamSets, &buf[0],
sizeof(kExpectedParamSets)));
- EXPECT_EQ("SPS SPS PPS", AnnexBToString(buf, subsamples));
+ EXPECT_EQ("SPS,SPS,PPS", AnnexBToString(buf, subsamples));
}
// Verify that we can round trip string -> Annex B -> string.
@@ -389,14 +371,18 @@ typedef struct {
TEST_F(AVCConversionTest, InsertParamSetsAnnexB) {
static const InsertTestCases test_cases[] = {
- { "I", "SPS SPS PPS I" },
- { "AUD I", "AUD SPS SPS PPS I" },
+ { "I", "SPS,SPS,PPS,I" },
+ { "AUD I", "AUD SPS,SPS,PPS,I" },
// Cases where param sets in |avc_config| are placed before
// the existing ones.
- { "SPS PPS I", "SPS SPS PPS SPS PPS I" },
- { "AUD SPS PPS I", "AUD SPS SPS PPS SPS PPS I" }, // Note: params placed
+ { "SPS,PPS,I", "SPS,SPS,PPS,SPS,PPS,I" },
+ { "AUD,SPS,PPS,I", "AUD,SPS,SPS,PPS,SPS,PPS,I" }, // Note: params placed
// after AUD.
+
+ // One or more NALUs might follow AUD in the first subsample, we need to
+ // handle this correctly. Params should be inserted right after AUD.
+ { "AUD,SEI I", "AUD,SPS,SPS,PPS,SEI I" },
};
AVCDecoderConfigurationRecord avc_config;
« no previous file with comments | « media/formats/mp4/avc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698