⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snow_altivec.c.svn-base

📁 mediastreamer2是开源的网络传输媒体流的库
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
/* * AltiVec-optimized snow DSP utils * Copyright (c) 2006 Luca Barbato <lu_zero@gentoo.org> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */#include "dsputil.h"#include "gcc_fixes.h"#include "dsputil_altivec.h"#include "snow.h"#undef NDEBUG#include <assert.h>//FIXME remove this replication#define slice_buffer_get_line(slice_buf, line_num) ((slice_buf)->line[line_num] ? (slice_buf)->line[line_num] : slice_buffer_load_line((slice_buf), (line_num)))static DWTELEM * slice_buffer_load_line(slice_buffer * buf, int line){    int offset;    DWTELEM * buffer;//  av_log(NULL, AV_LOG_DEBUG, "Cache hit: %d\n", line);    assert(buf->data_stack_top >= 0);//  assert(!buf->line[line]);    if (buf->line[line])        return buf->line[line];    offset = buf->line_width * line;    buffer = buf->data_stack[buf->data_stack_top];    buf->data_stack_top--;    buf->line[line] = buffer;//  av_log(NULL, AV_LOG_DEBUG, "slice_buffer_load_line: line: %d remaining: %d\n", line, buf->data_stack_top + 1);    return buffer;}//altivec codevoid ff_snow_horizontal_compose97i_altivec(IDWTELEM *b, int width){#if 0    const int w2= (width+1)>>1;    DECLARE_ALIGNED_16(IDWTELEM, temp[(width>>1)]);    const int w_l= (width>>1);    const int w_r= w2 - 1;    int i;    vector signed short t1, t2, x, y, tmp1, tmp2;    vector signed short *vbuf, *vtmp;    vector unsigned char align;    { // Lift 0        IDWTELEM * const ref = b + w2 - 1;        IDWTELEM b_0 = b[0];        vector signed short v7 = vec_splat_s16(7);        vbuf = (vector signed short *)b;        tmp1 = vec_ld (0, ref);        align = vec_lvsl (0, ref);        tmp2 = vec_ld (15, ref);        t1 = vec_perm(tmp1, tmp2, align);        for (i=0; i<w_l-15; i+=16) {#if 0/*        b[i+0] = b[i+0] - ((3 * (ref[i+0] + ref[i+1]) + 4) >> 3);        b[i+1] = b[i+1] - ((3 * (ref[i+1] + ref[i+2]) + 4) >> 3);        b[i+2] = b[i+2] - ((3 * (ref[i+2] + ref[i+3]) + 4) >> 3);        b[i+3] = b[i+3] - ((3 * (ref[i+3] + ref[i+4]) + 4) >> 3);*/        b[i+0] = b[i+0] + ((7 * (ref[i+0] + ref[i+1])-1) >> 8);#else        tmp1 = vec_ld (0, ref+8+i);        tmp2 = vec_ld (15, ref+8+i);        t2 = vec_perm(tmp1, tmp2, align);        y = vec_add(t1, vec_sld(t1,t2,2));//        y = vec_add(vec_add(y,y),y);        tmp1 = vec_ld (0, ref+12+i);        y = vec_add(y, vec_splat_s32(4));        y = vec_sra(y, vec_splat_u32(3));        tmp2 = vec_ld (15, ref+12+i);        *vbuf = vec_sub(*vbuf, y);        t1 = t2;        vbuf++;        t2 = vec_perm(tmp1, tmp2, align);        y = vec_add(t1,vec_sld(t1,t2,4));        y = vec_add(vec_add(y,y),y);        tmp1 = vec_ld (0, ref+12+i);        y = vec_add(y, vec_splat_s32(4));        y = vec_sra(y, vec_splat_u32(3));        tmp2 = vec_ld (15, ref+12+i);        *vbuf = vec_sub(*vbuf, y);        t1=t2;        vbuf++;        t2 = vec_perm(tmp1, tmp2, align);        y = vec_add(t1,vec_sld(t1,t2,4));        y = vec_add(vec_add(y,y),y);        tmp1 = vec_ld (0, ref+16+i);        y = vec_add(y, vec_splat_s32(4));        y = vec_sra(y, vec_splat_u32(3));        tmp2 = vec_ld (15, ref+16+i);        *vbuf = vec_sub(*vbuf, y);        t1=t2;        t2 = vec_perm(tmp1, tmp2, align);        y = vec_add(t1,vec_sld(t1,t2,4));        y = vec_add(vec_add(y,y),y);        vbuf++;        y = vec_add(y, vec_splat_s32(4));        y = vec_sra(y, vec_splat_u32(3));        *vbuf = vec_sub(*vbuf, y);        t1=t2;        vbuf++;#endif        }        snow_horizontal_compose_lift_lead_out(i, b, b, ref, width, w_l, 0, W_DM, W_DO, W_DS);        b[0] = b_0 - ((W_DM * 2 * ref[1]+W_DO)>>W_DS);    }    { // Lift 1        DWTELEM * const dst = b+w2;        i = 0;        for(; (((long)&dst[i]) & 0xF) && i<w_r; i++){            dst[i] = dst[i] - (b[i] + b[i + 1]);        }        align = vec_lvsl(0, b+i);        tmp1 = vec_ld(0, b+i);        vbuf = (vector signed int*) (dst + i);        tmp2 = vec_ld(15, b+i);        t1 = vec_perm(tmp1, tmp2, align);        for (; i<w_r-3; i+=4) {#if 0            dst[i]   = dst[i]   - (b[i]   + b[i + 1]);            dst[i+1] = dst[i+1] - (b[i+1] + b[i + 2]);            dst[i+2] = dst[i+2] - (b[i+2] + b[i + 3]);            dst[i+3] = dst[i+3] - (b[i+3] + b[i + 4]);#else        tmp1 = vec_ld(0, b+4+i);        tmp2 = vec_ld(15, b+4+i);        t2 = vec_perm(tmp1, tmp2, align);        y = vec_add(t1, vec_sld(t1,t2,4));        *vbuf = vec_sub (*vbuf, y);        vbuf++;        t1 = t2;#endif        }        snow_horizontal_compose_lift_lead_out(i, dst, dst, b, width, w_r, 1, W_CM, W_CO, W_CS);    }    { // Lift 2        DWTELEM * const ref = b+w2 - 1;        DWTELEM b_0 = b[0];        vbuf= (vector signed int *) b;        tmp1 = vec_ld (0, ref);        align = vec_lvsl (0, ref);        tmp2 = vec_ld (15, ref);        t1= vec_perm(tmp1, tmp2, align);        i = 0;        for (; i<w_l-15; i+=16) {#if 0            b[i]   = b[i]   - (((8 -(ref[i]   + ref[i+1])) - (b[i]  <<2)) >> 4);            b[i+1] = b[i+1] - (((8 -(ref[i+1] + ref[i+2])) - (b[i+1]<<2)) >> 4);            b[i+2] = b[i+2] - (((8 -(ref[i+2] + ref[i+3])) - (b[i+2]<<2)) >> 4);            b[i+3] = b[i+3] - (((8 -(ref[i+3] + ref[i+4])) - (b[i+3]<<2)) >> 4);#else            tmp1 = vec_ld (0, ref+4+i);            tmp2 = vec_ld (15, ref+4+i);            t2 = vec_perm(tmp1, tmp2, align);            y = vec_add(t1,vec_sld(t1,t2,4));            y = vec_sub(vec_splat_s32(8),y);            tmp1 = vec_ld (0, ref+8+i);            x = vec_sl(*vbuf,vec_splat_u32(2));            y = vec_sra(vec_sub(y,x),vec_splat_u32(4));            tmp2 = vec_ld (15, ref+8+i);            *vbuf = vec_sub( *vbuf, y);            t1 = t2;            vbuf++;            t2 = vec_perm(tmp1, tmp2, align);            y = vec_add(t1,vec_sld(t1,t2,4));            y = vec_sub(vec_splat_s32(8),y);            tmp1 = vec_ld (0, ref+12+i);            x = vec_sl(*vbuf,vec_splat_u32(2));            y = vec_sra(vec_sub(y,x),vec_splat_u32(4));            tmp2 = vec_ld (15, ref+12+i);            *vbuf = vec_sub( *vbuf, y);            t1 = t2;            vbuf++;            t2 = vec_perm(tmp1, tmp2, align);            y = vec_add(t1,vec_sld(t1,t2,4));            y = vec_sub(vec_splat_s32(8),y);            tmp1 = vec_ld (0, ref+16+i);            x = vec_sl(*vbuf,vec_splat_u32(2));            y = vec_sra(vec_sub(y,x),vec_splat_u32(4));            tmp2 = vec_ld (15, ref+16+i);            *vbuf = vec_sub( *vbuf, y);            t1 = t2;            vbuf++;            t2 = vec_perm(tmp1, tmp2, align);            y = vec_add(t1,vec_sld(t1,t2,4));            y = vec_sub(vec_splat_s32(8),y);            t1 = t2;            x = vec_sl(*vbuf,vec_splat_u32(2));            y = vec_sra(vec_sub(y,x),vec_splat_u32(4));            *vbuf = vec_sub( *vbuf, y);            vbuf++;#endif        }        snow_horizontal_compose_liftS_lead_out(i, b, b, ref, width, w_l);        b[0] = b_0 - (((-2 * ref[1] + W_BO) - 4 * b_0) >> W_BS);    }    { // Lift 3        DWTELEM * const src = b+w2;        vbuf = (vector signed int *)b;        vtmp = (vector signed int *)temp;        i = 0;        align = vec_lvsl(0, src);        for (; i<w_r-3; i+=4) {#if 0            temp[i] = src[i] - ((-3*(b[i] + b[i+1]))>>1);            temp[i+1] = src[i+1] - ((-3*(b[i+1] + b[i+2]))>>1);            temp[i+2] = src[i+2] - ((-3*(b[i+2] + b[i+3]))>>1);            temp[i+3] = src[i+3] - ((-3*(b[i+3] + b[i+4]))>>1);#else            tmp1 = vec_ld(0,src+i);            t1 = vec_add(vbuf[0],vec_sld(vbuf[0],vbuf[1],4));            tmp2 = vec_ld(15,src+i);            t1 = vec_sub(vec_splat_s32(0),t1); //bad!            t1 = vec_add(t1,vec_add(t1,t1));            t2 = vec_perm(tmp1 ,tmp2 ,align);            t1 = vec_sra(t1,vec_splat_u32(1));            vbuf++;            *vtmp = vec_sub(t2,t1);            vtmp++;#endif        }        snow_horizontal_compose_lift_lead_out(i, temp, src, b, width, w_r, 1, -3, 0, 1);    }    {    //Interleave        int a;        vector signed int *t = (vector signed int *)temp,                          *v = (vector signed int *)b;        snow_interleave_line_header(&i, width, b, temp);        for (; (i & 0xE) != 0xE; i-=2){            b[i+1] = temp[i>>1];            b[i] = b[i>>1];        }        for (i-=14; i>=0; i-=16){           a=i/4;           v[a+3]=vec_mergel(v[(a>>1)+1],t[(a>>1)+1]);           v[a+2]=vec_mergeh(v[(a>>1)+1],t[(a>>1)+1]);           v[a+1]=vec_mergel(v[a>>1],t[a>>1]);           v[a]=vec_mergeh(v[a>>1],t[a>>1]);        }    }#endif}void ff_snow_vertical_compose97i_altivec(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTELEM *b3, DWTELEM *b4, DWTELEM *b5, int width){    int i, w4 = width/4;    vector signed int *v0, *v1,*v2,*v3,*v4,*v5;    vector signed int t1, t2;    v0=(vector signed int *)b0;    v1=(vector signed int *)b1;    v2=(vector signed int *)b2;    v3=(vector signed int *)b3;    v4=(vector signed int *)b4;    v5=(vector signed int *)b5;    for (i=0; i< w4;i++)    {    #if 0        b4[i] -= (3*(b3[i] + b5[i])+4)>>3;        b3[i] -= ((b2[i] + b4[i]));        b2[i] += ((b1[i] + b3[i])+4*b2[i]+8)>>4;        b1[i] += (3*(b0[i] + b2[i]))>>1;    #else        t1 = vec_add(v3[i], v5[i]);        t2 = vec_add(t1, vec_add(t1,t1));        t1 = vec_add(t2, vec_splat_s32(4));        v4[i] = vec_sub(v4[i], vec_sra(t1,vec_splat_u32(3)));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -