X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fcavsdsp.c;h=cc7898968fb846614163471d08ff08f8059c1326;hb=e10b7ef2fe56603fb1baac6b20fd6bd0a3fdd0d0;hp=d2517d9e9ded49616bc031bb9a97b5c80ff3be6f;hpb=595e7bd94029713d87e3e4943b40676df1b2d0a0;p=ffmpeg diff --git a/libavcodec/cavsdsp.c b/libavcodec/cavsdsp.c index d2517d9e9de..cc7898968fb 100644 --- a/libavcodec/cavsdsp.c +++ b/libavcodec/cavsdsp.c @@ -5,23 +5,29 @@ * * 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 "idctdsp.h" +#include "mathops.h" +#include "cavsdsp.h" +#include "libavutil/common.h" /***************************************************************************** * @@ -61,16 +67,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 +102,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); } } @@ -179,10 +185,10 @@ 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) { +static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) { int i; - DCTELEM (*src)[8] = (DCTELEM(*)[8])block; - uint8_t *cm = cropTbl + MAX_NEG_CROP; + int16_t (*src)[8] = (int16_t(*)[8])block; + const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; src[0][0] += 8; @@ -246,7 +252,6 @@ static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) { dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5) >> 7)]; dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4) >> 7)]; } - memset(block,0,64*sizeof(DCTELEM)); } /***************************************************************************** @@ -256,9 +261,9 @@ 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){\ +static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\ const int h=8;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ + const uint8_t *cm = ff_crop_tab + 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; \ - c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_c; \ - c->PFX ## _pixels_tab[IDX][ 3] = ff_ ## PFX ## NUM ## _mc30_c; \ - c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_c; \ - c->PFX ## _pixels_tab[IDX][ 5] = ff_ ## PFX ## NUM ## _mc11_c; \ - c->PFX ## _pixels_tab[IDX][ 6] = ff_ ## PFX ## NUM ## _mc21_c; \ - c->PFX ## _pixels_tab[IDX][ 7] = ff_ ## PFX ## NUM ## _mc31_c; \ - c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_c; \ - c->PFX ## _pixels_tab[IDX][ 9] = ff_ ## PFX ## NUM ## _mc12_c; \ - c->PFX ## _pixels_tab[IDX][10] = ff_ ## PFX ## NUM ## _mc22_c; \ - c->PFX ## _pixels_tab[IDX][11] = ff_ ## PFX ## NUM ## _mc32_c; \ - c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_c; \ - c->PFX ## _pixels_tab[IDX][13] = ff_ ## PFX ## NUM ## _mc13_c; \ - c->PFX ## _pixels_tab[IDX][14] = ff_ ## PFX ## NUM ## _mc23_c; \ - c->PFX ## _pixels_tab[IDX][15] = ff_ ## PFX ## NUM ## _mc33_c + c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \ + c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \ + c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \ + c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \ + c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \ + c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \ + c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \ + c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \ + c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \ + c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \ + c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \ + c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \ + c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \ + c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \ + c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \ + c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c dspfunc(put_cavs_qpel, 0, 16); dspfunc(put_cavs_qpel, 1, 8); dspfunc(avg_cavs_qpel, 0, 16); @@ -541,4 +561,8 @@ 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; + c->idct_perm = FF_IDCT_PERM_NONE; + + if (ARCH_X86) + ff_cavsdsp_init_x86(c, avctx); }