summaryrefslogtreecommitdiffstats
path: root/camera/inc/NV12_resize.h
blob: 4b05a4ff32e604a9ce3519500cabcdc52532452f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * Copyright (C) Texas Instruments - http://www.ti.com/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef NV12_RESIZE_H_
#define NV12_RESIZE_H_

#include "Common.h"

typedef unsigned char  mmBool;
typedef unsigned char  mmUchar;
typedef unsigned char  mmUint8;
typedef unsigned char  mmByte;
typedef unsigned short mmUint16;
typedef unsigned int   mmUint32;
typedef unsigned long  mmUint64;
typedef signed char    mmInt8;
typedef char           mmChar;
typedef signed short   mmInt16;
typedef signed int     mmInt32;
typedef signed long    mmLong;
typedef signed int     mmHandle;
typedef float          mmFloat;
typedef double         mmDouble;
typedef int            HObj;
typedef HObj           HFile;
typedef int            HDir;
typedef void*          mmMutexHandle;
typedef struct _fstat {
    mmInt32 fileSize;
} VE_FileAttribute;

typedef struct {
    mmInt32 second;
    mmInt32 millisecond;
} tsVE_Time;

typedef struct {
    mmInt32 year;
    mmInt32 month;
    mmInt32 day;
    mmInt32 hour;
    mmInt32 minute;
    mmInt32 second;
} TmDateTime;

const mmUint8 bWeights[8][8][4] = {
  {{64, 0, 0, 0}, {56, 0, 0, 8}, {48, 0, 0,16}, {40, 0, 0,24},
   {32, 0, 0,32}, {24, 0, 0,40}, {16, 0, 0,48}, { 8, 0, 0,56}},

  {{56, 8, 0, 0}, {49, 7, 1, 7}, {42, 6, 2,14}, {35, 5, 3,21},
   {28, 4, 4,28}, {21, 3, 5,35}, {14, 2, 6,42}, { 7, 1, 7,49}},

  {{48,16, 0, 0}, {42,14, 2, 6}, {36,12,4 ,12}, {30,10,6 ,18},
   {24, 8, 8,24}, {18, 6,10,30}, {12,4 ,12,36}, { 6, 2,14,42}},

  {{40,24,0 ,0 }, {35,21, 3, 5}, {30,18, 6,10}, {25,15, 9,15},
   {20,12,12,20}, {15, 9,15,25}, {10, 6,18,30}, { 5, 3,21,35}},

  {{32,32, 0,0 }, {28,28, 4, 4}, {24,24, 8, 8}, {20,20,12,12},
   {16,16,16,16}, {12,12,20,20}, { 8, 8,24,24}, { 4, 4,28,28}},

  {{24,40,0 ,0 }, {21,35, 5, 3}, {18,30,10, 6}, {15,25,15, 9},
   {12,20,20,12}, { 9,15,25,15}, { 6,10,30,18}, { 3, 5,35,21}},

  {{16,48, 0,0 }, {14,42, 6, 2}, {12,36,12, 4}, {10,30,18, 6},
   {8 ,24,24,8 }, { 6,18,30,10}, { 4,12,36,12}, { 2, 6,42,14}},

  {{ 8,56, 0,0 }, { 7,49, 7, 1}, { 6,42,14, 2}, { 5,35,21, 3},
   { 4,28,28,4 }, { 3,21,35, 5}, { 2,14,42, 6}, { 1,7 ,49, 7}}
};

typedef enum {
    IC_FORMAT_NONE,
    IC_FORMAT_RGB565,
    IC_FORMAT_RGB888,
    IC_FORMAT_YCbCr420_lp,
    IC_FORMAT_YCbCr,
    IC_FORMAT_YCbCr420_FRAME_PK,
    IC_FORMAT_MAX
} enumImageFormat;

/* This structure defines the format of an image */
typedef struct {
    mmInt32                       uWidth;
    mmInt32                       uHeight;
    mmInt32                       uStride;
    enumImageFormat               eFormat;
    mmByte                        *imgPtr;
    mmByte                        *clrPtr;
    mmInt32                       uOffset;
} structConvImage;

typedef struct IC_crop_struct {
    mmUint32 x;             /* x pos of rectangle                              */
    mmUint32 y;             /* y pos of rectangle                              */
    mmUint32 uWidth;        /* dx of rectangle                                 */
    mmUint32 uHeight;       /* dy of rectangle                                 */
} IC_rect_type;

/*==========================================================================
* Function Name  : VT_resizeFrame_Video_opt2_lp
*
* Description    : Resize a yuv frame.
*
* Input(s)       : input_img_ptr        -> Input Image Structure
*                : output_img_ptr       -> Output Image Structure
*                : cropout             -> crop structure
*
* Value Returned : mmBool               -> FALSE on error TRUE on success
* NOTE:
*            Not tested for crop funtionallity.
*            faster version.
============================================================================*/
mmBool
VT_resizeFrame_Video_opt2_lp(
        structConvImage* i_img_ptr,        /* Points to the input image           */
        structConvImage* o_img_ptr,        /* Points to the output image          */
        IC_rect_type*  cropout,          /* how much to resize to in final image */
        mmUint16 dummy                         /* Transparent pixel value              */
        );

#endif //#define NV12_RESIZE_H_