Mercurial > libavcodec.hg
comparison dv.c @ 8164:ab31736c0f23 libavcodec
Getting rid of huge static DV tables
author | romansh |
---|---|
date | Tue, 18 Nov 2008 20:48:26 +0000 |
parents | e1a094cabfc3 |
children | 471b16105266 |
comparison
equal
deleted
inserted
replaced
8163:e1a094cabfc3 | 8164:ab31736c0f23 |
---|---|
88 if (DV_PROFILE_IS_720p50(d)) | 88 if (DV_PROFILE_IS_720p50(d)) |
89 size -= 4*27; | 89 size -= 4*27; |
90 return size; | 90 return size; |
91 } | 91 } |
92 | 92 |
93 static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, int slot, | |
94 uint16_t *tbl) | |
95 { | |
96 const static uint8_t off[] = { 2, 6, 8, 0, 4 }; | |
97 const static uint8_t shuf1[] = { 36, 18, 54, 0, 72 }; | |
98 const static uint8_t shuf2[] = { 24, 12, 36, 0, 48 }; | |
99 const static uint8_t shuf3[] = { 18, 9, 27, 0, 36 }; | |
100 | |
101 const static uint8_t l_start[] = {0, 4, 9, 13, 18, 22, 27, 31, 36, 40}; | |
102 const static uint8_t l_start_shuffled[] = { 9, 4, 13, 0, 18 }; | |
103 | |
104 const static uint8_t serpent1[] = {0, 1, 2, 2, 1, 0, | |
105 0, 1, 2, 2, 1, 0, | |
106 0, 1, 2, 2, 1, 0, | |
107 0, 1, 2, 2, 1, 0, | |
108 0, 1, 2}; | |
109 const static uint8_t serpent2[] = {0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, | |
110 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, | |
111 0, 1, 2, 3, 4, 5}; | |
112 | |
113 const static uint8_t remap[][2] = {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, /* dummy */ | |
114 { 0, 0}, { 0, 1}, { 0, 2}, { 0, 3}, {10, 0}, | |
115 {10, 1}, {10, 2}, {10, 3}, {20, 0}, {20, 1}, | |
116 {20, 2}, {20, 3}, {30, 0}, {30, 1}, {30, 2}, | |
117 {30, 3}, {40, 0}, {40, 1}, {40, 2}, {40, 3}, | |
118 {50, 0}, {50, 1}, {50, 2}, {50, 3}, {60, 0}, | |
119 {60, 1}, {60, 2}, {60, 3}, {70, 0}, {70, 1}, | |
120 {70, 2}, {70, 3}, { 0,64}, { 0,65}, { 0,66}, | |
121 {10,64}, {10,65}, {10,66}, {20,64}, {20,65}, | |
122 {20,66}, {30,64}, {30,65}, {30,66}, {40,64}, | |
123 {40,65}, {40,66}, {50,64}, {50,65}, {50,66}, | |
124 {60,64}, {60,65}, {60,66}, {70,64}, {70,65}, | |
125 {70,66}, { 0,67}, {20,67}, {40,67}, {60,67}}; | |
126 | |
127 int i, k, m; | |
128 int x, y, blk; | |
129 | |
130 for (m=0; m<5; m++) { | |
131 switch (d->width) { | |
132 case 1440: | |
133 blk = (chan*11+seq)*27+slot; | |
134 | |
135 if (chan == 0 && seq == 11) { | |
136 x = m*27+slot; | |
137 if (x<90) { | |
138 y = 0; | |
139 } else { | |
140 x = (x - 90)*2; | |
141 y = 67; | |
142 } | |
143 } else { | |
144 i = (4*chan + blk + off[m])%11; | |
145 k = (blk/11)%27; | |
146 | |
147 x = shuf1[m] + (chan&1)*9 + k%9; | |
148 y = (i*3+k/9)*2 + (chan>>1) + 1; | |
149 } | |
150 tbl[m] = (x<<1)|(y<<9); | |
151 break; | |
152 case 1280: | |
153 blk = (chan*10+seq)*27+slot; | |
154 | |
155 i = (4*chan + (seq/5) + 2*blk + off[m])%10; | |
156 k = (blk/5)%27; | |
157 | |
158 x = shuf1[m]+(chan&1)*9 + k%9; | |
159 y = (i*3+k/9)*2 + (chan>>1) + 4; | |
160 | |
161 if (x >= 80) { | |
162 x = remap[y][0]+((x-80)<<(y>59)); | |
163 y = remap[y][1]; | |
164 } | |
165 tbl[m] = (x<<1)|(y<<9); | |
166 break; | |
167 case 960: | |
168 blk = (chan*10+seq)*27+slot; | |
169 | |
170 i = (4*chan + (seq/5) + 2*blk + off[m])%10; | |
171 k = (blk/5)%27 + (i&1)*3; | |
172 | |
173 x = shuf2[m] + k%6 + 6*(chan&1); | |
174 y = l_start[i] + k/6 + 45*(chan>>1); | |
175 tbl[m] = (x<<1)|(y<<9); | |
176 break; | |
177 case 720: | |
178 switch (d->pix_fmt) { | |
179 case PIX_FMT_YUV422P: | |
180 x = shuf3[m] + slot/3; | |
181 y = serpent1[slot] + | |
182 ((((seq + off[m]) % d->difseg_size)<<1) + chan)*3; | |
183 tbl[m] = (x<<1)|(y<<8); | |
184 break; | |
185 case PIX_FMT_YUV420P: | |
186 x = shuf3[m] + slot/3; | |
187 y = serpent1[slot] + | |
188 ((seq + off[m]) % d->difseg_size)*3; | |
189 tbl[m] = (x<<1)|(y<<9); | |
190 break; | |
191 case PIX_FMT_YUV411P: | |
192 i = (seq + off[m]) % d->difseg_size; | |
193 k = slot + ((m==1||m==2)?3:0); | |
194 | |
195 x = l_start_shuffled[m] + k/6; | |
196 y = serpent2[k] + i*6; | |
197 if (x>21) | |
198 y = y*2 - i*6; | |
199 tbl[m] = (x<<2)|(y<<8); | |
200 break; | |
201 } | |
202 default: | |
203 break; | |
204 } | |
205 } | |
206 } | |
207 | |
93 static int dv_init_dynamic_tables(const DVprofile *d) | 208 static int dv_init_dynamic_tables(const DVprofile *d) |
94 { | 209 { |
95 int j,i,c,s,p,k; | 210 int j,i,c,s,p; |
96 | 211 |
97 if (d->work_chunks[dv_work_pool_size(d)-1].buf_offset) | 212 if (d->work_chunks[dv_work_pool_size(d)-1].buf_offset) |
98 return 0; | 213 return 0; |
99 | 214 |
100 p = i = 0; | 215 p = i = 0; |
103 p += 6; | 218 p += 6; |
104 for (j=0; j<27; j++) { | 219 for (j=0; j<27; j++) { |
105 p += !(j%3); | 220 p += !(j%3); |
106 if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) && | 221 if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) && |
107 !(DV_PROFILE_IS_720p50(d) && s > 9)) { | 222 !(DV_PROFILE_IS_720p50(d) && s > 9)) { |
108 for (k=0; k<5; k++) | 223 dv_calc_mb_coordinates(d, c, s, j, &d->work_chunks[i].mb_coordinates[0]); |
109 d->work_chunks[i].mb_coordinates[k] = d->video_place[(c*d->difseg_size+s)*27*5 + j*5 + k]; | |
110 d->work_chunks[i++].buf_offset = p; | 224 d->work_chunks[i++].buf_offset = p; |
111 } | 225 } |
112 p += 5; | 226 p += 5; |
113 } | 227 } |
114 } | 228 } |