 Chromium Code Reviews
 Chromium Code Reviews Issue 2122573003:
  media: replace LUMINANCE_F16 by RG_88 for 9/10-bit h264 videos 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 2122573003:
  media: replace LUMINANCE_F16 by RG_88 for 9/10-bit h264 videos 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <stddef.h> | 5 #include <stddef.h> | 
| 6 #include <stdint.h> | 6 #include <stdint.h> | 
| 7 #include <memory> | 7 #include <memory> | 
| 8 | 8 | 
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" | 
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" | 
| 11 #include "cc/output/gl_renderer.h" | 11 #include "cc/output/gl_renderer.h" | 
| 12 #include "cc/quads/draw_quad.h" | 12 #include "cc/quads/draw_quad.h" | 
| 13 #include "cc/quads/picture_draw_quad.h" | 13 #include "cc/quads/picture_draw_quad.h" | 
| 14 #include "cc/quads/texture_draw_quad.h" | 14 #include "cc/quads/texture_draw_quad.h" | 
| 15 #include "cc/resources/video_resource_updater.h" | 15 #include "cc/resources/video_resource_updater.h" | 
| 16 #include "cc/test/fake_raster_source.h" | 16 #include "cc/test/fake_raster_source.h" | 
| 17 #include "cc/test/fake_recording_source.h" | 17 #include "cc/test/fake_recording_source.h" | 
| 18 #include "cc/test/pixel_test.h" | 18 #include "cc/test/pixel_test.h" | 
| 19 #include "cc/test/test_in_process_context_provider.h" | |
| 19 #include "gpu/command_buffer/client/gles2_interface.h" | 20 #include "gpu/command_buffer/client/gles2_interface.h" | 
| 20 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" | 
| 21 #include "third_party/skia/include/core/SkColorPriv.h" | 22 #include "third_party/skia/include/core/SkColorPriv.h" | 
| 22 #include "third_party/skia/include/core/SkImageFilter.h" | 23 #include "third_party/skia/include/core/SkImageFilter.h" | 
| 23 #include "third_party/skia/include/core/SkMatrix.h" | 24 #include "third_party/skia/include/core/SkMatrix.h" | 
| 24 #include "third_party/skia/include/core/SkRefCnt.h" | 25 #include "third_party/skia/include/core/SkRefCnt.h" | 
| 25 #include "third_party/skia/include/core/SkSurface.h" | 26 #include "third_party/skia/include/core/SkSurface.h" | 
| 26 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" | 27 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" | 
| 27 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 28 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 
| 28 #include "ui/gfx/geometry/rect_conversions.h" | 29 #include "ui/gfx/geometry/rect_conversions.h" | 
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 tex_coord_rect.width() * uv_tex_size.width(), | 270 tex_coord_rect.width() * uv_tex_size.width(), | 
| 270 tex_coord_rect.height() * uv_tex_size.height()); | 271 tex_coord_rect.height() * uv_tex_size.height()); | 
| 271 | 272 | 
| 272 YUVVideoDrawQuad* yuv_quad = | 273 YUVVideoDrawQuad* yuv_quad = | 
| 273 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 274 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 
| 274 uint32_t bits_per_channel = 8; | 275 uint32_t bits_per_channel = 8; | 
| 275 if (video_frame->format() == media::PIXEL_FORMAT_YUV420P10 || | 276 if (video_frame->format() == media::PIXEL_FORMAT_YUV420P10 || | 
| 276 video_frame->format() == media::PIXEL_FORMAT_YUV422P10 || | 277 video_frame->format() == media::PIXEL_FORMAT_YUV422P10 || | 
| 277 video_frame->format() == media::PIXEL_FORMAT_YUV444P10) { | 278 video_frame->format() == media::PIXEL_FORMAT_YUV444P10) { | 
| 278 bits_per_channel = 10; | 279 bits_per_channel = 10; | 
| 280 ResourceFormat yuv_highbit_resource_format = | |
| 281 resource_provider->YuvResourceFormat(bits_per_channel); | |
| 282 if (yuv_highbit_resource_format != RG_88 && | |
| 283 yuv_highbit_resource_format != RGBA_8888) | |
| 284 bits_per_channel = 8; | |
| 279 } | 285 } | 
| 280 | 286 | 
| 281 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, | 287 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, | 
| 282 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 288 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 
| 283 uv_tex_size, y_resource, u_resource, v_resource, a_resource, | 289 uv_tex_size, y_resource, u_resource, v_resource, a_resource, | 
| 284 color_space, video_color_space, 0.0f, 1.0f, | 290 color_space, video_color_space, 0.0f, 1.0f, | 
| 285 bits_per_channel); | 291 bits_per_channel); | 
| 286 } | 292 } | 
| 287 | 293 | 
| 288 // Upshift video frame to 10 bit. | 294 // Upshift video frame to 10 bit. | 
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 | 1096 | 
| 1091 void SetUp() override { | 1097 void SetUp() override { | 
| 1092 GLRendererPixelTest::SetUp(); | 1098 GLRendererPixelTest::SetUp(); | 
| 1093 video_resource_updater_.reset(new VideoResourceUpdater( | 1099 video_resource_updater_.reset(new VideoResourceUpdater( | 
| 1094 output_surface_->context_provider(), resource_provider_.get())); | 1100 output_surface_->context_provider(), resource_provider_.get())); | 
| 1095 } | 1101 } | 
| 1096 | 1102 | 
| 1097 std::unique_ptr<VideoResourceUpdater> video_resource_updater_; | 1103 std::unique_ptr<VideoResourceUpdater> video_resource_updater_; | 
| 1098 }; | 1104 }; | 
| 1099 | 1105 | 
| 1106 enum class HighbitTexture { | |
| 1107 Y8, | |
| 1108 RG88, | |
| 1109 }; | |
| 1110 | |
| 1100 class VideoGLRendererPixelHiLoTest | 1111 class VideoGLRendererPixelHiLoTest | 
| 1101 : public VideoGLRendererPixelTest, | 1112 : public VideoGLRendererPixelTest, | 
| 1102 public ::testing::WithParamInterface<bool> {}; | 1113 public ::testing::WithParamInterface< | 
| 1114 ::testing::tuple<bool, HighbitTexture>> { | |
| 1115 public: | |
| 1116 void SetSupportHighbitTexture(HighbitTexture texture) { | |
| 1117 switch (texture) { | |
| 1118 case HighbitTexture::Y8: | |
| 1119 resource_provider_->SetYUVHighbitResourceFormatForTesting(LUMINANCE_8); | |
| 1120 break; | |
| 1121 case HighbitTexture::RG88: | |
| 1122 // |context_provider_| for test doesn't support RG texture, so use RGBA. | |
| 1123 resource_provider_->SetYUVHighbitResourceFormatForTesting(RGBA_8888); | |
| 1124 break; | |
| 1125 } | |
| 1126 } | |
| 1127 }; | |
| 1103 | 1128 | 
| 1104 TEST_P(VideoGLRendererPixelHiLoTest, SimpleYUVRect) { | 1129 TEST_P(VideoGLRendererPixelHiLoTest, SimpleYUVRect) { | 
| 1105 gfx::Rect rect(this->device_viewport_size_); | 1130 gfx::Rect rect(this->device_viewport_size_); | 
| 1106 | 1131 | 
| 1107 RenderPassId id(1, 1); | 1132 RenderPassId id(1, 1); | 
| 1108 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 1133 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 
| 1109 | 1134 | 
| 1110 SharedQuadState* shared_state = | 1135 SharedQuadState* shared_state = | 
| 1111 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); | 1136 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); | 
| 1112 | 1137 | 
| 1113 bool highbit = GetParam(); | 1138 const bool highbit = testing::get<0>(GetParam()); | 
| 1139 const HighbitTexture format = testing::get<1>(GetParam()); | |
| 1140 SetSupportHighbitTexture(format); | |
| 1114 CreateTestYUVVideoDrawQuad_Striped( | 1141 CreateTestYUVVideoDrawQuad_Striped( | 
| 1115 shared_state, media::PIXEL_FORMAT_YV12, false, highbit, | 1142 shared_state, media::PIXEL_FORMAT_YV12, false, highbit, | 
| 1116 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), pass.get(), | 1143 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), pass.get(), | 
| 1117 video_resource_updater_.get(), rect, rect, resource_provider_.get()); | 1144 video_resource_updater_.get(), rect, rect, resource_provider_.get()); | 
| 1118 | 1145 | 
| 1119 RenderPassList pass_list; | 1146 RenderPassList pass_list; | 
| 1120 pass_list.push_back(std::move(pass)); | 1147 pass_list.push_back(std::move(pass)); | 
| 1121 | 1148 | 
| 1122 EXPECT_TRUE( | 1149 base::FilePath file_path = | 
| 1123 this->RunPixelTest(&pass_list, | 1150 base::FilePath(FILE_PATH_LITERAL("yuv_stripes.png")); | 
| 1124 base::FilePath(FILE_PATH_LITERAL("yuv_stripes.png")), | 1151 if (highbit && format == HighbitTexture::RG88) { | 
| 1125 FuzzyPixelOffByOneComparator(true))); | 1152 file_path = base::FilePath(FILE_PATH_LITERAL("yuv_stripes_rg88.png")); | 
| 
dshwang
2016/10/05 15:13:42
RG88 path in shader.cc cannot produce exactly same
 
hubbe
2016/10/05 18:03:25
The values in these files differ quite a lot actua
 
dshwang
2016/10/07 12:35:01
Good point. To verity it, I added |disable_one_com
 | |
| 1153 } | |
| 1154 EXPECT_TRUE(this->RunPixelTest(&pass_list, file_path, | |
| 1155 FuzzyPixelOffByOneComparator(true))); | |
| 1126 } | 1156 } | 
| 1127 | 1157 | 
| 1128 TEST_P(VideoGLRendererPixelHiLoTest, ClippedYUVRect) { | 1158 TEST_P(VideoGLRendererPixelHiLoTest, ClippedYUVRect) { | 
| 1129 gfx::Rect viewport(this->device_viewport_size_); | 1159 gfx::Rect viewport(this->device_viewport_size_); | 
| 1130 gfx::Rect draw_rect(this->device_viewport_size_.width() * 1.5, | 1160 gfx::Rect draw_rect(this->device_viewport_size_.width() * 1.5, | 
| 1131 this->device_viewport_size_.height() * 1.5); | 1161 this->device_viewport_size_.height() * 1.5); | 
| 1132 | 1162 | 
| 1133 RenderPassId id(1, 1); | 1163 RenderPassId id(1, 1); | 
| 1134 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, viewport); | 1164 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, viewport); | 
| 1135 | 1165 | 
| 1136 SharedQuadState* shared_state = | 1166 SharedQuadState* shared_state = | 
| 1137 CreateTestSharedQuadState(gfx::Transform(), viewport, pass.get()); | 1167 CreateTestSharedQuadState(gfx::Transform(), viewport, pass.get()); | 
| 1138 | 1168 | 
| 1139 bool highbit = GetParam(); | 1169 const bool highbit = testing::get<0>(GetParam()); | 
| 1170 const HighbitTexture format = testing::get<1>(GetParam()); | |
| 1171 SetSupportHighbitTexture(format); | |
| 1140 CreateTestYUVVideoDrawQuad_Striped( | 1172 CreateTestYUVVideoDrawQuad_Striped( | 
| 1141 shared_state, media::PIXEL_FORMAT_YV12, false, highbit, | 1173 shared_state, media::PIXEL_FORMAT_YV12, false, highbit, | 
| 1142 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), pass.get(), | 1174 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), pass.get(), | 
| 1143 video_resource_updater_.get(), draw_rect, viewport, | 1175 video_resource_updater_.get(), draw_rect, viewport, | 
| 1144 resource_provider_.get()); | 1176 resource_provider_.get()); | 
| 1145 RenderPassList pass_list; | 1177 RenderPassList pass_list; | 
| 1146 pass_list.push_back(std::move(pass)); | 1178 pass_list.push_back(std::move(pass)); | 
| 1147 | 1179 | 
| 1148 EXPECT_TRUE(this->RunPixelTest( | 1180 base::FilePath file_path = | 
| 1149 &pass_list, base::FilePath(FILE_PATH_LITERAL("yuv_stripes_clipped.png")), | 1181 base::FilePath(FILE_PATH_LITERAL("yuv_stripes_clipped.png")); | 
| 1150 FuzzyPixelOffByOneComparator(true))); | 1182 if (highbit && format == HighbitTexture::RG88) { | 
| 1183 file_path = | |
| 1184 base::FilePath(FILE_PATH_LITERAL("yuv_stripes_clipped_rg88.png")); | |
| 
dshwang
2016/10/05 15:13:42
ditto
 | |
| 1185 } | |
| 1186 EXPECT_TRUE(this->RunPixelTest(&pass_list, file_path, | |
| 1187 FuzzyPixelOffByOneComparator(true))); | |
| 1151 } | 1188 } | 
| 1152 | 1189 | 
| 1153 TEST_F(VideoGLRendererPixelHiLoTest, OffsetYUVRect) { | 1190 TEST_F(VideoGLRendererPixelHiLoTest, OffsetYUVRect) { | 
| 1154 gfx::Rect rect(this->device_viewport_size_); | 1191 gfx::Rect rect(this->device_viewport_size_); | 
| 1155 | 1192 | 
| 1156 RenderPassId id(1, 1); | 1193 RenderPassId id(1, 1); | 
| 1157 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 1194 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 
| 1158 | 1195 | 
| 1159 SharedQuadState* shared_state = | 1196 SharedQuadState* shared_state = | 
| 1160 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); | 1197 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1192 pass_list.push_back(std::move(pass)); | 1229 pass_list.push_back(std::move(pass)); | 
| 1193 | 1230 | 
| 1194 // If we didn't get black out of the YUV values above, then we probably have a | 1231 // If we didn't get black out of the YUV values above, then we probably have a | 
| 1195 // color range issue. | 1232 // color range issue. | 
| 1196 EXPECT_TRUE(this->RunPixelTest(&pass_list, | 1233 EXPECT_TRUE(this->RunPixelTest(&pass_list, | 
| 1197 base::FilePath(FILE_PATH_LITERAL("black.png")), | 1234 base::FilePath(FILE_PATH_LITERAL("black.png")), | 
| 1198 FuzzyPixelOffByOneComparator(true))); | 1235 FuzzyPixelOffByOneComparator(true))); | 
| 1199 } | 1236 } | 
| 1200 | 1237 | 
| 1201 // First argument (test case prefix) is intentionally left empty. | 1238 // First argument (test case prefix) is intentionally left empty. | 
| 1202 INSTANTIATE_TEST_CASE_P(, VideoGLRendererPixelHiLoTest, ::testing::Bool()); | 1239 INSTANTIATE_TEST_CASE_P( | 
| 1240 , | |
| 1241 VideoGLRendererPixelHiLoTest, | |
| 1242 ::testing::Combine(::testing::Bool(), | |
| 1243 ::testing::Values(HighbitTexture::Y8, | |
| 1244 HighbitTexture::RG88))); | |
| 1203 | 1245 | 
| 1204 TEST_F(VideoGLRendererPixelTest, SimpleYUVJRect) { | 1246 TEST_F(VideoGLRendererPixelTest, SimpleYUVJRect) { | 
| 1205 gfx::Rect rect(this->device_viewport_size_); | 1247 gfx::Rect rect(this->device_viewport_size_); | 
| 1206 | 1248 | 
| 1207 RenderPassId id(1, 1); | 1249 RenderPassId id(1, 1); | 
| 1208 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 1250 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 
| 1209 | 1251 | 
| 1210 SharedQuadState* shared_state = | 1252 SharedQuadState* shared_state = | 
| 1211 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); | 1253 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); | 
| 1212 | 1254 | 
| (...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3171 | 3213 | 
| 3172 EXPECT_TRUE(this->RunPixelTest( | 3214 EXPECT_TRUE(this->RunPixelTest( | 
| 3173 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), | 3215 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), | 
| 3174 FuzzyPixelOffByOneComparator(true))); | 3216 FuzzyPixelOffByOneComparator(true))); | 
| 3175 } | 3217 } | 
| 3176 | 3218 | 
| 3177 #endif // !defined(OS_ANDROID) | 3219 #endif // !defined(OS_ANDROID) | 
| 3178 | 3220 | 
| 3179 } // namespace | 3221 } // namespace | 
| 3180 } // namespace cc | 3222 } // namespace cc | 
| OLD | NEW |