diff options
37 files changed, 157 insertions, 479 deletions
diff --git a/content/common/gpu/DEPS b/content/common/gpu/DEPS index aef4d63..98cc1f3 100644 --- a/content/common/gpu/DEPS +++ b/content/common/gpu/DEPS @@ -3,6 +3,7 @@ include_rules = [ "+gpu/command_buffer",
"+libEGL",
"+libGLESv2",
+ "+media/video/video_decode_accelerator.h",
"+skia",
"+third_party/angle/include",
"+third_party/openmax",
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 2f1caec..bebce90 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -537,7 +537,7 @@ void GpuCommandBufferStub::ReportState() { } void GpuCommandBufferStub::OnCreateVideoDecoder( - const std::vector<int32>& configs, + media::VideoDecodeAccelerator::Profile profile, IPC::Message* reply_message) { int decoder_route_id = channel_->GenerateRouteID(); GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams( @@ -546,7 +546,7 @@ void GpuCommandBufferStub::OnCreateVideoDecoder( new GpuVideoDecodeAccelerator(this, decoder_route_id, this); video_decoders_.AddWithID(decoder, decoder_route_id); channel_->AddRoute(decoder_route_id, decoder); - decoder->Initialize(configs, reply_message); + decoder->Initialize(profile, reply_message); } void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index e7c4050..d0319c6 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -114,8 +114,9 @@ class GpuCommandBufferStub void OnDestroyTransferBuffer(int32 id, IPC::Message* reply_message); void OnGetTransferBuffer(int32 id, IPC::Message* reply_message); - void OnCreateVideoDecoder(const std::vector<int32>& configs, - IPC::Message* reply_message); + void OnCreateVideoDecoder( + media::VideoDecodeAccelerator::Profile profile, + IPC::Message* reply_message); void OnDestroyVideoDecoder(int32 decoder_route_id); #if defined(OS_MACOSX) diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index 9d66de4..ded6b37 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -17,6 +17,7 @@ #include "gpu/ipc/gpu_command_buffer_traits.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" +#include "media/video/video_decode_accelerator.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/size.h" @@ -104,6 +105,8 @@ IPC_STRUCT_TRAITS_END() IPC_ENUM_TRAITS(content::CauseForGpuLaunch) IPC_ENUM_TRAITS(gpu::error::ContextLostReason) +IPC_ENUM_TRAITS(media::VideoDecodeAccelerator::Profile) + //------------------------------------------------------------------------------ // GPU Messages // These are messages from the browser to the GPU process. @@ -389,7 +392,7 @@ IPC_SYNC_MESSAGE_ROUTED1_2(GpuCommandBufferMsg_GetTransferBuffer, // Create and initialize a hardware video decoder, returning its new route_id. IPC_SYNC_MESSAGE_ROUTED1_1(GpuCommandBufferMsg_CreateVideoDecoder, - std::vector<int32> /* configs */, + media::VideoDecodeAccelerator::Profile /* profile */, int /* route_id */) // Release all resources held by the named hardware video decoder. diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc index 54e9091..42d1f65 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.cc +++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc @@ -104,7 +104,7 @@ void GpuVideoDecodeAccelerator::NotifyError( } void GpuVideoDecodeAccelerator::Initialize( - const std::vector<int32>& configs, + const media::VideoDecodeAccelerator::Profile profile, IPC::Message* init_done_msg) { DCHECK(!video_decode_accelerator_.get()); DCHECK(!init_done_msg_); @@ -117,7 +117,7 @@ void GpuVideoDecodeAccelerator::Initialize( gfx::GLSurfaceEGL::GetHardwareDisplay(), stub_->scheduler()->decoder()->GetGLContext()->GetHandle()); video_decode_accelerator_ = omx_decoder; - video_decode_accelerator_->Initialize(configs); + video_decode_accelerator_->Initialize(profile); #else NOTIMPLEMENTED() << "HW video decode acceleration not available."; NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.h b/content/common/gpu/media/gpu_video_decode_accelerator.h index 624f04f..f065cff 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.h +++ b/content/common/gpu/media/gpu_video_decode_accelerator.h @@ -43,9 +43,9 @@ class GpuVideoDecodeAccelerator // Function to delegate sending to actual sender. virtual bool Send(IPC::Message* message); - // Initialize the accelerator with the given configuration and send the + // Initialize the accelerator with the given profile and send the // |init_done_msg| when done. - void Initialize(const std::vector<int32>& configs, + void Initialize(const media::VideoDecodeAccelerator::Profile profile, IPC::Message* init_done_msg); private: diff --git a/content/common/gpu/media/omx_video_decode_accelerator.cc b/content/common/gpu/media/omx_video_decode_accelerator.cc index 89acf72..3f1ee3b 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator.cc +++ b/content/common/gpu/media/omx_video_decode_accelerator.cc @@ -46,36 +46,35 @@ static bool AreOMXFunctionPointersInitialized() { omx_free_handle && omx_deinit); } -// Maps the media::H264Profile members to the OMX_VIDEO_AVCPROFILETYPE members. +// Maps h264-related Profile enum values to OMX_VIDEO_AVCPROFILETYPE values. static OMX_U32 MapH264ProfileToOMXAVCProfile(uint32 profile) { switch (profile) { - case media::H264PROFILE_NONE: - return OMX_VIDEO_AVCProfileMax; - case media::H264PROFILE_BASELINE: + case media::VideoDecodeAccelerator::H264PROFILE_BASELINE: return OMX_VIDEO_AVCProfileBaseline; - case media::H264PROFILE_MAIN: + case media::VideoDecodeAccelerator::H264PROFILE_MAIN: return OMX_VIDEO_AVCProfileMain; - case media::H264PROFILE_EXTENDED: + case media::VideoDecodeAccelerator::H264PROFILE_EXTENDED: return OMX_VIDEO_AVCProfileExtended; - case media::H264PROFILE_HIGH: + case media::VideoDecodeAccelerator::H264PROFILE_HIGH: return OMX_VIDEO_AVCProfileHigh; - case media::H264PROFILE_HIGH10PROFILE: + case media::VideoDecodeAccelerator::H264PROFILE_HIGH10PROFILE: return OMX_VIDEO_AVCProfileHigh10; - case media::H264PROFILE_HIGH422PROFILE: + case media::VideoDecodeAccelerator::H264PROFILE_HIGH422PROFILE: return OMX_VIDEO_AVCProfileHigh422; - case media::H264PROFILE_HIGH444PREDICTIVEPROFILE: + case media::VideoDecodeAccelerator::H264PROFILE_HIGH444PREDICTIVEPROFILE: return OMX_VIDEO_AVCProfileHigh444; // Below enums don't have equivalent enum in Openmax. - case media::H264PROFILE_SCALABLEBASELINE: - case media::H264PROFILE_SCALABLEHIGH: - case media::H264PROFILE_STEREOHIGH: - case media::H264PROFILE_MULTIVIEWHIGH: + case media::VideoDecodeAccelerator::H264PROFILE_SCALABLEBASELINE: + case media::VideoDecodeAccelerator::H264PROFILE_SCALABLEHIGH: + case media::VideoDecodeAccelerator::H264PROFILE_STEREOHIGH: + case media::VideoDecodeAccelerator::H264PROFILE_MULTIVIEWHIGH: // Nvidia OMX video decoder requires the same resources (as that of the // High profile) in every profile higher to the Main profile. return OMX_VIDEO_AVCProfileHigh444; + default: + NOTREACHED(); + return OMX_VIDEO_AVCProfileMax; } - NOTREACHED(); - return OMX_VIDEO_AVCProfileMax; } // Helper macros for dealing with failure. If |result| evaluates false, emit @@ -133,44 +132,6 @@ void OmxVideoDecodeAccelerator::SetEglState( egl_context_ = egl_context; } -bool OmxVideoDecodeAccelerator::VerifyConfigs( - const std::vector<int32>& configs) { - size_t cur; - for (cur = 0; cur + 1 < configs.size(); cur++) { - uint32 n = configs[cur++]; - uint32 v = configs[cur]; - if ((n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_FOURCC && - v == media::VIDEOCODECFOURCC_H264) || - (n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_BITRATE && - v < 14000000 /* Baseline supports up to 14Mbps. */) || - (n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_WIDTH && - v <= 1920 /* Baseline supports upto 1080p. */) || - (n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_HEIGHT && - v <= 1080 /* Baseline supports up to 1080p. */) || - (n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_LEVEL || - n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_PAYLOADFORMAT || - n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_FMO || - n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_ASO || - n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_INTERLACE || - n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_CABAC || - /* TODO(fischman) Shorten the enum name. */ - n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_WEIGHTEDPREDICTION) - || - (n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_PROFILE && - (v == media::H264PROFILE_BASELINE || v == media::H264PROFILE_MAIN || - v == media::H264PROFILE_HIGH)) || - (n == media::VIDEOATTRIBUTEKEY_VIDEOCOLORFORMAT && - v == media::VIDEOCOLORFORMAT_RGBA)) { - if (n == media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_PROFILE) { - profile_ = v; - } - continue; - } - return false; - } - return cur == configs.size(); -} - // This is to initialize the OMX data structures to default values. template <typename T> static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { @@ -179,10 +140,15 @@ static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { param->nSize = sizeof(T); } -bool OmxVideoDecodeAccelerator::Initialize(const std::vector<int32>& config) { +bool OmxVideoDecodeAccelerator::Initialize(Profile profile) { DCHECK_EQ(message_loop_, MessageLoop::current()); - RETURN_ON_FAILURE(VerifyConfigs(config), "Invalid config", INVALID_ARGUMENT, - false); + + RETURN_ON_FAILURE(profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX, + "Only h264 supported", INVALID_ARGUMENT, false); + profile_ = MapH264ProfileToOMXAVCProfile(profile); + RETURN_ON_FAILURE(profile_ != OMX_VIDEO_AVCProfileMax, + "Unexpected profile", INVALID_ARGUMENT, false); + if (!CreateComponent()) // Does its own RETURN_ON_FAILURE dances. return false; @@ -515,9 +481,8 @@ void OmxVideoDecodeAccelerator::OnReachedIdleInInitializing() { DCHECK_EQ(client_state_, OMX_StateLoaded); client_state_ = OMX_StateIdle; // Query the resources with the component. - if (component_name_is_nvidia_h264ext_ && - (profile_ != OMX_VIDEO_AVCProfileMax)) { - OMX_INDEXTYPE extension_index; + if (component_name_is_nvidia_h264ext_) { + OMX_INDEXTYPE extension_index; OMX_ERRORTYPE result = OMX_GetExtensionIndex( component_handle_, const_cast<char*>("OMX.Nvidia.index.config.checkresources"), @@ -527,9 +492,7 @@ void OmxVideoDecodeAccelerator::OnReachedIdleInInitializing() { PLATFORM_FAILURE,); OMX_VIDEO_PARAM_PROFILELEVELTYPE video_profile_level; InitParam(*this, &video_profile_level); - video_profile_level.eProfile = MapH264ProfileToOMXAVCProfile(profile_); - RETURN_ON_FAILURE(video_profile_level.eProfile != OMX_VIDEO_AVCProfileMax, - "Unexpected profile", INVALID_ARGUMENT,); + video_profile_level.eProfile = profile_; result = OMX_SetConfig(component_handle_, extension_index, &video_profile_level); RETURN_ON_OMX_FAILURE(result, diff --git a/content/common/gpu/media/omx_video_decode_accelerator.h b/content/common/gpu/media/omx_video_decode_accelerator.h index b744068..d76cc5e 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator.h +++ b/content/common/gpu/media/omx_video_decode_accelerator.h @@ -42,7 +42,7 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); // media::VideoDecodeAccelerator implementation. - bool Initialize(const std::vector<int32>& config) OVERRIDE; + bool Initialize(Profile profile) OVERRIDE; void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; virtual void AssignPictureBuffers( const std::vector<media::PictureBuffer>& buffers) OVERRIDE; @@ -82,9 +82,6 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { }; typedef std::map<int32, OutputPicture> OutputPictureById; - // Verify that |config| is compatible with this class and hardware. - bool VerifyConfigs(const std::vector<int32>& configs); - MessageLoop* message_loop_; OMX_HANDLETYPE component_handle_; @@ -185,7 +182,7 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { Client* client_; // These two members are only used during Initialization. - // OMX_VIDEO_AVCProfile requested during Initialization. + // OMX_AVCProfile requested during Initialization. uint32 profile_; bool component_name_is_nvidia_h264ext_; diff --git a/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc b/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc index 49498e5..a2d4eb7 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc @@ -575,18 +575,11 @@ void EglRenderingVDAClient::CreateDecoder() { return; // Configure the decoder. - int32 config_array[] = { - media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_FOURCC, - media::VIDEOCODECFOURCC_H264, - media::VIDEOATTRIBUTEKEY_VIDEOCOLORFORMAT, media::VIDEOCOLORFORMAT_RGBA, - }; - std::vector<int32> config( - config_array, config_array + arraysize(config_array)); - if (profile_ != -1) { - config.push_back(media::VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_PROFILE); - config.push_back(profile_); - } - CHECK(decoder_->Initialize(config)); + media::VideoDecodeAccelerator::Profile profile = + media::VideoDecodeAccelerator::H264PROFILE_BASELINE; + if (profile_ != -1) + profile = static_cast<media::VideoDecodeAccelerator::Profile>(profile_); + CHECK(decoder_->Initialize(profile)); } void EglRenderingVDAClient::ProvidePictureBuffers( diff --git a/content/renderer/gpu/command_buffer_proxy.cc b/content/renderer/gpu/command_buffer_proxy.cc index c62210c..4c028c4 100644 --- a/content/renderer/gpu/command_buffer_proxy.cc +++ b/content/renderer/gpu/command_buffer_proxy.cc @@ -401,10 +401,10 @@ void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { scoped_refptr<GpuVideoDecodeAcceleratorHost> CommandBufferProxy::CreateVideoDecoder( - const std::vector<int32>& configs, + media::VideoDecodeAccelerator::Profile profile, media::VideoDecodeAccelerator::Client* client) { int decoder_route_id; - if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, configs, + if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, profile, &decoder_route_id))) { LOG(ERROR) << "Send(GpuChannelMsg_CreateVideoDecoder) failed"; return NULL; diff --git a/content/renderer/gpu/command_buffer_proxy.h b/content/renderer/gpu/command_buffer_proxy.h index 311cf9a..52cc471 100644 --- a/content/renderer/gpu/command_buffer_proxy.h +++ b/content/renderer/gpu/command_buffer_proxy.h @@ -91,7 +91,7 @@ class CommandBufferProxy : public gpu::CommandBuffer, // the GPU process, even if this returns non-NULL. In this case the client is // notified of an error later. scoped_refptr<GpuVideoDecodeAcceleratorHost> CreateVideoDecoder( - const std::vector<int32>& configs, + media::VideoDecodeAccelerator::Profile profile, media::VideoDecodeAccelerator::Client* client); private: diff --git a/content/renderer/gpu/gpu_channel_host.cc b/content/renderer/gpu/gpu_channel_host.cc index 910da7d..73bf14f 100644 --- a/content/renderer/gpu/gpu_channel_host.cc +++ b/content/renderer/gpu/gpu_channel_host.cc @@ -238,13 +238,13 @@ CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( GpuVideoDecodeAcceleratorHost* GpuChannelHost::CreateVideoDecoder( int command_buffer_route_id, - const std::vector<int32>& configs, + media::VideoDecodeAccelerator::Profile profile, media::VideoDecodeAccelerator::Client* client) { AutoLock lock(context_lock_); ProxyMap::iterator it = proxies_.find(command_buffer_route_id); DCHECK(it != proxies_.end()); CommandBufferProxy* proxy = it->second; - return proxy->CreateVideoDecoder(configs, client); + return proxy->CreateVideoDecoder(profile, client); } CommandBufferProxy* GpuChannelHost::CreateOffscreenCommandBuffer( diff --git a/content/renderer/gpu/gpu_channel_host.h b/content/renderer/gpu/gpu_channel_host.h index 44065bb..4bd9fbb 100644 --- a/content/renderer/gpu/gpu_channel_host.h +++ b/content/renderer/gpu/gpu_channel_host.h @@ -95,7 +95,7 @@ class GpuChannelHost : public IPC::Message::Sender, // Returned pointer is owned by the CommandBufferProxy for |route_id|. GpuVideoDecodeAcceleratorHost* CreateVideoDecoder( int command_buffer_route_id, - const std::vector<int32>& configs, + media::VideoDecodeAccelerator::Profile profile, media::VideoDecodeAccelerator::Client* client); // Destroy a command buffer created by this channel. diff --git a/content/renderer/gpu/gpu_video_decode_accelerator_host.cc b/content/renderer/gpu/gpu_video_decode_accelerator_host.cc index 2a58314..05697cb 100644 --- a/content/renderer/gpu/gpu_video_decode_accelerator_host.cc +++ b/content/renderer/gpu/gpu_video_decode_accelerator_host.cc @@ -60,8 +60,7 @@ bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { return handled; } -bool GpuVideoDecodeAcceleratorHost::Initialize( - const std::vector<int32>& configs) { +bool GpuVideoDecodeAcceleratorHost::Initialize(Profile profile) { NOTREACHED(); return true; } diff --git a/content/renderer/gpu/gpu_video_decode_accelerator_host.h b/content/renderer/gpu/gpu_video_decode_accelerator_host.h index de1c106..45d8c234 100644 --- a/content/renderer/gpu/gpu_video_decode_accelerator_host.h +++ b/content/renderer/gpu/gpu_video_decode_accelerator_host.h @@ -33,7 +33,7 @@ class GpuVideoDecodeAcceleratorHost virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; // media::VideoDecodeAccelerator implementation. - virtual bool Initialize(const std::vector<int32>& configs) OVERRIDE; + virtual bool Initialize(Profile profile) OVERRIDE; virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; virtual void AssignPictureBuffers( const std::vector<media::PictureBuffer>& buffers) OVERRIDE; diff --git a/content/renderer/pepper_platform_video_decoder_impl.cc b/content/renderer/pepper_platform_video_decoder_impl.cc index 79600bb..81b9857 100644 --- a/content/renderer/pepper_platform_video_decoder_impl.cc +++ b/content/renderer/pepper_platform_video_decoder_impl.cc @@ -24,7 +24,7 @@ PlatformVideoDecoderImpl::PlatformVideoDecoderImpl( PlatformVideoDecoderImpl::~PlatformVideoDecoderImpl() {} -bool PlatformVideoDecoderImpl::Initialize(const std::vector<int32>& configs) { +bool PlatformVideoDecoderImpl::Initialize(Profile profile) { // TODO(vrk): Support multiple decoders. if (decoder_) return true; @@ -45,7 +45,7 @@ bool PlatformVideoDecoderImpl::Initialize(const std::vector<int32>& configs) { // Send IPC message to initialize decoder in GPU process. decoder_ = channel->CreateVideoDecoder( - command_buffer_route_id_, configs, this); + command_buffer_route_id_, profile, this); return decoder_.get() != NULL; } diff --git a/content/renderer/pepper_platform_video_decoder_impl.h b/content/renderer/pepper_platform_video_decoder_impl.h index 36447a7..d90d352 100644 --- a/content/renderer/pepper_platform_video_decoder_impl.h +++ b/content/renderer/pepper_platform_video_decoder_impl.h @@ -21,7 +21,7 @@ class PlatformVideoDecoderImpl int32 command_buffer_route_id); // PlatformVideoDecoder (a.k.a. VideoDecodeAccelerator) implementation. - virtual bool Initialize(const std::vector<int32>& configs) OVERRIDE; + virtual bool Initialize(Profile profile) OVERRIDE; virtual void Decode( const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; virtual void AssignPictureBuffers( diff --git a/media/video/video_decode_accelerator.h b/media/video/video_decode_accelerator.h index 799dca7..9a31bfd 100644 --- a/media/video/video_decode_accelerator.h +++ b/media/video/video_decode_accelerator.h @@ -15,149 +15,6 @@ namespace media { -// Enumeration defining global dictionary ranges for various purposes that are -// used to handle the configurations of the video decoder. -// -// IMPORTANT! Dictionary keys and corresponding values MUST match the ones found -// in Pepper API dictionary for video (ppapi/c/dev/pp_video_dev.h)! -enum VideoAttributeKey { - VIDEOATTRIBUTEKEY_TERMINATOR = 0, - - VIDEOATTRIBUTEKEY_BITSTREAM_FORMAT_BASE = 0x100, - // Array of key/value pairs describing video configuration. - // It could include any keys from PP_VideoKey. Its last element shall be - // VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_NONE with no corresponding value. - // An example: - // { - // VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_FOURCC, PP_VIDEODECODECID_VP8, - // VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_VP8_PROFILE, (VP8PROFILE_1 | - // VP8PROFILE_2 | - // VP8PROFILE_3), - // VIDEOATTRIBUTEKEY_TERMINATOR - // }; - // Keys for defining video bitstream format. - // Value is type of PP_VideoCodecFourcc. Commonly known attributes values are - // defined in PP_VideoCodecFourcc enumeration. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_FOURCC, - // Bitrate in bits/s. Attribute value is 32-bit unsigned integer. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_BITRATE, - // Width and height of the input video bitstream, if known by the application. - // Decoder will expect the bitstream to match these values and does memory - // considerations accordingly. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_WIDTH, - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_HEIGHT, - // Following attributes are applicable only in case of VP8. - // Key for VP8 profile attribute. Attribute value is bitmask of flags defined - // in PP_VP8Profile_Dev enumeration. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_VP8_PROFILE, - // Number of partitions per picture. Attribute value is unsigned 32-bit - // integer. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_VP8_NUM_OF_PARTITIONS, - // Following attributes are applicable only in case of H.264. - // Value is bitmask collection from the flags defined in PP_H264Profile. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_PROFILE, - // Value is type of PP_H264Level. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_LEVEL, - // Value is type of PP_H264PayloadFormat_Dev. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_PAYLOADFORMAT, - // Subset for H.264 features, attribute value 0 signifies unsupported. - // This is needed in case decoder has partial support for certain profile. - // Default for features are enabled if they're part of supported profile. - // H264 tool called Flexible Macroblock Ordering. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_FMO, - // H264 tool called Arbitrary Slice Ordering. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_ASO, - // H264 tool called Interlacing. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_INTERLACE, - // H264 tool called Context-Adaptive Binary Arithmetic Coding. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_CABAC, - // H264 tool called Weighted Prediction. - VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_WEIGHTEDPREDICTION, - - VIDEOATTRIBUTEKEY_COLOR_FORMAT_BASE = 0x1000, - // This specifies the output color format for a decoded frame. Value is one - // of the values in VideoColorFormat enumeration. - VIDEOATTRIBUTEKEY_VIDEOCOLORFORMAT, -}; - -enum VideoCodecFourcc { - VIDEOCODECFOURCC_NONE = 0, - VIDEOCODECFOURCC_VP8 = 0x00385056, // a.k.a. Fourcc 'VP8\0'. - VIDEOCODECFOURCC_H264 = 0x31637661, // a.k.a. Fourcc 'avc1'. -}; - -// VP8 specific information to be carried over the APIs. -// Enumeration for flags defining supported VP8 profiles. -enum VP8Profile { - VP8PROFILE_NONE = 0, - VP8PROFILE_0 = 1, - VP8PROFILE_1 = 1 << 1, - VP8PROFILE_2 = 1 << 2, - VP8PROFILE_3 = 1 << 3, -}; - -// H.264 specific information to be carried over the APIs. -// Enumeration for flags defining supported H.264 profiles. -enum H264Profile { - H264PROFILE_NONE = 0, - H264PROFILE_BASELINE = 1, - H264PROFILE_MAIN = 1 << 2, - H264PROFILE_EXTENDED = 1 << 3, - H264PROFILE_HIGH = 1 << 4, - H264PROFILE_HIGH10PROFILE = 1 << 5, - H264PROFILE_HIGH422PROFILE = 1 << 6, - H264PROFILE_HIGH444PREDICTIVEPROFILE = 1 << 7, - H264PROFILE_SCALABLEBASELINE = 1 << 8, - H264PROFILE_SCALABLEHIGH = 1 << 9, - H264PROFILE_STEREOHIGH = 1 << 10, - H264PROFILE_MULTIVIEWHIGH = 1 << 11, -}; - -// Enumeration for defining H.264 level of decoder implementation. -enum H264Level { - H264LEVEL_NONE = 0, - H264LEVEL_10 = 1, - H264LEVEL_1B = H264LEVEL_10 | 1 << 1, - H264LEVEL_11 = H264LEVEL_1B | 1 << 2, - H264LEVEL_12 = H264LEVEL_11 | 1 << 3, - H264LEVEL_13 = H264LEVEL_12 | 1 << 4, - H264LEVEL_20 = H264LEVEL_13 | 1 << 5, - H264LEVEL_21 = H264LEVEL_20 | 1 << 6, - H264LEVEL_22 = H264LEVEL_21 | 1 << 7, - H264LEVEL_30 = H264LEVEL_22 | 1 << 8, - H264LEVEL_31 = H264LEVEL_30 | 1 << 9, - H264LEVEL_32 = H264LEVEL_31 | 1 << 10, - H264LEVEL_40 = H264LEVEL_32 | 1 << 11, - H264LEVEL_41 = H264LEVEL_40 | 1 << 12, - H264LEVEL_42 = H264LEVEL_41 | 1 << 13, - H264LEVEL_50 = H264LEVEL_42 | 1 << 14, - H264LEVEL_51 = H264LEVEL_50 | 1 << 15, -}; - -// Enumeration to describe which payload format is used within the exchanged -// bitstream buffers. -enum H264PayloadFormat { - H264PAYLOADFORMAT_NONE = 0, - // NALUs separated by Start Code. - H264PAYLOADFORMAT_BYTESTREAM = 1, - // Exactly one raw NALU per buffer. - H264PAYLOADFORMAT_ONE_NALU_PER_BUFFER = 1 << 1, - // NALU separated by 1-byte interleaved length field. - H264PAYLOADFORMAT_ONE_BYTE_INTERLEAVED_LENGTH = 1 << 2, - // NALU separated by 2-byte interleaved length field. - H264PAYLOADFORMAT_TWO_BYTE_INTERLEAVED_LENGTH = 1 << 3, - // NALU separated by 4-byte interleaved length field. - H264PAYLOADFORMAT_FOUR_BYTE_INTERLEAVED_LENGTH = 1 << 4, -}; - -// Enumeration for various color formats. -enum VideoColorFormat { - // Value represents 32-bit RGBA format where each component is 8-bit in order - // R-G-B-A. Regardless of endianness of the architecture color components are - // stored in this order in the memory. - VIDEOCOLORFORMAT_RGBA = 0, -}; - // Video decoder interface. // This interface is extended by the various components that ultimately // implement the backend of PPB_VideoDecode_Dev. @@ -167,6 +24,26 @@ enum VideoColorFormat { class MEDIA_EXPORT VideoDecodeAccelerator : public base::RefCountedThreadSafe<VideoDecodeAccelerator> { public: + // Video stream profile. This *must* match PP_VideoDecoder_Profile. + enum Profile { + // Keep the values in this enum unique, as they imply format (h.264 vs. VP8, + // for example), and keep the values for a particular format grouped + // together for clarity. + H264PROFILE_MIN = 0, + H264PROFILE_BASELINE = H264PROFILE_MIN, + H264PROFILE_MAIN, + H264PROFILE_EXTENDED, + H264PROFILE_HIGH, + H264PROFILE_HIGH10PROFILE, + H264PROFILE_HIGH422PROFILE, + H264PROFILE_HIGH444PREDICTIVEPROFILE, + H264PROFILE_SCALABLEBASELINE, + H264PROFILE_SCALABLEHIGH, + H264PROFILE_STEREOHIGH, + H264PROFILE_MULTIVIEWHIGH, + H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH, + }; + // Enumeration of potential errors generated by the API. // Note: Keep these in sync with PP_VideoDecodeError_Dev. enum Error { @@ -226,10 +103,10 @@ class MEDIA_EXPORT VideoDecodeAccelerator // Initializes the video decoder with specific configuration. // Parameters: - // |config| is the configuration on which the decoder should be initialized. + // |profile| is the video stream's format profile. // // Returns true when command successfully accepted. Otherwise false. - virtual bool Initialize(const std::vector<int32>& config) = 0; + virtual bool Initialize(Profile profile) = 0; // Decodes given bitstream buffer. Once decoder is done with processing // |bitstream_buffer| it will call NotifyEndOfBitstreamBuffer() with the diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h index 0ae1fd7..7b54f9d 100644 --- a/ppapi/c/dev/pp_video_dev.h +++ b/ppapi/c/dev/pp_video_dev.h @@ -13,157 +13,29 @@ #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" -// Enumeration defining global dictionary ranges for various purposes that are -// used to handle the configurations of the video decoder. -// -// IMPORTANT! Dictionary keys and corresponding values MUST match the ones found -// in VideoDecodeAccelerator interface in Chromium media stack -// (media/video/video_decode_accelerator.h)! -enum PP_VideoAttributeDictionary { - PP_VIDEOATTR_DICTIONARY_TERMINATOR = 0, - - PP_VIDEOATTR_DICTIONARY_BITSTREAM_FORMAT_BASE = 0x100, - // Array of key/value pairs describing video configuration. - // It could include any keys from PP_VideoKey. Its last element shall be - // PP_VIDEOATTR_BITSTREAMFORMATKEY_NONE with no corresponding value. - // An example: - // { - // PP_VIDEOATTR_BITSTREAMFORMATKEY_FOURCC, PP_VIDEODECODECID_VP8, - // PP_VIDEOATTR_BITSTREAMFORMATKEY_VP8_PROFILE, (PP_VP8PROFILE_1 | - // PP_VP8PROFILE_2 | - // PP_VP8PROFILE_3), - // PP_VIDEOATTR_DICTIONARY_TERMINATOR - // }; - // Keys for defining video bitstream format. - // Value is type of PP_VideoCodecFourcc. Commonly known attributes values are - // defined in PP_VideoCodecFourcc enumeration. - PP_VIDEOATTR_BITSTREAMFORMATKEY_FOURCC, - // Bitrate in bits/s. Attribute value is 32-bit unsigned integer. - PP_VIDEOATTR_BITSTREAMFORMATKEY_BITRATE, - // Width and height of the input video bitstream, if known by the application. - // Decoder will expect the bitstream to match these values and does memory - // considerations accordingly. - PP_VIDEOATTR_BITSTREAMFORMATKEY_WIDTH, - PP_VIDEOATTR_BITSTREAMFORMATKEY_HEIGHT, - // Following attributes are applicable only in case of VP8. - // Key for VP8 profile attribute. Attribute value is bitmask of flags defined - // in PP_VP8Profile_Dev enumeration. - PP_VIDEOATTR_BITSTREAMFORMATKEY_VP8_PROFILE, - // Number of partitions per picture. Attribute value is unsigned 32-bit - // integer. - PP_VIDEOATTR_BITSTREAMFORMATKEY_VP8_NUM_OF_PARTITIONS, - // Following attributes are applicable only in case of H.264. - // Value is bitmask collection from the flags defined in PP_H264Profile. - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_PROFILE, - // Value is type of PP_H264Level. - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_LEVEL, - // Value is type of PP_H264PayloadFormat_Dev. - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_PAYLOADFORMAT, - // Subset for H.264 features, attribute value 0 signifies unsupported. - // This is needed in case decoder has partial support for certain profile. - // Default for features are enabled if they're part of supported profile. - // H264 tool called Flexible Macroblock Ordering. - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_FEATURE_FMO, - // H264 tool called Arbitrary Slice Ordering. - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_FEATURE_ASO, - // H264 tool called Interlacing. - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_FEATURE_INTERLACE, - // H264 tool called Context-Adaptive Binary Arithmetic Coding. - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_FEATURE_CABAC, - // H264 tool called Weighted Prediction. - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_FEATURE_WEIGHTEDPREDICTION, - - PP_VIDEOATTR_DICTIONARY_COLOR_FORMAT_BASE = 0x1000, - // This specifies the output color format for a decoded frame. Value is one - // of the values in PP_ColorFormat_Dev enumeration. - PP_VIDEOATTR_PICTUREFORMATKEY_COLORFORMAT -}; -PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoAttributeDictionary, 4); -typedef int32_t PP_VideoConfigElement; - -enum PP_VideoCodecFourcc { - PP_VIDEOCODECFOURCC_NONE = 0, - PP_VIDEOCODECFOURCC_VP8 = 0x00385056, // a.k.a. Fourcc 'VP8\0'. - PP_VIDEOCODECFOURCC_H264 = 0x31637661 // a.k.a. Fourcc 'avc1'. -}; -PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoCodecFourcc, 4); - -// VP8 specific information to be carried over the APIs. -// Enumeration for flags defining supported VP8 profiles. -enum PP_VP8Profile_Dev { - PP_VP8PROFILE_NONE = 0, - PP_VP8PROFILE_0 = 1, - PP_VP8PROFILE_1 = 1 << 1, - PP_VP8PROFILE_2 = 1 << 2, - PP_VP8PROFILE_3 = 1 << 3 -}; -PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VP8Profile_Dev, 4); - -// H.264 specific information to be carried over the APIs. -// Enumeration for flags defining supported H.264 profiles. -enum PP_H264Profile_Dev { - PP_H264PROFILE_NONE = 0, - PP_H264PROFILE_BASELINE = 1, - PP_H264PROFILE_MAIN = 1 << 2, - PP_H264PROFILE_EXTENDED = 1 << 3, - PP_H264PROFILE_HIGH = 1 << 4, - PP_H264PROFILE_HIGH10PROFILE = 1 << 5, - PP_H264PROFILE_HIGH422PROFILE = 1 << 6, - PP_H264PROFILE_HIGH444PREDICTIVEPROFILE = 1 << 7, - PP_H264PROFILE_SCALABLEBASELINE = 1 << 8, - PP_H264PROFILE_SCALABLEHIGH = 1 << 9, - PP_H264PROFILE_STEREOHIGH = 1 << 10, - PP_H264PROFILE_MULTIVIEWHIGH = 1 << 11 -}; -PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_H264Profile_Dev, 4); - -// Enumeration for defining H.264 level of decoder implementation. -enum PP_H264Level_Dev { - PP_H264LEVEL_NONE = 0, - PP_H264LEVEL_10 = 1, - PP_H264LEVEL_1B = PP_H264LEVEL_10 | 1 << 1, - PP_H264LEVEL_11 = PP_H264LEVEL_1B | 1 << 2, - PP_H264LEVEL_12 = PP_H264LEVEL_11 | 1 << 3, - PP_H264LEVEL_13 = PP_H264LEVEL_12 | 1 << 4, - PP_H264LEVEL_20 = PP_H264LEVEL_13 | 1 << 5, - PP_H264LEVEL_21 = PP_H264LEVEL_20 | 1 << 6, - PP_H264LEVEL_22 = PP_H264LEVEL_21 | 1 << 7, - PP_H264LEVEL_30 = PP_H264LEVEL_22 | 1 << 8, - PP_H264LEVEL_31 = PP_H264LEVEL_30 | 1 << 9, - PP_H264LEVEL_32 = PP_H264LEVEL_31 | 1 << 10, - PP_H264LEVEL_40 = PP_H264LEVEL_32 | 1 << 11, - PP_H264LEVEL_41 = PP_H264LEVEL_40 | 1 << 12, - PP_H264LEVEL_42 = PP_H264LEVEL_41 | 1 << 13, - PP_H264LEVEL_50 = PP_H264LEVEL_42 | 1 << 14, - PP_H264LEVEL_51 = PP_H264LEVEL_50 | 1 << 15 -}; -PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_H264Level_Dev, 4); - -// Enumeration to describe which payload format is used within the exchanged -// bitstream buffers. -enum PP_H264PayloadFormat_Dev { - PP_H264PAYLOADFORMAT_NONE = 0, - // NALUs separated by Start Code. - PP_H264PAYLOADFORMAT_BYTESTREAM = 1, - // Exactly one raw NALU per buffer. - PP_H264PAYLOADFORMAT_ONE_NALU_PER_BUFFER = 1 << 1, - // NALU separated by 1-byte interleaved length field. - PP_H264PAYLOADFORMAT_ONE_BYTE_INTERLEAVED_LENGTH = 1 << 2, - // NALU separated by 2-byte interleaved length field. - PP_H264PAYLOADFORMAT_TWO_BYTE_INTERLEAVED_LENGTH = 1 << 3, - // NALU separated by 4-byte interleaved length field. - PP_H264PAYLOADFORMAT_FOUR_BYTE_INTERLEAVED_LENGTH = 1 << 4 -}; -PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_H264PayloadFormat_Dev, 4); - -// Enumeration for various color formats. -enum PP_ColorFormat_Dev { - // Value represents 32-bit RGBA format where each component is 8-bit in order - // R-G-B-A. Regardless of endianness of the architecture color components are - // stored in this order in the memory. - PP_VIDEOATTR_COLORFORMAT_RGBA = 0 +// Video decoder configuration-related enums. + +// NOTE: these must be kept in sync with the versions in +// media/video/video_decode_accelerator.h! + +// Video stream profile. +enum PP_VideoDecoder_Profile { + // Keep the values in this enum unique, as they imply format (h.264 vs. VP8, + // for example), and keep the values for a particular format grouped together + // for clarity. + PP_VIDEODECODER_H264PROFILE_NONE = 0, + PP_VIDEODECODER_H264PROFILE_BASELINE, + PP_VIDEODECODER_H264PROFILE_MAIN, + PP_VIDEODECODER_H264PROFILE_EXTENDED, + PP_VIDEODECODER_H264PROFILE_HIGH, + PP_VIDEODECODER_H264PROFILE_HIGH10PROFILE, + PP_VIDEODECODER_H264PROFILE_HIGH422PROFILE, + PP_VIDEODECODER_H264PROFILE_HIGH444PREDICTIVEPROFILE, + PP_VIDEODECODER_H264PROFILE_SCALABLEBASELINE, + PP_VIDEODECODER_H264PROFILE_SCALABLEHIGH, + PP_VIDEODECODER_H264PROFILE_STEREOHIGH, + PP_VIDEODECODER_H264PROFILE_MULTIVIEWHIGH }; -PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ColorFormat_Dev, 4); // The data structure for video bitstream buffer. struct PP_VideoBitstreamBuffer_Dev { diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h index 5a3417e..aab226e 100644 --- a/ppapi/c/dev/ppb_video_decoder_dev.h +++ b/ppapi/c/dev/ppb_video_decoder_dev.h @@ -9,8 +9,8 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_var.h" -#define PPB_VIDEODECODER_DEV_INTERFACE_0_15 "PPB_VideoDecoder(Dev);0.15" -#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_15 +#define PPB_VIDEODECODER_DEV_INTERFACE_0_16 "PPB_VideoDecoder(Dev);0.16" +#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_16 // Video decoder interface. // @@ -35,14 +35,12 @@ struct PPB_VideoDecoder_Dev { // Parameters: // |instance| pointer to the plugin instance. // |context_3d| a PPB_Context3D_Dev resource in which decoding will happen. - // |decoder_config| the configuration to use to initialize the decoder. + // |profile| the video stream's format profile. // // The created decoder is returned as PP_Resource. 0 means failure. - // TODO(fischman/vrk): Get rid of silly PP_VideoConfigElement* vector in favor - // of config struct. PP_Resource (*Create)(PP_Instance instance, PP_Resource context, - const PP_VideoConfigElement* decoder_config); + enum PP_VideoDecoder_Profile profile); // Tests whether |resource| is a video decoder created through Create // function of this interface. diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc index cde75f6..f7ab651 100644 --- a/ppapi/cpp/dev/video_decoder_dev.cc +++ b/ppapi/cpp/dev/video_decoder_dev.cc @@ -23,22 +23,22 @@ template <> const char* interface_name<PPB_VideoDecoder_Dev>() { } // namespace -VideoDecoder_Dev::VideoDecoder_Dev(const Instance& instance, +VideoDecoder_Dev::VideoDecoder_Dev(const Instance* instance, const Context3D_Dev& context, - const PP_VideoConfigElement* config) { + PP_VideoDecoder_Profile profile) { if (!has_interface<PPB_VideoDecoder_Dev>()) return; PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create( - instance.pp_instance(), context.pp_resource(), config)); + instance->pp_instance(), context.pp_resource(), profile)); } -VideoDecoder_Dev::VideoDecoder_Dev(const Instance& instance, +VideoDecoder_Dev::VideoDecoder_Dev(const Instance* instance, const Graphics3D_Dev& context, - const PP_VideoConfigElement* config) { + PP_VideoDecoder_Profile profile) { if (!has_interface<PPB_VideoDecoder_Dev>()) return; PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create( - instance.pp_instance(), context.pp_resource(), config)); + instance->pp_instance(), context.pp_resource(), profile)); } VideoDecoder_Dev::VideoDecoder_Dev(PP_Resource resource) : Resource(resource) { diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h index 504e713..e260050 100644 --- a/ppapi/cpp/dev/video_decoder_dev.h +++ b/ppapi/cpp/dev/video_decoder_dev.h @@ -25,12 +25,12 @@ class Instance; class VideoDecoder_Dev : public Resource { public: // See PPB_VideoDecoder_Dev::Create. - VideoDecoder_Dev(const Instance& instance, + VideoDecoder_Dev(const Instance* instance, const Context3D_Dev& context, - const PP_VideoConfigElement* config); - VideoDecoder_Dev(const Instance& instance, + PP_VideoDecoder_Profile profile); + VideoDecoder_Dev(const Instance* instance, const Graphics3D_Dev& context, - const PP_VideoConfigElement* config); + PP_VideoDecoder_Profile profile); explicit VideoDecoder_Dev(PP_Resource resource); virtual ~VideoDecoder_Dev(); diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc index f661d0a..26d94a4 100644 --- a/ppapi/examples/gles2/gles2.cc +++ b/ppapi/examples/gles2/gles2.cc @@ -235,16 +235,11 @@ void GLES2DemoInstance::DidChangeView( } void GLES2DemoInstance::InitializeDecoders() { - PP_VideoConfigElement configs[] = { - PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_PROFILE, - PP_H264PROFILE_BASELINE, - PP_VIDEOATTR_DICTIONARY_TERMINATOR, - }; - assert(video_decoders_.empty()); for (int i = 0; i < kNumDecoders; ++i) { DecoderClient* client = new DecoderClient( - this, new pp::VideoDecoder_Dev(*this, *context_, configs)); + this, new pp::VideoDecoder_Dev( + this, *context_, PP_VIDEODECODER_H264PROFILE_BASELINE)); assert(!client->decoder()->is_null()); assert(video_decoders_.insert(std::make_pair( client->decoder()->pp_resource(), client)).second); diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index dd98b5e..f8559b3 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -44,6 +44,7 @@ IPC_ENUM_TRAITS(PP_InputEvent_Type) IPC_ENUM_TRAITS(PP_InputEvent_MouseButton) +IPC_ENUM_TRAITS(PP_VideoDecoder_Profile) IPC_ENUM_TRAITS(PP_VideoDecodeError_Dev) IPC_STRUCT_TRAITS_BEGIN(PP_Point) @@ -1020,7 +1021,7 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBVideoCapture_StopCapture, IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBVideoDecoder_Create, PP_Instance /* instance */, ppapi::HostResource /* context */, - std::vector<PP_VideoConfigElement> /* config */, + PP_VideoDecoder_Profile /* profile */, ppapi::HostResource /* result */) IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBVideoDecoder_Decode, ppapi::HostResource /* video_decoder */, diff --git a/ppapi/proxy/ppb_video_decoder_proxy.cc b/ppapi/proxy/ppb_video_decoder_proxy.cc index 3763bbe..f9e4379 100644 --- a/ppapi/proxy/ppb_video_decoder_proxy.cc +++ b/ppapi/proxy/ppb_video_decoder_proxy.cc @@ -33,7 +33,7 @@ class VideoDecoder : public Resource, public VideoDecoderImpl { static VideoDecoder* Create(const HostResource& resource, PP_Resource graphics_context, - const PP_VideoConfigElement* config); + PP_VideoDecoder_Profile profile); // Resource overrides. virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE; @@ -210,17 +210,13 @@ bool PPB_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource( PP_Instance instance, PP_Resource graphics_context, - const PP_VideoConfigElement* config) { + PP_VideoDecoder_Profile profile) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); // Dispatcher is null if it cannot find the instance passed to it (i.e. if the // client passes in an invalid instance). if (!dispatcher) return 0; - std::vector<PP_VideoConfigElement> copied; - if (!VideoDecoderImpl::CopyConfigsToVector(config, &copied)) - return 0; - HostResource host_context; gpu::gles2::GLES2Implementation* gles2_impl = NULL; @@ -242,7 +238,7 @@ PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource( HostResource result; dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( INTERFACE_ID_PPB_VIDEO_DECODER_DEV, instance, - host_context, copied, &result)); + host_context, profile, &result)); if (result.is_null()) return 0; @@ -254,20 +250,17 @@ PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource( void PPB_VideoDecoder_Proxy::OnMsgCreate( PP_Instance instance, const HostResource& graphics_context, - const std::vector<PP_VideoConfigElement>& config, + PP_VideoDecoder_Profile profile, HostResource* result) { thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance, true); if (resource_creation.failed()) return; - std::vector<PP_VideoConfigElement> copied = config; - copied.push_back(PP_VIDEOATTR_DICTIONARY_TERMINATOR); - // Make the resource and get the API pointer to its interface. result->SetHostResource( instance, resource_creation.functions()->CreateVideoDecoder( - instance, graphics_context.host_resource(), &copied.front())); + instance, graphics_context.host_resource(), profile)); } void PPB_VideoDecoder_Proxy::OnMsgDecode( diff --git a/ppapi/proxy/ppb_video_decoder_proxy.h b/ppapi/proxy/ppb_video_decoder_proxy.h index 56c21c5..b34cb22 100644 --- a/ppapi/proxy/ppb_video_decoder_proxy.h +++ b/ppapi/proxy/ppb_video_decoder_proxy.h @@ -23,9 +23,10 @@ class PPB_VideoDecoder_Proxy : public InterfaceProxy { static const Info* GetInfo(); // Creates a VideoDecoder object in the plugin process. - static PP_Resource CreateProxyResource(PP_Instance instance, - PP_Resource graphics_context, - const PP_VideoConfigElement* config); + static PP_Resource CreateProxyResource( + PP_Instance instance, + PP_Resource graphics_context, + PP_VideoDecoder_Profile profile); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -39,7 +40,7 @@ class PPB_VideoDecoder_Proxy : public InterfaceProxy { // plugin process. void OnMsgCreate(PP_Instance instance, const ppapi::HostResource& graphics_context, - const std::vector<PP_VideoConfigElement>& config, + PP_VideoDecoder_Profile profile, ppapi::HostResource* result); void OnMsgDecode( const ppapi::HostResource& decoder, diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index bd020f3..0a0c791 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -305,9 +305,9 @@ PP_Resource ResourceCreationProxy::CreateVideoCapture(PP_Instance instance) { PP_Resource ResourceCreationProxy::CreateVideoDecoder( PP_Instance instance, PP_Resource context3d_id, - const PP_VideoConfigElement* config) { + PP_VideoDecoder_Profile profile) { return PPB_VideoDecoder_Proxy::CreateProxyResource( - instance, context3d_id, config); + instance, context3d_id, profile); } PP_Resource ResourceCreationProxy::CreateVideoLayer( diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 6ad936f..0f1589b 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -117,7 +117,7 @@ class ResourceCreationProxy : public FunctionGroupBase, virtual PP_Resource CreateVideoDecoder( PP_Instance instance, PP_Resource context3d_id, - const PP_VideoConfigElement* config) OVERRIDE; + PP_VideoDecoder_Profile profile) OVERRIDE; virtual PP_Resource CreateVideoLayer(PP_Instance instance, PP_VideoLayerMode_Dev mode) OVERRIDE; virtual PP_Resource CreateWheelInputEvent( diff --git a/ppapi/shared_impl/video_decoder_impl.cc b/ppapi/shared_impl/video_decoder_impl.cc index 00d971b..71921f92 100644 --- a/ppapi/shared_impl/video_decoder_impl.cc +++ b/ppapi/shared_impl/video_decoder_impl.cc @@ -89,19 +89,4 @@ void VideoDecoderImpl::FlushCommandBuffer() { gles2_impl_->Flush(); } -bool VideoDecoderImpl::CopyConfigsToVector( - const PP_VideoConfigElement* configs_to_copy, - std::vector<PP_VideoConfigElement>* out_configs) { - // TODO(fischman/vrk): This is still broken. We need to get rid of the silly - // PP_VideoConfigElement vector in favor of a struct (see TODO in - // ppb_video_decoder_dev.h). - const PP_VideoConfigElement* current = configs_to_copy; - while (current && *current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) { - out_configs->push_back(*current); - out_configs->push_back(*(current + 1)); - current += 2; - } - return true; -} - } // namespace ppapi diff --git a/ppapi/shared_impl/video_decoder_impl.h b/ppapi/shared_impl/video_decoder_impl.h index b71f27d..1060740 100644 --- a/ppapi/shared_impl/video_decoder_impl.h +++ b/ppapi/shared_impl/video_decoder_impl.h @@ -39,11 +39,6 @@ class PPAPI_SHARED_EXPORT VideoDecoderImpl // PPB_VideoDecoder_API implementation. virtual void Destroy() OVERRIDE; - // Copy C-style config list into |out_configs| vector. - static bool CopyConfigsToVector( - const PP_VideoConfigElement* configs_to_copy, - std::vector<PP_VideoConfigElement>* out_configs); - protected: bool SetFlushCallback(PP_CompletionCallback callback); bool SetResetCallback(PP_CompletionCallback callback); diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc index 9b9d965..0be8d95 100644 --- a/ppapi/tests/test_video_decoder.cc +++ b/ppapi/tests/test_video_decoder.cc @@ -28,7 +28,7 @@ void TestVideoDecoder::QuitMessageLoop() { std::string TestVideoDecoder::TestCreateFailure() { PP_Resource decoder = video_decoder_interface_->Create( - instance_->pp_instance(), 0, NULL); + instance_->pp_instance(), 0, static_cast<PP_VideoDecoder_Profile>(-1)); if (decoder != 0) return "Create: error detecting invalid context & configs"; diff --git a/ppapi/thunk/ppb_video_decoder_thunk.cc b/ppapi/thunk/ppb_video_decoder_thunk.cc index cb0485c..b7a72d9 100644 --- a/ppapi/thunk/ppb_video_decoder_thunk.cc +++ b/ppapi/thunk/ppb_video_decoder_thunk.cc @@ -18,11 +18,11 @@ typedef EnterResource<PPB_VideoDecoder_API> EnterVideoDecoder; PP_Resource Create(PP_Instance instance, PP_Resource context_3d, - const PP_VideoConfigElement* config) { + PP_VideoDecoder_Profile profile) { EnterFunction<ResourceCreationAPI> enter(instance, true); if (enter.failed()) return 0; - return enter.functions()->CreateVideoDecoder(instance, context_3d, config); + return enter.functions()->CreateVideoDecoder(instance, context_3d, profile); } PP_Bool IsVideoDecoder(PP_Resource resource) { diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 8757382..e34f659 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -119,7 +119,7 @@ class ResourceCreationAPI { virtual PP_Resource CreateVideoDecoder( PP_Instance instance, PP_Resource context3d_id, - const PP_VideoConfigElement* config) = 0; + PP_VideoDecoder_Profile profile) = 0; virtual PP_Resource CreateVideoLayer(PP_Instance instance, PP_VideoLayerMode_Dev mode) = 0; virtual PP_Resource CreateWheelInputEvent( diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc index e8cd2ac..7dc63a1 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc @@ -51,10 +51,19 @@ PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() { return this; } +// Convert PP_VideoDecoder_Profile to media::VideoDecodeAccelerator::Profile. +static media::VideoDecodeAccelerator::Profile PPToMediaProfile( + const PP_VideoDecoder_Profile pp_profile) { + // TODO(fischman,vrk): this assumes the enum values in the two Profile types + // match up exactly. Add a COMPILE_ASSERT for this somewhere. + return static_cast<media::VideoDecodeAccelerator::Profile>(pp_profile); +} + // static -PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance instance, - PP_Resource graphics_context, - const PP_VideoConfigElement* config) { +PP_Resource PPB_VideoDecoder_Impl::Create( + PP_Instance instance, + PP_Resource graphics_context, + PP_VideoDecoder_Profile profile) { PluginDelegate::PlatformContext3D* platform_context = NULL; gpu::gles2::GLES2Implementation* gles2_impl = NULL; EnterResourceNoLock<PPB_Context3D_API> enter_context(graphics_context, false); @@ -76,7 +85,7 @@ PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance instance, scoped_refptr<PPB_VideoDecoder_Impl> decoder( new PPB_VideoDecoder_Impl(instance)); - if (decoder->Init(graphics_context, platform_context, gles2_impl, config)) + if (decoder->Init(graphics_context, platform_context, gles2_impl, profile)) return decoder->GetReference(); return 0; } @@ -85,17 +94,13 @@ bool PPB_VideoDecoder_Impl::Init( PP_Resource graphics_context, PluginDelegate::PlatformContext3D* context, gpu::gles2::GLES2Implementation* gles2_impl, - const PP_VideoConfigElement* config) { + PP_VideoDecoder_Profile profile) { InitCommon(graphics_context, gles2_impl); int command_buffer_route_id = context->GetCommandBufferRouteId(); if (command_buffer_route_id == 0) return false; - std::vector<int32> copied; - if (!CopyConfigsToVector(config, &copied)) - return false; - PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); if (!plugin_delegate) return false; @@ -106,7 +111,7 @@ bool PPB_VideoDecoder_Impl::Init( return false; FlushCommandBuffer(); - return platform_video_decoder_->Initialize(copied); + return platform_video_decoder_->Initialize(PPToMediaProfile(profile)); } int32_t PPB_VideoDecoder_Impl::Decode( diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h index a76d0ec..48b7b15 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h @@ -19,7 +19,6 @@ #include "webkit/plugins/ppapi/plugin_delegate.h" struct PP_PictureBuffer_Dev; -struct PP_VideoDecoderConfig_Dev; struct PP_VideoBitstreamBuffer_Dev; struct PPB_VideoDecoder_Dev; struct PPP_VideoDecoder_Dev; @@ -49,7 +48,7 @@ class PPB_VideoDecoder_Impl : public ::ppapi::Resource, // initialize. static PP_Resource Create(PP_Instance instance, PP_Resource graphics_context, - const PP_VideoConfigElement* config); + PP_VideoDecoder_Profile profile); // Resource overrides. virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE; @@ -82,7 +81,7 @@ class PPB_VideoDecoder_Impl : public ::ppapi::Resource, bool Init(PP_Resource graphics_context, PluginDelegate::PlatformContext3D* context, gpu::gles2::GLES2Implementation* gles2_impl, - const PP_VideoConfigElement* config); + PP_VideoDecoder_Profile profile); // This is NULL before initialization, and if this PPB_VideoDecoder_Impl is // swapped with another. diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index 23b725b..eeffefb 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -276,8 +276,8 @@ PP_Resource ResourceCreationImpl::CreateVideoCapture(PP_Instance instance) { PP_Resource ResourceCreationImpl::CreateVideoDecoder( PP_Instance instance, PP_Resource context3d_id, - const PP_VideoConfigElement* config) { - return PPB_VideoDecoder_Impl::Create(instance, context3d_id, config); + PP_VideoDecoder_Profile profile) { + return PPB_VideoDecoder_Impl::Create(instance, context3d_id, profile); } PP_Resource ResourceCreationImpl::CreateVideoLayer(PP_Instance instance, diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h index 6e0129f..4a7a2a9 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.h +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -106,7 +106,7 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateVideoDecoder( PP_Instance instance, PP_Resource context3d_id, - const PP_VideoConfigElement* config) OVERRIDE; + PP_VideoDecoder_Profile profile) OVERRIDE; virtual PP_Resource CreateVideoLayer(PP_Instance instance, PP_VideoLayerMode_Dev mode) OVERRIDE; virtual PP_Resource CreateWheelInputEvent( |