dsputil_sh4.c
Go to the documentation of this file.
1 /*
2  * sh4 dsputil
3  *
4  * Copyright (c) 2003 BERO <bero@geocities.co.jp>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg 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.
12  *
13  * FFmpeg 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.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "libavutil/attributes.h"
24 #include "libavcodec/avcodec.h"
25 #include "libavcodec/dsputil.h"
26 #include "dsputil_sh4.h"
27 #include "sh4.h"
28 
29 static void memzero_align8(void *dst,size_t size)
30 {
31  int fpscr;
32  fp_single_enter(fpscr);
33  dst = (char *)dst + size;
34  size /= 32;
35  __asm__ volatile (
36  " fldi0 fr0\n"
37  " fldi0 fr1\n"
38  " fschg\n" // double
39  "1: \n" \
40  " dt %1\n"
41  " fmov dr0,@-%0\n"
42  " fmov dr0,@-%0\n"
43  " fmov dr0,@-%0\n"
44  " bf.s 1b\n"
45  " fmov dr0,@-%0\n"
46  " fschg" //back to single
47  : "+r"(dst),"+r"(size) :: "memory" );
48  fp_single_leave(fpscr);
49 }
50 
51 static void clear_blocks_sh4(int16_t *blocks)
52 {
53  memzero_align8(blocks,sizeof(int16_t)*6*64);
54 }
55 
56 static void idct_put(uint8_t *dest, int line_size, int16_t *block)
57 {
58  int i;
59  const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
60  ff_idct_sh4(block);
61  for(i=0;i<8;i++) {
62  dest[0] = cm[block[0]];
63  dest[1] = cm[block[1]];
64  dest[2] = cm[block[2]];
65  dest[3] = cm[block[3]];
66  dest[4] = cm[block[4]];
67  dest[5] = cm[block[5]];
68  dest[6] = cm[block[6]];
69  dest[7] = cm[block[7]];
70  dest+=line_size;
71  block+=8;
72  }
73 }
74 static void idct_add(uint8_t *dest, int line_size, int16_t *block)
75 {
76  int i;
77  const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
78  ff_idct_sh4(block);
79  for(i=0;i<8;i++) {
80  dest[0] = cm[dest[0]+block[0]];
81  dest[1] = cm[dest[1]+block[1]];
82  dest[2] = cm[dest[2]+block[2]];
83  dest[3] = cm[dest[3]+block[3]];
84  dest[4] = cm[dest[4]+block[4]];
85  dest[5] = cm[dest[5]+block[5]];
86  dest[6] = cm[dest[6]+block[6]];
87  dest[7] = cm[dest[7]+block[7]];
88  dest+=line_size;
89  block+=8;
90  }
91 }
92 
94 {
95  const int idct_algo= avctx->idct_algo;
96  const int high_bit_depth = avctx->bits_per_raw_sample > 8;
97  ff_dsputil_init_align(c,avctx);
98 
99  if (!high_bit_depth)
101  if (avctx->bits_per_raw_sample <= 8 &&
102  (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4)) {
103  c->idct_put = idct_put;
104  c->idct_add = idct_add;
105  c->idct = ff_idct_sh4;
107  }
108 }
#define ff_cropTbl
static void idct_put(uint8_t *dest, int line_size, int16_t *block)
Definition: dsputil_sh4.c:56
#define MAX_NEG_CROP
Definition: dsputil.h:47
av_cold void ff_dsputil_init_sh4(DSPContext *c, AVCodecContext *avctx)
Definition: dsputil_sh4.c:93
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static void clear_blocks_sh4(int16_t *blocks)
Definition: dsputil_sh4.c:51
Macro definitions for various function/variable attributes.
#define FF_IDCT_SH4
uint8_t
#define av_cold
Definition: attributes.h:78
#define cm
Definition: dvbsubdec.c:34
void(* clear_blocks)(int16_t *blocks)
Definition: dsputil.h:146
external API header
int size
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
static void memzero_align8(void *dst, size_t size)
Definition: dsputil_sh4.c:29
#define FF_NO_IDCT_PERM
Definition: dsputil.h:251
av_cold void ff_dsputil_init_align(DSPContext *c, AVCodecContext *avctx)
#define FF_IDCT_AUTO
dest
Definition: start.py:60
int idct_permutation_type
Definition: dsputil.h:250
void(* idct_add)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
Definition: dsputil.h:235
main external API structure.
static void idct_add(uint8_t *dest, int line_size, int16_t *block)
Definition: dsputil_sh4.c:74
synthesis window for stochastic i
void(* idct)(int16_t *block)
Definition: dsputil.h:222
#define fp_single_leave(fpscr)
Definition: sh4.h:41
static double c[64]
void ff_idct_sh4(int16_t *block)
Definition: idct_sh4.c:91
DSP utils.
void(* idct_put)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
Definition: dsputil.h:229
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
#define fp_single_enter(fpscr)
Definition: sh4.h:40
DSPContext.
Definition: dsputil.h:127