pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: missing math functions on powerpc (macppc)?
Martin Husemann wrote:
> The problem is that the bug is hiding as a pkg one - it would be really
> cool if you could create a small example code that triggers it as well
> and file a toolchain bug with that.
Here it is. A small function without any includes and dependencides. Just
compile the attachment with gcc 4.8.4 nb2 for PowerPC using the options
-maltivec and -O3.
--
Frank Wille
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
void vp9_temporal_filter_apply_c(uint8_t *frame1,
unsigned int stride,
uint8_t *frame2,
unsigned int block_width,
unsigned int block_height,
int strength,
int filter_weight,
unsigned int *accumulator,
uint16_t *count) {
unsigned int i, j, k;
int modifier;
int byte = 0;
const int rounding = strength > 0 ? 1 << (strength - 1) : 0;
for (i = 0, k = 0; i < block_height; i++) {
for (j = 0; j < block_width; j++, k++) {
int src_byte = frame1[byte];
int pixel_value = *frame2++;
modifier = src_byte - pixel_value;
// This is an integer approximation of:
// float coeff = (3.0 * modifer * modifier) / pow(2, strength);
// modifier = (int)roundf(coeff > 16 ? 0 : 16-coeff);
modifier *= modifier;
modifier *= 3;
modifier += rounding;
modifier >>= strength;
if (modifier > 16)
modifier = 16;
modifier = 16 - modifier;
modifier *= filter_weight;
count[k] += modifier;
accumulator[k] += modifier * pixel_value;
byte++;
}
byte += stride - block_width;
}
}
Home |
Main Index |
Thread Index |
Old Index