OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "media/gpu/dxva_video_decode_accelerator_win.h" | 5 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #if !defined(OS_WIN) | 9 #if !defined(OS_WIN) |
10 #error This file should only be built on Windows. | 10 #error This file should only be built on Windows. |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 config_changed_ = true; | 451 config_changed_ = true; |
452 } else { | 452 } else { |
453 pending_config_changed_ = true; | 453 pending_config_changed_ = true; |
454 } | 454 } |
455 } | 455 } |
456 last_pps_.swap(pps); | 456 last_pps_.swap(pps); |
457 } | 457 } |
458 return true; | 458 return true; |
459 } | 459 } |
460 | 460 |
| 461 gfx::ColorSpace H264ConfigChangeDetector::current_color_space() const { |
| 462 // TODO(hubbe): Is using last_sps_id_ correct here? |
| 463 const H264SPS* sps = parser_->GetSPS(last_sps_id_); |
| 464 if (sps) { |
| 465 return gfx::ColorSpace( |
| 466 static_cast<gfx::ColorSpace::PrimaryID>(sps->primary_idc), |
| 467 static_cast<gfx::ColorSpace::TransferID>(sps->transfer_idc), |
| 468 static_cast<gfx::ColorSpace::MatrixID>(sps->matrix_idc), |
| 469 sps->full_range ? gfx::ColorSpace::RangeID::FULL |
| 470 : gfx::ColorSpace::RangeID::LIMITED); |
| 471 } |
| 472 return gfx::ColorSpace(); |
| 473 } |
461 | 474 |
462 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( | 475 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( |
463 int32_t buffer_id, | 476 int32_t buffer_id, |
464 IMFSample* sample) | 477 IMFSample* sample) |
465 : input_buffer_id(buffer_id), picture_buffer_id(-1) { | 478 : input_buffer_id(buffer_id), picture_buffer_id(-1) { |
466 output_sample.Attach(sample); | 479 output_sample.Attach(sample); |
467 } | 480 } |
468 | 481 |
469 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( | 482 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( |
470 const PendingSampleInfo& other) = default; | 483 const PendingSampleInfo& other) = default; |
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 provide_nv12_textures ? 2 : 1, gfx::Size(width, height), | 1899 provide_nv12_textures ? 2 : 1, gfx::Size(width, height), |
1887 provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D); | 1900 provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D); |
1888 } | 1901 } |
1889 } | 1902 } |
1890 | 1903 |
1891 void DXVAVideoDecodeAccelerator::NotifyPictureReady(int picture_buffer_id, | 1904 void DXVAVideoDecodeAccelerator::NotifyPictureReady(int picture_buffer_id, |
1892 int input_buffer_id) { | 1905 int input_buffer_id) { |
1893 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1906 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
1894 // This task could execute after the decoder has been torn down. | 1907 // This task could execute after the decoder has been torn down. |
1895 if (GetState() != kUninitialized && client_) { | 1908 if (GetState() != kUninitialized && client_) { |
| 1909 gfx::ColorSpace color_space; |
| 1910 if (share_nv12_textures_ || copy_nv12_textures_) { |
| 1911 // Color space information is only valid for NV12 textures. |
| 1912 // If the texture has been converted to RGB, we don't actually know what |
| 1913 // Color space the output is in. |
| 1914 color_space = config_change_detector_->current_color_space(); |
| 1915 } |
1896 // TODO(henryhsu): Use correct visible size instead of (0, 0). We can't use | 1916 // TODO(henryhsu): Use correct visible size instead of (0, 0). We can't use |
1897 // coded size here so use (0, 0) intentionally to have the client choose. | 1917 // coded size here so use (0, 0) intentionally to have the client choose. |
1898 Picture picture(picture_buffer_id, input_buffer_id, gfx::Rect(0, 0), false); | 1918 Picture picture(picture_buffer_id, input_buffer_id, gfx::Rect(0, 0), |
| 1919 color_space, false); |
1899 client_->PictureReady(picture); | 1920 client_->PictureReady(picture); |
1900 } | 1921 } |
1901 } | 1922 } |
1902 | 1923 |
1903 void DXVAVideoDecodeAccelerator::NotifyInputBuffersDropped() { | 1924 void DXVAVideoDecodeAccelerator::NotifyInputBuffersDropped() { |
1904 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1925 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
1905 if (!client_) | 1926 if (!client_) |
1906 return; | 1927 return; |
1907 | 1928 |
1908 for (PendingInputs::iterator it = pending_input_buffers_.begin(); | 1929 for (PendingInputs::iterator it = pending_input_buffers_.begin(); |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2685 SetState(kConfigChange); | 2706 SetState(kConfigChange); |
2686 Invalidate(); | 2707 Invalidate(); |
2687 Initialize(config_, client_); | 2708 Initialize(config_, client_); |
2688 decoder_thread_task_runner_->PostTask( | 2709 decoder_thread_task_runner_->PostTask( |
2689 FROM_HERE, | 2710 FROM_HERE, |
2690 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2711 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
2691 base::Unretained(this))); | 2712 base::Unretained(this))); |
2692 } | 2713 } |
2693 | 2714 |
2694 } // namespace media | 2715 } // namespace media |
OLD | NEW |