Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/gpu/v4l2_video_decode_accelerator.h" | 5 #include "media/gpu/v4l2_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <linux/videodev2.h> | 10 #include <linux/videodev2.h> |
| (...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2031 fmtdesc.pixelformat) != processor_input_formats.end()) { | 2031 fmtdesc.pixelformat) != processor_input_formats.end()) { |
| 2032 DVLOGF(1) << "Image processor input format=" << fmtdesc.pixelformat; | 2032 DVLOGF(1) << "Image processor input format=" << fmtdesc.pixelformat; |
| 2033 return fmtdesc.pixelformat; | 2033 return fmtdesc.pixelformat; |
| 2034 } | 2034 } |
| 2035 ++fmtdesc.index; | 2035 ++fmtdesc.index; |
| 2036 } | 2036 } |
| 2037 return 0; | 2037 return 0; |
| 2038 } | 2038 } |
| 2039 | 2039 |
| 2040 uint32_t V4L2VideoDecodeAccelerator::FindImageProcessorOutputFormat() { | 2040 uint32_t V4L2VideoDecodeAccelerator::FindImageProcessorOutputFormat() { |
| 2041 // Prefer YVU420 and NV12 because ArcGpuVideoDecodeAccelerator only support | |
|
Pawel Osciak
2016/08/23 05:22:00
s/support/supports/
wuchengli
2016/08/23 08:52:32
Done.
| |
| 2042 // single physical plane. Prefer YVU420 over NV12 because chrome rendering | |
| 2043 // supports YV12 only. | |
| 2044 static const uint32_t kPreferredFormats[] = {V4L2_PIX_FMT_YVU420, | |
| 2045 V4L2_PIX_FMT_NV12}; | |
| 2046 auto preferred_formats_first = [](uint32_t a, uint32_t b) -> bool { | |
| 2047 auto iter_a = std::find(std::begin(kPreferredFormats), | |
| 2048 std::end(kPreferredFormats), a); | |
| 2049 auto iter_b = std::find(std::begin(kPreferredFormats), | |
| 2050 std::end(kPreferredFormats), b); | |
| 2051 return iter_a < iter_b; | |
| 2052 }; | |
| 2053 | |
| 2041 V4L2ImageProcessor image_processor(image_processor_device_); | 2054 V4L2ImageProcessor image_processor(image_processor_device_); |
| 2042 std::vector<uint32_t> processor_output_formats = | 2055 std::vector<uint32_t> processor_output_formats = |
| 2043 image_processor.GetSupportedOutputFormats(); | 2056 image_processor.GetSupportedOutputFormats(); |
| 2057 | |
| 2058 // Move the preferred format to the front. | |
|
Pawel Osciak
2016/08/23 05:22:00
s/format/formats/
/./in the same order as in kPref
wuchengli
2016/08/23 08:52:33
Done.
| |
| 2059 std::sort(processor_output_formats.begin(), processor_output_formats.end(), | |
| 2060 preferred_formats_first); | |
| 2061 | |
| 2044 for (uint32_t processor_output_format : processor_output_formats) { | 2062 for (uint32_t processor_output_format : processor_output_formats) { |
| 2045 if (device_->CanCreateEGLImageFrom(processor_output_format)) { | 2063 if (device_->CanCreateEGLImageFrom(processor_output_format)) { |
| 2046 DVLOGF(1) << "Image processor output format=" << processor_output_format; | 2064 DVLOGF(1) << "Image processor output format=" << processor_output_format; |
| 2047 return processor_output_format; | 2065 return processor_output_format; |
| 2048 } | 2066 } |
| 2049 } | 2067 } |
| 2050 | 2068 |
| 2051 return 0; | 2069 return 0; |
| 2052 } | 2070 } |
| 2053 | 2071 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2271 Enqueue(); | 2289 Enqueue(); |
| 2272 } | 2290 } |
| 2273 } | 2291 } |
| 2274 | 2292 |
| 2275 void V4L2VideoDecodeAccelerator::ImageProcessorError() { | 2293 void V4L2VideoDecodeAccelerator::ImageProcessorError() { |
| 2276 LOGF(ERROR) << "Image processor error"; | 2294 LOGF(ERROR) << "Image processor error"; |
| 2277 NOTIFY_ERROR(PLATFORM_FAILURE); | 2295 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 2278 } | 2296 } |
| 2279 | 2297 |
| 2280 } // namespace media | 2298 } // namespace media |
| OLD | NEW |