2 * aligned/packed access motion
4 * Copyright (c) 2001-2003 BERO <bero@geocities.co.jp>
6 * This file is part of FFmpeg.
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.
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.
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
26 #include "libavutil/attributes.h"
27 #include "libavcodec/h264chroma.h"
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);\
36 assert(x<8 && y<8 && x>=0 && y>=0);\
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));\
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);\
58 assert(x<8 && y<8 && x>=0 && y>=0);\
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));\
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);\
84 assert(x<8 && y<8 && x>=0 && y>=0);\
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));\
112 #define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
113 #define op_put(a, b) a = (((b) + 32)>>6)
115 H264_CHROMA_MC(put_ , op_put)
116 H264_CHROMA_MC(avg_ , op_avg)
120 av_cold void ff_h264chroma_init_sh4(H264ChromaContext *c, int bit_depth)
122 const int high_bit_depth = bit_depth > 8;
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;