diff options
author | Chih-Chung Chang <chihchung@google.com> | 2011-07-22 09:01:36 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2011-07-27 09:36:51 +0800 |
commit | 7efb8efc88ba529c1c57366a305855c2051ebb8b (patch) | |
tree | 4d13cead0028ee272f3c8267edbdd12b81ec1b23 /libvideoeditor/include | |
parent | abb85fd9090817686bbdaa5a5b29547728a8d385 (diff) | |
download | frameworks_av-7efb8efc88ba529c1c57366a305855c2051ebb8b.zip frameworks_av-7efb8efc88ba529c1c57366a305855c2051ebb8b.tar.gz frameworks_av-7efb8efc88ba529c1c57366a305855c2051ebb8b.tar.bz2 |
Add YV12 color converter interface for VideoEditor.
The original assumption in VideoEditor is that the decoder output
and encoder input are in YV12 format. However on different
hardware platform the actual formats may be different. So now we
load a platform-specific YV12 color conversion module which
knows the actual format and can convert to/from YV12, which is
the format used in VideoEditor internally for processing.
Bug: 5061733
Change-Id: I852f85efd30c05cf6c42810059ee4d2ef37ee3da
Diffstat (limited to 'libvideoeditor/include')
-rw-r--r-- | libvideoeditor/include/IYV12ColorConverter.h | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/libvideoeditor/include/IYV12ColorConverter.h b/libvideoeditor/include/IYV12ColorConverter.h new file mode 100644 index 0000000..e8f497a --- /dev/null +++ b/libvideoeditor/include/IYV12ColorConverter.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IYV12_COLOR_CONVERTER_H + +#define IYV12_COLOR_CONVERTER_H + +#include <stdint.h> +#include <android/rect.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct IYV12ColorConverter { + + /* + * getDecoderOutputFormat + * Returns the color format (OMX_COLOR_FORMATTYPE) of the decoder output. + * If it is YV12 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, + * and convertDecoderOutputToYV12() can be a no-op. + */ + int (*getDecoderOutputFormat)(); + + /* + * convertDecoderOutputToYV12 + * @Desc Converts from the decoder output format to YV12 format. + * @note Caller (e.g. VideoEditor) owns the buffers + * @param decoderBits (IN) Pointer to the buffer contains decoder output + * @param decoderWidth (IN) Buffer width, as reported by the decoder + * metadata (kKeyWidth) + * @param decoderHeight (IN) Buffer height, as reported by the decoder + * metadata (kKeyHeight) + * @param decoderRect (IN) The rectangle of the actual frame, as + * reported by decoder metadata (kKeyCropRect) + * @param dstBits (OUT) Pointer to the output YV12 buffer + * @return -1 Any error + * @return 0 No Error + */ + int (*convertDecoderOutputToYV12)( + void* decoderBits, int decoderWidth, int decoderHeight, + ARect decoderRect, void* dstBits); + + /* + * getEncoderIntputFormat + * Returns the color format (OMX_COLOR_FORMATTYPE) of the encoder input. + * If it is YV12 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, + * and convertYV12ToEncoderInput() and getEncoderInputBufferInfo() can + * be no-ops. + */ + int (*getEncoderInputFormat)(); + + /* convertYV12ToEncoderInput + * @Desc This function converts from YV12 to the encoder input format + * @note Caller (e.g. VideoEditor) owns the buffers + * @param srcBits (IN) Pointer to the input YV12 buffer + * @param srcWidth (IN) Width of the YV12 frame + * @param srcHeight (IN) Height of the YV12 frame + * @param encoderWidth (IN) Encoder buffer width, as calculated by + * getEncoderBufferInfo() + * @param encoderHeight (IN) Encoder buffer height, as calculated by + * getEncoderBufferInfo() + * @param encoderRect (IN) Rect coordinates of the actual frame inside + * the encoder buffer, as calculated by + * getEncoderBufferInfo(). + * @param encoderBits (OUT) Pointer to the output buffer. The size of + * this buffer is calculated by + * getEncoderBufferInfo() + * @return -1 Any error + * @return 0 No Error + */ + int (*convertYV12ToEncoderInput)( + void* srcBits, int srcWidth, int srcHeight, + int encoderWidth, int encoderHeight, ARect encoderRect, + void* encoderBits); + + /* getEncoderInputBufferInfo + * @Desc This function returns metadata for the encoder input buffer + * based on the actual YV12 frame width and height. + * @note This API should be be used to obtain the necessary information + * before calling convertYV12ToEncoderInput(). + * VideoEditor knows only the width and height of the YV12 buffer, + * but it also needs know the width, height, and size of the + * encoder input buffer. The encoder input buffer width and height + * are used to set the metadata for the encoder. + * @param srcWidth (IN) Width of the YV12 frame + * @param srcHeight (IN) Height of the YV12 frame + * @param encoderWidth (OUT) Encoder buffer width needed + * @param encoderHeight (OUT) Encoder buffer height needed + * @param encoderRect (OUT) Rect coordinates of the actual frame inside + * the encoder buffer + * @param encoderBufferSize (OUT) The size of the buffer that need to be + * allocated by the caller before invoking + * convertYV12ToEncoderInput(). + * @return -1 Any error + * @return 0 No Error + */ + int (*getEncoderInputBufferInfo)( + int srcWidth, int srcHeight, + int* encoderWidth, int* encoderHeight, + ARect* encoderRect, int* encoderBufferSize); + +} IYV12ColorConverter; + +/* The only function that the shared library needs to expose: It fills the + function pointers in IYV12ColorConverter */ +void getYV12ColorConverter(IYV12ColorConverter *converter); + +#if defined(__cplusplus) +} +#endif + +#endif // IYV12_COLOR_CONVERTER_H |