sh4/h264chroma_init.c
Go to the documentation of this file.
1 /*
2  * aligned/packed access motion
3  *
4  * Copyright (c) 2001-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 <assert.h>
24 #include <stdint.h>
25 
26 #include "libavutil/attributes.h"
27 #include "libavcodec/h264chroma.h"
28 
29 #define H264_CHROMA_MC(OPNAME, OP)\
30 static void OPNAME ## h264_chroma_mc2_sh4(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
31  const int A=(8-x)*(8-y);\
32  const int B=( x)*(8-y);\
33  const int C=(8-x)*( y);\
34  const int D=( x)*( y);\
35  \
36  assert(x<8 && y<8 && x>=0 && y>=0);\
37 \
38  do {\
39  int t0,t1,t2,t3; \
40  uint8_t *s0 = src; \
41  uint8_t *s1 = src+stride; \
42  t0 = *s0++; t2 = *s1++; \
43  t1 = *s0++; t3 = *s1++; \
44  OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
45  t0 = *s0++; t2 = *s1++; \
46  OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
47  dst+= stride;\
48  src+= stride;\
49  }while(--h);\
50 }\
51 \
52 static void OPNAME ## h264_chroma_mc4_sh4(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
53  const int A=(8-x)*(8-y);\
54  const int B=( x)*(8-y);\
55  const int C=(8-x)*( y);\
56  const int D=( x)*( y);\
57  \
58  assert(x<8 && y<8 && x>=0 && y>=0);\
59 \
60  do {\
61  int t0,t1,t2,t3; \
62  uint8_t *s0 = src; \
63  uint8_t *s1 = src+stride; \
64  t0 = *s0++; t2 = *s1++; \
65  t1 = *s0++; t3 = *s1++; \
66  OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
67  t0 = *s0++; t2 = *s1++; \
68  OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
69  t1 = *s0++; t3 = *s1++; \
70  OP(dst[2], (A*t0 + B*t1 + C*t2 + D*t3));\
71  t0 = *s0++; t2 = *s1++; \
72  OP(dst[3], (A*t1 + B*t0 + C*t3 + D*t2));\
73  dst+= stride;\
74  src+= stride;\
75  }while(--h);\
76 }\
77 \
78 static void OPNAME ## h264_chroma_mc8_sh4(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
79  const int A=(8-x)*(8-y);\
80  const int B=( x)*(8-y);\
81  const int C=(8-x)*( y);\
82  const int D=( x)*( y);\
83  \
84  assert(x<8 && y<8 && x>=0 && y>=0);\
85 \
86  do {\
87  int t0,t1,t2,t3; \
88  uint8_t *s0 = src; \
89  uint8_t *s1 = src+stride; \
90  t0 = *s0++; t2 = *s1++; \
91  t1 = *s0++; t3 = *s1++; \
92  OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
93  t0 = *s0++; t2 = *s1++; \
94  OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
95  t1 = *s0++; t3 = *s1++; \
96  OP(dst[2], (A*t0 + B*t1 + C*t2 + D*t3));\
97  t0 = *s0++; t2 = *s1++; \
98  OP(dst[3], (A*t1 + B*t0 + C*t3 + D*t2));\
99  t1 = *s0++; t3 = *s1++; \
100  OP(dst[4], (A*t0 + B*t1 + C*t2 + D*t3));\
101  t0 = *s0++; t2 = *s1++; \
102  OP(dst[5], (A*t1 + B*t0 + C*t3 + D*t2));\
103  t1 = *s0++; t3 = *s1++; \
104  OP(dst[6], (A*t0 + B*t1 + C*t2 + D*t3));\
105  t0 = *s0++; t2 = *s1++; \
106  OP(dst[7], (A*t1 + B*t0 + C*t3 + D*t2));\
107  dst+= stride;\
108  src+= stride;\
109  }while(--h);\
110 }
111 
112 #define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
113 #define op_put(a, b) a = (((b) + 32)>>6)
114 
115 H264_CHROMA_MC(put_ , op_put)
116 H264_CHROMA_MC(avg_ , op_avg)
117 #undef op_avg
118 #undef op_put
119 
121 {
122  const int high_bit_depth = bit_depth > 8;
123 
124  if (!high_bit_depth) {
125  c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_sh4;
126  c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_sh4;
127  c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_sh4;
128  c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_sh4;
129  c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_sh4;
130  c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_sh4;
131  }
132 }
#define op_put(a, b)
Macro definitions for various function/variable attributes.
#define av_cold
Definition: attributes.h:78
#define op_avg(a, b)
h264_chroma_mc_func avg_h264_chroma_pixels_tab[3]
Definition: h264chroma.h:28
av_cold void ff_h264chroma_init_sh4(H264ChromaContext *c, int bit_depth)
static double c[64]
#define H264_CHROMA_MC(OPNAME, OP)
h264_chroma_mc_func put_h264_chroma_pixels_tab[3]
Definition: h264chroma.h:27