1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/*
* aligned/packed access motion
*
* Copyright (c) 2001-2003 BERO <bero@geocities.co.jp>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <assert.h>
#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavcodec/h264chroma.h"
#define H264_CHROMA_MC(OPNAME, OP)\
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){\
const int A=(8-x)*(8-y);\
const int B=( x)*(8-y);\
const int C=(8-x)*( y);\
const int D=( x)*( y);\
\
assert(x<8 && y<8 && x>=0 && y>=0);\
\
do {\
int t0,t1,t2,t3; \
uint8_t *s0 = src; \
uint8_t *s1 = src+stride; \
t0 = *s0++; t2 = *s1++; \
t1 = *s0++; t3 = *s1++; \
OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
t0 = *s0++; t2 = *s1++; \
OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
dst+= stride;\
src+= stride;\
}while(--h);\
}\
\
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){\
const int A=(8-x)*(8-y);\
const int B=( x)*(8-y);\
const int C=(8-x)*( y);\
const int D=( x)*( y);\
\
assert(x<8 && y<8 && x>=0 && y>=0);\
\
do {\
int t0,t1,t2,t3; \
uint8_t *s0 = src; \
uint8_t *s1 = src+stride; \
t0 = *s0++; t2 = *s1++; \
t1 = *s0++; t3 = *s1++; \
OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
t0 = *s0++; t2 = *s1++; \
OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
t1 = *s0++; t3 = *s1++; \
OP(dst[2], (A*t0 + B*t1 + C*t2 + D*t3));\
t0 = *s0++; t2 = *s1++; \
OP(dst[3], (A*t1 + B*t0 + C*t3 + D*t2));\
dst+= stride;\
src+= stride;\
}while(--h);\
}\
\
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){\
const int A=(8-x)*(8-y);\
const int B=( x)*(8-y);\
const int C=(8-x)*( y);\
const int D=( x)*( y);\
\
assert(x<8 && y<8 && x>=0 && y>=0);\
\
do {\
int t0,t1,t2,t3; \
uint8_t *s0 = src; \
uint8_t *s1 = src+stride; \
t0 = *s0++; t2 = *s1++; \
t1 = *s0++; t3 = *s1++; \
OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
t0 = *s0++; t2 = *s1++; \
OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
t1 = *s0++; t3 = *s1++; \
OP(dst[2], (A*t0 + B*t1 + C*t2 + D*t3));\
t0 = *s0++; t2 = *s1++; \
OP(dst[3], (A*t1 + B*t0 + C*t3 + D*t2));\
t1 = *s0++; t3 = *s1++; \
OP(dst[4], (A*t0 + B*t1 + C*t2 + D*t3));\
t0 = *s0++; t2 = *s1++; \
OP(dst[5], (A*t1 + B*t0 + C*t3 + D*t2));\
t1 = *s0++; t3 = *s1++; \
OP(dst[6], (A*t0 + B*t1 + C*t2 + D*t3));\
t0 = *s0++; t2 = *s1++; \
OP(dst[7], (A*t1 + B*t0 + C*t3 + D*t2));\
dst+= stride;\
src+= stride;\
}while(--h);\
}
#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
#define op_put(a, b) a = (((b) + 32)>>6)
H264_CHROMA_MC(put_ , op_put)
H264_CHROMA_MC(avg_ , op_avg)
#undef op_avg
#undef op_put
av_cold void ff_h264chroma_init_sh4(H264ChromaContext *c, int bit_depth)
{
const int high_bit_depth = bit_depth > 8;
if (!high_bit_depth) {
c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_sh4;
c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_sh4;
c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_sh4;
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_sh4;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_sh4;
c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_sh4;
}
}
|