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

Side by Side Diff: media/formats/mp2t/es_parser_test_helper.cc

Issue 399433003: Mpeg2 TS - Fail when no valid timestamp in the ADTS parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update ComputePacketSize prototype. Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/formats/mp2t/es_parser_test_helper.h"
6
7 #include "media/base/buffers.h"
8 #include "media/formats/mp2t/es_parser.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace media {
12 namespace mp2t {
13
14 Packet::Packet()
15 : offset(0u),
16 size(0u) {
wolenetz 2014/07/16 00:21:03 I'm not sure, but you might want to default-initia
damienv1 2014/07/16 02:34:33 Done.
17 }
18
19 void ComputePacketSize(std::vector<Packet>* packets, size_t stream_size) {
wolenetz 2014/07/16 00:21:03 nit: Following convention in media/base/test_helpe
damienv1 2014/07/16 02:34:33 In fact, I checked at this file and not all functi
20 ASSERT_TRUE(packets);
21 if (packets->size() == 0u)
22 return;
23
24 Packet* cur = &packets->at(0);
wolenetz 2014/07/16 00:21:03 nit: I'm not convinced you need to use at(k) or at
damienv1 2014/07/16 02:34:33 Done.
25 for (size_t k = 0; k < packets->size() - 1; k++) {
26 Packet* next = &packets->at(k + 1);
27 DCHECK_GE(next->offset, cur->offset);
28 cur->size = next->offset - cur->offset;
29 cur = next;
30 }
31 cur->size = stream_size - cur->offset;
wolenetz 2014/07/16 00:21:03 nit: First, DCHECK_GE(stream_size, cur->offset); ?
damienv1 2014/07/16 02:34:33 Done.
32 }
33
34 bool ProcessPesPackets(
35 EsParser* es_parser,
36 const std::vector<uint8>& stream,
37 const std::vector<Packet>& pes_packets,
38 bool force_timing) {
39 for (size_t k = 0; k < pes_packets.size(); k++) {
wolenetz 2014/07/16 00:21:04 nit: First, ASSERT_TRUE(es_parser); ?
40 size_t cur_pes_offset = pes_packets[k].offset;
41 size_t cur_pes_size = pes_packets[k].size;
42
43 base::TimeDelta pts = kNoTimestamp();
44 base::TimeDelta dts = kNoTimestamp();
45 if (pes_packets[k].pts >= base::TimeDelta() || force_timing)
46 pts = pes_packets[k].pts;
47
48 if (!es_parser->Parse(&stream[cur_pes_offset], cur_pes_size, pts, dts))
wolenetz 2014/07/16 00:21:04 nit: just pass kNoTimestamp() here instead of dts
damienv1 2014/07/16 02:34:33 I was finding it more explicit to pass a variable
wolenetz 2014/07/16 20:35:30 I have no strong feeling here. Maybe s/dts/no_time
49 return false;
50 }
51 es_parser->Flush();
52 return true;
53 }
54
55 } // namespace mp2t
56 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698