• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavcodec/rv34dsp.c

Go to the documentation of this file.
00001 /*
00002  * RV30/40 decoder common dsp functions
00003  * Copyright (c) 2007 Mike Melanson, Konstantin Shishkov
00004  * Copyright (c) 2011 Janne Grunau
00005  *
00006  * This file is part of Libav.
00007  *
00008  * Libav is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * Libav is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with Libav; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00027 #include "dsputil.h"
00028 #include "rv34dsp.h"
00029 
00035 static av_always_inline void rv34_row_transform(int temp[16], DCTELEM *block)
00036 {
00037     int i;
00038 
00039     for(i = 0; i < 4; i++){
00040         const int z0 = 13*(block[i+4*0] +    block[i+4*2]);
00041         const int z1 = 13*(block[i+4*0] -    block[i+4*2]);
00042         const int z2 =  7* block[i+4*1] - 17*block[i+4*3];
00043         const int z3 = 17* block[i+4*1] +  7*block[i+4*3];
00044 
00045         temp[4*i+0] = z0 + z3;
00046         temp[4*i+1] = z1 + z2;
00047         temp[4*i+2] = z1 - z2;
00048         temp[4*i+3] = z0 - z3;
00049     }
00050 }
00051 
00056 static void rv34_idct_add_c(uint8_t *dst, int stride, DCTELEM *block){
00057     int      temp[16];
00058     uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00059     int      i;
00060 
00061     rv34_row_transform(temp, block);
00062     memset(block, 0, 16*sizeof(DCTELEM));
00063 
00064     for(i = 0; i < 4; i++){
00065         const int z0 = 13*(temp[4*0+i] +    temp[4*2+i]) + 0x200;
00066         const int z1 = 13*(temp[4*0+i] -    temp[4*2+i]) + 0x200;
00067         const int z2 =  7* temp[4*1+i] - 17*temp[4*3+i];
00068         const int z3 = 17* temp[4*1+i] +  7*temp[4*3+i];
00069 
00070         dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];
00071         dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];
00072         dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];
00073         dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];
00074 
00075         dst  += stride;
00076     }
00077 }
00078 
00085 static void rv34_inv_transform_noround_c(DCTELEM *block){
00086     int temp[16];
00087     int i;
00088 
00089     rv34_row_transform(temp, block);
00090 
00091     for(i = 0; i < 4; i++){
00092         const int z0 = 13*(temp[4*0+i] +    temp[4*2+i]);
00093         const int z1 = 13*(temp[4*0+i] -    temp[4*2+i]);
00094         const int z2 =  7* temp[4*1+i] - 17*temp[4*3+i];
00095         const int z3 = 17* temp[4*1+i] +  7*temp[4*3+i];
00096 
00097         block[i*4+0] = ((z0 + z3) * 3) >> 11;
00098         block[i*4+1] = ((z1 + z2) * 3) >> 11;
00099         block[i*4+2] = ((z1 - z2) * 3) >> 11;
00100         block[i*4+3] = ((z0 - z3) * 3) >> 11;
00101     }
00102 }
00103 
00104 static void rv34_idct_dc_add_c(uint8_t *dst, int stride, int dc)
00105 {
00106     const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00107     int i, j;
00108 
00109     cm += (13*13*dc + 0x200) >> 10;
00110 
00111     for (i = 0; i < 4; i++)
00112     {
00113         for (j = 0; j < 4; j++)
00114             dst[j] = cm[ dst[j] ];
00115 
00116         dst += stride;
00117     }
00118 }
00119 
00120 static void rv34_inv_transform_dc_noround_c(DCTELEM *block)
00121 {
00122     DCTELEM dc = (13 * 13 * 3 * block[0]) >> 11;
00123     int i, j;
00124 
00125     for (i = 0; i < 4; i++, block += 4)
00126         for (j = 0; j < 4; j++)
00127             block[j] = dc;
00128 }
00129  // transform
00131 
00132 
00133 av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
00134     c->rv34_inv_transform    = rv34_inv_transform_noround_c;
00135     c->rv34_inv_transform_dc = rv34_inv_transform_dc_noround_c;
00136 
00137     c->rv34_idct_add    = rv34_idct_add_c;
00138     c->rv34_idct_dc_add = rv34_idct_dc_add_c;
00139 
00140     if (HAVE_NEON)
00141         ff_rv34dsp_init_neon(c, dsp);
00142     if (HAVE_MMX)
00143         ff_rv34dsp_init_x86(c, dsp);
00144 }
Generated on Sun Apr 22 2012 21:54:04 for Libav by doxygen 1.7.1