X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fintrax8dsp.c;h=1a62fcde773f34718488cf52ffdded24d12005eb;hb=2467d8d9eaae52eb8e18e276a44a15d1d8fd7f97;hp=05e75e2c2c20c98629c05c5ac9f95eae5b44d97e;hpb=2916025765ee582da6fc7432ef02e1aaf64f4be6;p=ffmpeg diff --git a/libavcodec/intrax8dsp.c b/libavcodec/intrax8dsp.c index 05e75e2c2c2..1a62fcde773 100644 --- a/libavcodec/intrax8dsp.c +++ b/libavcodec/intrax8dsp.c @@ -1,25 +1,24 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * 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.1 of the License, or (at your option) any later version. * - * FFmpeg 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 FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** -* @file intrax8dsp.c - *@brief IntraX8 frame sub-decoder image manipulation routines - * +* @file + *@brief IntraX8 frame subdecoder image manipulation routines */ #include "dsputil.h" @@ -48,21 +47,21 @@ area positions, #3 is 1 pixel only, other are 8 pixels #define area6 (8+8+1+16) /** - Collect statistics and prepare the edge pixels required by the other spacial compensation functions. + Collect statistics and prepare the edge pixels required by the other spatial compensation functions. * @param src pointer to the beginning of the processed block - * @param dst pointer to emu_edge, edge pixels are stored in way other compensation routines use. + * @param dst pointer to emu_edge, edge pixels are stored the way other compensation routines do. * @param linesize byte offset between 2 vertical pixels in the source image - * @param range pointer to the variable where the range of edge pixels is to be stored (max-min values) - * @param psum pointer to the variable where the sum of edge pixels is to be stored - * @param edges informs this routine that the block is on image border, so it have to interpolate the missing edge pixels. - and some of the edge pixels should be interpolated, flag have following meaning: + * @param range pointer to the variable where the edge pixel range is to be stored (max-min values) + * @param psum pointer to the variable where the edge pixel sum is to be stored + * @param edges Informs this routine that the block is on an image border, so it has to interpolate the missing edge pixels. + and some of the edge pixels should be interpolated, the flag has the following meaning: 1 - mb_x==0 - first block in the row, interpolate area #1,#2,#3; 2 - mb_y==0 - first row, interpolate area #3,#4,#5,#6; note: 1|2 - mb_x==mb_y==0 - first block, use 0x80 value for all areas; - 4 - mb_x>= (mb_width-1) last block on the row, interpolate area #5; + 4 - mb_x>= (mb_width-1) last block in the row, interpolate area #5; */ -static void x8_setup_spacial_compensation(uint8_t *src, uint8_t *dst, int linesize, +static void x8_setup_spatial_compensation(uint8_t *src, uint8_t *dst, int linesize, int * range, int * psum, int edges){ uint8_t * ptr; int sum; @@ -116,7 +115,7 @@ static void x8_setup_spacial_compensation(uint8_t *src, uint8_t *dst, int linesi } memcpy(dst+area6, ptr-linesize, 8);//area6 always present in the above block } -//now calc the stuff we need + //now calculate the stuff we need if(edges&3){//mb_x==0 || mb_y==0){ int avg=(sum+4)>>3; if(edges&1){ //(mb_x==0) {//implies mb_y!=0 @@ -126,8 +125,7 @@ static void x8_setup_spacial_compensation(uint8_t *src, uint8_t *dst, int linesi } sum+=avg*9; }else{ - uint8_t c; - c=*(src-1-linesize);//the edge pixel,in the top line and left column + uint8_t c=*(src-1-linesize);//the edge pixel, in the top line and left column dst[area3]=c; sum+=c; //edge pixel is not part of min/max @@ -149,7 +147,7 @@ static const uint16_t zero_prediction_weights[64*2] = { 110, 1172, 144, 1107, 193, 1028, 254, 932, 317, 846, 366, 731, 458, 611, 499, 499 }; -static void spacial_compensation_0(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_0(uint8_t *src , uint8_t *dst, int linesize){ int i,j; int x,y; unsigned int p;//power divided by 2 @@ -204,7 +202,7 @@ static void spacial_compensation_0(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_1(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_1(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -214,7 +212,7 @@ static void spacial_compensation_1(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_2(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_2(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -224,7 +222,7 @@ static void spacial_compensation_2(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_3(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_3(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -234,7 +232,7 @@ static void spacial_compensation_3(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_4(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_4(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -244,7 +242,7 @@ static void spacial_compensation_4(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_5(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_5(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -258,7 +256,7 @@ static void spacial_compensation_5(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_6(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_6(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -268,7 +266,7 @@ static void spacial_compensation_6(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_7(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_7(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -282,7 +280,7 @@ static void spacial_compensation_7(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_8(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_8(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -292,7 +290,7 @@ static void spacial_compensation_8(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_9(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_9(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -302,7 +300,7 @@ static void spacial_compensation_9(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_10(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_10(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -312,7 +310,7 @@ static void spacial_compensation_10(uint8_t *src , uint8_t *dst, int linesize){ dst+=linesize; } } -static void spacial_compensation_11(uint8_t *src , uint8_t *dst, int linesize){ +static void spatial_compensation_11(uint8_t *src , uint8_t *dst, int linesize){ int x,y; for(y=0;y<8;y++){ @@ -345,7 +343,7 @@ static void x8_loop_filter(uint8_t * ptr, const int a_stride, const int b_stride (FFABS(p2-p3) <= ql) + (FFABS(p3-p4) <= ql) + (FFABS(p4-p5) <= ql); - if(t>0){//you need at least 1 to be able to reach total score of 6. + if(t>0){//You need at least 1 to be able to reach a total score of 6. t+= (FFABS(p5-p6) <= ql) + (FFABS(p6-p7) <= ql) + @@ -415,69 +413,20 @@ static void x8_v_loop_filter(uint8_t *src, int stride, int qscale){ x8_loop_filter(src, 1, stride, qscale); } -void ff_intrax8dsp_init(DSPContext* dsp, AVCodecContext *avctx) { +av_cold void ff_intrax8dsp_init(DSPContext* dsp, AVCodecContext *avctx) { dsp->x8_h_loop_filter=x8_h_loop_filter; dsp->x8_v_loop_filter=x8_v_loop_filter; - dsp->x8_setup_spacial_compensation=x8_setup_spacial_compensation; - dsp->x8_spacial_compensation[0]=spacial_compensation_0; - dsp->x8_spacial_compensation[1]=spacial_compensation_1; - dsp->x8_spacial_compensation[2]=spacial_compensation_2; - dsp->x8_spacial_compensation[3]=spacial_compensation_3; - dsp->x8_spacial_compensation[4]=spacial_compensation_4; - dsp->x8_spacial_compensation[5]=spacial_compensation_5; - dsp->x8_spacial_compensation[6]=spacial_compensation_6; - dsp->x8_spacial_compensation[7]=spacial_compensation_7; - dsp->x8_spacial_compensation[8]=spacial_compensation_8; - dsp->x8_spacial_compensation[9]=spacial_compensation_9; - dsp->x8_spacial_compensation[10]=spacial_compensation_10; - dsp->x8_spacial_compensation[11]=spacial_compensation_11; -} - -#if 0 -static void wmv2_loop_filter(uint8_t * ptr, const int a_stride, const int b_stride, int quant){ - int i,t; - int p0,p1,p2,p3,p4,p5,p6,p7,p8,p9; - - for(i=0; i<8; i++,ptr+=b_stride){ - p1=ptr[-4*a_stride]; - p2=ptr[-3*a_stride]; - p3=ptr[-2*a_stride]; - p4=ptr[-1*a_stride]; - p5=ptr[ 0 ]; - p6=ptr[ 1*a_stride]; - p7=ptr[ 2*a_stride]; - p8=ptr[ 3*a_stride]; - - { - int x,x0,x1,x2; - int m; - - x0 = (2*p3 - 5*p4 + 5*p5 - 2*p6 + 4)>>3; - if(abs(x0) < quant){ - x1=(2*p1 - 5*p2 + 5*p3 - 2*p4 + 4)>>3; - x2=(2*p5 - 5*p6 + 5*p7 - 2*p8 + 4)>>3; - - x=abs(x0) - FFMIN( abs(x1), abs(x2) ); - m=p4-p5; - - if( x > 0 && (m^x0) < 0){ - int32_t sign; - - sign=m>>31; - m=(m^sign)-sign;//abs(m) - m>>=1; - - x=(5*x)>>3; - - if(x>m) x=m; - - x=(x^sign)-sign; - - ptr[-1*a_stride] -= x; - ptr[ 0] += x; - } - } - } - } + dsp->x8_setup_spatial_compensation=x8_setup_spatial_compensation; + dsp->x8_spatial_compensation[0]=spatial_compensation_0; + dsp->x8_spatial_compensation[1]=spatial_compensation_1; + dsp->x8_spatial_compensation[2]=spatial_compensation_2; + dsp->x8_spatial_compensation[3]=spatial_compensation_3; + dsp->x8_spatial_compensation[4]=spatial_compensation_4; + dsp->x8_spatial_compensation[5]=spatial_compensation_5; + dsp->x8_spatial_compensation[6]=spatial_compensation_6; + dsp->x8_spatial_compensation[7]=spatial_compensation_7; + dsp->x8_spatial_compensation[8]=spatial_compensation_8; + dsp->x8_spatial_compensation[9]=spatial_compensation_9; + dsp->x8_spatial_compensation[10]=spatial_compensation_10; + dsp->x8_spatial_compensation[11]=spatial_compensation_11; } -#endif