diff options
Diffstat (limited to 'libavcodec/h264chroma_template.c')
-rw-r--r-- | libavcodec/h264chroma_template.c | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/libavcodec/h264chroma_template.c b/libavcodec/h264chroma_template.c index 351d9d2f2e..b64172aadf 100644 --- a/libavcodec/h264chroma_template.c +++ b/libavcodec/h264chroma_template.c @@ -2,28 +2,56 @@ * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * 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 "libavutil/avassert.h" #include "bit_depth_template.c" #define H264_CHROMA_MC(OPNAME, OP)\ +static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\ + pixel *dst = (pixel*)_dst;\ + pixel *src = (pixel*)_src;\ + const int A=(8-x)*(8-y);\ + const int B=( x)*(8-y);\ + const int C=(8-x)*( y);\ + const int D=( x)*( y);\ + int i;\ + stride >>= sizeof(pixel)-1;\ + \ + av_assert2(x<8 && y<8 && x>=0 && y>=0);\ +\ + if(D){\ + for(i=0; i<h; i++){\ + OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\ + dst+= stride;\ + src+= stride;\ + }\ + }else{\ + const int E= B+C;\ + const int step= C ? stride : 1;\ + for(i=0; i<h; i++){\ + OP(dst[0], (A*src[0] + E*src[step+0]));\ + dst+= stride;\ + src+= stride;\ + }\ + }\ +}\ static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\ pixel *dst = (pixel*)_dst;\ pixel *src = (pixel*)_src;\ @@ -32,9 +60,9 @@ static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t * const int C=(8-x)*( y);\ const int D=( x)*( y);\ int i;\ - stride /= sizeof(pixel);\ + stride >>= sizeof(pixel)-1;\ \ - assert(x<8 && y<8 && x>=0 && y>=0);\ + av_assert2(x<8 && y<8 && x>=0 && y>=0);\ \ if(D){\ for(i=0; i<h; i++){\ @@ -63,9 +91,9 @@ static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t * const int C=(8-x)*( y);\ const int D=( x)*( y);\ int i;\ - stride /= sizeof(pixel);\ + stride >>= sizeof(pixel)-1;\ \ - assert(x<8 && y<8 && x>=0 && y>=0);\ + av_assert2(x<8 && y<8 && x>=0 && y>=0);\ \ if(D){\ for(i=0; i<h; i++){\ @@ -98,9 +126,9 @@ static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst/*align 8*/, uint8_t * const int C=(8-x)*( y);\ const int D=( x)*( y);\ int i;\ - stride /= sizeof(pixel);\ + stride >>= sizeof(pixel)-1;\ \ - assert(x<8 && y<8 && x>=0 && y>=0);\ + av_assert2(x<8 && y<8 && x>=0 && y>=0);\ \ if(D){\ for(i=0; i<h; i++){\ |