1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/omx-plugin/include/ics/II420ColorConverter.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,127 @@ 1.4 +/* 1.5 + * Copyright (C) 2011 The Android Open Source Project 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * Unless required by applicable law or agreed to in writing, software 1.14 + * distributed under the License is distributed on an "AS IS" BASIS, 1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.16 + * See the License for the specific language governing permissions and 1.17 + * limitations under the License. 1.18 + */ 1.19 + 1.20 +#ifndef II420_COLOR_CONVERTER_H 1.21 + 1.22 +#define II420_COLOR_CONVERTER_H 1.23 + 1.24 +#include <stdint.h> 1.25 +#include <android/rect.h> 1.26 + 1.27 +#ifdef __cplusplus 1.28 +extern "C" { 1.29 +#endif 1.30 + 1.31 +typedef struct II420ColorConverter { 1.32 + 1.33 + /* 1.34 + * getDecoderOutputFormat 1.35 + * Returns the color format (OMX_COLOR_FORMATTYPE) of the decoder output. 1.36 + * If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, 1.37 + * and convertDecoderOutputToI420() can be a no-op. 1.38 + */ 1.39 + int (*getDecoderOutputFormat)(); 1.40 + 1.41 + /* 1.42 + * convertDecoderOutputToI420 1.43 + * @Desc Converts from the decoder output format to I420 format. 1.44 + * @note Caller (e.g. VideoEditor) owns the buffers 1.45 + * @param decoderBits (IN) Pointer to the buffer contains decoder output 1.46 + * @param decoderWidth (IN) Buffer width, as reported by the decoder 1.47 + * metadata (kKeyWidth) 1.48 + * @param decoderHeight (IN) Buffer height, as reported by the decoder 1.49 + * metadata (kKeyHeight) 1.50 + * @param decoderRect (IN) The rectangle of the actual frame, as 1.51 + * reported by decoder metadata (kKeyCropRect) 1.52 + * @param dstBits (OUT) Pointer to the output I420 buffer 1.53 + * @return -1 Any error 1.54 + * @return 0 No Error 1.55 + */ 1.56 + int (*convertDecoderOutputToI420)( 1.57 + void* decoderBits, int decoderWidth, int decoderHeight, 1.58 + ARect decoderRect, void* dstBits); 1.59 + 1.60 + /* 1.61 + * getEncoderIntputFormat 1.62 + * Returns the color format (OMX_COLOR_FORMATTYPE) of the encoder input. 1.63 + * If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, 1.64 + * and convertI420ToEncoderInput() and getEncoderInputBufferInfo() can 1.65 + * be no-ops. 1.66 + */ 1.67 + int (*getEncoderInputFormat)(); 1.68 + 1.69 + /* convertI420ToEncoderInput 1.70 + * @Desc This function converts from I420 to the encoder input format 1.71 + * @note Caller (e.g. VideoEditor) owns the buffers 1.72 + * @param srcBits (IN) Pointer to the input I420 buffer 1.73 + * @param srcWidth (IN) Width of the I420 frame 1.74 + * @param srcHeight (IN) Height of the I420 frame 1.75 + * @param encoderWidth (IN) Encoder buffer width, as calculated by 1.76 + * getEncoderBufferInfo() 1.77 + * @param encoderHeight (IN) Encoder buffer height, as calculated by 1.78 + * getEncoderBufferInfo() 1.79 + * @param encoderRect (IN) Rect coordinates of the actual frame inside 1.80 + * the encoder buffer, as calculated by 1.81 + * getEncoderBufferInfo(). 1.82 + * @param encoderBits (OUT) Pointer to the output buffer. The size of 1.83 + * this buffer is calculated by 1.84 + * getEncoderBufferInfo() 1.85 + * @return -1 Any error 1.86 + * @return 0 No Error 1.87 + */ 1.88 + int (*convertI420ToEncoderInput)( 1.89 + void* srcBits, int srcWidth, int srcHeight, 1.90 + int encoderWidth, int encoderHeight, ARect encoderRect, 1.91 + void* encoderBits); 1.92 + 1.93 + /* getEncoderInputBufferInfo 1.94 + * @Desc This function returns metadata for the encoder input buffer 1.95 + * based on the actual I420 frame width and height. 1.96 + * @note This API should be be used to obtain the necessary information 1.97 + * before calling convertI420ToEncoderInput(). 1.98 + * VideoEditor knows only the width and height of the I420 buffer, 1.99 + * but it also needs know the width, height, and size of the 1.100 + * encoder input buffer. The encoder input buffer width and height 1.101 + * are used to set the metadata for the encoder. 1.102 + * @param srcWidth (IN) Width of the I420 frame 1.103 + * @param srcHeight (IN) Height of the I420 frame 1.104 + * @param encoderWidth (OUT) Encoder buffer width needed 1.105 + * @param encoderHeight (OUT) Encoder buffer height needed 1.106 + * @param encoderRect (OUT) Rect coordinates of the actual frame inside 1.107 + * the encoder buffer 1.108 + * @param encoderBufferSize (OUT) The size of the buffer that need to be 1.109 + * allocated by the caller before invoking 1.110 + * convertI420ToEncoderInput(). 1.111 + * @return -1 Any error 1.112 + * @return 0 No Error 1.113 + */ 1.114 + int (*getEncoderInputBufferInfo)( 1.115 + int srcWidth, int srcHeight, 1.116 + int* encoderWidth, int* encoderHeight, 1.117 + ARect* encoderRect, int* encoderBufferSize); 1.118 + 1.119 +} II420ColorConverter; 1.120 + 1.121 +/* The only function that the shared library needs to expose: It fills the 1.122 + function pointers in II420ColorConverter */ 1.123 +void getI420ColorConverter(II420ColorConverter *converter); 1.124 + 1.125 +#if defined(__cplusplus) 1.126 +} 1.127 +#endif 1.128 + 1.129 +#endif // II420_COLOR_CONVERTER_H 1.130 +