Commit ee2a19b1 authored by fischman@chromium.org's avatar fischman@chromium.org

Revert 86681 - Updated OMX decoder for recent PPAPI changes, and added to the build.

Had to move from content/gpu to content/common/gpu to allow gpu_video_service.cc
to depend on the decoder.
Removed some dead code and did some random cleanup while I was in there.

BUG=none
TEST=chrome compiles on cros/arm!

Review URL: http://codereview.chromium.org/7057027

TBR=fischman@chromium.org
Review URL: http://codereview.chromium.org/6979017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86687 0039d316-1c4b-4281-b951-d872f2087c98
parent 76420799
......@@ -3471,6 +3471,22 @@
# '<(DEPTH)/ui/gfx/size.cc',
# '<(DEPTH)/ui/gfx/size.h',
# ],
# 'conditions': [
# ['target_arch=="arm"', {
# 'sources': [
# '<(DEPTH)/content/gpu/gles2_texture_to_egl_image_translator.cc',
# '<(DEPTH)/content/gpu/gles2_texture_to_egl_image_translator.h',
# '<(DEPTH)/content/gpu/omx_video_decode_accelerator.cc',
# '<(DEPTH)/content/gpu/omx_video_decode_accelerator.h',
# ],
# 'link_settings': {
# 'libraries': [
# '-lEGL',
# '-lGLESv2',
# ],
# },
# }],
# ],
# },
{
'target_name': 'plugin_tests',
......
......@@ -6,5 +6,4 @@ include_rules = [
"+media/base",
"+media/video",
"+skia",
"+third_party/openmax",
]
......@@ -108,7 +108,7 @@ void GpuVideoDecodeAccelerator::OnGetConfigs(
void GpuVideoDecodeAccelerator::OnInitialize(
const std::vector<uint32>& configs) {
if (!video_decode_accelerator_.get())
if (!video_decode_accelerator_)
return;
video_decode_accelerator_->Initialize(configs);
......@@ -117,7 +117,7 @@ void GpuVideoDecodeAccelerator::OnInitialize(
void GpuVideoDecodeAccelerator::OnDecode(int32 id,
base::SharedMemoryHandle handle,
int32 size) {
if (!video_decode_accelerator_.get())
if (!video_decode_accelerator_)
return;
video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size));
}
......@@ -140,14 +140,14 @@ void GpuVideoDecodeAccelerator::OnAssignSysmemBuffers(
}
void GpuVideoDecodeAccelerator::OnReusePictureBuffer(int32 picture_buffer_id) {
if (!video_decode_accelerator_.get())
if (!video_decode_accelerator_)
return;
video_decode_accelerator_->ReusePictureBuffer(picture_buffer_id);
}
void GpuVideoDecodeAccelerator::OnFlush() {
if (!video_decode_accelerator_.get())
if (!video_decode_accelerator_)
return;
if (!video_decode_accelerator_->Flush()) {
......@@ -157,7 +157,7 @@ void GpuVideoDecodeAccelerator::OnFlush() {
}
void GpuVideoDecodeAccelerator::OnAbort() {
if (!video_decode_accelerator_.get())
if (!video_decode_accelerator_)
return;
video_decode_accelerator_->Abort();
......
......@@ -45,8 +45,7 @@ class GpuVideoDecodeAccelerator
void set_video_decode_accelerator(
media::VideoDecodeAccelerator* accelerator) {
DCHECK(!video_decode_accelerator_.get());
video_decode_accelerator_.reset(accelerator);
video_decode_accelerator_ = accelerator;
}
private:
......@@ -73,7 +72,7 @@ class GpuVideoDecodeAccelerator
int32 route_id_;
// Pointer to the underlying VideoDecodeAccelerator.
scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_;
media::VideoDecodeAccelerator* video_decode_accelerator_;
DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator);
};
......
......@@ -8,10 +8,6 @@
#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/gpu_video_decode_accelerator.h"
#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
#include "content/common/gpu/omx_video_decode_accelerator.h"
#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
GpuVideoService::GpuVideoService() {
// TODO(jiesun): move this time consuming stuff out of here.
IntializeGpuVideoService();
......@@ -61,10 +57,6 @@ bool GpuVideoService::CreateVideoDecoder(
// Create GpuVideoDecodeAccelerator and add to map.
scoped_refptr<GpuVideoDecodeAccelerator> decoder =
new GpuVideoDecodeAccelerator(channel, decoder_host_id);
#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
decoder->set_video_decode_accelerator(
new OmxVideoDecodeAccelerator(decoder, MessageLoop::current()));
#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
bool result = decoder_map_.insert(std::make_pair(decoder_id, decoder)).second;
......
......@@ -289,23 +289,6 @@
'../gpu/gpu.gyp:command_buffer_service',
],
}],
['target_arch=="arm"', {
'sources': [
'common/gpu/gles2_texture_to_egl_image_translator.cc',
'common/gpu/gles2_texture_to_egl_image_translator.h',
'common/gpu/omx_video_decode_accelerator.cc',
'common/gpu/omx_video_decode_accelerator.h',
],
'include_dirs': [
'<(DEPTH)/third_party/openmax/il',
],
'link_settings': {
'libraries': [
'-lEGL',
'-lGLESv2',
],
},
}],
],
},
],
......
......@@ -8,4 +8,5 @@ include_rules = [
"+media/video",
"+sandbox",
"+skia",
"+third_party/openmax",
]
......@@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/common/gpu/gles2_texture_to_egl_image_translator.h"
#include "base/logging.h"
#include "content/gpu/gles2_texture_to_egl_image_translator.h"
// Get EGL extension functions.
static PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr =
......@@ -71,3 +69,5 @@ void Gles2TextureToEglImageTranslator::DestroyEglImage(EGLImageKHR egl_image) {
}
egl_destroy_image_khr(egl_display_, egl_image);
}
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_COMMON_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
#define CONTENT_COMMON_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
#ifndef CONTENT_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
#define CONTENT_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
#include <EGL/egl.h>
#include <EGL/eglext.h>
......@@ -36,4 +36,6 @@ class Gles2TextureToEglImageTranslator {
DISALLOW_IMPLICIT_CONSTRUCTORS(Gles2TextureToEglImageTranslator);
};
#endif // CONTENT_COMMON_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
#endif // CONTENT_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
#define CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
#ifndef CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
#define CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
#include <dlfcn.h>
#include <map>
......@@ -30,25 +30,20 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
virtual ~OmxVideoDecodeAccelerator();
// media::VideoDecodeAccelerator implementation.
void GetConfigs(const std::vector<uint32>& requested_configs,
std::vector<uint32>* matched_configs) OVERRIDE;
bool Initialize(const std::vector<uint32>& config) OVERRIDE;
bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
virtual void AssignGLESBuffers(
const std::vector<media::GLESBuffer>& buffers) OVERRIDE;
virtual void AssignSysmemBuffers(
const std::vector<media::SysmemBuffer>& buffers) OVERRIDE;
void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
bool Flush() OVERRIDE;
bool Abort() OVERRIDE;
const std::vector<uint32>& GetConfig(
const std::vector<uint32>& prototype_config);
bool Initialize(const std::vector<uint32>& config);
bool Decode(const media::BitstreamBuffer& bitstream_buffer,
const media::VideoDecodeAcceleratorCallback& callback);
void AssignPictureBuffer(std::vector<PictureBuffer*> picture_buffers);
void ReusePictureBuffer(int32 picture_buffer_id);
bool Flush(const media::VideoDecodeAcceleratorCallback& callback);
bool Abort(const media::VideoDecodeAcceleratorCallback& callback);
private:
MessageLoop* message_loop_;
OMX_HANDLETYPE component_handle_;
// Common initialization code for Assign{GLES,Sysmem}Buffers.
void AssignBuffersHelper(const std::vector<media::BaseBuffer*>& buffers);
// Create the Component for OMX. Handles all OMX initialization.
bool CreateComponent();
// Buffer allocation/free methods for input and output buffers.
......@@ -107,13 +102,18 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_;
// For output buffer recycling cases.
std::vector<media::BaseBuffer*> assigned_picture_buffers_;
typedef std::pair<int32, OMX_BUFFERHEADERTYPE*> OutputPicture;
std::vector<media::VideoDecodeAccelerator::PictureBuffer*>
assigned_picture_buffers_;
typedef std::pair<PictureBuffer*,
OMX_BUFFERHEADERTYPE*> OutputPicture;
std::vector<OutputPicture> output_pictures_;
// To expose client callbacks from VideoDecodeAccelerator.
Client* client_;
media::VideoDecodeAcceleratorCallback flush_done_callback_;
media::VideoDecodeAcceleratorCallback abort_done_callback_;
std::vector<uint32> texture_ids_;
std::vector<uint32> context_ids_;
// Method to handle events
......@@ -127,10 +127,14 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
// Method to receive buffers from component's output port
void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer);
typedef std::pair<OMX_BUFFERHEADERTYPE*, uint32> OMXbufferTexture;
// void pointer to hold EGLImage handle.
void* egl_image_;
typedef std::map<OMX_BUFFERHEADERTYPE*,
std::pair<base::SharedMemory*, int32> > OMXBufferIdMap;
OMXBufferIdMap omx_buff_ids_;
typedef std::map<
OMX_BUFFERHEADERTYPE*,
std::pair<base::SharedMemory*,
media::VideoDecodeAcceleratorCallback> > OMXBufferCallbackMap;
OMXBufferCallbackMap omx_buff_cb_;
// Method used the change the state of the port.
void ChangePort(OMX_COMMANDTYPE cmd, int port_index);
......@@ -158,4 +162,4 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
OMX_BUFFERHEADERTYPE* buffer);
};
#endif // CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
#endif // CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
......@@ -14,6 +14,7 @@
#include "ipc/ipc_message_utils.h"
using media::VideoDecodeAccelerator;
using media::VideoDecodeAcceleratorCallback;
GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost(
MessageRouter* router,
......@@ -104,11 +105,11 @@ void GpuVideoDecodeAcceleratorHost::AssignGLESBuffers(
std::vector<uint32> context_ids;
std::vector<gfx::Size> sizes;
for (uint32 i = 0; i < buffers.size(); i++) {
const media::GLESBuffer& buffer = buffers[i];
texture_ids.push_back(buffer.texture_id());
context_ids.push_back(buffer.context_id());
buffer_ids.push_back(buffer.id());
sizes.push_back(buffer.size());
const media::BufferInfo& info = buffers[i].buffer_info();
texture_ids.push_back(buffers[i].texture_id());
context_ids.push_back(buffers[i].context_id());
buffer_ids.push_back(info.id());
sizes.push_back(info.size());
}
if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_AssignGLESBuffers(
decoder_id_, buffer_ids, texture_ids, context_ids, sizes))) {
......
......@@ -15,6 +15,7 @@
#include "content/renderer/render_thread.h"
using media::BitstreamBuffer;
using media::VideoDecodeAcceleratorCallback;
PlatformVideoDecoderImpl::PlatformVideoDecoderImpl(
VideoDecodeAccelerator::Client* client)
......
......@@ -6,22 +6,25 @@
namespace media {
BaseBuffer::~BaseBuffer() {}
// Implementations for the other constructors are found in
// webkit/plugins/ppapi/ppb_video_decoder_impl.cc.
// They are not included in this file because it would require
// media/ to depend on files in ppapi/.
BaseBuffer::BaseBuffer(int32 id, gfx::Size size) : id_(id), size_(size) {
BufferInfo::BufferInfo(int32 id, gfx::Size size)
: id_(id),
size_(size) {
}
GLESBuffer::GLESBuffer(
int32 id, gfx::Size size, uint32 texture_id, uint32 context_id)
: BaseBuffer(id, size), texture_id_(texture_id), context_id_(context_id) {
: texture_id_(texture_id),
context_id_(context_id),
info_(id, size) {
}
SysmemBuffer::SysmemBuffer(int32 id, gfx::Size size, void* data)
: BaseBuffer(id, size), data_(data) {
: data_(data),
info_(id, size) {
}
Picture::Picture(int32 picture_buffer_id, int32 bitstream_buffer_id,
......
......@@ -15,13 +15,12 @@ struct PP_SysmemBuffer_Dev;
namespace media {
// Common information about GLES & Sysmem picture buffers.
// Information about the picture buffer.
// This is the media-namespace equivalent of PP_BufferInfo_Dev.
class BaseBuffer {
class BufferInfo {
public:
BaseBuffer(int32 id, gfx::Size size);
BaseBuffer(const PP_BufferInfo_Dev& info);
virtual ~BaseBuffer();
BufferInfo(int32 id, gfx::Size size);
BufferInfo(const PP_BufferInfo_Dev& info);
// Returns the client-specified id of the buffer.
int32 id() const {
......@@ -40,7 +39,7 @@ class BaseBuffer {
// A picture buffer that is composed of a GLES2 texture and context.
// This is the media-namespace equivalent of PP_GLESBuffer_Dev.
class GLESBuffer : public BaseBuffer {
class GLESBuffer {
public:
GLESBuffer(int32 id, gfx::Size size, uint32 texture_id, uint32 context_id);
GLESBuffer(const PP_GLESBuffer_Dev& buffer);
......@@ -57,14 +56,20 @@ class GLESBuffer : public BaseBuffer {
return context_id_;
}
// Returns information regarding the buffer.
const BufferInfo& buffer_info() const {
return info_;
}
private:
uint32 texture_id_;
uint32 context_id_;
BufferInfo info_;
};
// A picture buffer that lives in system memory.
// This is the media-namespace equivalent of PP_SysmemBuffer_Dev.
class SysmemBuffer : public BaseBuffer {
class SysmemBuffer {
public:
SysmemBuffer(int32 id, gfx::Size size, void* data);
SysmemBuffer(const PP_SysmemBuffer_Dev&);
......@@ -74,8 +79,14 @@ class SysmemBuffer : public BaseBuffer {
return data_;
}
// Returns information regarding the buffer.
const BufferInfo& buffer_info() const {
return info_;
}
private:
void* data_;
BufferInfo info_;
};
// A decoded picture frame.
......@@ -92,9 +103,7 @@ class Picture {
}
// Returns the id of the bitstream buffer from which this frame was decoded.
// TODO(fischman,vrk): Remove this field; pictures can span arbitrarily many
// BitstreamBuffers, and it's not clear what clients would do with this
// information, anyway.
// TODO(vrk): Handle the case where a picture can span multiple buffers.
int32 bitstream_buffer_id() const {
return bitstream_buffer_id_;
}
......
......@@ -15,6 +15,8 @@
namespace media {
typedef Callback0::Type VideoDecodeAcceleratorCallback;
// Enumeration defining global dictionary ranges for various purposes that are
// used to handle the configurations of the video decoder.
enum VideoAttributeKey {
......
......@@ -398,7 +398,7 @@ void PPB_VideoDecoder_Impl::NotifyFlushDone() {
// These functions are declared in picture.h but are defined here because of
// dependencies (we can't depend on ppapi types from media).
namespace media {
BaseBuffer::BaseBuffer(const PP_BufferInfo_Dev& info)
BufferInfo::BufferInfo(const PP_BufferInfo_Dev& info)
: id_(info.id),
size_(info.size.width, info.size.height) {
}
......@@ -406,13 +406,13 @@ BaseBuffer::BaseBuffer(const PP_BufferInfo_Dev& info)
// TODO(vrk): This assigns the PP_Resource context to be
// the context_id. Not sure what it's actually supposed to be.
GLESBuffer::GLESBuffer(const PP_GLESBuffer_Dev& buffer)
: BaseBuffer(buffer.info),
texture_id_(buffer.texture_id),
context_id_(buffer.context) {
: texture_id_(buffer.texture_id),
context_id_(buffer.context),
info_(buffer.info) {
}
SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer)
: BaseBuffer(buffer.info) {
: info_(buffer.info) {
scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer =
webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>(
buffer.data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment