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

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

Issue 447963003: Introduce DecodeTimestamp class to make it easier to distiguish presentation and decode timestamps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/mp2t/ts_section_pes.h" 5 #include "media/formats/mp2t/ts_section_pes.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "media/base/bit_reader.h" 9 #include "media/base/bit_reader.h"
10 #include "media/base/buffers.h" 10 #include "media/base/buffers.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 RCHECK((((pts_section >> 36) & 0xf) == 0x3) && 260 RCHECK((((pts_section >> 36) & 0xf) == 0x3) &&
261 IsTimestampSectionValid(pts_section)); 261 IsTimestampSectionValid(pts_section));
262 RCHECK((((dts_section >> 36) & 0xf) == 0x1) && 262 RCHECK((((dts_section >> 36) & 0xf) == 0x1) &&
263 IsTimestampSectionValid(dts_section)); 263 IsTimestampSectionValid(dts_section));
264 is_pts_valid = true; 264 is_pts_valid = true;
265 is_dts_valid = true; 265 is_dts_valid = true;
266 } 266 }
267 267
268 // Convert and unroll the timestamps. 268 // Convert and unroll the timestamps.
269 base::TimeDelta media_pts(kNoTimestamp()); 269 base::TimeDelta media_pts(kNoTimestamp());
270 base::TimeDelta media_dts(kNoTimestamp()); 270 DecodeTimestamp media_dts(kNoDecodeTimestamp());
271 if (is_pts_valid) { 271 if (is_pts_valid) {
272 int64 pts = ConvertTimestampSectionToTimestamp(pts_section); 272 int64 pts = ConvertTimestampSectionToTimestamp(pts_section);
273 if (previous_pts_valid_) 273 if (previous_pts_valid_)
274 pts = UnrollTimestamp(previous_pts_, pts); 274 pts = UnrollTimestamp(previous_pts_, pts);
275 previous_pts_ = pts; 275 previous_pts_ = pts;
276 previous_pts_valid_ = true; 276 previous_pts_valid_ = true;
277 media_pts = base::TimeDelta::FromMicroseconds((1000 * pts) / 90); 277 media_pts = base::TimeDelta::FromMicroseconds((1000 * pts) / 90);
278 } 278 }
279 if (is_dts_valid) { 279 if (is_dts_valid) {
280 int64 dts = ConvertTimestampSectionToTimestamp(dts_section); 280 int64 dts = ConvertTimestampSectionToTimestamp(dts_section);
281 if (previous_dts_valid_) 281 if (previous_dts_valid_)
282 dts = UnrollTimestamp(previous_dts_, dts); 282 dts = UnrollTimestamp(previous_dts_, dts);
283 previous_dts_ = dts; 283 previous_dts_ = dts;
284 previous_dts_valid_ = true; 284 previous_dts_valid_ = true;
285 media_dts = base::TimeDelta::FromMicroseconds((1000 * dts) / 90); 285 media_dts = DecodeTimestamp::FromMicroseconds((1000 * dts) / 90);
286 } 286 }
287 287
288 // Discard the rest of the PES packet header. 288 // Discard the rest of the PES packet header.
289 // TODO(damienv): check if some info of the PES packet header are useful. 289 // TODO(damienv): check if some info of the PES packet header are useful.
290 DCHECK_EQ(bit_reader.bits_available() % 8, 0); 290 DCHECK_EQ(bit_reader.bits_available() % 8, 0);
291 int pes_header_remaining_size = pes_header_data_length - 291 int pes_header_remaining_size = pes_header_data_length -
292 (pes_header_start_size - bit_reader.bits_available() / 8); 292 (pes_header_start_size - bit_reader.bits_available() / 8);
293 RCHECK(pes_header_remaining_size >= 0); 293 RCHECK(pes_header_remaining_size >= 0);
294 294
295 // Read the PES packet. 295 // Read the PES packet.
296 DVLOG(LOG_LEVEL_PES) 296 DVLOG(LOG_LEVEL_PES)
297 << "Emit a reassembled PES:" 297 << "Emit a reassembled PES:"
298 << " size=" << es_size 298 << " size=" << es_size
299 << " pts=" << media_pts.InMilliseconds() 299 << " pts=" << media_pts.InMilliseconds()
300 << " dts=" << media_dts.InMilliseconds() 300 << " dts=" << media_dts.InMilliseconds()
301 << " data_alignment_indicator=" << data_alignment_indicator; 301 << " data_alignment_indicator=" << data_alignment_indicator;
302 return es_parser_->Parse(&raw_pes[es_offset], es_size, media_pts, media_dts); 302 return es_parser_->Parse(&raw_pes[es_offset], es_size, media_pts, media_dts);
303 } 303 }
304 304
305 void TsSectionPes::ResetPesState() { 305 void TsSectionPes::ResetPesState() {
306 pes_byte_queue_.Reset(); 306 pes_byte_queue_.Reset();
307 wait_for_pusi_ = true; 307 wait_for_pusi_ = true;
308 } 308 }
309 309
310 } // namespace mp2t 310 } // namespace mp2t
311 } // namespace media 311 } // namespace media
312
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698