Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2011 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef II420_COLOR_CONVERTER_H |
michael@0 | 18 | |
michael@0 | 19 | #define II420_COLOR_CONVERTER_H |
michael@0 | 20 | |
michael@0 | 21 | #include <stdint.h> |
michael@0 | 22 | #include <android/rect.h> |
michael@0 | 23 | |
michael@0 | 24 | #ifdef __cplusplus |
michael@0 | 25 | extern "C" { |
michael@0 | 26 | #endif |
michael@0 | 27 | |
michael@0 | 28 | typedef struct II420ColorConverter { |
michael@0 | 29 | |
michael@0 | 30 | /* |
michael@0 | 31 | * getDecoderOutputFormat |
michael@0 | 32 | * Returns the color format (OMX_COLOR_FORMATTYPE) of the decoder output. |
michael@0 | 33 | * If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, |
michael@0 | 34 | * and convertDecoderOutputToI420() can be a no-op. |
michael@0 | 35 | */ |
michael@0 | 36 | int (*getDecoderOutputFormat)(); |
michael@0 | 37 | |
michael@0 | 38 | /* |
michael@0 | 39 | * convertDecoderOutputToI420 |
michael@0 | 40 | * @Desc Converts from the decoder output format to I420 format. |
michael@0 | 41 | * @note Caller (e.g. VideoEditor) owns the buffers |
michael@0 | 42 | * @param decoderBits (IN) Pointer to the buffer contains decoder output |
michael@0 | 43 | * @param decoderWidth (IN) Buffer width, as reported by the decoder |
michael@0 | 44 | * metadata (kKeyWidth) |
michael@0 | 45 | * @param decoderHeight (IN) Buffer height, as reported by the decoder |
michael@0 | 46 | * metadata (kKeyHeight) |
michael@0 | 47 | * @param decoderRect (IN) The rectangle of the actual frame, as |
michael@0 | 48 | * reported by decoder metadata (kKeyCropRect) |
michael@0 | 49 | * @param dstBits (OUT) Pointer to the output I420 buffer |
michael@0 | 50 | * @return -1 Any error |
michael@0 | 51 | * @return 0 No Error |
michael@0 | 52 | */ |
michael@0 | 53 | int (*convertDecoderOutputToI420)( |
michael@0 | 54 | void* decoderBits, int decoderWidth, int decoderHeight, |
michael@0 | 55 | ARect decoderRect, void* dstBits); |
michael@0 | 56 | |
michael@0 | 57 | /* |
michael@0 | 58 | * getEncoderIntputFormat |
michael@0 | 59 | * Returns the color format (OMX_COLOR_FORMATTYPE) of the encoder input. |
michael@0 | 60 | * If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, |
michael@0 | 61 | * and convertI420ToEncoderInput() and getEncoderInputBufferInfo() can |
michael@0 | 62 | * be no-ops. |
michael@0 | 63 | */ |
michael@0 | 64 | int (*getEncoderInputFormat)(); |
michael@0 | 65 | |
michael@0 | 66 | /* convertI420ToEncoderInput |
michael@0 | 67 | * @Desc This function converts from I420 to the encoder input format |
michael@0 | 68 | * @note Caller (e.g. VideoEditor) owns the buffers |
michael@0 | 69 | * @param srcBits (IN) Pointer to the input I420 buffer |
michael@0 | 70 | * @param srcWidth (IN) Width of the I420 frame |
michael@0 | 71 | * @param srcHeight (IN) Height of the I420 frame |
michael@0 | 72 | * @param encoderWidth (IN) Encoder buffer width, as calculated by |
michael@0 | 73 | * getEncoderBufferInfo() |
michael@0 | 74 | * @param encoderHeight (IN) Encoder buffer height, as calculated by |
michael@0 | 75 | * getEncoderBufferInfo() |
michael@0 | 76 | * @param encoderRect (IN) Rect coordinates of the actual frame inside |
michael@0 | 77 | * the encoder buffer, as calculated by |
michael@0 | 78 | * getEncoderBufferInfo(). |
michael@0 | 79 | * @param encoderBits (OUT) Pointer to the output buffer. The size of |
michael@0 | 80 | * this buffer is calculated by |
michael@0 | 81 | * getEncoderBufferInfo() |
michael@0 | 82 | * @return -1 Any error |
michael@0 | 83 | * @return 0 No Error |
michael@0 | 84 | */ |
michael@0 | 85 | int (*convertI420ToEncoderInput)( |
michael@0 | 86 | void* srcBits, int srcWidth, int srcHeight, |
michael@0 | 87 | int encoderWidth, int encoderHeight, ARect encoderRect, |
michael@0 | 88 | void* encoderBits); |
michael@0 | 89 | |
michael@0 | 90 | /* getEncoderInputBufferInfo |
michael@0 | 91 | * @Desc This function returns metadata for the encoder input buffer |
michael@0 | 92 | * based on the actual I420 frame width and height. |
michael@0 | 93 | * @note This API should be be used to obtain the necessary information |
michael@0 | 94 | * before calling convertI420ToEncoderInput(). |
michael@0 | 95 | * VideoEditor knows only the width and height of the I420 buffer, |
michael@0 | 96 | * but it also needs know the width, height, and size of the |
michael@0 | 97 | * encoder input buffer. The encoder input buffer width and height |
michael@0 | 98 | * are used to set the metadata for the encoder. |
michael@0 | 99 | * @param srcWidth (IN) Width of the I420 frame |
michael@0 | 100 | * @param srcHeight (IN) Height of the I420 frame |
michael@0 | 101 | * @param encoderWidth (OUT) Encoder buffer width needed |
michael@0 | 102 | * @param encoderHeight (OUT) Encoder buffer height needed |
michael@0 | 103 | * @param encoderRect (OUT) Rect coordinates of the actual frame inside |
michael@0 | 104 | * the encoder buffer |
michael@0 | 105 | * @param encoderBufferSize (OUT) The size of the buffer that need to be |
michael@0 | 106 | * allocated by the caller before invoking |
michael@0 | 107 | * convertI420ToEncoderInput(). |
michael@0 | 108 | * @return -1 Any error |
michael@0 | 109 | * @return 0 No Error |
michael@0 | 110 | */ |
michael@0 | 111 | int (*getEncoderInputBufferInfo)( |
michael@0 | 112 | int srcWidth, int srcHeight, |
michael@0 | 113 | int* encoderWidth, int* encoderHeight, |
michael@0 | 114 | ARect* encoderRect, int* encoderBufferSize); |
michael@0 | 115 | |
michael@0 | 116 | } II420ColorConverter; |
michael@0 | 117 | |
michael@0 | 118 | /* The only function that the shared library needs to expose: It fills the |
michael@0 | 119 | function pointers in II420ColorConverter */ |
michael@0 | 120 | void getI420ColorConverter(II420ColorConverter *converter); |
michael@0 | 121 | |
michael@0 | 122 | #if defined(__cplusplus) |
michael@0 | 123 | } |
michael@0 | 124 | #endif |
michael@0 | 125 | |
michael@0 | 126 | #endif // II420_COLOR_CONVERTER_H |
michael@0 | 127 |