OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (!planes || !planes[0] || !planes[1] || !planes[2] | 148 if (!planes || !planes[0] || !planes[1] || !planes[2] |
149 || !rowBytes || !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) { | 149 || !rowBytes || !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) { |
150 return false; | 150 return false; |
151 } | 151 } |
152 | 152 |
153 SharedBuffer* data = 0; | 153 SharedBuffer* data = 0; |
154 bool allDataReceived = false; | 154 bool allDataReceived = false; |
155 m_data.data(&data, &allDataReceived); | 155 m_data.data(&data, &allDataReceived); |
156 | 156 |
157 // FIXME: YUV decoding does not currently support progressive decoding. | 157 // FIXME: YUV decoding does not currently support progressive decoding. |
158 if (!allDataReceived) | 158 ASSERT(allDataReceived); |
159 return false; | |
160 | 159 |
161 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageSource::Alph
aPremultiplied, ImageSource::GammaAndColorProfileApplied); | 160 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageSource::Alph
aPremultiplied, ImageSource::GammaAndColorProfileApplied); |
162 if (!decoder) | 161 if (!decoder) |
163 return false; | 162 return false; |
164 | 163 |
165 decoder->setData(data, allDataReceived); | 164 decoder->setData(data, allDataReceived); |
166 | 165 |
167 OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes(planes, rowBytes)
); | 166 OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes(planes, rowBytes)
); |
168 decoder->setImagePlanes(imagePlanes.release()); | 167 decoder->setImagePlanes(imagePlanes.release()); |
169 bool yuvDecoded = decoder->decodeToYUV(); | 168 bool yuvDecoded = decoder->decodeToYUV(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 { | 295 { |
297 ASSERT(componentSizes); | 296 ASSERT(componentSizes); |
298 | 297 |
299 TRACE_EVENT2("webkit", "ImageFrameGenerator::getYUVComponentSizes", "width",
m_fullSize.width(), "height", m_fullSize.height()); | 298 TRACE_EVENT2("webkit", "ImageFrameGenerator::getYUVComponentSizes", "width",
m_fullSize.width(), "height", m_fullSize.height()); |
300 | 299 |
301 SharedBuffer* data = 0; | 300 SharedBuffer* data = 0; |
302 bool allDataReceived = false; | 301 bool allDataReceived = false; |
303 m_data.data(&data, &allDataReceived); | 302 m_data.data(&data, &allDataReceived); |
304 | 303 |
305 // FIXME: YUV decoding does not currently support progressive decoding. | 304 // FIXME: YUV decoding does not currently support progressive decoding. |
306 ASSERT(allDataReceived); | 305 if (!allDataReceived) |
| 306 return false; |
307 | 307 |
308 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageSource::Alph
aPremultiplied, ImageSource::GammaAndColorProfileApplied); | 308 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageSource::Alph
aPremultiplied, ImageSource::GammaAndColorProfileApplied); |
309 if (!decoder) | 309 if (!decoder) |
310 return false; | 310 return false; |
311 | 311 |
312 // Setting a dummy ImagePlanes object signals to the decoder that we want to
do YUV decoding. | 312 // Setting a dummy ImagePlanes object signals to the decoder that we want to
do YUV decoding. |
313 decoder->setData(data, allDataReceived); | 313 decoder->setData(data, allDataReceived); |
314 OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes); | 314 OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes); |
315 decoder->setImagePlanes(dummyImagePlanes.release()); | 315 decoder->setImagePlanes(dummyImagePlanes.release()); |
316 | 316 |
317 // canDecodeToYUV() has to be called AFTER isSizeAvailable(), | 317 // canDecodeToYUV() has to be called AFTER isSizeAvailable(), |
318 // otherwise the output color space may not be set in the decoder. | 318 // otherwise the output color space may not be set in the decoder. |
319 if (!decoder->isSizeAvailable() || !decoder->canDecodeToYUV()) | 319 if (!decoder->isSizeAvailable() || !decoder->canDecodeToYUV()) |
320 return false; | 320 return false; |
321 | 321 |
322 IntSize size = decoder->decodedYUVSize(0); | 322 IntSize size = decoder->decodedYUVSize(0); |
323 componentSizes[0].set(size.width(), size.height()); | 323 componentSizes[0].set(size.width(), size.height()); |
324 size = decoder->decodedYUVSize(1); | 324 size = decoder->decodedYUVSize(1); |
325 componentSizes[1].set(size.width(), size.height()); | 325 componentSizes[1].set(size.width(), size.height()); |
326 size = decoder->decodedYUVSize(2); | 326 size = decoder->decodedYUVSize(2); |
327 componentSizes[2].set(size.width(), size.height()); | 327 componentSizes[2].set(size.width(), size.height()); |
328 return true; | 328 return true; |
329 } | 329 } |
330 | 330 |
331 } // namespace blink | 331 } // namespace blink |
OLD | NEW |