yuv2rgb brightness/contrast/saturation/different colorspaces support finished
[libav.git] / postproc / swscale_internal.h
CommitLineData
5427e242
MN
1/*
2 Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#ifndef SWSCALE_INTERNAL_H
20#define SWSCALE_INTERNAL_H
21
22#define MAX_FILTER_SIZE 256
23
24struct SwsContext;
25
26typedef void (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
27 int srcSliceH, uint8_t* dst[], int dstStride[]);
28
29/* this struct should be aligned on at least 32-byte boundary */
30typedef struct SwsContext{
31 int srcW, srcH, dstH;
32 int chrSrcW, chrSrcH, chrDstW, chrDstH;
33 int lumXInc, chrXInc;
34 int lumYInc, chrYInc;
35 int dstFormat, srcFormat;
36 int chrSrcHSubSample, chrSrcVSubSample;
37 int chrIntHSubSample, chrIntVSubSample;
38 int chrDstHSubSample, chrDstVSubSample;
39 int vChrDrop;
40
41 int16_t **lumPixBuf;
42 int16_t **chrPixBuf;
43 int16_t *hLumFilter;
44 int16_t *hLumFilterPos;
45 int16_t *hChrFilter;
46 int16_t *hChrFilterPos;
47 int16_t *vLumFilter;
48 int16_t *vLumFilterPos;
49 int16_t *vChrFilter;
50 int16_t *vChrFilterPos;
51
52 uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
53
54 int hLumFilterSize;
55 int hChrFilterSize;
56 int vLumFilterSize;
57 int vChrFilterSize;
58 int vLumBufSize;
59 int vChrBufSize;
60
61 uint8_t __attribute__((aligned(32))) funnyYCode[10000];
62 uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
63 int32_t *lumMmx2FilterPos;
64 int32_t *chrMmx2FilterPos;
65 int16_t *lumMmx2Filter;
66 int16_t *chrMmx2Filter;
67
68 int canMMX2BeUsed;
69
70 int lastInLumBuf;
71 int lastInChrBuf;
72 int lumBufIndex;
73 int chrBufIndex;
74 int dstY;
75 int flags;
76 void * yuvTable; // pointer to the yuv->rgb table start so it can be freed()
77 void * table_rV[256];
78 void * table_gU[256];
79 int table_gV[256];
80 void * table_bU[256];
81
82 //Colorspace stuff
83 int contrast, brightness, saturation; // for sws_getColorspaceDetails
84 int srcColorspaceTable[4];
85 int dstColorspaceTable[4];
86 int srcRange, dstRange;
87
88 SwsFunc swScale;
89
90#define RED_DITHER "0*8"
91#define GREEN_DITHER "1*8"
92#define BLUE_DITHER "2*8"
93#define Y_COEFF "3*8"
94#define VR_COEFF "4*8"
95#define UB_COEFF "5*8"
96#define VG_COEFF "6*8"
97#define UG_COEFF "7*8"
98#define Y_OFFSET "8*8"
99#define U_OFFSET "9*8"
100#define V_OFFSET "10*8"
101#define LUM_MMX_FILTER_OFFSET "11*8"
102#define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
103#define DSTW_OFFSET "11*8+4*4*256*2"
104#define ESP_OFFSET "11*8+4*4*256*2+4"
105
106 uint64_t redDither __attribute__((aligned(8)));
107 uint64_t greenDither __attribute__((aligned(8)));
108 uint64_t blueDither __attribute__((aligned(8)));
109
110 uint64_t yCoeff __attribute__((aligned(8)));
111 uint64_t vrCoeff __attribute__((aligned(8)));
112 uint64_t ubCoeff __attribute__((aligned(8)));
113 uint64_t vgCoeff __attribute__((aligned(8)));
114 uint64_t ugCoeff __attribute__((aligned(8)));
115 uint64_t yOffset __attribute__((aligned(8)));
116 uint64_t uOffset __attribute__((aligned(8)));
117 uint64_t vOffset __attribute__((aligned(8)));
118 int32_t lumMmxFilter[4*MAX_FILTER_SIZE];
119 int32_t chrMmxFilter[4*MAX_FILTER_SIZE];
120 int dstW;
121 int esp;
122} SwsContext;
123//FIXME check init (where 0)
124//FIXME split private & public
125
126inline void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]);
127SwsFunc yuv2rgb_get_func_ptr (SwsContext *c);
128int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
129
130#endif