Libav
|
00001 /* 00002 * sh4 dsputil 00003 * 00004 * Copyright (c) 2003 BERO <bero@geocities.co.jp> 00005 * 00006 * This file is part of FFmpeg. 00007 * 00008 * FFmpeg 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 * FFmpeg 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 FFmpeg; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #include "libavcodec/avcodec.h" 00024 #include "libavcodec/dsputil.h" 00025 #include "dsputil_sh4.h" 00026 #include "sh4.h" 00027 00028 static void memzero_align8(void *dst,size_t size) 00029 { 00030 int fpscr; 00031 fp_single_enter(fpscr); 00032 dst = (char *)dst + size; 00033 size /= 32; 00034 __asm__ volatile ( 00035 " fldi0 fr0\n" 00036 " fldi0 fr1\n" 00037 " fschg\n" // double 00038 "1: \n" \ 00039 " dt %1\n" 00040 " fmov dr0,@-%0\n" 00041 " fmov dr0,@-%0\n" 00042 " fmov dr0,@-%0\n" 00043 " bf.s 1b\n" 00044 " fmov dr0,@-%0\n" 00045 " fschg" //back to single 00046 : "+r"(dst),"+r"(size) :: "memory" ); 00047 fp_single_leave(fpscr); 00048 } 00049 00050 static void clear_blocks_sh4(DCTELEM *blocks) 00051 { 00052 memzero_align8(blocks,sizeof(DCTELEM)*6*64); 00053 } 00054 00055 static void idct_put(uint8_t *dest, int line_size, DCTELEM *block) 00056 { 00057 int i; 00058 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; 00059 idct_sh4(block); 00060 for(i=0;i<8;i++) { 00061 dest[0] = cm[block[0]]; 00062 dest[1] = cm[block[1]]; 00063 dest[2] = cm[block[2]]; 00064 dest[3] = cm[block[3]]; 00065 dest[4] = cm[block[4]]; 00066 dest[5] = cm[block[5]]; 00067 dest[6] = cm[block[6]]; 00068 dest[7] = cm[block[7]]; 00069 dest+=line_size; 00070 block+=8; 00071 } 00072 } 00073 static void idct_add(uint8_t *dest, int line_size, DCTELEM *block) 00074 { 00075 int i; 00076 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; 00077 idct_sh4(block); 00078 for(i=0;i<8;i++) { 00079 dest[0] = cm[dest[0]+block[0]]; 00080 dest[1] = cm[dest[1]+block[1]]; 00081 dest[2] = cm[dest[2]+block[2]]; 00082 dest[3] = cm[dest[3]+block[3]]; 00083 dest[4] = cm[dest[4]+block[4]]; 00084 dest[5] = cm[dest[5]+block[5]]; 00085 dest[6] = cm[dest[6]+block[6]]; 00086 dest[7] = cm[dest[7]+block[7]]; 00087 dest+=line_size; 00088 block+=8; 00089 } 00090 } 00091 00092 void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx) 00093 { 00094 const int idct_algo= avctx->idct_algo; 00095 dsputil_init_align(c,avctx); 00096 00097 c->clear_blocks = clear_blocks_sh4; 00098 if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){ 00099 c->idct_put = idct_put; 00100 c->idct_add = idct_add; 00101 c->idct = idct_sh4; 00102 c->idct_permutation_type= FF_NO_IDCT_PERM; 00103 } 00104 }