Mercurial > libavcodec.hg
comparison imgresample.c @ 1488:766a2f4edbea libavcodec
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
| author | michaelni |
|---|---|
| date | Mon, 29 Sep 2003 15:44:59 +0000 |
| parents | 1e39f273ecd6 |
| children | 0c23a5564489 |
comparison
equal
deleted
inserted
replaced
| 1487:dfd69e00951c | 1488:766a2f4edbea |
|---|---|
| 56 { | 56 { |
| 57 return ((pos) >> (POS_FRAC_BITS - PHASE_BITS)) & ((1 << PHASE_BITS) - 1); | 57 return ((pos) >> (POS_FRAC_BITS - PHASE_BITS)) & ((1 << PHASE_BITS) - 1); |
| 58 } | 58 } |
| 59 | 59 |
| 60 /* This function must be optimized */ | 60 /* This function must be optimized */ |
| 61 static void h_resample_fast(uint8_t *dst, int dst_width, uint8_t *src, int src_width, | 61 static void h_resample_fast(uint8_t *dst, int dst_width, const uint8_t *src, |
| 62 int src_start, int src_incr, int16_t *filters) | 62 int src_width, int src_start, int src_incr, |
| 63 int16_t *filters) | |
| 63 { | 64 { |
| 64 int src_pos, phase, sum, i; | 65 int src_pos, phase, sum, i; |
| 65 uint8_t *s; | 66 const uint8_t *s; |
| 66 int16_t *filter; | 67 int16_t *filter; |
| 67 | 68 |
| 68 src_pos = src_start; | 69 src_pos = src_start; |
| 69 for(i=0;i<dst_width;i++) { | 70 for(i=0;i<dst_width;i++) { |
| 70 #ifdef TEST | 71 #ifdef TEST |
| 99 dst++; | 100 dst++; |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 | 103 |
| 103 /* This function must be optimized */ | 104 /* This function must be optimized */ |
| 104 static void v_resample(uint8_t *dst, int dst_width, uint8_t *src, int wrap, | 105 static void v_resample(uint8_t *dst, int dst_width, const uint8_t *src, |
| 105 int16_t *filter) | 106 int wrap, int16_t *filter) |
| 106 { | 107 { |
| 107 int sum, i; | 108 int sum, i; |
| 108 uint8_t *s; | 109 const uint8_t *s; |
| 109 | 110 |
| 110 s = src; | 111 s = src; |
| 111 for(i=0;i<dst_width;i++) { | 112 for(i=0;i<dst_width;i++) { |
| 112 #if NB_TAPS == 4 | 113 #if NB_TAPS == 4 |
| 113 sum = s[0 * wrap] * filter[0] + | 114 sum = s[0 * wrap] * filter[0] + |
| 158 } | 159 } |
| 159 | 160 |
| 160 #define DUMP(reg) movq_r2m(reg, tmp); printf(#reg "=%016Lx\n", tmp.uq); | 161 #define DUMP(reg) movq_r2m(reg, tmp); printf(#reg "=%016Lx\n", tmp.uq); |
| 161 | 162 |
| 162 /* XXX: do four pixels at a time */ | 163 /* XXX: do four pixels at a time */ |
| 163 static void h_resample_fast4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int src_width, | 164 static void h_resample_fast4_mmx(uint8_t *dst, int dst_width, |
| 165 const uint8_t *src, int src_width, | |
| 164 int src_start, int src_incr, int16_t *filters) | 166 int src_start, int src_incr, int16_t *filters) |
| 165 { | 167 { |
| 166 int src_pos, phase; | 168 int src_pos, phase; |
| 167 uint8_t *s; | 169 const uint8_t *s; |
| 168 int16_t *filter; | 170 int16_t *filter; |
| 169 mmx_t tmp; | 171 mmx_t tmp; |
| 170 | 172 |
| 171 src_pos = src_start; | 173 src_pos = src_start; |
| 172 pxor_r2r(mm7, mm7); | 174 pxor_r2r(mm7, mm7); |
| 202 dst_width--; | 204 dst_width--; |
| 203 } | 205 } |
| 204 emms(); | 206 emms(); |
| 205 } | 207 } |
| 206 | 208 |
| 207 static void v_resample4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int wrap, | 209 static void v_resample4_mmx(uint8_t *dst, int dst_width, const uint8_t *src, |
| 208 int16_t *filter) | 210 int wrap, int16_t *filter) |
| 209 { | 211 { |
| 210 int sum, i, v; | 212 int sum, i, v; |
| 211 uint8_t *s; | 213 const uint8_t *s; |
| 212 mmx_t tmp; | 214 mmx_t tmp; |
| 213 mmx_t coefs[4]; | 215 mmx_t coefs[4]; |
| 214 | 216 |
| 215 for(i=0;i<4;i++) { | 217 for(i=0;i<4;i++) { |
| 216 v = filter[i]; | 218 v = filter[i]; |
| 278 typedef union { | 280 typedef union { |
| 279 vector signed short v; | 281 vector signed short v; |
| 280 signed short s[8]; | 282 signed short s[8]; |
| 281 } vec_ss_t; | 283 } vec_ss_t; |
| 282 | 284 |
| 283 void v_resample16_altivec(uint8_t *dst, int dst_width, uint8_t *src, int wrap, | 285 void v_resample16_altivec(uint8_t *dst, int dst_width, const uint8_t *src, |
| 284 int16_t *filter) | 286 int wrap, int16_t *filter) |
| 285 { | 287 { |
| 286 int sum, i; | 288 int sum, i; |
| 287 uint8_t *s; | 289 const uint8_t *s; |
| 288 vector unsigned char *tv, tmp, dstv, zero; | 290 vector unsigned char *tv, tmp, dstv, zero; |
| 289 vec_ss_t srchv[4], srclv[4], fv[4]; | 291 vec_ss_t srchv[4], srclv[4], fv[4]; |
| 290 vector signed short zeros, sumhv, sumlv; | 292 vector signed short zeros, sumhv, sumlv; |
| 291 s = src; | 293 s = src; |
| 292 | 294 |
| 395 } | 397 } |
| 396 } | 398 } |
| 397 #endif | 399 #endif |
| 398 | 400 |
| 399 /* slow version to handle limit cases. Does not need optimisation */ | 401 /* slow version to handle limit cases. Does not need optimisation */ |
| 400 static void h_resample_slow(uint8_t *dst, int dst_width, uint8_t *src, int src_width, | 402 static void h_resample_slow(uint8_t *dst, int dst_width, |
| 403 const uint8_t *src, int src_width, | |
| 401 int src_start, int src_incr, int16_t *filters) | 404 int src_start, int src_incr, int16_t *filters) |
| 402 { | 405 { |
| 403 int src_pos, phase, sum, j, v, i; | 406 int src_pos, phase, sum, j, v, i; |
| 404 uint8_t *s, *src_end; | 407 const uint8_t *s, *src_end; |
| 405 int16_t *filter; | 408 int16_t *filter; |
| 406 | 409 |
| 407 src_end = src + src_width; | 410 src_end = src + src_width; |
| 408 src_pos = src_start; | 411 src_pos = src_start; |
| 409 for(i=0;i<dst_width;i++) { | 412 for(i=0;i<dst_width;i++) { |
| 430 src_pos += src_incr; | 433 src_pos += src_incr; |
| 431 dst++; | 434 dst++; |
| 432 } | 435 } |
| 433 } | 436 } |
| 434 | 437 |
| 435 static void h_resample(uint8_t *dst, int dst_width, uint8_t *src, int src_width, | 438 static void h_resample(uint8_t *dst, int dst_width, const uint8_t *src, |
| 436 int src_start, int src_incr, int16_t *filters) | 439 int src_width, int src_start, int src_incr, |
| 440 int16_t *filters) | |
| 437 { | 441 { |
| 438 int n, src_end; | 442 int n, src_end; |
| 439 | 443 |
| 440 if (src_start < 0) { | 444 if (src_start < 0) { |
| 441 n = (0 - src_start + src_incr - 1) / src_incr; | 445 n = (0 - src_start + src_incr - 1) / src_incr; |
| 605 av_free(s); | 609 av_free(s); |
| 606 return NULL; | 610 return NULL; |
| 607 } | 611 } |
| 608 | 612 |
| 609 void img_resample(ImgReSampleContext *s, | 613 void img_resample(ImgReSampleContext *s, |
| 610 AVPicture *output, AVPicture *input) | 614 AVPicture *output, const AVPicture *input) |
| 611 { | 615 { |
| 612 int i, shift; | 616 int i, shift; |
| 613 | 617 |
| 614 for(i=0;i<3;i++) { | 618 for(i=0;i<3;i++) { |
| 615 shift = (i == 0) ? 0 : 1; | 619 shift = (i == 0) ? 0 : 1; |
