OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/gpu/media/omx_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/omx_video_decode_accelerator.h" |
6 | 6 |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
10 #include "content/common/gpu/media/gles2_texture_to_egl_image_translator.h" | 10 #include "content/common/gpu/media/gles2_texture_to_egl_image_translator.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 const std::vector<media::GLESBuffer>& buffers) { | 384 const std::vector<media::GLESBuffer>& buffers) { |
385 if (!CanFillBuffer()) { | 385 if (!CanFillBuffer()) { |
386 StopOnError(VIDEODECODERERROR_UNINITIALIZED); | 386 StopOnError(VIDEODECODERERROR_UNINITIALIZED); |
387 return; | 387 return; |
388 } | 388 } |
389 CHECK_EQ(output_buffers_at_component_, 0); | 389 CHECK_EQ(output_buffers_at_component_, 0); |
390 CHECK_EQ(fake_output_buffers_.size(), 0U); | 390 CHECK_EQ(fake_output_buffers_.size(), 0U); |
391 CHECK_EQ(pictures_.size(), 0U); | 391 CHECK_EQ(pictures_.size(), 0U); |
392 | 392 |
393 CHECK_EQ(message_loop_, MessageLoop::current()); | 393 CHECK_EQ(message_loop_, MessageLoop::current()); |
394 static Gles2TextureToEglImageTranslator texture2eglImage_translator; | |
394 for (size_t i = 0; i < buffers.size(); ++i) { | 395 for (size_t i = 0; i < buffers.size(); ++i) { |
396 void* egl_image = texture2eglImage_translator.TranslateToEglImage( | |
Ami GONE FROM CHROMIUM
2011/07/07 06:13:33
s/void*/EGLImageKHR/ here and below.
| |
397 egl_display_, egl_context_, buffers[i].texture_id()); | |
395 CHECK(pictures_.insert(std::make_pair( | 398 CHECK(pictures_.insert(std::make_pair( |
396 buffers[i].id(), OutputPicture(buffers[i], NULL))).second); | 399 buffers[i].id(), OutputPicture(buffers[i], NULL, egl_image))).second); |
397 } | 400 } |
398 | 401 |
399 if (pictures_.size() < kNumPictureBuffers) | 402 if (pictures_.size() < kNumPictureBuffers) |
400 return; // get all the buffers first. | 403 return; // get all the buffers first. |
401 DCHECK_EQ(pictures_.size(), kNumPictureBuffers); | 404 DCHECK_EQ(pictures_.size(), kNumPictureBuffers); |
402 | 405 |
403 if (!AllocateOutputBuffers()) { | 406 if (!AllocateOutputBuffers()) { |
404 LOG(ERROR) << "OMX_AllocateBuffer() Output buffer error"; | 407 LOG(ERROR) << "OMX_AllocateBuffer() Output buffer error"; |
405 StopOnError(VIDEODECODERERROR_MEMFAILURE); | 408 StopOnError(VIDEODECODERERROR_MEMFAILURE); |
406 return; | 409 return; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 buffer->nInputPortIndex = input_port_; | 684 buffer->nInputPortIndex = input_port_; |
682 buffer->nOffset = 0; | 685 buffer->nOffset = 0; |
683 buffer->nFlags = 0; | 686 buffer->nFlags = 0; |
684 free_input_buffers_.push(buffer); | 687 free_input_buffers_.push(buffer); |
685 } | 688 } |
686 return true; | 689 return true; |
687 } | 690 } |
688 | 691 |
689 bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() { | 692 bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() { |
690 CHECK_EQ(message_loop_, MessageLoop::current()); | 693 CHECK_EQ(message_loop_, MessageLoop::current()); |
691 static Gles2TextureToEglImageTranslator texture2eglImage_translator; | |
692 | 694 |
693 DCHECK(!pictures_.empty()); | 695 DCHECK(!pictures_.empty()); |
694 gfx::Size decoded_pixel_size(pictures_.begin()->second.gles_buffer.size()); | 696 gfx::Size decoded_pixel_size(pictures_.begin()->second.gles_buffer.size()); |
695 gfx::Size visible_pixel_size(pictures_.begin()->second.gles_buffer.size()); | 697 gfx::Size visible_pixel_size(pictures_.begin()->second.gles_buffer.size()); |
696 for (OutputPictureById::iterator it = pictures_.begin(); | 698 for (OutputPictureById::iterator it = pictures_.begin(); |
697 it != pictures_.end(); ++it) { | 699 it != pictures_.end(); ++it) { |
698 media::GLESBuffer& gles_buffer = it->second.gles_buffer; | 700 media::GLESBuffer& gles_buffer = it->second.gles_buffer; |
699 OMX_BUFFERHEADERTYPE** omx_buffer = &it->second.omx_buffer_header; | 701 OMX_BUFFERHEADERTYPE** omx_buffer = &it->second.omx_buffer_header; |
700 DCHECK(!*omx_buffer); | 702 DCHECK(!*omx_buffer); |
701 void* egl = texture2eglImage_translator.TranslateToEglImage( | |
702 egl_display_, egl_context_, gles_buffer.texture_id()); | |
703 OMX_ERRORTYPE result = OMX_UseEGLImage( | 703 OMX_ERRORTYPE result = OMX_UseEGLImage( |
704 component_handle_, omx_buffer, output_port_, &gles_buffer, egl); | 704 component_handle_, omx_buffer, output_port_, &gles_buffer, |
705 it->second.egl_image); | |
705 if (result != OMX_ErrorNone) { | 706 if (result != OMX_ErrorNone) { |
706 LOG(ERROR) << "OMX_UseEGLImage failed with: " << result; | 707 LOG(ERROR) << "OMX_UseEGLImage failed with: " << result; |
707 return false; | 708 return false; |
708 } | 709 } |
709 // Here we set a garbage bitstream buffer id, and then overwrite it before | 710 // Here we set a garbage bitstream buffer id, and then overwrite it before |
710 // passing to PictureReady. | 711 // passing to PictureReady. |
711 int garbage_bitstream_buffer_id = -1; | 712 int garbage_bitstream_buffer_id = -1; |
712 (*omx_buffer)->pAppPrivate = | 713 (*omx_buffer)->pAppPrivate = |
713 new media::Picture(gles_buffer.id(), garbage_bitstream_buffer_id, | 714 new media::Picture(gles_buffer.id(), garbage_bitstream_buffer_id, |
714 decoded_pixel_size, visible_pixel_size); | 715 decoded_pixel_size, visible_pixel_size); |
(...skipping 14 matching lines...) Expand all Loading... | |
729 StopOnError(VIDEODECODERERROR_INVALIDINPUT); | 730 StopOnError(VIDEODECODERERROR_INVALIDINPUT); |
730 return; | 731 return; |
731 } | 732 } |
732 } | 733 } |
733 VLOG(1) << "Input buffers freed."; | 734 VLOG(1) << "Input buffers freed."; |
734 } | 735 } |
735 | 736 |
736 void OmxVideoDecodeAccelerator::FreeOutputBuffers() { | 737 void OmxVideoDecodeAccelerator::FreeOutputBuffers() { |
737 // Calls to OMX to free buffers. | 738 // Calls to OMX to free buffers. |
738 OMX_ERRORTYPE result; | 739 OMX_ERRORTYPE result; |
740 static Gles2TextureToEglImageTranslator texture2eglImage_translator; | |
739 for (OutputPictureById::iterator it = pictures_.begin(); | 741 for (OutputPictureById::iterator it = pictures_.begin(); |
740 it != pictures_.end(); ++it) { | 742 it != pictures_.end(); ++it) { |
741 OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header; | 743 OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header; |
742 CHECK(omx_buffer); | 744 CHECK(omx_buffer); |
743 delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate); | 745 delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate); |
744 result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer); | 746 result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer); |
745 if (result != OMX_ErrorNone) { | 747 if (result != OMX_ErrorNone) { |
746 LOG(ERROR) << "OMX_FreeBuffer failed with: " << result; | 748 LOG(ERROR) << "OMX_FreeBuffer failed with: " << result; |
747 StopOnError(VIDEODECODERERROR_INVALIDINPUT); | 749 StopOnError(VIDEODECODERERROR_INVALIDINPUT); |
748 return; | 750 return; |
749 } | 751 } |
752 texture2eglImage_translator.DestroyEglImage(egl_display_, | |
753 it->second.egl_image); | |
750 client_->DismissPictureBuffer(it->first); | 754 client_->DismissPictureBuffer(it->first); |
751 } | 755 } |
752 pictures_.clear(); | 756 pictures_.clear(); |
753 } | 757 } |
754 | 758 |
755 void OmxVideoDecodeAccelerator::OnIndexParamPortDefinitionChanged(int port) { | 759 void OmxVideoDecodeAccelerator::OnIndexParamPortDefinitionChanged(int port) { |
756 DCHECK_EQ(port, output_port_); | 760 DCHECK_EQ(port, output_port_); |
757 DCHECK(!on_port_disable_event_func_); | 761 DCHECK(!on_port_disable_event_func_); |
758 on_port_disable_event_func_ = | 762 on_port_disable_event_func_ = |
759 &OmxVideoDecodeAccelerator::PortDisabledForSettingsChange; | 763 &OmxVideoDecodeAccelerator::PortDisabledForSettingsChange; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1030 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, | 1034 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, |
1031 cmd, port_index, 0); | 1035 cmd, port_index, 0); |
1032 if (result != OMX_ErrorNone) { | 1036 if (result != OMX_ErrorNone) { |
1033 LOG(ERROR) << "SendCommand() failed" << cmd << ":" << result; | 1037 LOG(ERROR) << "SendCommand() failed" << cmd << ":" << result; |
1034 StopOnError(VIDEODECODERERROR_INVALIDINPUT); | 1038 StopOnError(VIDEODECODERERROR_INVALIDINPUT); |
1035 return; | 1039 return; |
1036 } | 1040 } |
1037 } | 1041 } |
1038 | 1042 |
1039 DISABLE_RUNNABLE_METHOD_REFCOUNT(OmxVideoDecodeAccelerator); | 1043 DISABLE_RUNNABLE_METHOD_REFCOUNT(OmxVideoDecodeAccelerator); |
OLD | NEW |