OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/webm/webm_video_client.h" | 5 #include "media/webm/webm_video_client.h" |
6 | 6 |
7 #include "media/base/video_decoder_config.h" | 7 #include "media/base/video_decoder_config.h" |
8 #include "media/webm/webm_constants.h" | 8 #include "media/webm/webm_constants.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 WebMVideoClient::WebMVideoClient(const LogCB& log_cb) | 12 WebMVideoClient::WebMVideoClient(const LogCB& log_cb) |
13 : log_cb_(log_cb) { | 13 : log_cb_(log_cb) { |
14 Reset(); | 14 Reset(); |
15 } | 15 } |
16 | 16 |
17 WebMVideoClient::~WebMVideoClient() { | 17 WebMVideoClient::~WebMVideoClient() { |
18 } | 18 } |
19 | 19 |
20 void WebMVideoClient::Reset() { | 20 void WebMVideoClient::Reset() { |
21 pixel_width_ = -1; | 21 pixel_width_ = -1; |
22 pixel_height_ = -1; | 22 pixel_height_ = -1; |
23 crop_bottom_ = -1; | 23 crop_bottom_ = -1; |
24 crop_top_ = -1; | 24 crop_top_ = -1; |
25 crop_left_ = -1; | 25 crop_left_ = -1; |
26 crop_right_ = -1; | 26 crop_right_ = -1; |
27 display_width_ = -1; | 27 display_width_ = -1; |
28 display_height_ = -1; | 28 display_height_ = -1; |
29 display_unit_ = -1; | 29 display_unit_ = -1; |
| 30 alpha_mode_ = -1; |
30 } | 31 } |
31 | 32 |
32 bool WebMVideoClient::InitializeConfig( | 33 bool WebMVideoClient::InitializeConfig( |
33 const std::string& codec_id, const std::vector<uint8>& codec_private, | 34 const std::string& codec_id, const std::vector<uint8>& codec_private, |
34 bool is_encrypted, VideoDecoderConfig* config) { | 35 bool is_encrypted, VideoDecoderConfig* config) { |
35 DCHECK(config); | 36 DCHECK(config); |
36 | 37 |
37 VideoCodec video_codec = kUnknownVideoCodec; | 38 VideoCodec video_codec = kUnknownVideoCodec; |
38 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; | 39 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; |
39 if (codec_id == "V_VP8") { | 40 if (codec_id == "V_VP8") { |
40 video_codec = kCodecVP8; | 41 video_codec = kCodecVP8; |
41 profile = VP8PROFILE_MAIN; | 42 profile = VP8PROFILE_MAIN; |
42 } else if (codec_id == "V_VP9") { | 43 } else if (codec_id == "V_VP9") { |
43 video_codec = kCodecVP9; | 44 video_codec = kCodecVP9; |
44 profile = VP9PROFILE_MAIN; | 45 profile = VP9PROFILE_MAIN; |
45 } else { | 46 } else { |
46 MEDIA_LOG(log_cb_) << "Unsupported video codec_id " << codec_id; | 47 MEDIA_LOG(log_cb_) << "Unsupported video codec_id " << codec_id; |
47 return false; | 48 return false; |
48 } | 49 } |
49 | 50 |
| 51 VideoFrame::Format format = |
| 52 (alpha_mode_ == 1) ? VideoFrame::YV12A : VideoFrame::YV12; |
| 53 |
50 if (pixel_width_ <= 0 || pixel_height_ <= 0) | 54 if (pixel_width_ <= 0 || pixel_height_ <= 0) |
51 return false; | 55 return false; |
52 | 56 |
53 // Set crop and display unit defaults if these elements are not present. | 57 // Set crop and display unit defaults if these elements are not present. |
54 if (crop_bottom_ == -1) | 58 if (crop_bottom_ == -1) |
55 crop_bottom_ = 0; | 59 crop_bottom_ = 0; |
56 | 60 |
57 if (crop_top_ == -1) | 61 if (crop_top_ == -1) |
58 crop_top_ = 0; | 62 crop_top_ = 0; |
59 | 63 |
(...skipping 26 matching lines...) Expand all Loading... |
86 return false; | 90 return false; |
87 } | 91 } |
88 const uint8* extra_data = NULL; | 92 const uint8* extra_data = NULL; |
89 size_t extra_data_size = 0; | 93 size_t extra_data_size = 0; |
90 if (codec_private.size() > 0) { | 94 if (codec_private.size() > 0) { |
91 extra_data = &codec_private[0]; | 95 extra_data = &codec_private[0]; |
92 extra_data_size = codec_private.size(); | 96 extra_data_size = codec_private.size(); |
93 } | 97 } |
94 | 98 |
95 config->Initialize( | 99 config->Initialize( |
96 video_codec, profile, VideoFrame::YV12, coded_size, | 100 video_codec, profile, format, coded_size, visible_rect, natural_size, |
97 visible_rect, natural_size, extra_data, extra_data_size, | 101 extra_data, extra_data_size, is_encrypted, true); |
98 is_encrypted, true); | |
99 return config->IsValidConfig(); | 102 return config->IsValidConfig(); |
100 } | 103 } |
101 | 104 |
102 bool WebMVideoClient::OnUInt(int id, int64 val) { | 105 bool WebMVideoClient::OnUInt(int id, int64 val) { |
103 int64* dst = NULL; | 106 int64* dst = NULL; |
104 | 107 |
105 switch (id) { | 108 switch (id) { |
106 case kWebMIdPixelWidth: | 109 case kWebMIdPixelWidth: |
107 dst = &pixel_width_; | 110 dst = &pixel_width_; |
108 break; | 111 break; |
(...skipping 14 matching lines...) Expand all Loading... |
123 break; | 126 break; |
124 case kWebMIdDisplayWidth: | 127 case kWebMIdDisplayWidth: |
125 dst = &display_width_; | 128 dst = &display_width_; |
126 break; | 129 break; |
127 case kWebMIdDisplayHeight: | 130 case kWebMIdDisplayHeight: |
128 dst = &display_height_; | 131 dst = &display_height_; |
129 break; | 132 break; |
130 case kWebMIdDisplayUnit: | 133 case kWebMIdDisplayUnit: |
131 dst = &display_unit_; | 134 dst = &display_unit_; |
132 break; | 135 break; |
| 136 case kWebMIdAlphaMode: |
| 137 dst = &alpha_mode_; |
| 138 break; |
133 default: | 139 default: |
134 return true; | 140 return true; |
135 } | 141 } |
136 | 142 |
137 if (*dst != -1) { | 143 if (*dst != -1) { |
138 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id | 144 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id |
139 << " specified (" << *dst << " and " << val << ")"; | 145 << " specified (" << *dst << " and " << val << ")"; |
140 return false; | 146 return false; |
141 } | 147 } |
142 | 148 |
143 *dst = val; | 149 *dst = val; |
144 return true; | 150 return true; |
145 } | 151 } |
146 | 152 |
147 bool WebMVideoClient::OnBinary(int id, const uint8* data, int size) { | 153 bool WebMVideoClient::OnBinary(int id, const uint8* data, int size) { |
148 // Accept binary fields we don't care about for now. | 154 // Accept binary fields we don't care about for now. |
149 return true; | 155 return true; |
150 } | 156 } |
151 | 157 |
152 bool WebMVideoClient::OnFloat(int id, double val) { | 158 bool WebMVideoClient::OnFloat(int id, double val) { |
153 // Accept float fields we don't care about for now. | 159 // Accept float fields we don't care about for now. |
154 return true; | 160 return true; |
155 } | 161 } |
156 | 162 |
157 } // namespace media | 163 } // namespace media |
OLD | NEW |