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

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

Issue 2678343011: chromeos: decode video into NV12 format instead of RGBA in vaapi decoder (Closed)
Patch Set: fix redtint with --disable-accelerated-video-decode --enable-native-gpu-memory-buffers Created 3 years, 6 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
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/vaapi_drm_picture.h" 5 #include "media/gpu/vaapi_drm_picture.h"
6 6
7 #include "base/file_descriptor_posix.h" 7 #include "base/file_descriptor_posix.h"
8 #include "media/gpu/va_surface.h" 8 #include "media/gpu/va_surface.h"
9 #include "media/gpu/vaapi_wrapper.h" 9 #include "media/gpu/vaapi_wrapper.h"
10 #include "third_party/libva/va/drm/va_drm.h" 10 #include "third_party/libva/va/drm/va_drm.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 static unsigned BufferFormatToInternalFormat(gfx::BufferFormat format) { 45 static unsigned BufferFormatToInternalFormat(gfx::BufferFormat format) {
46 switch (format) { 46 switch (format) {
47 case gfx::BufferFormat::BGRA_8888: 47 case gfx::BufferFormat::BGRA_8888:
48 return GL_BGRA_EXT; 48 return GL_BGRA_EXT;
49 49
50 case gfx::BufferFormat::YVU_420: 50 case gfx::BufferFormat::YVU_420:
51 return GL_RGB_YCRCB_420_CHROMIUM; 51 return GL_RGB_YCRCB_420_CHROMIUM;
52 52
53 case gfx::BufferFormat::YUV_420_BIPLANAR:
54 return GL_RGB_YCBCR_420V_CHROMIUM;
55
53 default: 56 default:
54 NOTREACHED(); 57 NOTREACHED();
55 return GL_BGRA_EXT; 58 return GL_BGRA_EXT;
56 } 59 }
57 } 60 }
58 61
59 bool VaapiDrmPicture::Initialize() { 62 bool VaapiDrmPicture::Initialize() {
60 DCHECK(pixmap_); 63 DCHECK(pixmap_);
61 64
62 va_surface_ = vaapi_wrapper_->CreateVASurfaceForPixmap(pixmap_); 65 va_surface_ = vaapi_wrapper_->CreateVASurfaceForPixmap(pixmap_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return false; 100 return false;
98 } 101 }
99 } 102 }
100 103
101 return true; 104 return true;
102 } 105 }
103 106
104 bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) { 107 bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) {
105 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); 108 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance();
106 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); 109 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone();
107 pixmap_ = factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size_, 110 // TODO(dshwang): make it scanout when cros kernel supports NV12 overlay.
108 format, gfx::BufferUsage::SCANOUT); 111 // crbug.com/683347
gurchetansingh 2017/06/22 23:31:59 Shouldn't you be able to query drm plane resources
dshwang 2017/06/23 01:07:05 there is good news and bad news. bad news: There i
gurchetansingh 2017/06/23 03:18:33 I don't understand. drmModeGetPlaneResources shou
dshwang 2017/06/23 23:25:14 Oh, that's good to know. It works. I'll make Clien
gurchetansingh 2017/06/24 01:50:48 If NV12 is not overlay-able yet, that's fine. Let
Daniele Castagna 2017/06/26 18:06:43 I'm not sure we want to dynamically pick the decod
dshwang 2017/06/28 02:08:34 In my opinion, we should choose NV12 always becaus
112 pixmap_ =
113 factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size_, format,
114 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE);
gurchetansingh 2017/06/22 23:31:59 What GBM use flags is the NV12 buffer allocated wi
dshwang 2017/06/23 01:07:05 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE is conve
gurchetansingh 2017/06/23 03:18:33 That's incorrect. NV12 is Y-tiled in the upstream
dshwang 2017/06/23 23:25:14 Does "NV12 is Y-tiled in the upstream kernel" mean
gurchetansingh 2017/06/24 01:50:48 So the buffer is 1) imported into VAAPI, 2) a v
dshwang 2017/06/28 02:08:34 I could not reproduce glitch anymore after repo sy
109 if (!pixmap_) { 115 if (!pixmap_) {
110 DVLOG(1) << "Failed allocating a pixmap"; 116 DVLOG(1) << "Failed allocating a pixmap";
111 return false; 117 return false;
112 } 118 }
113 119
114 return Initialize(); 120 return Initialize();
115 } 121 }
116 122
117 bool VaapiDrmPicture::ImportGpuMemoryBufferHandle( 123 bool VaapiDrmPicture::ImportGpuMemoryBufferHandle(
118 gfx::BufferFormat format, 124 gfx::BufferFormat format,
(...skipping 11 matching lines...) Expand all
130 136
131 return Initialize(); 137 return Initialize();
132 } 138 }
133 139
134 bool VaapiDrmPicture::DownloadFromSurface( 140 bool VaapiDrmPicture::DownloadFromSurface(
135 const scoped_refptr<VASurface>& va_surface) { 141 const scoped_refptr<VASurface>& va_surface) {
136 return vaapi_wrapper_->BlitSurface(va_surface, va_surface_); 142 return vaapi_wrapper_->BlitSurface(va_surface, va_surface_);
137 } 143 }
138 144
139 bool VaapiDrmPicture::AllowOverlay() const { 145 bool VaapiDrmPicture::AllowOverlay() const {
140 return true; 146 // TODO(dshwang): make it true when cros kernel supports NV12 overlay.
gurchetansingh 2017/06/24 01:50:48 Should be a runtime decision based on plane resour
Daniele Castagna 2017/06/26 18:06:43 This is really just some metadata that ends up in
dshwang 2017/06/28 02:08:34 new patch set remove this change. as usage is chos
147 // crbug.com/683347
148 return false;
141 } 149 }
142 150
143 } // namespace media 151 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698