00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #include "libavutil/intreadwrite.h"
00029 #include "internal.h"
00030 #include "dsputil.h"
00031 #include "avcodec.h"
00032 #include "mpegvideo.h"
00033 #include "h264.h"
00034 #include "mathops.h"
00035 #include "rectangle.h"
00036
00037
00038 #include <assert.h>
00039
00040
00041 static const uint8_t alpha_table[52*3] = {
00042 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00043 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00044 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00045 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00046 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00047 0, 0, 0, 0, 0, 0, 4, 4, 5, 6,
00048 7, 8, 9, 10, 12, 13, 15, 17, 20, 22,
00049 25, 28, 32, 36, 40, 45, 50, 56, 63, 71,
00050 80, 90,101,113,127,144,162,182,203,226,
00051 255,255,
00052 255,255,255,255,255,255,255,255,255,255,255,255,255,
00053 255,255,255,255,255,255,255,255,255,255,255,255,255,
00054 255,255,255,255,255,255,255,255,255,255,255,255,255,
00055 255,255,255,255,255,255,255,255,255,255,255,255,255,
00056 };
00057 static const uint8_t beta_table[52*3] = {
00058 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00059 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00060 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00061 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00062 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00063 0, 0, 0, 0, 0, 0, 2, 2, 2, 3,
00064 3, 3, 3, 4, 4, 4, 6, 6, 7, 7,
00065 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
00066 13, 13, 14, 14, 15, 15, 16, 16, 17, 17,
00067 18, 18,
00068 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
00069 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
00070 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
00071 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
00072 };
00073 static const uint8_t tc0_table[52*3][4] = {
00074 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00075 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00076 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00077 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00078 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00079 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00080 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00081 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00082 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00083 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00084 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
00085 {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 1 },
00086 {-1, 0, 0, 1 }, {-1, 0, 0, 1 }, {-1, 0, 0, 1 }, {-1, 0, 1, 1 }, {-1, 0, 1, 1 }, {-1, 1, 1, 1 },
00087 {-1, 1, 1, 1 }, {-1, 1, 1, 1 }, {-1, 1, 1, 1 }, {-1, 1, 1, 2 }, {-1, 1, 1, 2 }, {-1, 1, 1, 2 },
00088 {-1, 1, 1, 2 }, {-1, 1, 2, 3 }, {-1, 1, 2, 3 }, {-1, 2, 2, 3 }, {-1, 2, 2, 4 }, {-1, 2, 3, 4 },
00089 {-1, 2, 3, 4 }, {-1, 3, 3, 5 }, {-1, 3, 4, 6 }, {-1, 3, 4, 6 }, {-1, 4, 5, 7 }, {-1, 4, 5, 8 },
00090 {-1, 4, 6, 9 }, {-1, 5, 7,10 }, {-1, 6, 8,11 }, {-1, 6, 8,13 }, {-1, 7,10,14 }, {-1, 8,11,16 },
00091 {-1, 9,12,18 }, {-1,10,13,20 }, {-1,11,15,23 }, {-1,13,17,25 },
00092 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00093 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00094 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00095 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00096 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00097 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00098 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00099 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00100 {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
00101 };
00102
00103
00104 static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
00105 const unsigned int index_a = qp + a;
00106 const int alpha = alpha_table[index_a];
00107 const int beta = beta_table[qp + b];
00108 if (alpha ==0 || beta == 0) return;
00109
00110 if( bS[0] < 4 || !intra ) {
00111 int8_t tc[4];
00112 tc[0] = tc0_table[index_a][bS[0]];
00113 tc[1] = tc0_table[index_a][bS[1]];
00114 tc[2] = tc0_table[index_a][bS[2]];
00115 tc[3] = tc0_table[index_a][bS[3]];
00116 h->h264dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc);
00117 } else {
00118 h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta);
00119 }
00120 }
00121 static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
00122 const unsigned int index_a = qp + a;
00123 const int alpha = alpha_table[index_a];
00124 const int beta = beta_table[qp + b];
00125 if (alpha ==0 || beta == 0) return;
00126
00127 if( bS[0] < 4 || !intra ) {
00128 int8_t tc[4];
00129 tc[0] = tc0_table[index_a][bS[0]]+1;
00130 tc[1] = tc0_table[index_a][bS[1]]+1;
00131 tc[2] = tc0_table[index_a][bS[2]]+1;
00132 tc[3] = tc0_table[index_a][bS[3]]+1;
00133 h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
00134 } else {
00135 h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
00136 }
00137 }
00138
00139 static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int a, int b, int intra ) {
00140 const unsigned int index_a = qp + a;
00141 const int alpha = alpha_table[index_a];
00142 const int beta = beta_table[qp + b];
00143 if (alpha ==0 || beta == 0) return;
00144
00145 if( bS[0] < 4 || !intra ) {
00146 int8_t tc[4];
00147 tc[0] = tc0_table[index_a][bS[0*bsi]];
00148 tc[1] = tc0_table[index_a][bS[1*bsi]];
00149 tc[2] = tc0_table[index_a][bS[2*bsi]];
00150 tc[3] = tc0_table[index_a][bS[3*bsi]];
00151 h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);
00152 } else {
00153 h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
00154 }
00155 }
00156 static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int a, int b, int intra ) {
00157 const unsigned int index_a = qp + a;
00158 const int alpha = alpha_table[index_a];
00159 const int beta = beta_table[qp + b];
00160 if (alpha ==0 || beta == 0) return;
00161
00162 if( bS[0] < 4 || !intra ) {
00163 int8_t tc[4];
00164 tc[0] = tc0_table[index_a][bS[0*bsi]] + 1;
00165 tc[1] = tc0_table[index_a][bS[1*bsi]] + 1;
00166 tc[2] = tc0_table[index_a][bS[2*bsi]] + 1;
00167 tc[3] = tc0_table[index_a][bS[3*bsi]] + 1;
00168 h->h264dsp.h264_h_loop_filter_chroma_mbaff(pix, stride, alpha, beta, tc);
00169 } else {
00170 h->h264dsp.h264_h_loop_filter_chroma_mbaff_intra(pix, stride, alpha, beta);
00171 }
00172 }
00173
00174 static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
00175 const unsigned int index_a = qp + a;
00176 const int alpha = alpha_table[index_a];
00177 const int beta = beta_table[qp + b];
00178 if (alpha ==0 || beta == 0) return;
00179
00180 if( bS[0] < 4 || !intra ) {
00181 int8_t tc[4];
00182 tc[0] = tc0_table[index_a][bS[0]];
00183 tc[1] = tc0_table[index_a][bS[1]];
00184 tc[2] = tc0_table[index_a][bS[2]];
00185 tc[3] = tc0_table[index_a][bS[3]];
00186 h->h264dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
00187 } else {
00188 h->h264dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);
00189 }
00190 }
00191
00192 static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) {
00193 const unsigned int index_a = qp + a;
00194 const int alpha = alpha_table[index_a];
00195 const int beta = beta_table[qp + b];
00196 if (alpha ==0 || beta == 0) return;
00197
00198 if( bS[0] < 4 || !intra ) {
00199 int8_t tc[4];
00200 tc[0] = tc0_table[index_a][bS[0]]+1;
00201 tc[1] = tc0_table[index_a][bS[1]]+1;
00202 tc[2] = tc0_table[index_a][bS[2]]+1;
00203 tc[3] = tc0_table[index_a][bS[3]]+1;
00204 h->h264dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
00205 } else {
00206 h->h264dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);
00207 }
00208 }
00209
00210 static void av_always_inline h264_filter_mb_fast_internal( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
00211 unsigned int linesize, unsigned int uvlinesize, int pixel_shift) {
00212 MpegEncContext * const s = &h->s;
00213 int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
00214 int chroma444 = CHROMA444;
00215 int chroma422 = CHROMA422;
00216
00217 int mb_xy = h->mb_xy;
00218 int left_type= h->left_type[LTOP];
00219 int top_type= h->top_type;
00220
00221 int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
00222 int a = h->slice_alpha_c0_offset - qp_bd_offset;
00223 int b = h->slice_beta_offset - qp_bd_offset;
00224
00225 int mb_type = s->current_picture.f.mb_type[mb_xy];
00226 int qp = s->current_picture.f.qscale_table[mb_xy];
00227 int qp0 = s->current_picture.f.qscale_table[mb_xy - 1];
00228 int qp1 = s->current_picture.f.qscale_table[h->top_mb_xy];
00229 int qpc = get_chroma_qp( h, 0, qp );
00230 int qpc0 = get_chroma_qp( h, 0, qp0 );
00231 int qpc1 = get_chroma_qp( h, 0, qp1 );
00232 qp0 = (qp + qp0 + 1) >> 1;
00233 qp1 = (qp + qp1 + 1) >> 1;
00234 qpc0 = (qpc + qpc0 + 1) >> 1;
00235 qpc1 = (qpc + qpc1 + 1) >> 1;
00236
00237 if( IS_INTRA(mb_type) ) {
00238 static const int16_t bS4[4] = {4,4,4,4};
00239 static const int16_t bS3[4] = {3,3,3,3};
00240 const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4;
00241 if(left_type)
00242 filter_mb_edgev( &img_y[4*0<<pixel_shift], linesize, bS4, qp0, a, b, h, 1);
00243 if( IS_8x8DCT(mb_type) ) {
00244 filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
00245 if(top_type){
00246 filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1);
00247 }
00248 filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0);
00249 } else {
00250 filter_mb_edgev( &img_y[4*1<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
00251 filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
00252 filter_mb_edgev( &img_y[4*3<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
00253 if(top_type){
00254 filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1);
00255 }
00256 filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, a, b, h, 0);
00257 filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0);
00258 filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, a, b, h, 0);
00259 }
00260 if(chroma){
00261 if(chroma444){
00262 if(left_type){
00263 filter_mb_edgev( &img_cb[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1);
00264 filter_mb_edgev( &img_cr[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1);
00265 }
00266 if( IS_8x8DCT(mb_type) ) {
00267 filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
00268 filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
00269 if(top_type){
00270 filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 );
00271 filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 );
00272 }
00273 filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
00274 filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
00275 } else {
00276 filter_mb_edgev( &img_cb[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
00277 filter_mb_edgev( &img_cr[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
00278 filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
00279 filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
00280 filter_mb_edgev( &img_cb[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
00281 filter_mb_edgev( &img_cr[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
00282 if(top_type){
00283 filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1);
00284 filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1);
00285 }
00286 filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, a, b, h, 0);
00287 filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, a, b, h, 0);
00288 filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
00289 filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
00290 filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
00291 filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
00292 }
00293 }else if(chroma422){
00294 if(left_type){
00295 filter_mb_edgecv(&img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
00296 filter_mb_edgecv(&img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
00297 }
00298 filter_mb_edgecv(&img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
00299 filter_mb_edgecv(&img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
00300 if(top_type){
00301 filter_mb_edgech(&img_cb[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
00302 filter_mb_edgech(&img_cr[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
00303 }
00304 filter_mb_edgech(&img_cb[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
00305 filter_mb_edgech(&img_cr[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
00306 filter_mb_edgech(&img_cb[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
00307 filter_mb_edgech(&img_cr[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
00308 filter_mb_edgech(&img_cb[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
00309 filter_mb_edgech(&img_cr[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
00310 }else{
00311 if(left_type){
00312 filter_mb_edgecv( &img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
00313 filter_mb_edgecv( &img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
00314 }
00315 filter_mb_edgecv( &img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
00316 filter_mb_edgecv( &img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
00317 if(top_type){
00318 filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
00319 filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
00320 }
00321 filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
00322 filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
00323 }
00324 }
00325 return;
00326 } else {
00327 LOCAL_ALIGNED_8(int16_t, bS, [2], [4][4]);
00328 int edges;
00329 if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 && !chroma444 ) {
00330 edges = 4;
00331 AV_WN64A(bS[0][0], 0x0002000200020002ULL);
00332 AV_WN64A(bS[0][2], 0x0002000200020002ULL);
00333 AV_WN64A(bS[1][0], 0x0002000200020002ULL);
00334 AV_WN64A(bS[1][2], 0x0002000200020002ULL);
00335 } else {
00336 int mask_edge1 = (3*(((5*mb_type)>>5)&1)) | (mb_type>>4);
00337 int mask_edge0 = 3*((mask_edge1>>1) & ((5*left_type)>>5)&1);
00338 int step = 1+(mb_type>>24);
00339 edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15));
00340 h->h264dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache,
00341 h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE);
00342 }
00343 if( IS_INTRA(left_type) )
00344 AV_WN64A(bS[0][0], 0x0004000400040004ULL);
00345 if( IS_INTRA(top_type) )
00346 AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL);
00347
00348 #define FILTER(hv,dir,edge,intra)\
00349 if(AV_RN64A(bS[dir][edge])) { \
00350 filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qp : qp##dir, a, b, h, intra );\
00351 if(chroma){\
00352 if(chroma444){\
00353 filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
00354 filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
00355 } else if(!(edge&1)) {\
00356 filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
00357 filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
00358 }\
00359 }\
00360 }
00361 if(left_type)
00362 FILTER(v,0,0,1);
00363 if( edges == 1 ) {
00364 if(top_type)
00365 FILTER(h,1,0,1);
00366 } else if( IS_8x8DCT(mb_type) ) {
00367 FILTER(v,0,2,0);
00368 if(top_type)
00369 FILTER(h,1,0,1);
00370 FILTER(h,1,2,0);
00371 } else {
00372 FILTER(v,0,1,0);
00373 FILTER(v,0,2,0);
00374 FILTER(v,0,3,0);
00375 if(top_type)
00376 FILTER(h,1,0,1);
00377 FILTER(h,1,1,0);
00378 FILTER(h,1,2,0);
00379 FILTER(h,1,3,0);
00380 }
00381 #undef FILTER
00382 }
00383 }
00384
00385 void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
00386 assert(!FRAME_MBAFF);
00387 if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) {
00388 ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize);
00389 return;
00390 }
00391
00392 #if CONFIG_SMALL
00393 h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, h->pixel_shift);
00394 #else
00395 if(h->pixel_shift){
00396 h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 1);
00397 }else{
00398 h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 0);
00399 }
00400 #endif
00401 }
00402
00403 static int check_mv(H264Context *h, long b_idx, long bn_idx, int mvy_limit){
00404 int v;
00405
00406 v= h->ref_cache[0][b_idx] != h->ref_cache[0][bn_idx];
00407 if(!v && h->ref_cache[0][b_idx]!=-1)
00408 v= h->mv_cache[0][b_idx][0] - h->mv_cache[0][bn_idx][0] + 3 >= 7U |
00409 FFABS( h->mv_cache[0][b_idx][1] - h->mv_cache[0][bn_idx][1] ) >= mvy_limit;
00410
00411 if(h->list_count==2){
00412 if(!v)
00413 v = h->ref_cache[1][b_idx] != h->ref_cache[1][bn_idx] |
00414 h->mv_cache[1][b_idx][0] - h->mv_cache[1][bn_idx][0] + 3 >= 7U |
00415 FFABS( h->mv_cache[1][b_idx][1] - h->mv_cache[1][bn_idx][1] ) >= mvy_limit;
00416
00417 if(v){
00418 if(h->ref_cache[0][b_idx] != h->ref_cache[1][bn_idx] |
00419 h->ref_cache[1][b_idx] != h->ref_cache[0][bn_idx])
00420 return 1;
00421 return
00422 h->mv_cache[0][b_idx][0] - h->mv_cache[1][bn_idx][0] + 3 >= 7U |
00423 FFABS( h->mv_cache[0][b_idx][1] - h->mv_cache[1][bn_idx][1] ) >= mvy_limit |
00424 h->mv_cache[1][b_idx][0] - h->mv_cache[0][bn_idx][0] + 3 >= 7U |
00425 FFABS( h->mv_cache[1][b_idx][1] - h->mv_cache[0][bn_idx][1] ) >= mvy_limit;
00426 }
00427 }
00428
00429 return v;
00430 }
00431
00432 static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int a, int b, int chroma, int dir) {
00433 MpegEncContext * const s = &h->s;
00434 int edge;
00435 int chroma_qp_avg[2];
00436 int chroma444 = CHROMA444;
00437 int chroma422 = CHROMA422;
00438 const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy;
00439 const int mbm_type = dir == 0 ? h->left_type[LTOP] : h->top_type;
00440
00441
00442 static const uint8_t mask_edge_tab[2][8]={{0,3,3,3,1,1,1,1},
00443 {0,3,1,1,3,3,3,3}};
00444 const int mask_edge = mask_edge_tab[dir][(mb_type>>3)&7];
00445 const int edges = mask_edge== 3 && !(h->cbp&15) ? 1 : 4;
00446
00447
00448 const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir));
00449
00450 if(mbm_type && !first_vertical_edge_done){
00451
00452 if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0)
00453 && IS_INTERLACED(mbm_type&~mb_type)
00454 ) {
00455
00456
00457
00458
00459 unsigned int tmp_linesize = 2 * linesize;
00460 unsigned int tmp_uvlinesize = 2 * uvlinesize;
00461 int mbn_xy = mb_xy - 2 * s->mb_stride;
00462 int j;
00463
00464 for(j=0; j<2; j++, mbn_xy += s->mb_stride){
00465 DECLARE_ALIGNED(8, int16_t, bS)[4];
00466 int qp;
00467 if (IS_INTRA(mb_type | s->current_picture.f.mb_type[mbn_xy])) {
00468 AV_WN64A(bS, 0x0003000300030003ULL);
00469 } else {
00470 if (!CABAC && IS_8x8DCT(s->current_picture.f.mb_type[mbn_xy])) {
00471 bS[0]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+0]);
00472 bS[1]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+1]);
00473 bS[2]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+2]);
00474 bS[3]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+3]);
00475 }else{
00476 const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy] + 3*4;
00477 int i;
00478 for( i = 0; i < 4; i++ ) {
00479 bS[i] = 1 + !!(h->non_zero_count_cache[scan8[0]+i] | mbn_nnz[i]);
00480 }
00481 }
00482 }
00483
00484
00485 qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbn_xy] + 1) >> 1;
00486 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
00487 { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
00488 filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, a, b, h, 0 );
00489 chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1;
00490 chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1;
00491 if (chroma) {
00492 if (chroma444) {
00493 filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0);
00494 filter_mb_edgeh (&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], a, b, h, 0);
00495 } else {
00496 filter_mb_edgech(&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0);
00497 filter_mb_edgech(&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], a, b, h, 0);
00498 }
00499 }
00500 }
00501 }else{
00502 DECLARE_ALIGNED(8, int16_t, bS)[4];
00503 int qp;
00504
00505 if( IS_INTRA(mb_type|mbm_type)) {
00506 AV_WN64A(bS, 0x0003000300030003ULL);
00507 if ( (!IS_INTERLACED(mb_type|mbm_type))
00508 || ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0))
00509 )
00510 AV_WN64A(bS, 0x0004000400040004ULL);
00511 } else {
00512 int i;
00513 int mv_done;
00514
00515 if( dir && FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbm_type)) {
00516 AV_WN64A(bS, 0x0001000100010001ULL);
00517 mv_done = 1;
00518 }
00519 else if( mask_par0 && ((mbm_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) {
00520 int b_idx= 8 + 4;
00521 int bn_idx= b_idx - (dir ? 8:1);
00522
00523 bS[0] = bS[1] = bS[2] = bS[3] = check_mv(h, 8 + 4, bn_idx, mvy_limit);
00524 mv_done = 1;
00525 }
00526 else
00527 mv_done = 0;
00528
00529 for( i = 0; i < 4; i++ ) {
00530 int x = dir == 0 ? 0 : i;
00531 int y = dir == 0 ? i : 0;
00532 int b_idx= 8 + 4 + x + 8*y;
00533 int bn_idx= b_idx - (dir ? 8:1);
00534
00535 if( h->non_zero_count_cache[b_idx] |
00536 h->non_zero_count_cache[bn_idx] ) {
00537 bS[i] = 2;
00538 }
00539 else if(!mv_done)
00540 {
00541 bS[i] = check_mv(h, b_idx, bn_idx, mvy_limit);
00542 }
00543 }
00544 }
00545
00546
00547
00548
00549 if(bS[0]+bS[1]+bS[2]+bS[3]){
00550 qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbm_xy] + 1) >> 1;
00551
00552 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
00553
00554 chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1;
00555 chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1;
00556 if( dir == 0 ) {
00557 filter_mb_edgev( &img_y[0], linesize, bS, qp, a, b, h, 1 );
00558 if (chroma) {
00559 if (chroma444) {
00560 filter_mb_edgev ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
00561 filter_mb_edgev ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
00562 } else {
00563 filter_mb_edgecv( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
00564 filter_mb_edgecv( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
00565 }
00566 }
00567 } else {
00568 filter_mb_edgeh( &img_y[0], linesize, bS, qp, a, b, h, 1 );
00569 if (chroma) {
00570 if (chroma444) {
00571 filter_mb_edgeh ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
00572 filter_mb_edgeh ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
00573 } else {
00574 filter_mb_edgech( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
00575 filter_mb_edgech( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
00576 }
00577 }
00578 }
00579 }
00580 }
00581 }
00582
00583
00584 for( edge = 1; edge < edges; edge++ ) {
00585 DECLARE_ALIGNED(8, int16_t, bS)[4];
00586 int qp;
00587 const int deblock_edge = !IS_8x8DCT(mb_type & (edge<<24));
00588
00589 if (!deblock_edge && (!chroma422 || dir == 0))
00590 continue;
00591
00592 if( IS_INTRA(mb_type)) {
00593 AV_WN64A(bS, 0x0003000300030003ULL);
00594 } else {
00595 int i;
00596 int mv_done;
00597
00598 if( edge & mask_edge ) {
00599 AV_ZERO64(bS);
00600 mv_done = 1;
00601 }
00602 else if( mask_par0 ) {
00603 int b_idx= 8 + 4 + edge * (dir ? 8:1);
00604 int bn_idx= b_idx - (dir ? 8:1);
00605
00606 bS[0] = bS[1] = bS[2] = bS[3] = check_mv(h, b_idx, bn_idx, mvy_limit);
00607 mv_done = 1;
00608 }
00609 else
00610 mv_done = 0;
00611
00612 for( i = 0; i < 4; i++ ) {
00613 int x = dir == 0 ? edge : i;
00614 int y = dir == 0 ? i : edge;
00615 int b_idx= 8 + 4 + x + 8*y;
00616 int bn_idx= b_idx - (dir ? 8:1);
00617
00618 if( h->non_zero_count_cache[b_idx] |
00619 h->non_zero_count_cache[bn_idx] ) {
00620 bS[i] = 2;
00621 }
00622 else if(!mv_done)
00623 {
00624 bS[i] = check_mv(h, b_idx, bn_idx, mvy_limit);
00625 }
00626 }
00627
00628 if(bS[0]+bS[1]+bS[2]+bS[3] == 0)
00629 continue;
00630 }
00631
00632
00633
00634
00635 qp = s->current_picture.f.qscale_table[mb_xy];
00636
00637 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
00638
00639 if( dir == 0 ) {
00640 filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, a, b, h, 0 );
00641 if (chroma) {
00642 if (chroma444) {
00643 filter_mb_edgev ( &img_cb[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
00644 filter_mb_edgev ( &img_cr[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
00645 } else if( (edge&1) == 0 ) {
00646 filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
00647 filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
00648 }
00649 }
00650 } else {
00651 if (chroma422) {
00652 if (deblock_edge)
00653 filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0);
00654 if (chroma) {
00655 filter_mb_edgech(&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
00656 filter_mb_edgech(&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
00657 }
00658 } else {
00659 filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0);
00660 if (chroma) {
00661 if (chroma444) {
00662 filter_mb_edgeh (&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
00663 filter_mb_edgeh (&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
00664 } else if ((edge&1) == 0) {
00665 filter_mb_edgech(&img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
00666 filter_mb_edgech(&img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
00667 }
00668 }
00669 }
00670 }
00671 }
00672 }
00673
00674 void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
00675 MpegEncContext * const s = &h->s;
00676 const int mb_xy= mb_x + mb_y*s->mb_stride;
00677 const int mb_type = s->current_picture.f.mb_type[mb_xy];
00678 const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
00679 int first_vertical_edge_done = 0;
00680 av_unused int dir;
00681 int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
00682 int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
00683 int a = h->slice_alpha_c0_offset - qp_bd_offset;
00684 int b = h->slice_beta_offset - qp_bd_offset;
00685
00686 if (FRAME_MBAFF
00687
00688 && IS_INTERLACED(mb_type^h->left_type[LTOP])
00689
00690 && h->left_type[LTOP]) {
00691
00692
00693
00694 DECLARE_ALIGNED(8, int16_t, bS)[8];
00695 int qp[2];
00696 int bqp[2];
00697 int rqp[2];
00698 int mb_qp, mbn0_qp, mbn1_qp;
00699 int i;
00700 first_vertical_edge_done = 1;
00701
00702 if( IS_INTRA(mb_type) ) {
00703 AV_WN64A(&bS[0], 0x0004000400040004ULL);
00704 AV_WN64A(&bS[4], 0x0004000400040004ULL);
00705 } else {
00706 static const uint8_t offset[2][2][8]={
00707 {
00708 {3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
00709 {3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
00710 },{
00711 {3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
00712 {3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
00713 }
00714 };
00715 const uint8_t *off= offset[MB_FIELD][mb_y&1];
00716 for( i = 0; i < 8; i++ ) {
00717 int j= MB_FIELD ? i>>2 : i&1;
00718 int mbn_xy = h->left_mb_xy[LEFT(j)];
00719 int mbn_type= h->left_type[LEFT(j)];
00720
00721 if( IS_INTRA( mbn_type ) )
00722 bS[i] = 4;
00723 else{
00724 bS[i] = 1 + !!(h->non_zero_count_cache[12+8*(i>>1)] |
00725 ((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
00726 (h->cbp_table[mbn_xy] & (((MB_FIELD ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
00727 :
00728 h->non_zero_count[mbn_xy][ off[i] ]));
00729 }
00730 }
00731 }
00732
00733 mb_qp = s->current_picture.f.qscale_table[mb_xy];
00734 mbn0_qp = s->current_picture.f.qscale_table[h->left_mb_xy[0]];
00735 mbn1_qp = s->current_picture.f.qscale_table[h->left_mb_xy[1]];
00736 qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
00737 bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
00738 get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
00739 rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
00740 get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
00741 qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
00742 bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
00743 get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
00744 rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
00745 get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
00746
00747
00748 tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
00749 { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
00750 if(MB_FIELD){
00751 filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
00752 filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
00753 if (chroma){
00754 if (CHROMA444) {
00755 filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
00756 filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
00757 filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
00758 filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
00759 } else if (CHROMA422) {
00760 filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
00761 filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
00762 filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
00763 filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
00764 }else{
00765 filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
00766 filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
00767 filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
00768 filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
00769 }
00770 }
00771 }else{
00772 filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
00773 filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
00774 if (chroma){
00775 if (CHROMA444) {
00776 filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
00777 filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
00778 filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
00779 filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
00780 }else{
00781 filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
00782 filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
00783 filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
00784 filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
00785 }
00786 }
00787 }
00788 }
00789
00790 #if CONFIG_SMALL
00791 for( dir = 0; dir < 2; dir++ )
00792 filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, dir);
00793 #else
00794 filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
00795 filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
00796 #endif
00797 }