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

Unified Diff: content/common/gpu/media/omx_video_decode_accelerator.cc

Issue 9346012: Video decode in hardware on ARM platform. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/omx_video_decode_accelerator.cc
===================================================================
--- content/common/gpu/media/omx_video_decode_accelerator.cc (revision 120554)
+++ content/common/gpu/media/omx_video_decode_accelerator.cc (working copy)
@@ -22,7 +22,7 @@
enum { kNumPictureBuffers = 4 };
// Open the libnvomx here for now.
-void* omx_handle = dlopen("libnvomx.so", RTLD_NOW);
+void* omx_handle = dlopen("libOMXCore.so", RTLD_NOW);
Ami GONE FROM CHROMIUM 2012/03/12 16:48:30 Is this capitalization open to discussion? The teg
typedef OMX_ERRORTYPE (*OMXInit)();
typedef OMX_ERRORTYPE (*OMXGetHandle)(
@@ -107,11 +107,13 @@
input_buffer_size_(0),
input_port_(0),
input_buffers_at_component_(0),
+ output_buffer_size_(0),
output_port_(0),
output_buffers_at_component_(0),
client_(client),
profile_(OMX_VIDEO_AVCProfileMax),
- component_name_is_nvidia_h264ext_(false) {
+ component_name_is_nvidia_h264ext_(false),
+ component_name_is_sec_h264ext_(false) {
RETURN_ON_FAILURE(AreOMXFunctionPointersInitialized(),
"Failed to load openmax library", PLATFORM_FAILURE,);
RETURN_ON_OMX_FAILURE(omx_init(), "Failed to init OpenMAX core",
@@ -160,13 +162,15 @@
if (!AllocateInputBuffers()) // Does its own RETURN_ON_FAILURE dances.
return false;
+ if (!AllocateFakeOutputBuffers()) // Does its own RETURN_ON_FAILURE dances.
+ return false;
return true;
}
bool OmxVideoDecodeAccelerator::CreateComponent() {
DCHECK_EQ(message_loop_, MessageLoop::current());
- OMX_CALLBACKTYPE omx_accelerator_callbacks = {
+ static OMX_CALLBACKTYPE omx_accelerator_callbacks = {
Ami GONE FROM CHROMIUM 2012/03/12 16:48:30 Why?
&OmxVideoDecodeAccelerator::EventHandler,
&OmxVideoDecodeAccelerator::EmptyBufferCallback,
&OmxVideoDecodeAccelerator::FillBufferCallback
@@ -199,6 +203,13 @@
reinterpret_cast<char *>(component.get()),
"OMX.Nvidia.h264ext.decode");
+ component_name_is_sec_h264ext_ = !strcmp(
+ reinterpret_cast<char *>(component.get()),
+ "OMX.SEC.AVC.Decoder");
+ Gles2TextureToEglImageTranslator* texture_to_egl_image_translator =
+ new Gles2TextureToEglImageTranslator(component_name_is_sec_h264ext_);
+ texture_to_egl_image_translator_.reset(texture_to_egl_image_translator);
+
// Get the port information. This will obtain information about the number of
// ports and index of the first port.
OMX_PORT_PARAM_TYPE port_param;
@@ -256,6 +267,7 @@
// Set output port parameters.
port_format.nBufferCountActual = kNumPictureBuffers;
port_format.nBufferCountMin = kNumPictureBuffers;
+ output_buffer_size_ = port_format.nBufferSize;
// Force an OMX_EventPortSettingsChanged event to be sent once we know the
// stream's real dimensions (which can only happen once some Decode() work has
// been done).
@@ -267,20 +279,6 @@
RETURN_ON_OMX_FAILURE(result,
"SetParameter(OMX_IndexParamPortDefinition) failed",
PLATFORM_FAILURE, false);
-
- // Fill the component with fake output buffers. This seems to be required for
- // the component to move from Loaded to Idle. How bogus.
- for (int i = 0; i < kNumPictureBuffers; ++i) {
- OMX_BUFFERHEADERTYPE* buffer;
- result = OMX_UseBuffer(component_handle_, &buffer, output_port_,
- NULL, 0, reinterpret_cast<OMX_U8*>(0x1));
- RETURN_ON_OMX_FAILURE(result, "OMX_UseBuffer failed",
- PLATFORM_FAILURE, false);
- buffer->pAppPrivate = NULL;
- buffer->nTimeStamp = -1;
- buffer->nOutputPortIndex = output_port_;
- CHECK(fake_output_buffers_.insert(buffer).second);
- }
return true;
}
@@ -344,10 +342,12 @@
DCHECK_EQ(fake_output_buffers_.size(), 0U);
DCHECK_EQ(pictures_.size(), 0U);
- static Gles2TextureToEglImageTranslator texture2eglImage_translator;
for (size_t i = 0; i < buffers.size(); ++i) {
- EGLImageKHR egl_image = texture2eglImage_translator.TranslateToEglImage(
- egl_display_, egl_context_, buffers[i].texture_id());
+ EGLImageKHR egl_image =
+ texture_to_egl_image_translator_->TranslateToEglImage(
+ egl_display_, egl_context_,
+ buffers[i].texture_id(),
+ last_requested_picture_buffer_dimensions_);
CHECK(pictures_.insert(std::make_pair(
buffers[i].id(), OutputPicture(buffers[i], NULL, egl_image))).second);
}
@@ -657,6 +657,30 @@
return true;
}
+bool OmxVideoDecodeAccelerator::AllocateFakeOutputBuffers() {
+ // Fill the component with fake output buffers.
+ for (unsigned int i = 0; i < kNumPictureBuffers; ++i) {
+ OMX_BUFFERHEADERTYPE* buffer;
+ OMX_ERRORTYPE result;
+ if (component_name_is_sec_h264ext_) {
+ result = OMX_AllocateBuffer(component_handle_, &buffer, output_port_,
+ NULL, output_buffer_size_);
Ami GONE FROM CHROMIUM 2012/03/12 16:48:30 Since this buffer will never be used for anything
+ RETURN_ON_OMX_FAILURE(result, "OMX_AllocateBuffer failed",
+ PLATFORM_FAILURE, false);
+ } else {
+ result = OMX_UseBuffer(component_handle_, &buffer, output_port_,
+ NULL, 0, reinterpret_cast<OMX_U8*>(0x1));
+ RETURN_ON_OMX_FAILURE(result, "OMX_UseBuffer failed",
+ PLATFORM_FAILURE, false);
+ }
+ buffer->pAppPrivate = NULL;
+ buffer->nTimeStamp = -1;
+ buffer->nOutputPortIndex = output_port_;
+ CHECK(fake_output_buffers_.insert(buffer).second);
+ }
+ return true;
+}
+
bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() {
DCHECK_EQ(message_loop_, MessageLoop::current());
@@ -696,7 +720,6 @@
DCHECK_EQ(message_loop_, MessageLoop::current());
// Calls to OMX to free buffers.
OMX_ERRORTYPE result;
- static Gles2TextureToEglImageTranslator texture2eglImage_translator;
for (OutputPictureById::iterator it = pictures_.begin();
it != pictures_.end(); ++it) {
OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header;
@@ -704,8 +727,8 @@
delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate);
result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer);
RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,);
- texture2eglImage_translator.DestroyEglImage(egl_display_,
- it->second.egl_image);
+ texture_to_egl_image_translator_->DestroyEglImage(egl_display_,
+ it->second.egl_image);
if (client_)
client_->DismissPictureBuffer(it->first);
}
@@ -730,6 +753,8 @@
// ProvidePictureBuffers() will trigger AssignPictureBuffers, which ultimately
// assigns the textures to the component and re-enables the port.
const OMX_VIDEO_PORTDEFINITIONTYPE& vformat = port_format.format.video;
+ last_requested_picture_buffer_dimensions_.SetSize(vformat.nFrameWidth,
+ vformat.nFrameHeight);
if (client_) {
client_->ProvidePictureBuffers(
kNumPictureBuffers,
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698