annotate ffmpeg/libavcodec/sh4/h264chroma_init.c @ 13:844d341cf643 tip

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