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

Side by Side Diff: media/base/decoder_buffer.cc

Issue 712593003: Move key frame flag from StreamParserBuffer to DecoderBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/decoder_buffer.h" 5 #include "media/base/decoder_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/buffers.h" 8 #include "media/base/buffers.h"
9 #include "media/base/decrypt_config.h" 9 #include "media/base/decrypt_config.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 DecoderBuffer::DecoderBuffer(int size) 13 DecoderBuffer::DecoderBuffer(int size)
14 : size_(size), 14 : size_(size),
15 side_data_size_(0) { 15 side_data_size_(0),
16 is_keyframe_(false) {
16 Initialize(); 17 Initialize();
17 } 18 }
18 19
19 DecoderBuffer::DecoderBuffer(const uint8* data, int size, 20 DecoderBuffer::DecoderBuffer(const uint8* data, int size,
20 const uint8* side_data, int side_data_size) 21 const uint8* side_data, int side_data_size,
22 bool is_keyframe)
21 : size_(size), 23 : size_(size),
22 side_data_size_(side_data_size) { 24 side_data_size_(side_data_size),
25 is_keyframe_(is_keyframe) {
23 if (!data) { 26 if (!data) {
24 CHECK_EQ(size_, 0); 27 CHECK_EQ(size_, 0);
25 CHECK(!side_data); 28 CHECK(!side_data);
26 return; 29 return;
27 } 30 }
28 31
29 Initialize(); 32 Initialize();
30 memcpy(data_.get(), data, size_); 33 memcpy(data_.get(), data, size_);
31 if (side_data) 34 if (side_data)
32 memcpy(side_data_.get(), side_data, side_data_size_); 35 memcpy(side_data_.get(), side_data, side_data_size_);
33 } 36 }
34 37
35 DecoderBuffer::~DecoderBuffer() {} 38 DecoderBuffer::~DecoderBuffer() {}
36 39
37 void DecoderBuffer::Initialize() { 40 void DecoderBuffer::Initialize() {
38 CHECK_GE(size_, 0); 41 CHECK_GE(size_, 0);
39 data_.reset(reinterpret_cast<uint8*>( 42 data_.reset(reinterpret_cast<uint8*>(
40 base::AlignedAlloc(size_ + kPaddingSize, kAlignmentSize))); 43 base::AlignedAlloc(size_ + kPaddingSize, kAlignmentSize)));
41 memset(data_.get() + size_, 0, kPaddingSize); 44 memset(data_.get() + size_, 0, kPaddingSize);
42 if (side_data_size_ > 0) { 45 if (side_data_size_ > 0) {
43 side_data_.reset(reinterpret_cast<uint8*>( 46 side_data_.reset(reinterpret_cast<uint8*>(
44 base::AlignedAlloc(side_data_size_ + kPaddingSize, kAlignmentSize))); 47 base::AlignedAlloc(side_data_size_ + kPaddingSize, kAlignmentSize)));
45 memset(side_data_.get() + side_data_size_, 0, kPaddingSize); 48 memset(side_data_.get() + side_data_size_, 0, kPaddingSize);
46 } 49 }
47 splice_timestamp_ = kNoTimestamp(); 50 splice_timestamp_ = kNoTimestamp();
48 } 51 }
49 52
50 // static 53 // static
51 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8* data, 54 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8* data,
52 int data_size) { 55 int data_size,
56 bool is_keyframe) {
53 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. 57 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it.
54 CHECK(data); 58 CHECK(data);
55 return make_scoped_refptr(new DecoderBuffer(data, data_size, NULL, 0)); 59 return make_scoped_refptr(new DecoderBuffer(data, data_size, NULL, 0,
60 is_keyframe));
56 } 61 }
57 62
58 // static 63 // static
59 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8* data, 64 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8* data,
60 int data_size, 65 int data_size,
61 const uint8* side_data, 66 const uint8* side_data,
62 int side_data_size) { 67 int side_data_size,
68 bool is_keyframe) {
63 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. 69 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it.
64 CHECK(data); 70 CHECK(data);
65 CHECK(side_data); 71 CHECK(side_data);
66 return make_scoped_refptr(new DecoderBuffer(data, data_size, 72 return make_scoped_refptr(new DecoderBuffer(data, data_size,
67 side_data, side_data_size)); 73 side_data, side_data_size,
74 is_keyframe));
68 } 75 }
69 76
70 // static 77 // static
71 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() { 78 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() {
72 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0)); 79 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0, false));
73 } 80 }
74 81
75 std::string DecoderBuffer::AsHumanReadableString() { 82 std::string DecoderBuffer::AsHumanReadableString() {
76 if (end_of_stream()) { 83 if (end_of_stream()) {
77 return "end of stream"; 84 return "end of stream";
78 } 85 }
79 86
80 std::ostringstream s; 87 std::ostringstream s;
81 s << "timestamp: " << timestamp_.InMicroseconds() 88 s << "timestamp: " << timestamp_.InMicroseconds()
82 << " duration: " << duration_.InMicroseconds() 89 << " duration: " << duration_.InMicroseconds()
83 << " size: " << size_ 90 << " size: " << size_
84 << " side_data_size: " << side_data_size_ 91 << " side_data_size: " << side_data_size_
92 << " is_keyframe: " << is_keyframe_
85 << " encrypted: " << (decrypt_config_ != NULL) 93 << " encrypted: " << (decrypt_config_ != NULL)
86 << " discard_padding (ms): (" << discard_padding_.first.InMilliseconds() 94 << " discard_padding (ms): (" << discard_padding_.first.InMilliseconds()
87 << ", " << discard_padding_.second.InMilliseconds() << ")"; 95 << ", " << discard_padding_.second.InMilliseconds() << ")";
88 return s.str(); 96 return s.str();
89 } 97 }
90 98
91 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) { 99 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) {
92 DCHECK(!end_of_stream()); 100 DCHECK(!end_of_stream());
93 timestamp_ = timestamp; 101 timestamp_ = timestamp;
94 } 102 }
95 103
96 } // namespace media 104 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698