michael@0: /* michael@0: * Copyright (C) 2011 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef II420_COLOR_CONVERTER_H michael@0: michael@0: #define II420_COLOR_CONVERTER_H michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: typedef struct II420ColorConverter { michael@0: michael@0: /* michael@0: * getDecoderOutputFormat michael@0: * Returns the color format (OMX_COLOR_FORMATTYPE) of the decoder output. michael@0: * If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, michael@0: * and convertDecoderOutputToI420() can be a no-op. michael@0: */ michael@0: int (*getDecoderOutputFormat)(); michael@0: michael@0: /* michael@0: * convertDecoderOutputToI420 michael@0: * @Desc Converts from the decoder output format to I420 format. michael@0: * @note Caller (e.g. VideoEditor) owns the buffers michael@0: * @param decoderBits (IN) Pointer to the buffer contains decoder output michael@0: * @param decoderWidth (IN) Buffer width, as reported by the decoder michael@0: * metadata (kKeyWidth) michael@0: * @param decoderHeight (IN) Buffer height, as reported by the decoder michael@0: * metadata (kKeyHeight) michael@0: * @param decoderRect (IN) The rectangle of the actual frame, as michael@0: * reported by decoder metadata (kKeyCropRect) michael@0: * @param dstBits (OUT) Pointer to the output I420 buffer michael@0: * @return -1 Any error michael@0: * @return 0 No Error michael@0: */ michael@0: int (*convertDecoderOutputToI420)( michael@0: void* decoderBits, int decoderWidth, int decoderHeight, michael@0: ARect decoderRect, void* dstBits); michael@0: michael@0: /* michael@0: * getEncoderIntputFormat michael@0: * Returns the color format (OMX_COLOR_FORMATTYPE) of the encoder input. michael@0: * If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, michael@0: * and convertI420ToEncoderInput() and getEncoderInputBufferInfo() can michael@0: * be no-ops. michael@0: */ michael@0: int (*getEncoderInputFormat)(); michael@0: michael@0: /* convertI420ToEncoderInput michael@0: * @Desc This function converts from I420 to the encoder input format michael@0: * @note Caller (e.g. VideoEditor) owns the buffers michael@0: * @param srcBits (IN) Pointer to the input I420 buffer michael@0: * @param srcWidth (IN) Width of the I420 frame michael@0: * @param srcHeight (IN) Height of the I420 frame michael@0: * @param encoderWidth (IN) Encoder buffer width, as calculated by michael@0: * getEncoderBufferInfo() michael@0: * @param encoderHeight (IN) Encoder buffer height, as calculated by michael@0: * getEncoderBufferInfo() michael@0: * @param encoderRect (IN) Rect coordinates of the actual frame inside michael@0: * the encoder buffer, as calculated by michael@0: * getEncoderBufferInfo(). michael@0: * @param encoderBits (OUT) Pointer to the output buffer. The size of michael@0: * this buffer is calculated by michael@0: * getEncoderBufferInfo() michael@0: * @return -1 Any error michael@0: * @return 0 No Error michael@0: */ michael@0: int (*convertI420ToEncoderInput)( michael@0: void* srcBits, int srcWidth, int srcHeight, michael@0: int encoderWidth, int encoderHeight, ARect encoderRect, michael@0: void* encoderBits); michael@0: michael@0: /* getEncoderInputBufferInfo michael@0: * @Desc This function returns metadata for the encoder input buffer michael@0: * based on the actual I420 frame width and height. michael@0: * @note This API should be be used to obtain the necessary information michael@0: * before calling convertI420ToEncoderInput(). michael@0: * VideoEditor knows only the width and height of the I420 buffer, michael@0: * but it also needs know the width, height, and size of the michael@0: * encoder input buffer. The encoder input buffer width and height michael@0: * are used to set the metadata for the encoder. michael@0: * @param srcWidth (IN) Width of the I420 frame michael@0: * @param srcHeight (IN) Height of the I420 frame michael@0: * @param encoderWidth (OUT) Encoder buffer width needed michael@0: * @param encoderHeight (OUT) Encoder buffer height needed michael@0: * @param encoderRect (OUT) Rect coordinates of the actual frame inside michael@0: * the encoder buffer michael@0: * @param encoderBufferSize (OUT) The size of the buffer that need to be michael@0: * allocated by the caller before invoking michael@0: * convertI420ToEncoderInput(). michael@0: * @return -1 Any error michael@0: * @return 0 No Error michael@0: */ michael@0: int (*getEncoderInputBufferInfo)( michael@0: int srcWidth, int srcHeight, michael@0: int* encoderWidth, int* encoderHeight, michael@0: ARect* encoderRect, int* encoderBufferSize); michael@0: michael@0: } II420ColorConverter; michael@0: michael@0: /* The only function that the shared library needs to expose: It fills the michael@0: function pointers in II420ColorConverter */ michael@0: void getI420ColorConverter(II420ColorConverter *converter); michael@0: michael@0: #if defined(__cplusplus) michael@0: } michael@0: #endif michael@0: michael@0: #endif // II420_COLOR_CONVERTER_H michael@0: