4 * Copyright (c) 2003 BERO <bero@geocities.co.jp>
6 * This file is part of Libav.
8 * Libav is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * Libav is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "libavcodec/avcodec.h"
24 #include "libavcodec/dsputil.h"
25 #include "dsputil_sh4.h"
28 static void memzero_align8(void *dst,size_t size)
31 fp_single_enter(fpscr);
32 dst = (char *)dst + size;
45 " fschg" //back to single
46 : "+r"(dst),"+r"(size) :: "memory" );
47 fp_single_leave(fpscr);
50 static void clear_blocks_sh4(DCTELEM *blocks)
52 memzero_align8(blocks,sizeof(DCTELEM)*6*64);
55 static void idct_put(uint8_t *dest, int line_size, DCTELEM *block)
58 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
61 dest[0] = cm[block[0]];
62 dest[1] = cm[block[1]];
63 dest[2] = cm[block[2]];
64 dest[3] = cm[block[3]];
65 dest[4] = cm[block[4]];
66 dest[5] = cm[block[5]];
67 dest[6] = cm[block[6]];
68 dest[7] = cm[block[7]];
73 static void idct_add(uint8_t *dest, int line_size, DCTELEM *block)
76 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
79 dest[0] = cm[dest[0]+block[0]];
80 dest[1] = cm[dest[1]+block[1]];
81 dest[2] = cm[dest[2]+block[2]];
82 dest[3] = cm[dest[3]+block[3]];
83 dest[4] = cm[dest[4]+block[4]];
84 dest[5] = cm[dest[5]+block[5]];
85 dest[6] = cm[dest[6]+block[6]];
86 dest[7] = cm[dest[7]+block[7]];
92 void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
94 const int idct_algo= avctx->idct_algo;
95 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
96 dsputil_init_align(c,avctx);
99 c->clear_blocks = clear_blocks_sh4;
100 if (avctx->bits_per_raw_sample <= 8 &&
101 (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4)) {
102 c->idct_put = idct_put;
103 c->idct_add = idct_add;
105 c->idct_permutation_type= FF_NO_IDCT_PERM;