From 48e1ffea05883acdc563f767211dfbc0fbc41df7 Mon Sep 17 00:00:00 2001 From: "vrk@google.com" Date: Tue, 10 May 2011 22:01:32 +0000 Subject: Update VideoDecode PPAPI structs to be consistent with media structures, part 1 This patch fixes some of the inconsistencies between the VideoDecode structs in the ppapi namespace and their wrappers in the media namespace. It also implements some of the hooks to pass messages to and from the browser and plugin. BUG=NONE TEST=NONE Review URL: http://codereview.chromium.org/6901036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84871 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/c/dev/pp_video_dev.h | 188 ++++++++++------------------------ ppapi/c/dev/ppb_video_decoder_dev.h | 60 +++++------ ppapi/c/dev/ppp_video_decoder_dev.h | 14 +-- ppapi/tests/arch_dependent_sizes_32.h | 6 +- ppapi/tests/arch_dependent_sizes_64.h | 6 +- 5 files changed, 96 insertions(+), 178 deletions(-) (limited to 'ppapi') diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h index 95d078e..7c4c73b 100644 --- a/ppapi/c/dev/pp_video_dev.h +++ b/ppapi/c/dev/pp_video_dev.h @@ -69,92 +69,14 @@ enum PP_VideoAttributeDictionary { // H264 tool called Weighted Prediction. PP_VIDEOATTR_BITSTREAMFORMATKEY_H264_FEATURE_WEIGHTEDPREDICTION, - PP_VIDEOATTR_DICTIONARY_COLOR_CORMAT_BASE = 0x1000, - // Keys for definining attributes of a color buffer. Using these attributes - // users can define color spaces in terms of red, green, blue and alpha - // components as well as with combination of luma and chroma values with - // different subsampling schemes. Also planar, semiplanar and interleaved - // formats can be described by using the provided keys as instructed. + PP_VIDEOATTR_DICTIONARY_COLOR_FORMAT_BASE = 0x1000, + // This specifies the output color format for a decoded frame. // - // Rules for describing the color planes (1 or more) that constitute the whole - // picture are: - // 1. Each plane starts with PP_VIDEOATTR_COLORFORMATKEY_PLANE_PIXEL_SIZE - // attribute telling how many bits per pixel the plane contains. - // 2. PP_VIDEOATTR_COLORFORMATKEY_PLANE_PIXEL_SIZE attribute must be - // followed either by - // a. Red, green and blue components followed optionally by alpha size - // attribute. - // OR - // b. Luma, blue difference chroma and red difference chroma components as - // well as three sampling reference factors that tell how the chroma may - // have been subsampled with respect to luma. - // 3. Description must be terminated with PP_VIDEOATTR_COLORFORMATKEY_NONE - // key with no value for attribute. - // - // For example, semiplanar YCbCr 4:2:2 (2 planes, one containing 8-bit luma, - // the other containing two interleaved chroma data components) may be - // described with the following attributes: - // { - // PP_VIDEOATTR_COLORFORMATKEY_PLANE_PIXEL_SIZE, 8, - // PP_VIDEOATTR_COLORFORMATKEY_LUMA_SIZE, 8, - // PP_VIDEOATTR_COLORFORMATKEY_PLANE_PIXEL_SIZE, 16, - // PP_VIDEOATTR_COLORFORMATKEY_CHROMA_BLUE_SIZE, 8, - // PP_VIDEOATTR_COLORFORMATKEY_CHROMA_RED_SIZE, 8, - // PP_VIDEOATTR_COLORFORMATKEY_HORIZONTAL_SAMPLING_FACTOR_REFERENCE, 4, - // PP_VIDEOATTR_COLORFORMATKEY_CHROMA_HORIZONTAL_SUBSAMPLING_FACTOR, 2, - // PP_VIDEOATTR_COLORFORMATKEY_CHROMA_VERTICAL_SUBSAMPLING_FACTOR, 2 - // PP_VIDEOATTR_DICTIONARY_TERMINATOR - // } - // - // Another example, commonly known 16-bit RGB 565 color format may be - // specified as follows: - // { - // PP_VIDEOATTR_COLORFORMATKEY_PLANE_PIXEL_SIZE, 16, - // PP_VIDEOATTR_COLORFORMATKEY_RED_SIZE, 5, - // PP_VIDEOATTR_COLORFORMATKEY_GREEN_SIZE, 6, - // PP_VIDEOATTR_COLORFORMATKEY_BLUE_SIZE, 5, - // PP_VIDEOATTR_DICTIONARY_TERMINATOR - // } - // Total color component bits per pixel in the picture buffer. - PP_VIDEOATTR_COLORFORMATKEY_PLANE_PIXEL_SIZE, - // Bits of red per pixel in picture buffer. - PP_VIDEOATTR_COLORFORMATKEY_RED_SIZE, - // Bits of green per pixel in picture buffer. - PP_VIDEOATTR_COLORFORMATKEY_GREEN_SIZE, - // Bits of blue per pixel in picture buffer. - PP_VIDEOATTR_COLORFORMATKEY_BLUE_SIZE, - // Bits of alpha in color buffer. - PP_VIDEOATTR_COLORFORMATKEY_ALPHA_SIZE, - // Bits of luma per pixel in color buffer. - PP_VIDEOATTR_COLORFORMATKEY_LUMA_SIZE, - // Bits of blue difference chroma (Cb) data in color buffer. - PP_VIDEOATTR_COLORFORMATKEY_CHROMA_BLUE_SIZE, - // Bits of blue difference chroma (Cr) data in color buffer. - PP_VIDEOATTR_COLORFORMATKEY_CHROMA_RED_SIZE, - // Three keys to describe the subsampling of YCbCr sampled digital video - // signal. For example, 4:2:2 sampling could be defined by setting: - // PP_VIDEOATTR_COLORFORMATKEY_HORIZONTAL_SAMPLING_FACTOR_REFERENCE = 4 - // PP_VIDEOATTR_COLORFORMATKEY_CHROMINANCE_HORIZONTAL_SUBSAMPLING_FACTOR = 2 - // PP_VIDEOATTR_COLORFORMATKEY_CHROMINANCE_VERTICAL_SUBSAMPLING_FACTOR = 2 - PP_VIDEOATTR_COLORFORMATKEY_HORIZONTAL_SAMPLING_FACTOR_REFERENCE, - PP_VIDEOATTR_COLORFORMATKEY_CHROMA_HORIZONTAL_SUBSAMPLING_FACTOR, - PP_VIDEOATTR_COLORFORMATKEY_CHROMA_VERTICAL_SUBSAMPLING_FACTOR, - // Base for telling implementation specific information about the optimal - // number of picture buffers to be provided to the implementation. - PP_VIDEOATTR_DICTIONARY_PICTUREBUFFER_REQUIREMENTS_BASE = 0x10000, - // Following two keys are used to signal how many buffers are needed by the - // implementation as a function of the maximum number of reference frames set - // by the stream. Number of required buffers is - // MAX_REF_FRAMES * REFERENCE_PIC_MULTIPLIER + ADDITIONAL_BUFFERS - PP_VIDEOATTR_PICTUREBUFFER_REQUIREMENTS_ADDITIONAL_BUFFERS, - PP_VIDEOATTR_PICTUREBUFFER_REQUIREMENTS_REFERENCE_PIC_MULTIPLIER, - // If decoder does not support pixel accurate strides for picture buffer, this - // parameter tells the stride multiple that is needed by the decoder. Plugin - // must obey the given stride in its picture buffer allocations. - PP_VIDEOATTR_PICTUREBUFFER_REQUIREMENTS_STRIDE_MULTIPLE + // Value represents 32-bit RGBA format where each component is 8-bit. + PP_VIDEOATTR_COLORFORMAT_RGBA }; PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_VideoAttributeDictionary, 4); -typedef int32_t* PP_VideoConfigElement; +typedef int32_t PP_VideoConfigElement; enum PP_VideoCodecFourcc { PP_VIDEOCODECFOURCC_NONE = 0, @@ -241,26 +163,6 @@ enum PP_PictureBufferType_Dev { }; PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_PictureBufferType_Dev, 4); -// Structure to describe storage properties for a picture. -struct PP_PictureBufferProperties_Dev { - // Size of the storage (as per width & height in pixels). - struct PP_Size size; - - // Type of the picture buffer (GLES, system memory). - enum PP_PictureBufferType_Dev type; - - // Key-attribute pairs defining color format for the buffer. - PP_VideoConfigElement color_format; -}; - -// Requested decoder configuration and callback from plugin. -struct PP_VideoDecoderConfig_Dev { - // Input bitstream properties. - PP_VideoConfigElement bitstream_properties; - // Output picture properties. - struct PP_PictureBufferProperties_Dev picture_properties; -}; - // The data structure for video bitstream buffer. struct PP_VideoBitstreamBuffer_Dev { // Buffer to hold the bitstream data. Should be allocated using the PPB_Buffer @@ -270,49 +172,65 @@ struct PP_VideoBitstreamBuffer_Dev { // Size of the bitstream contained in buffer (in bytes). int32_t bitstream_size; - // Optional pointer for application to associate information with a sample. - // The pointer will be associated with the resulting decoded picture. - // Typically applications associate timestamps with buffers. + // Handle to identify the bitstream buffer. void* user_handle; - - // TODO(vmr): Add information about access unit boundaries. }; -// Union for specifying picture data. -union PP_PictureData_Dev { - // Resource representing system memory from shared memory address space. - // Use PPB_Buffer_Dev interface to handle this resource. - PP_Resource sysmem; - - // Structure to define explicitly a GLES2 context. - struct { - // Context allocated using PPB_Context3D_Dev. - PP_Resource context; - - // Texture ID in the given context where picture is stored. - GLuint texture_id; - } gles2_texture; - +// Struct for specifying data about buffer. +struct PP_BufferInfo_Dev { // Client-specified id for the picture buffer. By using this value client can // keep track of the buffers it has assigned to the video decoder and how they // are passed back to it. int32_t id; + + // Dimensions of the buffer. + struct PP_Size size; +}; + +// Struct for specifying texture-backed picture data. +struct PP_GLESBuffer_Dev { + // Context allocated using PPB_Context3D_Dev. + PP_Resource context; + + // Texture ID in the given context where picture is stored. + GLuint texture_id; + + // Information about the buffer. + struct PP_BufferInfo_Dev info; }; -// Structure to describe the decoded output picture for the plug-in along with -// optional metadata associated with the picture. +// Struct for specifying sysmem-backed picture data. +struct PP_SysmemBuffer_Dev { + // Resource representing system memory from shared memory address space. + // Use PPB_Buffer_Dev interface to handle this resource. + PP_Resource data; + + // Information about the buffer. + struct PP_BufferInfo_Dev info; +}; + +// Structure to describe a decoded output frame. +// The decoded pixels will always begin flush with the upper left-hand corner +// of the buffer (0, 0). struct PP_Picture_Dev { - // Resource that represents the buffer where the picture data is stored. - // Actual implementation style of the picture buffer may be OpenGL ES texture - // (allocated using PPB_OpenGLES2_Dev) or system memory (allocated using - // PPB_Buffer_Dev). - union PP_PictureData_Dev picture_data; + // ID of the picture buffer where the picture is stored. + int32_t picture_buffer_id; - // Optional pointer to associated metadata with the picture. Typical - // information carried over metadata includes timestamps. If there is - // multiple NAL units each with their own respective metadata, only the - // metadata from the latest call to Decode will be carried over. - void* user_handle; + // Visible size of the picture. + // This describes the dimensions of the picture that is intended to be + // displayed from the decoded output. + struct PP_Size visible_size; + + // Decoded size of the picture. + // This describes the dimensions of the decoded output. This may be slightly + // larger than the visible size because the stride is sometimes larger than + // the width of the output. The plugin should handle rendering the frame + // appropriately with respect to the sizes. + struct PP_Size decoded_size; + + // Handle to identify the bitstream buffer from which this picture was + // decoded. + void* bitstream_user_handle; }; // Enumeration for error events that may be reported through diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h index 1aed02d..53869a0 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_5 "PPB_VideoDecoder(Dev);0.5" -#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_5 +#define PPB_VIDEODECODER_DEV_INTERFACE_0_6 "PPB_VideoDecoder(Dev);0.6" +#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_6 // Video decoder interface. // @@ -70,10 +70,10 @@ struct PPB_VideoDecoder_Dev { // // Returns PP_TRUE on success, PP_FALSE otherwise. PP_Bool (*GetConfigs)(PP_Instance instance, - struct PP_VideoDecoderConfig_Dev* proto_config, - struct PP_VideoDecoderConfig_Dev* matching_configs, - int32_t matching_configs_size, - int32_t* num_of_matching_configs); + PP_VideoConfigElement* proto_config, + PP_VideoConfigElement* matching_configs, + uint32_t matching_configs_size, + uint32_t* num_of_matching_configs); // Creates a video decoder with requested |decoder_config|. // |input_format| in |decoder_config| specifies the format of input access @@ -88,7 +88,7 @@ struct PPB_VideoDecoder_Dev { // // The created decoder is returned as PP_Resource. NULL means failure. PP_Resource (*Create)(PP_Instance instance, - struct PP_VideoDecoderConfig_Dev* dec_config); + PP_VideoConfigElement* dec_config); // Tests whether |resource| is a video decoder created through Create // function of this interface. @@ -114,37 +114,39 @@ struct PPB_VideoDecoder_Dev { struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer, struct PP_CompletionCallback callback); - // Provides the decoder with picture buffers for video decoding. This - // function should be called when decoder has issued ProvidePictureBuffers - // callback to the plugin with buffer requirements. + // Provides the decoder with picture buffers for video decoding. + // AssignGLESBuffers provides texture-backed buffers, whereas + // AssignSysmemBuffers provides system memory-backed buffers. // - // If the plugin is can determine how many and what kind of buffers are - // needed by the decoder it can provide them in advance. For this purpose - // the configuration map can provide how many extra buffers the decoder - // implementation requires for seamless operation. + // This function should be called when decoder has issued the + // ProvidePictureBuffers callback to the plugin with buffer requirements. // - // The decoder will pause if AssignPictureBuffer hasn't been called with - // sufficient buffers. + // It can also be called in advance or outside of ProvidePictureBuffers calls + // to provide the decoder with additional buffers. Additional buffers will be + // added to the decoder's buffer pool. // - // If the decoder rejects the buffers it will return the buffers and issue - // ProvidePictureBuffers again. + // The decoder will pause in decoding if it has not received enough buffers. // - // If AssignPictureBuffer is called multiple times the decoder will add them - // to its pool of output pictures. + // If the buffer is invalid, the decoder will return the buffer and will issue + // ProvidePictureBuffers again. // - // TODO(vmr): this API feels too flexible... should we make it more strict - // where the decoder errors on bad buffers/duplicate buffers? Perhaps - // AssignPictureBuffer should only get called in response to - // ProvidePictureBuffer? + // TODO(vmr/vrk): Decide if the API is too flexible, i.e. stricter rules on + // errors/duplicates or requiring Assign*Buffers to only be called in response + // to ProvidePictureBuffers... in which case the output buffers should be + // callback parameters to ProvidePictureBuffers instead of being part of the + // PPB API. // // Parameters: // |video_decoder| is the previously created handle to the decoder instance. // |no_of_buffers| how many buffers are behind picture buffer pointer. - // |picture_buffer| contains the reference to the picture buffer that was - // processed. - void (*AssignPictureBuffer)(PP_Resource video_decoder, + // |buffers| contains the reference to the picture buffer that was + // allocated. + void (*AssignGLESBuffers)(PP_Resource video_decoder, + uint32_t no_of_buffers, + struct PP_GLESBuffer_Dev* buffers); + void (*AssignSysmemBuffers)(PP_Resource video_decoder, uint32_t no_of_buffers, - union PP_PictureData_Dev* picture_buffer); + struct PP_SysmemBuffer_Dev* buffers); // Tells the decoder to reuse given picture buffer. Typical use of this // function is to call from PictureReady callback to recycle picture buffer @@ -164,7 +166,7 @@ struct PPB_VideoDecoder_Dev { // |picture_buffer| contains the reference to the picture buffer that was // processed. void (*ReusePictureBuffer)(PP_Resource video_decoder, - union PP_PictureData_Dev* picture_buffer); + int32_t picture_buffer_id); // Dispatches flushing request to the decoder to flush both input and output // buffers. Successful flushing will result in output of the pictures and diff --git a/ppapi/c/dev/ppp_video_decoder_dev.h b/ppapi/c/dev/ppp_video_decoder_dev.h index 3fb265c..7ae8c55 100644 --- a/ppapi/c/dev/ppp_video_decoder_dev.h +++ b/ppapi/c/dev/ppp_video_decoder_dev.h @@ -7,7 +7,7 @@ #include "ppapi/c/dev/pp_video_dev.h" -#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.1" +#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.2" // PPP_VideoDecoder_Dev structure contains the function pointers that the // plugin MUST implement to provide services needed by the video decoder @@ -16,18 +16,20 @@ struct PPP_VideoDecoder_Dev { // Callback function to provide buffers for the decoded output pictures. If // succeeds plugin must provide buffers through AssignPictureBuffers function // to the API. If |req_num_of_bufs| matching exactly the specification - // given in |props| cannot be allocated decoder should be destroyed. + // given in the parameters cannot be allocated decoder should be destroyed. // // Decoding will not proceed until buffers have been provided. // // Parameters: // |decoder| is pointer to the Pepper Video Decoder instance. // |req_num_of_bufs| tells how many buffers are needed by the decoder. - // |props| tells the properties that are required from the textures. + // |dimensions| tells the dimensions of the buffer to allocate. + // |type| specifies whether the buffer lives in system memory or GL texture. void (*ProvidePictureBuffers)( PP_Resource decoder, uint32_t req_num_of_bufs, - const struct PP_PictureBufferProperties_Dev* props); + struct PP_Size dimensions, + enum PP_PictureBufferType_Dev type); // Callback function for decoder to deliver unneeded picture buffers back to // the plugin. @@ -36,7 +38,7 @@ struct PPP_VideoDecoder_Dev { // |decoder| is pointer to the Pepper Video Decoder instance. // |picture_buffer| points to the picture buffer that is no longer needed. void (*DismissPictureBuffer)(PP_Resource decoder, - union PP_PictureData_Dev* picture_buffer); + int32_t picture_buffer_id); // Callback function for decoder to deliver decoded pictures ready to be // displayed. Decoder expects the plugin to return the buffer back to the @@ -46,7 +48,7 @@ struct PPP_VideoDecoder_Dev { // |decoder| is pointer to the Pepper Video Decoder instance. // |picture| is the picture that is ready. void (*PictureReady)(PP_Resource decoder, - struct PP_Picture_Dev* picture); + struct PP_Picture_Dev picture); // Callback function to tell the plugin that decoder has decoded end of stream // marker and output all the pictures that should be displayed from the diff --git a/ppapi/tests/arch_dependent_sizes_32.h b/ppapi/tests/arch_dependent_sizes_32.h index 25252d8..b7661cb 100644 --- a/ppapi/tests/arch_dependent_sizes_32.h +++ b/ppapi/tests/arch_dependent_sizes_32.h @@ -17,11 +17,9 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CompletionCallback_Func, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLLoaderTrusted_StatusCallback, 4); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 8); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 8); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 12); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PictureBufferProperties_Dev, 16); +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 24); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig_Dev, 20); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 32); +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 36); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPP_VideoDecoder_Dev, 20); #endif /* PPAPI_TESTS_ARCH_DEPENDENT_SIZES_32_H_ */ diff --git a/ppapi/tests/arch_dependent_sizes_64.h b/ppapi/tests/arch_dependent_sizes_64.h index 79f87618..80cc7b2 100644 --- a/ppapi/tests/arch_dependent_sizes_64.h +++ b/ppapi/tests/arch_dependent_sizes_64.h @@ -17,11 +17,9 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CompletionCallback_Func, 8); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLLoaderTrusted_StatusCallback, 8); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 16); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 16); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 16); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PictureBufferProperties_Dev, 24); +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 32); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 16); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig_Dev, 32); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 64); +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 72); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPP_VideoDecoder_Dev, 40); #endif /* PPAPI_TESTS_ARCH_DEPENDENT_SIZES_64_H_ */ -- cgit v1.1