X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fcavsdsp.c;h=04e521be75c0914e379e0343123488c543b7bf2a;hb=3fd3632ffeb18aeca6c0ab3fbe1034c3da75d983;hp=6a1a4b4a46c99a69492a57b37e7ea61b16dd0f40;hpb=b482e2d12fdc380b48a3aa55334c698b9a36b82d;p=ffmpeg diff --git a/libavcodec/cavsdsp.c b/libavcodec/cavsdsp.c index 6a1a4b4a46c..04e521be75c 100644 --- a/libavcodec/cavsdsp.c +++ b/libavcodec/cavsdsp.c @@ -5,23 +5,26 @@ * * Copyright (c) 2006 Stefan Gehrer * - * This library is free software; you can redistribute it and/or + * This file is part of Libav. + * + * Libav 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 of the License, or (at your option) any later version. + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, + * Libav 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include "dsputil.h" +#include "cavsdsp.h" /***************************************************************************** * @@ -61,16 +64,16 @@ static inline void loop_filter_l1(uint8_t *p0_p, int stride, int alpha, int beta int q0 = Q0; if(abs(p0-q0)>3,-tc, tc); - P0 = clip_uint8(p0+delta); - Q0 = clip_uint8(q0-delta); + int delta = av_clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc); + P0 = av_clip_uint8(p0+delta); + Q0 = av_clip_uint8(q0-delta); if(abs(P2-p0)>3, -tc, tc); - P1 = clip_uint8(P1+delta); + delta = av_clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc); + P1 = av_clip_uint8(P1+delta); } if(abs(Q2-q0)>3, -tc, tc); - Q1 = clip_uint8(Q1-delta); + delta = av_clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc); + Q1 = av_clip_uint8(Q1-delta); } } } @@ -96,9 +99,9 @@ static inline void loop_filter_c2(uint8_t *p0_p,int stride,int alpha, int beta) static inline void loop_filter_c1(uint8_t *p0_p,int stride,int alpha, int beta, int tc) { if(abs(P0-Q0)>3, -tc, tc); - P0 = clip_uint8(P0+delta); - Q0 = clip_uint8(Q0-delta); + int delta = av_clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc); + P0 = av_clip_uint8(P0+delta); + Q0 = av_clip_uint8(Q0-delta); } } @@ -182,7 +185,9 @@ static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) { int i; DCTELEM (*src)[8] = (DCTELEM(*)[8])block; - uint8_t *cm = cropTbl + MAX_NEG_CROP; + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + + src[0][0] += 8; for( i = 0; i < 8; i++ ) { const int a0 = 3*src[i][1] - (src[i][7]<<1); @@ -197,22 +202,22 @@ static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) { const int a7 = (src[i][2]<<2) - 10*src[i][6]; const int a6 = (src[i][6]<<2) + 10*src[i][2]; - const int a5 = (src[i][0] - src[i][4]) << 3; - const int a4 = (src[i][0] + src[i][4]) << 3; + const int a5 = ((src[i][0] - src[i][4]) << 3) + 4; + const int a4 = ((src[i][0] + src[i][4]) << 3) + 4; const int b0 = a4 + a6; const int b1 = a5 + a7; const int b2 = a5 - a7; const int b3 = a4 - a6; - src[i][0] = (b0 + b4 + 4) >> 3; - src[i][1] = (b1 + b5 + 4) >> 3; - src[i][2] = (b2 + b6 + 4) >> 3; - src[i][3] = (b3 + b7 + 4) >> 3; - src[i][4] = (b3 - b7 + 4) >> 3; - src[i][5] = (b2 - b6 + 4) >> 3; - src[i][6] = (b1 - b5 + 4) >> 3; - src[i][7] = (b0 - b4 + 4) >> 3; + src[i][0] = (b0 + b4) >> 3; + src[i][1] = (b1 + b5) >> 3; + src[i][2] = (b2 + b6) >> 3; + src[i][3] = (b3 + b7) >> 3; + src[i][4] = (b3 - b7) >> 3; + src[i][5] = (b2 - b6) >> 3; + src[i][6] = (b1 - b5) >> 3; + src[i][7] = (b0 - b4) >> 3; } for( i = 0; i < 8; i++ ) { const int a0 = 3*src[1][i] - (src[7][i]<<1); @@ -235,14 +240,14 @@ static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) { const int b2 = a5 - a7; const int b3 = a4 - a6; - dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4 + 64) >> 7)]; - dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5 + 64) >> 7)]; - dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6 + 64) >> 7)]; - dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7 + 64) >> 7)]; - dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7 + 64) >> 7)]; - dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6 + 64) >> 7)]; - dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5 + 64) >> 7)]; - dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4 + 64) >> 7)]; + dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4) >> 7)]; + dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5) >> 7)]; + dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6) >> 7)]; + dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7) >> 7)]; + dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7) >> 7)]; + dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6) >> 7)]; + dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5) >> 7)]; + dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4) >> 7)]; } } @@ -255,7 +260,7 @@ static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) { #define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \ static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ const int h=8;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ int i;\ for(i=0; iPFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \ c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \ @@ -538,4 +543,6 @@ void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) { c->cavs_filter_cv = cavs_filter_cv_c; c->cavs_filter_ch = cavs_filter_ch_c; c->cavs_idct8_add = cavs_idct8_add_c; + + if (HAVE_MMX) ff_cavsdsp_init_mmx(c, avctx); }