• 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     int      i;
00059 
00060     rv34_row_transform(temp, block);
00061     memset(block, 0, 16*sizeof(DCTELEM));
00062 
00063     for(i = 0; i < 4; i++){
00064         const int z0 = 13*(temp[4*0+i] +    temp[4*2+i]) + 0x200;
00065         const int z1 = 13*(temp[4*0+i] -    temp[4*2+i]) + 0x200;
00066         const int z2 =  7* temp[4*1+i] - 17*temp[4*3+i];
00067         const int z3 = 17* temp[4*1+i] +  7*temp[4*3+i];
00068 
00069         dst[0] = av_clip_uint8( dst[0] + ( (z0 + z3) >> 10 ) );
00070         dst[1] = av_clip_uint8( dst[1] + ( (z1 + z2) >> 10 ) );
00071         dst[2] = av_clip_uint8( dst[2] + ( (z1 - z2) >> 10 ) );
00072         dst[3] = av_clip_uint8( dst[3] + ( (z0 - z3) >> 10 ) );
00073 
00074         dst  += stride;
00075     }
00076 }
00077 
00084 static void rv34_inv_transform_noround_c(DCTELEM *block){
00085     int temp[16];
00086     int i;
00087 
00088     rv34_row_transform(temp, block);
00089 
00090     for(i = 0; i < 4; i++){
00091         const int z0 = 13*(temp[4*0+i] +    temp[4*2+i]);
00092         const int z1 = 13*(temp[4*0+i] -    temp[4*2+i]);
00093         const int z2 =  7* temp[4*1+i] - 17*temp[4*3+i];
00094         const int z3 = 17* temp[4*1+i] +  7*temp[4*3+i];
00095 
00096         block[i*4+0] = ((z0 + z3) * 3) >> 11;
00097         block[i*4+1] = ((z1 + z2) * 3) >> 11;
00098         block[i*4+2] = ((z1 - z2) * 3) >> 11;
00099         block[i*4+3] = ((z0 - z3) * 3) >> 11;
00100     }
00101 }
00102 
00103 static void rv34_idct_dc_add_c(uint8_t *dst, int stride, int dc)
00104 {
00105     int i, j;
00106 
00107     dc = (13*13*dc + 0x200) >> 10;
00108     for (i = 0; i < 4; i++)
00109     {
00110         for (j = 0; j < 4; j++)
00111             dst[j] = av_clip_uint8( dst[j] + dc );
00112 
00113         dst += stride;
00114     }
00115 }
00116 
00117 static void rv34_inv_transform_dc_noround_c(DCTELEM *block)
00118 {
00119     DCTELEM dc = (13 * 13 * 3 * block[0]) >> 11;
00120     int i, j;
00121 
00122     for (i = 0; i < 4; i++, block += 4)
00123         for (j = 0; j < 4; j++)
00124             block[j] = dc;
00125 }
00126  // transform
00128 
00129 
00130 av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
00131     c->rv34_inv_transform    = rv34_inv_transform_noround_c;
00132     c->rv34_inv_transform_dc = rv34_inv_transform_dc_noround_c;
00133 
00134     c->rv34_idct_add    = rv34_idct_add_c;
00135     c->rv34_idct_dc_add = rv34_idct_dc_add_c;
00136 
00137     if (HAVE_NEON)
00138         ff_rv34dsp_init_neon(c, dsp);
00139     if (HAVE_MMX)
00140         ff_rv34dsp_init_x86(c, dsp);
00141 }
Generated on Thu Jan 24 2013 17:08:53 for Libav by doxygen 1.7.1