Mercurial > libavcodec.hg
comparison vp8dsp.c @ 11950:56aba5a9761c libavcodec
Make VP8 DSP functions take two strides
This isn't useful for the C functions, but will allow re-using H and V functions
for HV functions without adding separate H and V wrappers.
author | darkshikari |
---|---|
date | Fri, 25 Jun 2010 18:14:07 +0000 |
parents | f2007d7c3f1d |
children | 4aae15516d2c |
comparison
equal
deleted
inserted
replaced
11949:778bdafd5496 | 11950:56aba5a9761c |
---|---|
248 { 0, 6, 50, 93, 9, 0 }, | 248 { 0, 6, 50, 93, 9, 0 }, |
249 { 1, 8, 36, 108, 11, 2 }, | 249 { 1, 8, 36, 108, 11, 2 }, |
250 { 0, 1, 12, 123, 6, 0 }, | 250 { 0, 1, 12, 123, 6, 0 }, |
251 }; | 251 }; |
252 | 252 |
253 #define PUT_PIXELS(WIDTH) \ | |
254 static void put_vp8_pixels ## WIDTH ##_c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int x, int y) { \ | |
255 for (int y = 0; y < h; y++, dst+= dststride, src+= srcstride) { \ | |
256 memcpy(dst, src, WIDTH); \ | |
257 } \ | |
258 } | |
259 | |
260 PUT_PIXELS(16) | |
261 PUT_PIXELS(8) | |
262 PUT_PIXELS(4) | |
253 | 263 |
254 #define FILTER_6TAP(src, F, stride) \ | 264 #define FILTER_6TAP(src, F, stride) \ |
255 av_clip_uint8((F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + F[0]*src[x-2*stride] + \ | 265 av_clip_uint8((F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + F[0]*src[x-2*stride] + \ |
256 F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + F[5]*src[x+3*stride] + 64) >> 7) | 266 F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + F[5]*src[x+3*stride] + 64) >> 7) |
257 | 267 |
258 #define FILTER_4TAP(src, F, stride) \ | 268 #define FILTER_4TAP(src, F, stride) \ |
259 av_clip_uint8((F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + \ | 269 av_clip_uint8((F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + \ |
260 F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + 64) >> 7) | 270 F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + 64) >> 7) |
261 | 271 |
262 #define VP8_EPEL_H(SIZE, FILTER, FILTERNAME) \ | 272 #define VP8_EPEL_H(SIZE, FILTER, FILTERNAME) \ |
263 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, uint8_t *src, int stride, int h, int mx, int my) \ | 273 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ |
264 { \ | 274 { \ |
265 const uint8_t *filter = subpel_filters[mx-1]; \ | 275 const uint8_t *filter = subpel_filters[mx-1]; \ |
266 int x, y; \ | 276 int x, y; \ |
267 \ | 277 \ |
268 for (y = 0; y < h; y++) { \ | 278 for (y = 0; y < h; y++) { \ |
269 for (x = 0; x < SIZE; x++) \ | 279 for (x = 0; x < SIZE; x++) \ |
270 dst[x] = FILTER(src, filter, 1); \ | 280 dst[x] = FILTER(src, filter, 1); \ |
271 dst += stride; \ | 281 dst += dststride; \ |
272 src += stride; \ | 282 src += srcstride; \ |
273 } \ | 283 } \ |
274 } | 284 } |
275 #define VP8_EPEL_V(SIZE, FILTER, FILTERNAME) \ | 285 #define VP8_EPEL_V(SIZE, FILTER, FILTERNAME) \ |
276 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, uint8_t *src, int stride, int h, int mx, int my) \ | 286 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ |
277 { \ | 287 { \ |
278 const uint8_t *filter = subpel_filters[my-1]; \ | 288 const uint8_t *filter = subpel_filters[my-1]; \ |
279 int x, y; \ | 289 int x, y; \ |
280 \ | 290 \ |
281 for (y = 0; y < h; y++) { \ | 291 for (y = 0; y < h; y++) { \ |
282 for (x = 0; x < SIZE; x++) \ | 292 for (x = 0; x < SIZE; x++) \ |
283 dst[x] = FILTER(src, filter, stride); \ | 293 dst[x] = FILTER(src, filter, srcstride); \ |
284 dst += stride; \ | 294 dst += dststride; \ |
285 src += stride; \ | 295 src += srcstride; \ |
286 } \ | 296 } \ |
287 } | 297 } |
288 #define VP8_EPEL_HV(SIZE, FILTERX, FILTERY, FILTERNAME) \ | 298 #define VP8_EPEL_HV(SIZE, FILTERX, FILTERY, FILTERNAME) \ |
289 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, uint8_t *src, int stride, int h, int mx, int my) \ | 299 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ |
290 { \ | 300 { \ |
291 const uint8_t *filter = subpel_filters[mx-1]; \ | 301 const uint8_t *filter = subpel_filters[mx-1]; \ |
292 int x, y; \ | 302 int x, y; \ |
293 uint8_t tmp_array[(2*SIZE+5)*SIZE]; \ | 303 uint8_t tmp_array[(2*SIZE+5)*SIZE]; \ |
294 uint8_t *tmp = tmp_array; \ | 304 uint8_t *tmp = tmp_array; \ |
295 src -= 2*stride; \ | 305 src -= 2*srcstride; \ |
296 \ | 306 \ |
297 for (y = 0; y < h+5; y++) { \ | 307 for (y = 0; y < h+5; y++) { \ |
298 for (x = 0; x < SIZE; x++) \ | 308 for (x = 0; x < SIZE; x++) \ |
299 tmp[x] = FILTERX(src, filter, 1); \ | 309 tmp[x] = FILTERX(src, filter, 1); \ |
300 tmp += SIZE; \ | 310 tmp += SIZE; \ |
301 src += stride; \ | 311 src += srcstride; \ |
302 } \ | 312 } \ |
303 \ | 313 \ |
304 tmp = tmp_array + 2*SIZE; \ | 314 tmp = tmp_array + 2*SIZE; \ |
305 filter = subpel_filters[my-1]; \ | 315 filter = subpel_filters[my-1]; \ |
306 \ | 316 \ |
307 for (y = 0; y < h; y++) { \ | 317 for (y = 0; y < h; y++) { \ |
308 for (x = 0; x < SIZE; x++) \ | 318 for (x = 0; x < SIZE; x++) \ |
309 dst[x] = FILTERY(tmp, filter, SIZE); \ | 319 dst[x] = FILTERY(tmp, filter, SIZE); \ |
310 dst += stride; \ | 320 dst += dststride; \ |
311 tmp += SIZE; \ | 321 tmp += SIZE; \ |
312 } \ | 322 } \ |
313 } | 323 } |
314 | 324 |
315 VP8_EPEL_H(16, FILTER_4TAP, h4) | 325 VP8_EPEL_H(16, FILTER_4TAP, h4) |
336 VP8_EPEL_HV(16, FILTER_6TAP, FILTER_6TAP, h6v6) | 346 VP8_EPEL_HV(16, FILTER_6TAP, FILTER_6TAP, h6v6) |
337 VP8_EPEL_HV(8, FILTER_6TAP, FILTER_6TAP, h6v6) | 347 VP8_EPEL_HV(8, FILTER_6TAP, FILTER_6TAP, h6v6) |
338 VP8_EPEL_HV(4, FILTER_6TAP, FILTER_6TAP, h6v6) | 348 VP8_EPEL_HV(4, FILTER_6TAP, FILTER_6TAP, h6v6) |
339 | 349 |
340 #define VP8_MC_FUNC(IDX, SIZE) \ | 350 #define VP8_MC_FUNC(IDX, SIZE) \ |
341 dsp->put_vp8_epel_pixels_tab[IDX][0][0] = ff_put_vp8_pixels ## SIZE ## _c; \ | 351 dsp->put_vp8_epel_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \ |
342 dsp->put_vp8_epel_pixels_tab[IDX][0][1] = put_vp8_epel ## SIZE ## _h4_c; \ | 352 dsp->put_vp8_epel_pixels_tab[IDX][0][1] = put_vp8_epel ## SIZE ## _h4_c; \ |
343 dsp->put_vp8_epel_pixels_tab[IDX][0][2] = put_vp8_epel ## SIZE ## _h6_c; \ | 353 dsp->put_vp8_epel_pixels_tab[IDX][0][2] = put_vp8_epel ## SIZE ## _h6_c; \ |
344 dsp->put_vp8_epel_pixels_tab[IDX][1][0] = put_vp8_epel ## SIZE ## _v4_c; \ | 354 dsp->put_vp8_epel_pixels_tab[IDX][1][0] = put_vp8_epel ## SIZE ## _v4_c; \ |
345 dsp->put_vp8_epel_pixels_tab[IDX][1][1] = put_vp8_epel ## SIZE ## _h4v4_c; \ | 355 dsp->put_vp8_epel_pixels_tab[IDX][1][1] = put_vp8_epel ## SIZE ## _h4v4_c; \ |
346 dsp->put_vp8_epel_pixels_tab[IDX][1][2] = put_vp8_epel ## SIZE ## _h6v4_c; \ | 356 dsp->put_vp8_epel_pixels_tab[IDX][1][2] = put_vp8_epel ## SIZE ## _h6v4_c; \ |