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 /////////////////////////////////////////////////// 18 // MosaicTypes.h 19 // S.O. # : 20 // Author(s): zkira 21 // $Id: MosaicTypes.h,v 1.15 2011/06/17 13:35:48 mbansal Exp $ 22 23 24 #ifndef MOSAIC_TYPES_H 25 #define MOSAIC_TYPES_H 26 27 #include "ImageUtils.h" 28 29 /** 30 * Definition of rectangle in a mosaic. 31 */ 32 class MosaicRect 33 { 34 public: MosaicRect()35 MosaicRect() 36 { 37 left = right = top = bottom = 0.0; 38 } 39 Width()40 inline int Width() 41 { 42 return right - left; 43 } 44 Height()45 inline int Height() 46 { 47 return bottom - top; 48 } 49 50 /** 51 * Bounds of the rectangle 52 */ 53 int left, right, top, bottom; 54 }; 55 56 class BlendRect 57 { 58 public: 59 double lft, rgt, top, bot; 60 }; 61 62 /** 63 * A frame making up the mosaic. 64 * Note: Currently assumes a YVU image 65 * containing separate Y,V, and U planes 66 * in contiguous memory (in that order). 67 */ 68 class MosaicFrame { 69 public: 70 ImageType image; 71 double trs[3][3]; 72 int width, height; 73 BlendRect brect; // This frame warped to the Mosaic coordinate system 74 BlendRect vcrect; // brect clipped using the voronoi neighbors 75 bool internal_allocation; 76 MosaicFrame()77 MosaicFrame() { }; 78 MosaicFrame(int _width, int _height, bool allocate=true) 79 { 80 width = _width; 81 height = _height; 82 internal_allocation = allocate; 83 if(internal_allocation) 84 image = ImageUtils::allocateImage(width, height, ImageUtils::IMAGE_TYPE_NUM_CHANNELS); 85 } 86 87 ~MosaicFrame()88 ~MosaicFrame() 89 { 90 if(internal_allocation) 91 if (image) 92 free(image); 93 } 94 95 /** 96 * Get the V plane of the image. 97 */ getV()98 inline ImageType getV() 99 { 100 return (image + (width*height)); 101 } 102 103 /** 104 * Get the U plane of the image. 105 */ getU()106 inline ImageType getU() 107 { 108 return (image + (width*height*2)); 109 } 110 111 /** 112 * Get a pixel from the V plane of the image. 113 */ getV(int y,int x)114 inline int getV(int y, int x) 115 { 116 ImageType U = image + (width*height); 117 return U[y*width+x]; 118 } 119 120 /** 121 * Get a pixel from the U plane of the image. 122 */ getU(int y,int x)123 inline int getU(int y, int x) 124 { 125 ImageType U = image + (width*height*2); 126 return U[y*width+x]; 127 } 128 129 }; 130 131 /** 132 * Structure for describing a warp. 133 */ 134 typedef struct { 135 int horizontal; 136 double theta; 137 double x; 138 double y; 139 double width; 140 double radius; 141 double direction; 142 double correction; 143 int blendRange; 144 int blendRangeUV; 145 int nlevs; 146 int nlevsC; 147 int blendingType; 148 int stripType; 149 // Add an overlap to prevent a gap between pictures due to roundoffs 150 double roundoffOverlap;// 1.5 151 152 } BlendParams; 153 154 #endif 155