1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ANDROID_VE_TOOLS_H 18#define ANDROID_VE_TOOLS_H 19 20#include "M4OSA_Types.h" 21#include "M4OSA_Memory.h" 22#include "M4OSA_Debug.h" 23#include "M4VIFI_FiltersAPI.h" 24/* Macro definitions */ 25#include "M4VIFI_Defines.h" 26/* Clip table declaration */ 27#include "M4VIFI_Clip.h" 28#include "M4VFL_transition.h" 29#include "M4VSS3GPP_API.h" 30#include "M4xVSS_API.h" 31#include "M4xVSS_Internal.h" 32#include "M4AIR_API.h" 33#include "PreviewRenderer.h" 34 35#define MEDIA_RENDERING_INVALID 255 36#define TRANSPARENT_COLOR 0x7E0 37#define LUM_FACTOR_MAX 10 38enum { 39 VIDEO_EFFECT_NONE = 0, 40 VIDEO_EFFECT_BLACKANDWHITE = 1, 41 VIDEO_EFFECT_PINK = 2, 42 VIDEO_EFFECT_GREEN = 4, 43 VIDEO_EFFECT_SEPIA = 8, 44 VIDEO_EFFECT_NEGATIVE = 16, 45 VIDEO_EFFECT_FRAMING = 32, 46 VIDEO_EFFECT_FIFTIES = 64, 47 VIDEO_EFFECT_COLOR_RGB16 = 128, 48 VIDEO_EFFECT_GRADIENT = 256, 49 VIDEO_EFFECT_FADEFROMBLACK = 512, 50 VIDEO_EFFECT_FADETOBLACK = 2048, 51}; 52 53typedef struct { 54 M4VIFI_UInt8 *vidBuffer; 55 M4OSA_UInt32 videoWidth; 56 M4OSA_UInt32 videoHeight; 57 M4OSA_UInt32 timeMs; 58 M4OSA_UInt32 timeOffset; //has the duration of clips played. 59 //The flag shall be used for Framing. 60 M4VSS3GPP_EffectSettings* effectsSettings; 61 M4OSA_UInt32 numberEffects; 62 M4OSA_UInt32 outVideoWidth; 63 M4OSA_UInt32 outVideoHeight; 64 M4OSA_UInt32 currentVideoEffect; 65 M4OSA_Bool isFiftiesEffectStarted; 66 M4xVSS_MediaRendering renderingMode; 67 uint8_t *pOutBuffer; 68 size_t outBufferStride; 69 M4VIFI_UInt8* overlayFrameRGBBuffer; 70 M4VIFI_UInt8* overlayFrameYUVBuffer; 71} vePostProcessParams; 72 73M4VIFI_UInt8 M4VIFI_YUV420PlanarToYUV420Semiplanar(void *user_data, M4VIFI_ImagePlane *PlaneIn, M4VIFI_ImagePlane *PlaneOut ); 74M4VIFI_UInt8 M4VIFI_SemiplanarYUV420toYUV420(void *user_data, M4VIFI_ImagePlane *PlaneIn, M4VIFI_ImagePlane *PlaneOut ); 75 76M4OSA_ERR M4VSS3GPP_externalVideoEffectColor(M4OSA_Void *pFunctionContext, M4VIFI_ImagePlane *PlaneIn, 77 M4VIFI_ImagePlane *PlaneOut,M4VSS3GPP_ExternalProgress *pProgress, M4OSA_UInt32 uiEffectKind); 78 79M4OSA_ERR M4VSS3GPP_externalVideoEffectFraming( M4OSA_Void *userData, M4VIFI_ImagePlane PlaneIn[3], M4VIFI_ImagePlane *PlaneOut, M4VSS3GPP_ExternalProgress *pProgress, M4OSA_UInt32 uiEffectKind ); 80 81M4OSA_ERR M4VSS3GPP_externalVideoEffectFifties( M4OSA_Void *pUserData, M4VIFI_ImagePlane *pPlaneIn, M4VIFI_ImagePlane *pPlaneOut, M4VSS3GPP_ExternalProgress *pProgress, M4OSA_UInt32 uiEffectKind ); 82 83unsigned char M4VFL_modifyLumaWithScale(M4ViComImagePlane *plane_in, M4ViComImagePlane *plane_out, unsigned long lum_factor, void *user_data); 84 85M4OSA_ERR M4xVSS_internalConvertRGBtoYUV(M4xVSS_FramingStruct* framingCtx); 86M4VIFI_UInt8 M4VIFI_xVSS_RGB565toYUV420(void *pUserData, M4VIFI_ImagePlane *pPlaneIn, 87 M4VIFI_ImagePlane *pPlaneOut); 88 89M4OSA_ERR M4xVSS_internalConvertRGB888toYUV(M4xVSS_FramingStruct* framingCtx); 90M4VIFI_UInt8 M4VIFI_RGB888toYUV420(void *pUserData, M4VIFI_ImagePlane *PlaneIn, M4VIFI_ImagePlane PlaneOut[3]); 91 92/*+ Handle the image files here */ 93M4OSA_ERR LvGetImageThumbNail(const char *fileName, M4OSA_UInt32 height, M4OSA_UInt32 width, M4OSA_Void **pBuffer); 94/*- Handle the image files here */ 95 96M4OSA_ERR applyRenderingMode(M4VIFI_ImagePlane* pPlaneIn, M4VIFI_ImagePlane* pPlaneOut, M4xVSS_MediaRendering mediaRendering); 97 98 99M4VIFI_UInt8 M4VIFI_YUV420toYUV420(void *user_data, M4VIFI_ImagePlane PlaneIn[3], M4VIFI_ImagePlane *PlaneOut ); 100M4VIFI_UInt8 M4VIFI_ResizeBilinearYUV420toYUV420(void *pUserData, 101 M4VIFI_ImagePlane *pPlaneIn, 102 M4VIFI_ImagePlane *pPlaneOut); 103 104M4OSA_Void prepareYUV420ImagePlane(M4VIFI_ImagePlane *plane, 105 M4OSA_UInt32 width, M4OSA_UInt32 height, M4VIFI_UInt8 *buffer, 106 M4OSA_UInt32 reportedWidth, M4OSA_UInt32 reportedHeight); 107 108M4OSA_Void prepareYV12ImagePlane(M4VIFI_ImagePlane *plane, 109 M4OSA_UInt32 width, M4OSA_UInt32 height, M4OSA_UInt32 stride, M4VIFI_UInt8 *buffer); 110 111M4OSA_Void swapImagePlanes( 112 M4VIFI_ImagePlane *planeIn, M4VIFI_ImagePlane *planeOut, 113 M4VIFI_UInt8 *buffer1, M4VIFI_UInt8 *buffer2); 114 115M4OSA_Void computePercentageDone( 116 M4OSA_UInt32 ctsMs, M4OSA_UInt32 effectStartTimeMs, 117 M4OSA_UInt32 effectDuration, M4OSA_Double *percentageDone); 118 119M4OSA_Void computeProgressForVideoEffect( 120 M4OSA_UInt32 ctsMs, M4OSA_UInt32 effectStartTimeMs, 121 M4OSA_UInt32 effectDuration, M4VSS3GPP_ExternalProgress* extProgress); 122 123M4OSA_ERR prepareFramingStructure( 124 M4xVSS_FramingStruct* framingCtx, 125 M4VSS3GPP_EffectSettings* effectsSettings, M4OSA_UInt32 index, 126 M4VIFI_UInt8* overlayRGB, M4VIFI_UInt8* overlayYUV); 127 128M4OSA_ERR applyColorEffect(M4xVSS_VideoEffectType colorEffect, 129 M4VIFI_ImagePlane *planeIn, M4VIFI_ImagePlane *planeOut, 130 M4VIFI_UInt8 *buffer1, M4VIFI_UInt8 *buffer2, M4OSA_UInt16 rgbColorData); 131 132M4OSA_ERR applyLumaEffect(M4VSS3GPP_VideoEffectType videoEffect, 133 M4VIFI_ImagePlane *planeIn, M4VIFI_ImagePlane *planeOut, 134 M4VIFI_UInt8 *buffer1, M4VIFI_UInt8 *buffer2, M4OSA_Int32 lum_factor); 135 136M4OSA_ERR applyEffectsAndRenderingMode(vePostProcessParams *params, 137 M4OSA_UInt32 reportedWidth, M4OSA_UInt32 reportedHeight); 138 139android::status_t getVideoSizeByResolution(M4VIDEOEDITING_VideoFrameSize resolution, 140 uint32_t *pWidth, uint32_t *pHeight); 141 142M4VIFI_UInt8 M4VIFI_Rotate90LeftYUV420toYUV420(void* pUserData, 143 M4VIFI_ImagePlane *pPlaneIn, M4VIFI_ImagePlane *pPlaneOut); 144 145M4VIFI_UInt8 M4VIFI_Rotate90RightYUV420toYUV420(void* pUserData, 146 M4VIFI_ImagePlane *pPlaneIn, M4VIFI_ImagePlane *pPlaneOut); 147 148M4VIFI_UInt8 M4VIFI_Rotate180YUV420toYUV420(void* pUserData, 149 M4VIFI_ImagePlane *pPlaneIn, M4VIFI_ImagePlane *pPlaneOut); 150 151M4OSA_ERR applyVideoRotation(M4OSA_Void* pBuffer, 152 M4OSA_UInt32 width, M4OSA_UInt32 height, M4OSA_UInt32 rotation); 153#endif // ANDROID_VE_TOOLS_H 154