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

Side by Side Diff: content/renderer/pepper/video_decoder_shim.cc

Issue 1230593005: Reland: Change the video color space default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: big rebase Created 5 years, 5 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 | « chromecast/media/cma/test/mock_frame_provider.cc ('k') | media/base/test_helpers.cc » ('j') | 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 "content/renderer/pepper/video_decoder_shim.h" 5 #include "content/renderer/pepper/video_decoder_shim.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 10
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // U - 128 : Turns unsigned U into signed U [-128,127] 367 // U - 128 : Turns unsigned U into signed U [-128,127]
368 // V - 128 : Turns unsigned V into signed V [-128,127] 368 // V - 128 : Turns unsigned V into signed V [-128,127]
369 const float yuv_adjust_constrained[3] = { 369 const float yuv_adjust_constrained[3] = {
370 -0.0625f, -0.5f, -0.5f, 370 -0.0625f, -0.5f, -0.5f,
371 }; 371 };
372 // Same as above, but without the head and footroom. 372 // Same as above, but without the head and footroom.
373 const float yuv_adjust_full[3] = { 373 const float yuv_adjust_full[3] = {
374 0.0f, -0.5f, -0.5f, 374 0.0f, -0.5f, -0.5f,
375 }; 375 };
376 376
377 yuv_adjust = yuv_adjust_constrained;
378 yuv_matrix = yuv_to_rgb_rec601;
379
380 int result;
381 if (frame->metadata()->GetInteger(media::VideoFrameMetadata::COLOR_SPACE,
382 &result)) {
383 if (result == media::COLOR_SPACE_JPEG) {
384 yuv_matrix = yuv_to_rgb_jpeg;
385 yuv_adjust = yuv_adjust_full;
386 } else if (result == media::COLOR_SPACE_HD_REC709) {
387 yuv_matrix = yuv_to_rgb_rec709;
388 }
389 }
390
377 switch (frame->format()) { 391 switch (frame->format()) {
378 case media::PIXEL_FORMAT_YV12: // 420 392 case media::PIXEL_FORMAT_YV12: // 420
379 case media::PIXEL_FORMAT_YV12A: 393 case media::PIXEL_FORMAT_YV12A:
380 case media::PIXEL_FORMAT_I420: 394 case media::PIXEL_FORMAT_I420:
381 uv_height_divisor_ = 2; 395 uv_height_divisor_ = 2;
382 uv_width_divisor_ = 2; 396 uv_width_divisor_ = 2;
383 yuv_adjust = yuv_adjust_constrained;
384 int result;
385 if (frame->metadata()->GetInteger(
386 media::VideoFrameMetadata::COLOR_SPACE, &result)) {
387 if (result == media::COLOR_SPACE_JPEG) {
388 yuv_matrix = yuv_to_rgb_jpeg;
389 yuv_adjust = yuv_adjust_full;
390 } else {
391 yuv_matrix = yuv_to_rgb_rec709;
392 }
393 } else {
394 yuv_matrix = yuv_to_rgb_rec601;
395 }
396 break; 397 break;
397 case media::PIXEL_FORMAT_YV16: // 422 398 case media::PIXEL_FORMAT_YV16: // 422
398 uv_width_divisor_ = 2; 399 uv_width_divisor_ = 2;
399 uv_height_divisor_ = 1; 400 uv_height_divisor_ = 1;
400 yuv_matrix = yuv_to_rgb_rec601;
401 yuv_adjust = yuv_adjust_constrained;
402 break; 401 break;
403 case media::PIXEL_FORMAT_YV24: // 444 402 case media::PIXEL_FORMAT_YV24: // 444
404 uv_width_divisor_ = 1; 403 uv_width_divisor_ = 1;
405 uv_height_divisor_ = 1; 404 uv_height_divisor_ = 1;
406 yuv_matrix = yuv_to_rgb_rec601;
407 yuv_adjust = yuv_adjust_constrained;
408 break; 405 break;
409 406
410 default: 407 default:
411 NOTREACHED(); 408 NOTREACHED();
412 } 409 }
413 410
414 video_format_ = frame->format(); 411 video_format_ = frame->format();
415 412
416 // Zero these so everything is reset below. 413 // Zero these so everything is reset below.
417 y_width_ = y_height_ = 0; 414 y_width_ = y_height_ = 0;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 codec = media::kCodecVP8; 851 codec = media::kCodecVP8;
855 else if (profile <= media::VP9PROFILE_MAX) 852 else if (profile <= media::VP9PROFILE_MAX)
856 codec = media::kCodecVP9; 853 codec = media::kCodecVP9;
857 DCHECK_NE(codec, media::kUnknownVideoCodec); 854 DCHECK_NE(codec, media::kUnknownVideoCodec);
858 855
859 if (!yuv_converter_->Initialize()) { 856 if (!yuv_converter_->Initialize()) {
860 return false; 857 return false;
861 } 858 }
862 859
863 media::VideoDecoderConfig config( 860 media::VideoDecoderConfig config(
864 codec, profile, media::PIXEL_FORMAT_YV12, 861 codec, profile, media::PIXEL_FORMAT_YV12, media::COLOR_SPACE_UNSPECIFIED,
865 gfx::Size(32, 24), // Small sizes that won't fail. 862 gfx::Size(32, 24), // Small sizes that won't fail.
866 gfx::Rect(32, 24), gfx::Size(32, 24), 863 gfx::Rect(32, 24), gfx::Size(32, 24),
867 NULL /* extra_data */, // TODO(bbudge) Verify this isn't needed. 864 NULL /* extra_data */, // TODO(bbudge) Verify this isn't needed.
868 0 /* extra_data_size */, false /* decryption */); 865 0 /* extra_data_size */, false /* decryption */);
869 866
870 media_task_runner_->PostTask( 867 media_task_runner_->PostTask(
871 FROM_HERE, 868 FROM_HERE,
872 base::Bind(&VideoDecoderShim::DecoderImpl::Initialize, 869 base::Bind(&VideoDecoderShim::DecoderImpl::Initialize,
873 base::Unretained(decoder_impl_.get()), 870 base::Unretained(decoder_impl_.get()),
874 config)); 871 config));
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { 1087 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) {
1091 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); 1088 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL();
1092 gles2->DeleteTextures(1, &texture_id); 1089 gles2->DeleteTextures(1, &texture_id);
1093 } 1090 }
1094 1091
1095 void VideoDecoderShim::FlushCommandBuffer() { 1092 void VideoDecoderShim::FlushCommandBuffer() {
1096 context_provider_->ContextGL()->Flush(); 1093 context_provider_->ContextGL()->Flush();
1097 } 1094 }
1098 1095
1099 } // namespace content 1096 } // namespace content
OLDNEW
« no previous file with comments | « chromecast/media/cma/test/mock_frame_provider.cc ('k') | media/base/test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698