1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "vpx_config.h"
12 #include "vp8_rtcd.h"
13 #include "loopfilter.h"
14 #include "onyxc_int.h"
15 #include "vpx_mem/vpx_mem.h"
16 
lf_init_lut(loop_filter_info_n * lfi)17 static void lf_init_lut(loop_filter_info_n *lfi) {
18   int filt_lvl;
19 
20   for (filt_lvl = 0; filt_lvl <= MAX_LOOP_FILTER; ++filt_lvl) {
21     if (filt_lvl >= 40) {
22       lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 2;
23       lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 3;
24     } else if (filt_lvl >= 20) {
25       lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1;
26       lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 2;
27     } else if (filt_lvl >= 15) {
28       lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1;
29       lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 1;
30     } else {
31       lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 0;
32       lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 0;
33     }
34   }
35 
36   lfi->mode_lf_lut[DC_PRED] = 1;
37   lfi->mode_lf_lut[V_PRED] = 1;
38   lfi->mode_lf_lut[H_PRED] = 1;
39   lfi->mode_lf_lut[TM_PRED] = 1;
40   lfi->mode_lf_lut[B_PRED] = 0;
41 
42   lfi->mode_lf_lut[ZEROMV] = 1;
43   lfi->mode_lf_lut[NEARESTMV] = 2;
44   lfi->mode_lf_lut[NEARMV] = 2;
45   lfi->mode_lf_lut[NEWMV] = 2;
46   lfi->mode_lf_lut[SPLITMV] = 3;
47 }
48 
vp8_loop_filter_update_sharpness(loop_filter_info_n * lfi,int sharpness_lvl)49 void vp8_loop_filter_update_sharpness(loop_filter_info_n *lfi,
50                                       int sharpness_lvl) {
51   int i;
52 
53   /* For each possible value for the loop filter fill out limits */
54   for (i = 0; i <= MAX_LOOP_FILTER; ++i) {
55     int filt_lvl = i;
56     int block_inside_limit = 0;
57 
58     /* Set loop filter paramaeters that control sharpness. */
59     block_inside_limit = filt_lvl >> (sharpness_lvl > 0);
60     block_inside_limit = block_inside_limit >> (sharpness_lvl > 4);
61 
62     if (sharpness_lvl > 0) {
63       if (block_inside_limit > (9 - sharpness_lvl)) {
64         block_inside_limit = (9 - sharpness_lvl);
65       }
66     }
67 
68     if (block_inside_limit < 1) block_inside_limit = 1;
69 
70     memset(lfi->lim[i], block_inside_limit, SIMD_WIDTH);
71     memset(lfi->blim[i], (2 * filt_lvl + block_inside_limit), SIMD_WIDTH);
72     memset(lfi->mblim[i], (2 * (filt_lvl + 2) + block_inside_limit),
73            SIMD_WIDTH);
74   }
75 }
76 
vp8_loop_filter_init(VP8_COMMON * cm)77 void vp8_loop_filter_init(VP8_COMMON *cm) {
78   loop_filter_info_n *lfi = &cm->lf_info;
79   int i;
80 
81   /* init limits for given sharpness*/
82   vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level);
83   cm->last_sharpness_level = cm->sharpness_level;
84 
85   /* init LUT for lvl  and hev thr picking */
86   lf_init_lut(lfi);
87 
88   /* init hev threshold const vectors */
89   for (i = 0; i < 4; ++i) {
90     memset(lfi->hev_thr[i], i, SIMD_WIDTH);
91   }
92 }
93 
vp8_loop_filter_frame_init(VP8_COMMON * cm,MACROBLOCKD * mbd,int default_filt_lvl)94 void vp8_loop_filter_frame_init(VP8_COMMON *cm, MACROBLOCKD *mbd,
95                                 int default_filt_lvl) {
96   int seg,  /* segment number */
97       ref,  /* index in ref_lf_deltas */
98       mode; /* index in mode_lf_deltas */
99 
100   loop_filter_info_n *lfi = &cm->lf_info;
101 
102   /* update limits if sharpness has changed */
103   if (cm->last_sharpness_level != cm->sharpness_level) {
104     vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level);
105     cm->last_sharpness_level = cm->sharpness_level;
106   }
107 
108   for (seg = 0; seg < MAX_MB_SEGMENTS; ++seg) {
109     int lvl_seg = default_filt_lvl;
110     int lvl_ref, lvl_mode;
111 
112     /* Note the baseline filter values for each segment */
113     if (mbd->segmentation_enabled) {
114       if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA) {
115         lvl_seg = mbd->segment_feature_data[MB_LVL_ALT_LF][seg];
116       } else { /* Delta Value */
117         lvl_seg += mbd->segment_feature_data[MB_LVL_ALT_LF][seg];
118       }
119       lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63 : lvl_seg) : 0;
120     }
121 
122     if (!mbd->mode_ref_lf_delta_enabled) {
123       /* we could get rid of this if we assume that deltas are set to
124        * zero when not in use; encoder always uses deltas
125        */
126       memset(lfi->lvl[seg][0], lvl_seg, 4 * 4);
127       continue;
128     }
129 
130     /* INTRA_FRAME */
131     ref = INTRA_FRAME;
132 
133     /* Apply delta for reference frame */
134     lvl_ref = lvl_seg + mbd->ref_lf_deltas[ref];
135 
136     /* Apply delta for Intra modes */
137     mode = 0; /* B_PRED */
138     /* Only the split mode BPRED has a further special case */
139     lvl_mode = lvl_ref + mbd->mode_lf_deltas[mode];
140     /* clamp */
141     lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0;
142 
143     lfi->lvl[seg][ref][mode] = lvl_mode;
144 
145     mode = 1; /* all the rest of Intra modes */
146     /* clamp */
147     lvl_mode = (lvl_ref > 0) ? (lvl_ref > 63 ? 63 : lvl_ref) : 0;
148     lfi->lvl[seg][ref][mode] = lvl_mode;
149 
150     /* LAST, GOLDEN, ALT */
151     for (ref = 1; ref < MAX_REF_FRAMES; ++ref) {
152       /* Apply delta for reference frame */
153       lvl_ref = lvl_seg + mbd->ref_lf_deltas[ref];
154 
155       /* Apply delta for Inter modes */
156       for (mode = 1; mode < 4; ++mode) {
157         lvl_mode = lvl_ref + mbd->mode_lf_deltas[mode];
158         /* clamp */
159         lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0;
160 
161         lfi->lvl[seg][ref][mode] = lvl_mode;
162       }
163     }
164   }
165 }
166 
vp8_loop_filter_row_normal(VP8_COMMON * cm,MODE_INFO * mode_info_context,int mb_row,int post_ystride,int post_uvstride,unsigned char * y_ptr,unsigned char * u_ptr,unsigned char * v_ptr)167 void vp8_loop_filter_row_normal(VP8_COMMON *cm, MODE_INFO *mode_info_context,
168                                 int mb_row, int post_ystride, int post_uvstride,
169                                 unsigned char *y_ptr, unsigned char *u_ptr,
170                                 unsigned char *v_ptr) {
171   int mb_col;
172   int filter_level;
173   loop_filter_info_n *lfi_n = &cm->lf_info;
174   loop_filter_info lfi;
175   FRAME_TYPE frame_type = cm->frame_type;
176 
177   for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
178     int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
179                    mode_info_context->mbmi.mode != SPLITMV &&
180                    mode_info_context->mbmi.mb_skip_coeff);
181 
182     const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
183     const int seg = mode_info_context->mbmi.segment_id;
184     const int ref_frame = mode_info_context->mbmi.ref_frame;
185 
186     filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
187 
188     if (filter_level) {
189       const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
190       lfi.mblim = lfi_n->mblim[filter_level];
191       lfi.blim = lfi_n->blim[filter_level];
192       lfi.lim = lfi_n->lim[filter_level];
193       lfi.hev_thr = lfi_n->hev_thr[hev_index];
194 
195       if (mb_col > 0)
196         vp8_loop_filter_mbv(y_ptr, u_ptr, v_ptr, post_ystride, post_uvstride,
197                             &lfi);
198 
199       if (!skip_lf)
200         vp8_loop_filter_bv(y_ptr, u_ptr, v_ptr, post_ystride, post_uvstride,
201                            &lfi);
202 
203       /* don't apply across umv border */
204       if (mb_row > 0)
205         vp8_loop_filter_mbh(y_ptr, u_ptr, v_ptr, post_ystride, post_uvstride,
206                             &lfi);
207 
208       if (!skip_lf)
209         vp8_loop_filter_bh(y_ptr, u_ptr, v_ptr, post_ystride, post_uvstride,
210                            &lfi);
211     }
212 
213     y_ptr += 16;
214     u_ptr += 8;
215     v_ptr += 8;
216 
217     mode_info_context++; /* step to next MB */
218   }
219 }
220 
vp8_loop_filter_row_simple(VP8_COMMON * cm,MODE_INFO * mode_info_context,int mb_row,int post_ystride,unsigned char * y_ptr)221 void vp8_loop_filter_row_simple(VP8_COMMON *cm, MODE_INFO *mode_info_context,
222                                 int mb_row, int post_ystride,
223                                 unsigned char *y_ptr) {
224   int mb_col;
225   int filter_level;
226   loop_filter_info_n *lfi_n = &cm->lf_info;
227 
228   for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
229     int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
230                    mode_info_context->mbmi.mode != SPLITMV &&
231                    mode_info_context->mbmi.mb_skip_coeff);
232 
233     const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
234     const int seg = mode_info_context->mbmi.segment_id;
235     const int ref_frame = mode_info_context->mbmi.ref_frame;
236 
237     filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
238 
239     if (filter_level) {
240       if (mb_col > 0)
241         vp8_loop_filter_simple_mbv(y_ptr, post_ystride,
242                                    lfi_n->mblim[filter_level]);
243 
244       if (!skip_lf)
245         vp8_loop_filter_simple_bv(y_ptr, post_ystride,
246                                   lfi_n->blim[filter_level]);
247 
248       /* don't apply across umv border */
249       if (mb_row > 0)
250         vp8_loop_filter_simple_mbh(y_ptr, post_ystride,
251                                    lfi_n->mblim[filter_level]);
252 
253       if (!skip_lf)
254         vp8_loop_filter_simple_bh(y_ptr, post_ystride,
255                                   lfi_n->blim[filter_level]);
256     }
257 
258     y_ptr += 16;
259 
260     mode_info_context++; /* step to next MB */
261   }
262 }
vp8_loop_filter_frame(VP8_COMMON * cm,MACROBLOCKD * mbd,int frame_type)263 void vp8_loop_filter_frame(VP8_COMMON *cm, MACROBLOCKD *mbd, int frame_type) {
264   YV12_BUFFER_CONFIG *post = cm->frame_to_show;
265   loop_filter_info_n *lfi_n = &cm->lf_info;
266   loop_filter_info lfi;
267 
268   int mb_row;
269   int mb_col;
270   int mb_rows = cm->mb_rows;
271   int mb_cols = cm->mb_cols;
272 
273   int filter_level;
274 
275   unsigned char *y_ptr, *u_ptr, *v_ptr;
276 
277   /* Point at base of Mb MODE_INFO list */
278   const MODE_INFO *mode_info_context = cm->mi;
279   int post_y_stride = post->y_stride;
280   int post_uv_stride = post->uv_stride;
281 
282   /* Initialize the loop filter for this frame. */
283   vp8_loop_filter_frame_init(cm, mbd, cm->filter_level);
284 
285   /* Set up the buffer pointers */
286   y_ptr = post->y_buffer;
287   u_ptr = post->u_buffer;
288   v_ptr = post->v_buffer;
289 
290   /* vp8_filter each macro block */
291   if (cm->filter_type == NORMAL_LOOPFILTER) {
292     for (mb_row = 0; mb_row < mb_rows; ++mb_row) {
293       for (mb_col = 0; mb_col < mb_cols; ++mb_col) {
294         int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
295                        mode_info_context->mbmi.mode != SPLITMV &&
296                        mode_info_context->mbmi.mb_skip_coeff);
297 
298         const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
299         const int seg = mode_info_context->mbmi.segment_id;
300         const int ref_frame = mode_info_context->mbmi.ref_frame;
301 
302         filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
303 
304         if (filter_level) {
305           const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
306           lfi.mblim = lfi_n->mblim[filter_level];
307           lfi.blim = lfi_n->blim[filter_level];
308           lfi.lim = lfi_n->lim[filter_level];
309           lfi.hev_thr = lfi_n->hev_thr[hev_index];
310 
311           if (mb_col > 0)
312             vp8_loop_filter_mbv(y_ptr, u_ptr, v_ptr, post_y_stride,
313                                 post_uv_stride, &lfi);
314 
315           if (!skip_lf)
316             vp8_loop_filter_bv(y_ptr, u_ptr, v_ptr, post_y_stride,
317                                post_uv_stride, &lfi);
318 
319           /* don't apply across umv border */
320           if (mb_row > 0)
321             vp8_loop_filter_mbh(y_ptr, u_ptr, v_ptr, post_y_stride,
322                                 post_uv_stride, &lfi);
323 
324           if (!skip_lf)
325             vp8_loop_filter_bh(y_ptr, u_ptr, v_ptr, post_y_stride,
326                                post_uv_stride, &lfi);
327         }
328 
329         y_ptr += 16;
330         u_ptr += 8;
331         v_ptr += 8;
332 
333         mode_info_context++; /* step to next MB */
334       }
335       y_ptr += post_y_stride * 16 - post->y_width;
336       u_ptr += post_uv_stride * 8 - post->uv_width;
337       v_ptr += post_uv_stride * 8 - post->uv_width;
338 
339       mode_info_context++; /* Skip border mb */
340     }
341   } else { /* SIMPLE_LOOPFILTER */
342     for (mb_row = 0; mb_row < mb_rows; ++mb_row) {
343       for (mb_col = 0; mb_col < mb_cols; ++mb_col) {
344         int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
345                        mode_info_context->mbmi.mode != SPLITMV &&
346                        mode_info_context->mbmi.mb_skip_coeff);
347 
348         const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
349         const int seg = mode_info_context->mbmi.segment_id;
350         const int ref_frame = mode_info_context->mbmi.ref_frame;
351 
352         filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
353         if (filter_level) {
354           const unsigned char *mblim = lfi_n->mblim[filter_level];
355           const unsigned char *blim = lfi_n->blim[filter_level];
356 
357           if (mb_col > 0)
358             vp8_loop_filter_simple_mbv(y_ptr, post_y_stride, mblim);
359 
360           if (!skip_lf) vp8_loop_filter_simple_bv(y_ptr, post_y_stride, blim);
361 
362           /* don't apply across umv border */
363           if (mb_row > 0)
364             vp8_loop_filter_simple_mbh(y_ptr, post_y_stride, mblim);
365 
366           if (!skip_lf) vp8_loop_filter_simple_bh(y_ptr, post_y_stride, blim);
367         }
368 
369         y_ptr += 16;
370         u_ptr += 8;
371         v_ptr += 8;
372 
373         mode_info_context++; /* step to next MB */
374       }
375       y_ptr += post_y_stride * 16 - post->y_width;
376       u_ptr += post_uv_stride * 8 - post->uv_width;
377       v_ptr += post_uv_stride * 8 - post->uv_width;
378 
379       mode_info_context++; /* Skip border mb */
380     }
381   }
382 }
383 
vp8_loop_filter_frame_yonly(VP8_COMMON * cm,MACROBLOCKD * mbd,int default_filt_lvl)384 void vp8_loop_filter_frame_yonly(VP8_COMMON *cm, MACROBLOCKD *mbd,
385                                  int default_filt_lvl) {
386   YV12_BUFFER_CONFIG *post = cm->frame_to_show;
387 
388   unsigned char *y_ptr;
389   int mb_row;
390   int mb_col;
391 
392   loop_filter_info_n *lfi_n = &cm->lf_info;
393   loop_filter_info lfi;
394 
395   int filter_level;
396   FRAME_TYPE frame_type = cm->frame_type;
397 
398   /* Point at base of Mb MODE_INFO list */
399   const MODE_INFO *mode_info_context = cm->mi;
400 
401 #if 0
402     if(default_filt_lvl == 0) /* no filter applied */
403         return;
404 #endif
405 
406   /* Initialize the loop filter for this frame. */
407   vp8_loop_filter_frame_init(cm, mbd, default_filt_lvl);
408 
409   /* Set up the buffer pointers */
410   y_ptr = post->y_buffer;
411 
412   /* vp8_filter each macro block */
413   for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) {
414     for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
415       int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
416                      mode_info_context->mbmi.mode != SPLITMV &&
417                      mode_info_context->mbmi.mb_skip_coeff);
418 
419       const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
420       const int seg = mode_info_context->mbmi.segment_id;
421       const int ref_frame = mode_info_context->mbmi.ref_frame;
422 
423       filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
424 
425       if (filter_level) {
426         if (cm->filter_type == NORMAL_LOOPFILTER) {
427           const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
428           lfi.mblim = lfi_n->mblim[filter_level];
429           lfi.blim = lfi_n->blim[filter_level];
430           lfi.lim = lfi_n->lim[filter_level];
431           lfi.hev_thr = lfi_n->hev_thr[hev_index];
432 
433           if (mb_col > 0)
434             vp8_loop_filter_mbv(y_ptr, 0, 0, post->y_stride, 0, &lfi);
435 
436           if (!skip_lf)
437             vp8_loop_filter_bv(y_ptr, 0, 0, post->y_stride, 0, &lfi);
438 
439           /* don't apply across umv border */
440           if (mb_row > 0)
441             vp8_loop_filter_mbh(y_ptr, 0, 0, post->y_stride, 0, &lfi);
442 
443           if (!skip_lf)
444             vp8_loop_filter_bh(y_ptr, 0, 0, post->y_stride, 0, &lfi);
445         } else {
446           if (mb_col > 0)
447             vp8_loop_filter_simple_mbv(y_ptr, post->y_stride,
448                                        lfi_n->mblim[filter_level]);
449 
450           if (!skip_lf)
451             vp8_loop_filter_simple_bv(y_ptr, post->y_stride,
452                                       lfi_n->blim[filter_level]);
453 
454           /* don't apply across umv border */
455           if (mb_row > 0)
456             vp8_loop_filter_simple_mbh(y_ptr, post->y_stride,
457                                        lfi_n->mblim[filter_level]);
458 
459           if (!skip_lf)
460             vp8_loop_filter_simple_bh(y_ptr, post->y_stride,
461                                       lfi_n->blim[filter_level]);
462         }
463       }
464 
465       y_ptr += 16;
466       mode_info_context++; /* step to next MB */
467     }
468 
469     y_ptr += post->y_stride * 16 - post->y_width;
470     mode_info_context++; /* Skip border mb */
471   }
472 }
473 
vp8_loop_filter_partial_frame(VP8_COMMON * cm,MACROBLOCKD * mbd,int default_filt_lvl)474 void vp8_loop_filter_partial_frame(VP8_COMMON *cm, MACROBLOCKD *mbd,
475                                    int default_filt_lvl) {
476   YV12_BUFFER_CONFIG *post = cm->frame_to_show;
477 
478   unsigned char *y_ptr;
479   int mb_row;
480   int mb_col;
481   int mb_cols = post->y_width >> 4;
482   int mb_rows = post->y_height >> 4;
483 
484   int linestocopy;
485 
486   loop_filter_info_n *lfi_n = &cm->lf_info;
487   loop_filter_info lfi;
488 
489   int filter_level;
490   FRAME_TYPE frame_type = cm->frame_type;
491 
492   const MODE_INFO *mode_info_context;
493 
494 #if 0
495     if(default_filt_lvl == 0) /* no filter applied */
496         return;
497 #endif
498 
499   /* Initialize the loop filter for this frame. */
500   vp8_loop_filter_frame_init(cm, mbd, default_filt_lvl);
501 
502   /* number of MB rows to use in partial filtering */
503   linestocopy = mb_rows / PARTIAL_FRAME_FRACTION;
504   linestocopy = linestocopy ? linestocopy << 4 : 16; /* 16 lines per MB */
505 
506   /* Set up the buffer pointers; partial image starts at ~middle of frame */
507   y_ptr = post->y_buffer + ((post->y_height >> 5) * 16) * post->y_stride;
508   mode_info_context = cm->mi + (post->y_height >> 5) * (mb_cols + 1);
509 
510   /* vp8_filter each macro block */
511   for (mb_row = 0; mb_row < (linestocopy >> 4); ++mb_row) {
512     for (mb_col = 0; mb_col < mb_cols; ++mb_col) {
513       int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
514                      mode_info_context->mbmi.mode != SPLITMV &&
515                      mode_info_context->mbmi.mb_skip_coeff);
516 
517       const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
518       const int seg = mode_info_context->mbmi.segment_id;
519       const int ref_frame = mode_info_context->mbmi.ref_frame;
520 
521       filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
522 
523       if (filter_level) {
524         if (cm->filter_type == NORMAL_LOOPFILTER) {
525           const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
526           lfi.mblim = lfi_n->mblim[filter_level];
527           lfi.blim = lfi_n->blim[filter_level];
528           lfi.lim = lfi_n->lim[filter_level];
529           lfi.hev_thr = lfi_n->hev_thr[hev_index];
530 
531           if (mb_col > 0)
532             vp8_loop_filter_mbv(y_ptr, 0, 0, post->y_stride, 0, &lfi);
533 
534           if (!skip_lf)
535             vp8_loop_filter_bv(y_ptr, 0, 0, post->y_stride, 0, &lfi);
536 
537           vp8_loop_filter_mbh(y_ptr, 0, 0, post->y_stride, 0, &lfi);
538 
539           if (!skip_lf)
540             vp8_loop_filter_bh(y_ptr, 0, 0, post->y_stride, 0, &lfi);
541         } else {
542           if (mb_col > 0)
543             vp8_loop_filter_simple_mbv(y_ptr, post->y_stride,
544                                        lfi_n->mblim[filter_level]);
545 
546           if (!skip_lf)
547             vp8_loop_filter_simple_bv(y_ptr, post->y_stride,
548                                       lfi_n->blim[filter_level]);
549 
550           vp8_loop_filter_simple_mbh(y_ptr, post->y_stride,
551                                      lfi_n->mblim[filter_level]);
552 
553           if (!skip_lf)
554             vp8_loop_filter_simple_bh(y_ptr, post->y_stride,
555                                       lfi_n->blim[filter_level]);
556         }
557       }
558 
559       y_ptr += 16;
560       mode_info_context += 1; /* step to next MB */
561     }
562 
563     y_ptr += post->y_stride * 16 - post->y_width;
564     mode_info_context += 1; /* Skip border mb */
565   }
566 }
567