simd 双线性插值

本文探讨了如何使用Single Instruction Multiple Data (SIMD)技术来优化双线性插值算法,通过并行处理提升计算效率,详细阐述了SIMD指令在图像处理和数值计算中的关键作用。
摘要由CSDN通过智能技术生成
#include "simd_type.h"

extern uint32 xRatZoom[4096];
extern uint32 yRatZoom[4096];

//  zoom_c
// ================
EXPORT
void CDECL zoom_c (
/* des pointer */ uint32 *d,
/* src pointer */ uint32 *s, 
/* des pitch */ msize_uint dp, 
/* src pitch */ msize_uint sp, 
/* width */ msize_uint w, 
/* height */ msize_uint h, 
/* zoom count */ msize_float c)
{
    msize_uint x;
    msize_uint y;
    msize_uint new_w = (msize_uint)(c * (msize_float)w);
    msize_uint new_h = (msize_uint)(c * (msize_float)h); 
    msize_uint _sp;
    msize_uint _dp;
    msize_uint y_count_cache;
    msize_uint y_cahce;
    msize_float r;
    msize_float y_add_cache;
    msize_float x_count_cache;
    uint32 *dptr_cache;
    uint32 *sptr_cache;
    
    if (!new_w || !new_h)
        return;

    r = 1.0/c;
    
    _sp = sp >> 2;
    _dp = dp >> 2;

    y_count_cache = 0;
    y_add_cache = 0.0;
    // please OPEN sse2 optimization in Release Mode 
    for (y = 0; y != new_h; y ++) {
        x_count_cache = 0.0;
        dptr_cache = &d[y_count_cache];
        sptr_cache = &s[_sp * (msize_uint)(y_add_cache)];   
        
        for (x = 0; x != new_w; x ++) {
            dptr_cache[x] = sptr_cache[(msize_uint)x_count_cache];
            x_count_cache += r;
        }
        y_add_cache += r;
        y_count_cache += _dp;
    }
}
// =============================================================
//  zoom_sc [bilinear interpolation]
// =============================================================
// note, not range check, use inline texture type [realloc]...
// =============================================================
#ifdef _M_IX86
NAKED
#endif
EXPORT
void CDECL zoom_sc (
/* des pointer */ uint32 *d,
/* src pointer */ uint32 *s, 
/* des pitch */ msize_uint dp, 
/* src pitch */ msize_uint sp, 
/* width */ msize_uint w, 
/* height */ msize_uint h, 
/* zoom count */ msize_float c)
{
#ifndef _M_IX86

#define GET_B(x)((msize_float)(((x) & 0x000000FF) >> 0))
#define GET_G(x)((msize_float)(((x) & 0x0000FF00) >> 8))
#define GET_R(x)((msize_float)(((x) & 0x00FF0000) >> 16))

    msize_uint X;
    msize_uint Y;
    msize_uint NewWidth  = (msize_uint)(c * (msize_float)w);
    msize_uint NewHeight = (msize_uint)(c * (msize_float)h);
    msize_uint DesPitch;
    msize_uint SrcPitch;
    msize_uint BPosTX;
    msize_uint BPosTY;
    uint32 TLeft;
    uint32 TRight;
    uint32 BLeft;
    uint32 BRight;
    uint32 R;
    uint32 G;
    uint32 B;
    msize_float RevseRatio;
    msize_fl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值