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

Side by Side Diff: media/gpu/v4l2_video_decode_accelerator.cc

Issue 2260123002: V4L2VDA: use YV12 as output format if processor supports it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address Pawel's offline comment. Prefer YVU420>NV12>others Created 4 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
« no previous file with comments | « media/gpu/v4l2_device.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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 and drm_gralloc
2042 // only support single physical plane. Prefer YVU420 over NV12 because chrome
2043 // rendering supports YV12 only. When we use NV12, chrome thinks it is RGBA
2044 // and mali handles that transparently knowing it is really NV12.
2045 static const uint32_t kPreferredFormats[] = {V4L2_PIX_FMT_YVU420,
2046 V4L2_PIX_FMT_NV12};
2047 struct {
kcwu 2016/08/22 08:07:00 I feel it's unnecessary to use struct. A normal fu
wuchengli 2016/08/22 09:08:04 Yeah. Lambda is simpler. Done.
2048 bool operator()(uint32_t a, uint32_t b) {
2049 auto iter_a = std::find(std::begin(kPreferredFormats),
2050 std::end(kPreferredFormats), a);
2051 auto iter_b = std::find(std::begin(kPreferredFormats),
2052 std::end(kPreferredFormats), b);
2053 return iter_a < iter_b;
2054 }
2055 } preferred_formats_first;
2056
2041 V4L2ImageProcessor image_processor(image_processor_device_); 2057 V4L2ImageProcessor image_processor(image_processor_device_);
2042 std::vector<uint32_t> processor_output_formats = 2058 std::vector<uint32_t> processor_output_formats =
2043 image_processor.GetSupportedOutputFormats(); 2059 image_processor.GetSupportedOutputFormats();
2060
2061 // Move the preferred format to the front.
2062 std::sort(processor_output_formats.begin(), processor_output_formats.end(),
kcwu 2016/08/22 08:07:00 Just curious, does the ordering of GetSupportedOut
wuchengli 2016/08/22 09:08:03 The order of GetSupportedOutputFormats does not me
2063 preferred_formats_first);
2064
2044 for (uint32_t processor_output_format : processor_output_formats) { 2065 for (uint32_t processor_output_format : processor_output_formats) {
2045 if (device_->CanCreateEGLImageFrom(processor_output_format)) { 2066 if (device_->CanCreateEGLImageFrom(processor_output_format)) {
2046 DVLOGF(1) << "Image processor output format=" << processor_output_format; 2067 DVLOGF(1) << "Image processor output format=" << processor_output_format;
2047 return processor_output_format; 2068 return processor_output_format;
2048 } 2069 }
2049 } 2070 }
2050 2071
2051 return 0; 2072 return 0;
2052 } 2073 }
2053 2074
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 Enqueue(); 2292 Enqueue();
2272 } 2293 }
2273 } 2294 }
2274 2295
2275 void V4L2VideoDecodeAccelerator::ImageProcessorError() { 2296 void V4L2VideoDecodeAccelerator::ImageProcessorError() {
2276 LOGF(ERROR) << "Image processor error"; 2297 LOGF(ERROR) << "Image processor error";
2277 NOTIFY_ERROR(PLATFORM_FAILURE); 2298 NOTIFY_ERROR(PLATFORM_FAILURE);
2278 } 2299 }
2279 2300
2280 } // namespace media 2301 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/v4l2_device.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698