LCOV - code coverage report
Current view: top level - libavcodec - vc1_loopfilter.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 704 724 97.2 %
Date: 2018-05-20 11:54:08 Functions: 16 17 94.1 %

          Line data    Source code
       1             : /*
       2             :  * VC-1 and WMV3 decoder
       3             :  * Copyright (c) 2011 Mashiat Sarker Shakkhar
       4             :  * Copyright (c) 2006-2007 Konstantin Shishkov
       5             :  * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer
       6             :  *
       7             :  * This file is part of FFmpeg.
       8             :  *
       9             :  * FFmpeg is free software; you can redistribute it and/or
      10             :  * modify it under the terms of the GNU Lesser General Public
      11             :  * License as published by the Free Software Foundation; either
      12             :  * version 2.1 of the License, or (at your option) any later version.
      13             :  *
      14             :  * FFmpeg is distributed in the hope that it will be useful,
      15             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17             :  * Lesser General Public License for more details.
      18             :  *
      19             :  * You should have received a copy of the GNU Lesser General Public
      20             :  * License along with FFmpeg; if not, write to the Free Software
      21             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      22             :  */
      23             : 
      24             : /**
      25             :  * @file
      26             :  * VC-1 and WMV3 loopfilter
      27             :  */
      28             : 
      29             : #include "avcodec.h"
      30             : #include "mpegvideo.h"
      31             : #include "vc1.h"
      32             : #include "vc1dsp.h"
      33             : 
      34       12480 : void ff_vc1_loop_filter_iblk(VC1Context *v, int pq)
      35             : {
      36       12480 :     MpegEncContext *s = &v->s;
      37             :     int j;
      38       12480 :     if (!s->first_slice_line) {
      39       11390 :         v->vc1dsp.vc1_v_loop_filter16(s->dest[0], s->linesize, pq);
      40       11390 :         if (s->mb_x)
      41       10635 :             v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq);
      42       11390 :         v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize + 8, s->linesize, pq);
      43             :         if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY))
      44       34170 :         for (j = 0; j < 2; j++) {
      45       22780 :             v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1], s->uvlinesize, pq);
      46       22780 :             if (s->mb_x)
      47       21270 :                 v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq);
      48             :         }
      49             :     }
      50       12480 :     v->vc1dsp.vc1_v_loop_filter16(s->dest[0] + 8 * s->linesize, s->linesize, pq);
      51             : 
      52       12480 :     if (s->mb_y == s->end_mb_y - 1) {
      53        1090 :         if (s->mb_x) {
      54        1009 :             v->vc1dsp.vc1_h_loop_filter16(s->dest[0], s->linesize, pq);
      55             :             if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
      56        1009 :             v->vc1dsp.vc1_h_loop_filter8(s->dest[1], s->uvlinesize, pq);
      57        1009 :             v->vc1dsp.vc1_h_loop_filter8(s->dest[2], s->uvlinesize, pq);
      58             :             }
      59             :         }
      60        1090 :         v->vc1dsp.vc1_h_loop_filter16(s->dest[0] + 8, s->linesize, pq);
      61             :     }
      62       12480 : }
      63             : 
      64        1344 : static av_always_inline void vc1_h_overlap_filter(VC1Context *v, int16_t (*left_block)[64],
      65             :                                                   int16_t (*right_block)[64], int block_num)
      66             : {
      67        1344 :     if (left_block != right_block || (block_num & 5) == 1) {
      68        1344 :         if (block_num > 3)
      69         420 :             v->vc1dsp.vc1_h_s_overlap(left_block[block_num], right_block[block_num]);
      70         924 :         else if (block_num & 1)
      71         504 :             v->vc1dsp.vc1_h_s_overlap(right_block[block_num - 1], right_block[block_num]);
      72             :         else
      73         420 :             v->vc1dsp.vc1_h_s_overlap(left_block[block_num + 1], right_block[block_num]);
      74             :     }
      75        1344 : }
      76             : 
      77        1228 : static av_always_inline void vc1_v_overlap_filter(VC1Context *v, int16_t (*top_block)[64],
      78             :                                                   int16_t (*bottom_block)[64], int block_num)
      79             : {
      80        1228 :     if (top_block != bottom_block || block_num & 2) {
      81        1228 :         if (block_num > 3)
      82         362 :             v->vc1dsp.vc1_v_s_overlap(top_block[block_num], bottom_block[block_num]);
      83         866 :         else if (block_num & 2)
      84         504 :             v->vc1dsp.vc1_v_s_overlap(bottom_block[block_num - 2], bottom_block[block_num]);
      85             :         else
      86         362 :             v->vc1dsp.vc1_v_s_overlap(top_block[block_num + 2], bottom_block[block_num]);
      87             :     }
      88        1228 : }
      89             : 
      90         399 : void ff_vc1_i_overlap_filter(VC1Context *v)
      91             : {
      92         399 :     MpegEncContext *s = &v->s;
      93             :     int16_t (*topleft_blk)[64], (*top_blk)[64], (*left_blk)[64], (*cur_blk)[64];
      94         399 :     int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
      95         399 :     int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
      96             :     int i;
      97             : 
      98         399 :     topleft_blk = v->block[v->topleft_blk_idx];
      99         399 :     top_blk = v->block[v->top_blk_idx];
     100         399 :     left_blk = v->block[v->left_blk_idx];
     101         399 :     cur_blk = v->block[v->cur_blk_idx];
     102             : 
     103             :     /* Within a MB, the horizontal overlap always runs before the vertical.
     104             :      * To accomplish that, we run the H on the left and internal vertical
     105             :      * borders of the currently decoded MB. Then, we wait for the next overlap
     106             :      * iteration to do H overlap on the right edge of this MB, before moving
     107             :      * over and running the V overlap on the top and internal horizontal
     108             :      * borders. Therefore, the H overlap trails by one MB col and the
     109             :      * V overlap trails by one MB row. This is reflected in the time at which
     110             :      * we run the put_pixels loop, i.e. delayed by one row and one column. */
     111        2793 :     for (i = 0; i < block_count; i++)
     112        4788 :         if (v->pq >= 9 || v->condover == CONDOVER_ALL ||
     113        3906 :             (v->over_flags_plane[mb_pos] && ((i & 5) == 1 || (s->mb_x && v->over_flags_plane[mb_pos - 1]))))
     114        1344 :             vc1_h_overlap_filter(v, s->mb_x ? left_blk : cur_blk, cur_blk, i);
     115             : 
     116         399 :     if (v->fcm != ILACE_FRAME)
     117        2793 :         for (i = 0; i < block_count; i++) {
     118        4644 :             if (s->mb_x && (v->pq >= 9 || v->condover == CONDOVER_ALL ||
     119        3660 :                 (v->over_flags_plane[mb_pos - 1] &&
     120        2350 :                  ((i & 2) || (!s->first_slice_line && v->over_flags_plane[mb_pos - 1 - s->mb_stride])))))
     121        1142 :                 vc1_v_overlap_filter(v, s->first_slice_line ? left_blk : topleft_blk, left_blk, i);
     122        2394 :             if (s->mb_x == s->mb_width - 1)
     123         288 :                 if (v->pq >= 9 || v->condover == CONDOVER_ALL ||
     124         246 :                     (v->over_flags_plane[mb_pos] &&
     125         170 :                      ((i & 2) || (!s->first_slice_line && v->over_flags_plane[mb_pos - s->mb_stride]))))
     126          86 :                     vc1_v_overlap_filter(v, s->first_slice_line ? cur_blk : top_blk, cur_blk, i);
     127             :         }
     128         399 : }
     129             : 
     130           0 : void ff_vc1_p_overlap_filter(VC1Context *v)
     131             : {
     132           0 :     MpegEncContext *s = &v->s;
     133             :     int16_t (*topleft_blk)[64], (*top_blk)[64], (*left_blk)[64], (*cur_blk)[64];
     134           0 :     int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
     135             :     int i;
     136             : 
     137           0 :     topleft_blk = v->block[v->topleft_blk_idx];
     138           0 :     top_blk = v->block[v->top_blk_idx];
     139           0 :     left_blk = v->block[v->left_blk_idx];
     140           0 :     cur_blk = v->block[v->cur_blk_idx];
     141             : 
     142           0 :     for (i = 0; i < block_count; i++)
     143           0 :         if (v->mb_type[0][s->block_index[i]] && (s->mb_x == 0 || v->mb_type[0][s->block_index[i] - 1]))
     144           0 :             vc1_h_overlap_filter(v, s->mb_x ? left_blk : cur_blk, cur_blk, i);
     145             : 
     146           0 :     if (v->fcm != ILACE_FRAME)
     147           0 :         for (i = 0; i < block_count; i++) {
     148           0 :             if (s->mb_x && v->mb_type[0][s->block_index[i] - 1] &&
     149           0 :                 (s->first_slice_line || v->mb_type[0][s->block_index[i] - s->block_wrap[i] - 1]))
     150           0 :                 vc1_v_overlap_filter(v, s->first_slice_line ? left_blk : topleft_blk, left_blk, i);
     151           0 :             if (s->mb_x == s->mb_width - 1)
     152           0 :                 if (v->mb_type[0][s->block_index[i]] &&
     153           0 :                     (s->first_slice_line || v->mb_type[0][s->block_index[i] - s->block_wrap[i]]))
     154           0 :                     vc1_v_overlap_filter(v, s->first_slice_line ? cur_blk : top_blk, cur_blk, i);
     155             :         }
     156           0 : }
     157             : 
     158             : #define LEFT_EDGE   (1 << 0)
     159             : #define RIGHT_EDGE  (1 << 1)
     160             : #define TOP_EDGE    (1 << 2)
     161             : #define BOTTOM_EDGE (1 << 3)
     162             : 
     163      107424 : static av_always_inline void vc1_i_h_loop_filter(VC1Context *v, uint8_t *dest,
     164             :                                                  uint32_t flags, int block_num)
     165             : {
     166      107424 :     MpegEncContext *s  = &v->s;
     167      107424 :     int pq = v->pq;
     168             :     uint8_t *dst;
     169             : 
     170      107424 :     if (block_num & 2)
     171       35808 :         return;
     172             : 
     173       71616 :     if (!(flags & LEFT_EDGE) || (block_num & 5) == 1) {
     174       69900 :         if (block_num > 3)
     175       34664 :             dst = dest;
     176             :         else
     177       35236 :             dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) * 8;
     178             : 
     179       69900 :         if (v->fcm == ILACE_FRAME)
     180       32436 :             if (block_num > 3) {
     181       16184 :                 v->vc1dsp.vc1_h_loop_filter4(dst, 2 * s->uvlinesize, pq);
     182       16184 :                 v->vc1dsp.vc1_h_loop_filter4(dst + s->uvlinesize, 2 * s->uvlinesize, pq);
     183             :             } else {
     184       16252 :                 v->vc1dsp.vc1_h_loop_filter8(dst, 2 * s->linesize, pq);
     185       16252 :                 v->vc1dsp.vc1_h_loop_filter8(dst + s->linesize, 2 * s->linesize, pq);
     186             :             }
     187             :         else
     188       37464 :             if (block_num > 3)
     189       18480 :                 v->vc1dsp.vc1_h_loop_filter8(dst, s->uvlinesize, pq);
     190             :             else
     191       18984 :                 v->vc1dsp.vc1_h_loop_filter16(dst, s->linesize, pq);
     192             :     }
     193             : }
     194             : 
     195      107424 : static av_always_inline void vc1_i_v_loop_filter(VC1Context *v, uint8_t *dest,
     196             :                                                  uint32_t flags, uint8_t fieldtx,
     197             :                                                  int block_num)
     198             : {
     199      107424 :     MpegEncContext *s  = &v->s;
     200      107424 :     int pq = v->pq;
     201             :     uint8_t *dst;
     202             : 
     203      107424 :     if ((block_num & 5) == 1)
     204       35808 :         return;
     205             : 
     206       71616 :     if (!(flags & TOP_EDGE) || block_num & 2) {
     207       67320 :         if (block_num > 3)
     208       32944 :             dst = dest;
     209             :         else
     210       34376 :             dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) * 8;
     211             : 
     212       67320 :         if (v->fcm == ILACE_FRAME) {
     213       32280 :             if (block_num > 3) {
     214       16080 :                 v->vc1dsp.vc1_v_loop_filter8(dst, 2 * s->uvlinesize, pq);
     215       16080 :                 v->vc1dsp.vc1_v_loop_filter8(dst + s->uvlinesize, 2 * s->uvlinesize, pq);
     216       16200 :             } else if (block_num < 2 || !fieldtx) {
     217       13573 :                 v->vc1dsp.vc1_v_loop_filter16(dst, 2 * s->linesize, pq);
     218       13573 :                 v->vc1dsp.vc1_v_loop_filter16(dst + s->linesize, 2 * s->linesize, pq);
     219             :             }
     220             :         } else
     221       35040 :             if (block_num > 3)
     222       16864 :                 v->vc1dsp.vc1_v_loop_filter8(dst, s->uvlinesize, pq);
     223             :             else
     224       18176 :                 v->vc1dsp.vc1_v_loop_filter16(dst, s->linesize, pq);
     225             :     }
     226             : }
     227             : 
     228       17904 : void ff_vc1_i_loop_filter(VC1Context *v)
     229             : {
     230       17904 :     MpegEncContext *s = &v->s;
     231       17904 :     int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
     232       17904 :     int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
     233             :     uint8_t *dest, fieldtx;
     234       17904 :     uint32_t flags = 0;
     235             :     int i;
     236             : 
     237             :     /* Within a MB, the vertical loop filter always runs before the horizontal.
     238             :      * To accomplish that, we run the V loop filter on top and internal
     239             :      * horizontal borders of the last overlap filtered MB. Then, we wait for
     240             :      * the loop filter iteration on the next row to do V loop filter on the
     241             :      * bottom edge of this MB, before moving over and running the H loop
     242             :      * filter on the left and internal vertical borders. Therefore, the loop
     243             :      * filter trails by one row and one column relative to the overlap filter
     244             :      * and two rows and two colums relative to the decoding loop. */
     245       17904 :     if (!s->first_slice_line) {
     246       16472 :         dest = s->dest[0] - 16 * s->linesize - 16;
     247       16472 :         flags = s->mb_y == s->start_mb_y + 1 ? TOP_EDGE : 0;
     248       16472 :         if (s->mb_x) {
     249       15971 :             fieldtx = v->fieldtx_plane[mb_pos - s->mb_stride - 1];
     250      111797 :             for (i = 0; i < block_count; i++)
     251       95826 :                 vc1_i_v_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest, flags, fieldtx, i);
     252             :         }
     253       16472 :         if (s->mb_x == s->mb_width - 1) {
     254         501 :             dest += 16;
     255         501 :             fieldtx = v->fieldtx_plane[mb_pos - s->mb_stride];
     256        3507 :             for (i = 0; i < block_count; i++)
     257        3006 :                 vc1_i_v_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest, flags, fieldtx, i);
     258             :         }
     259             :     }
     260       17904 :     if (s->mb_y == s->end_mb_y - 1) {
     261        1432 :         dest = s->dest[0] - 16;
     262        1432 :         flags = s->first_slice_line ? TOP_EDGE | BOTTOM_EDGE : BOTTOM_EDGE;
     263        1432 :         if (s->mb_x) {
     264        1361 :             fieldtx = v->fieldtx_plane[mb_pos - 1];
     265        9527 :             for (i = 0; i < block_count; i++)
     266        8166 :                 vc1_i_v_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 : dest, flags, fieldtx, i);
     267             :         }
     268        1432 :         if (s->mb_x == s->mb_width - 1) {
     269          71 :             dest += 16;
     270          71 :             fieldtx = v->fieldtx_plane[mb_pos];
     271         497 :             for (i = 0; i < block_count; i++)
     272         426 :                 vc1_i_v_loop_filter(v, i > 3 ? s->dest[i - 3] : dest, flags, fieldtx, i);
     273             :         }
     274             :     }
     275             : 
     276       17904 :     if (s->mb_y >= s->start_mb_y + 2) {
     277       15129 :         dest = s->dest[0] - 32 * s->linesize - 16;
     278       15129 :         if (s->mb_x) {
     279       14697 :             flags = s->mb_x == 1 ? LEFT_EDGE : 0;
     280      102879 :             for (i = 0; i < block_count; i++)
     281       88182 :                 vc1_i_h_loop_filter(v, i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize - 8 : dest, flags, i);
     282             :         }
     283       15129 :         if (s->mb_x == s->mb_width - 1) {
     284         432 :             dest += 16;
     285         432 :             flags = s->mb_x == 0 ? LEFT_EDGE | RIGHT_EDGE : RIGHT_EDGE;
     286        3024 :             for (i = 0; i < block_count; i++)
     287        2592 :                 vc1_i_h_loop_filter(v, i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize : dest, flags, i);
     288             :         }
     289             :     }
     290       17904 :     if (s->mb_y == s->end_mb_y - 1) {
     291        1432 :         if (s->mb_y >= s->start_mb_y + 1) {
     292        1343 :             dest = s->dest[0] - 16 * s->linesize - 16;
     293        1343 :             if (s->mb_x) {
     294        1274 :                 flags = s->mb_x == 1 ? LEFT_EDGE : 0;
     295        8918 :                 for (i = 0; i < block_count; i++)
     296        7644 :                     vc1_i_h_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest, flags, i);
     297             :             }
     298        1343 :             if (s->mb_x == s->mb_width - 1) {
     299          69 :                 flags = s->mb_x == 0 ? LEFT_EDGE | RIGHT_EDGE : RIGHT_EDGE;
     300          69 :                 dest += 16;
     301         483 :                 for (i = 0; i < block_count; i++)
     302         414 :                     vc1_i_h_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest, flags, i);
     303             :             }
     304             :         }
     305        1432 :         dest = s->dest[0] - 16;
     306        1432 :         if (s->mb_x) {
     307        1361 :             flags = s->mb_x == 1 ? LEFT_EDGE : 0;
     308        9527 :             for (i = 0; i < block_count; i++)
     309        8166 :                 vc1_i_h_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 : dest, flags, i);
     310             :         }
     311        1432 :         if (s->mb_x == s->mb_width - 1) {
     312          71 :             dest += 16;
     313          71 :             flags = s->mb_x == 0 ? LEFT_EDGE | RIGHT_EDGE : RIGHT_EDGE;
     314         497 :             for (i = 0; i < block_count; i++)
     315         426 :                 vc1_i_h_loop_filter(v, i > 3 ? s->dest[i - 3] : dest, flags, i);
     316             :         }
     317             :     }
     318       17904 : }
     319             : 
     320      783294 : static av_always_inline void vc1_p_h_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp,
     321             :                                                  uint8_t *is_intra, int16_t (*mv)[2], uint8_t *mv_f,
     322             :                                                  int *ttblk, uint32_t flags, int block_num)
     323             : {
     324      783294 :     MpegEncContext *s  = &v->s;
     325      783294 :     int pq = v->pq;
     326      783294 :     uint32_t left_cbp = cbp[0] >> (block_num * 4), right_cbp;
     327             :     uint8_t left_is_intra, right_is_intra;
     328             :     int tt;
     329      783294 :     int idx, linesize  = block_num > 3 ? s->uvlinesize : s->linesize;
     330             :     uint8_t *dst;
     331             : 
     332      783294 :     if (block_num > 3)
     333      261098 :         dst = dest;
     334             :     else
     335      522196 :         dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) * 8;
     336             : 
     337      783294 :     if (!(flags & RIGHT_EDGE) || !(block_num & 5)) {
     338      768126 :         left_is_intra = is_intra[0] & (1 << block_num);
     339             : 
     340      768126 :         if (block_num > 3) {
     341      253514 :             right_is_intra = is_intra[1] & (1 << block_num);
     342      253514 :             right_cbp = cbp[1] >> (block_num * 4);
     343      514612 :         } else if (block_num & 1) {
     344      253514 :             right_is_intra = is_intra[1] & (1 << block_num - 1);
     345      253514 :             right_cbp = cbp[1] >> ((block_num - 1) * 4);
     346             :         } else {
     347      261098 :             right_is_intra = is_intra[0] & (1 << block_num + 1);
     348      261098 :             right_cbp = cbp[0] >> ((block_num + 1) * 4);
     349             :         }
     350             : 
     351     1262585 :         if (left_is_intra || right_is_intra ||
     352     1072097 :             mv[0][0] != mv[1][0] || mv[0][1] != mv[1][1] ||
     353      349033 :             (v->fcm == ILACE_FIELD && mv_f[0] != mv_f[1]))
     354      504015 :             v->vc1dsp.vc1_h_loop_filter8(dst + 8, linesize, pq);
     355             :         else {
     356      264111 :             idx = (left_cbp | (right_cbp >> 1)) & 5;
     357      264111 :             if (idx & 1)
     358      104079 :                 v->vc1dsp.vc1_h_loop_filter4(dst + 4 * linesize + 8, linesize, pq);
     359      264111 :             if (idx & 4)
     360      103658 :                 v->vc1dsp.vc1_h_loop_filter4(dst + 8, linesize, pq);
     361             :         }
     362             :     }
     363             : 
     364      783294 :     tt = ttblk[0] >> (block_num * 4) & 0xf;
     365      783294 :     if (tt == TT_4X4 || tt == TT_4X8) {
     366       85161 :         if (left_cbp & 3)
     367       78316 :             v->vc1dsp.vc1_h_loop_filter4(dst + 4 * linesize + 4, linesize, pq);
     368       85161 :         if (left_cbp & 12)
     369       77775 :             v->vc1dsp.vc1_h_loop_filter4(dst + 4, linesize, pq);
     370             :     }
     371      783294 : }
     372             : 
     373      783294 : static av_always_inline void vc1_p_v_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp,
     374             :                                                  uint8_t *is_intra, int16_t (*mv)[2], uint8_t *mv_f,
     375             :                                                  int *ttblk, uint32_t flags, int block_num)
     376             : {
     377      783294 :     MpegEncContext *s  = &v->s;
     378      783294 :     int pq = v->pq;
     379      783294 :     uint32_t top_cbp = cbp[0] >> (block_num * 4), bottom_cbp;
     380             :     uint8_t top_is_intra, bottom_is_intra;
     381             :     int tt;
     382      783294 :     int idx, linesize  = block_num > 3 ? s->uvlinesize : s->linesize;
     383             :     uint8_t *dst;
     384             : 
     385      783294 :     if (block_num > 3)
     386      261098 :         dst = dest;
     387             :     else
     388      522196 :         dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) * 8;
     389             : 
     390      783294 :     if(!(flags & BOTTOM_EDGE) || block_num < 2) {
     391      649330 :         top_is_intra = is_intra[0] & (1 << block_num);
     392             : 
     393      649330 :         if (block_num > 3) {
     394      194116 :             bottom_is_intra = is_intra[s->mb_stride] & (1 << block_num);
     395      194116 :             bottom_cbp = cbp[s->mb_stride] >> (block_num * 4);
     396      455214 :         } else if (block_num < 2) {
     397      261098 :             bottom_is_intra = is_intra[0] & (1 << block_num + 2);
     398      261098 :             bottom_cbp = cbp[0] >> ((block_num + 2) * 4);
     399             :         } else {
     400      194116 :             bottom_is_intra = is_intra[s->mb_stride] & (1 << block_num - 2);
     401      194116 :             bottom_cbp = cbp[s->mb_stride] >> ((block_num - 2) * 4);
     402             :         }
     403             : 
     404     1090364 :         if (top_is_intra || bottom_is_intra ||
     405      720734 :             mv[0][0] != mv[block_num > 3 ? s->mb_stride : s->b8_stride][0] ||
     406      523690 :             mv[0][1] != mv[block_num > 3 ? s->mb_stride : s->b8_stride][1] ||
     407      317720 :             (v->fcm == ILACE_FIELD && mv_f[0] != mv_f[block_num > 3 ? s->mb_stride : s->b8_stride]))
     408      411689 :             v->vc1dsp.vc1_v_loop_filter8(dst + 8 * linesize, linesize, pq);
     409             :         else {
     410      237641 :             idx = (top_cbp | (bottom_cbp >> 2)) & 3;
     411      237641 :             if (idx & 1)
     412       99049 :                 v->vc1dsp.vc1_v_loop_filter4(dst + 8 * linesize + 4, linesize, pq);
     413      237641 :             if (idx & 2)
     414       99021 :                 v->vc1dsp.vc1_v_loop_filter4(dst + 8 * linesize, linesize, pq);
     415             :         }
     416             :     }
     417             : 
     418      783294 :     tt = ttblk[0] >> (block_num * 4) & 0xf;
     419      783294 :     if (tt == TT_4X4 || tt == TT_8X4) {
     420       84736 :         if (top_cbp & 5)
     421       78324 :             v->vc1dsp.vc1_v_loop_filter4(dst + 4 * linesize + 4, linesize, pq);
     422       84736 :         if (top_cbp & 10)
     423       78360 :             v->vc1dsp.vc1_v_loop_filter4(dst + 4 * linesize, linesize, pq);
     424             :     }
     425      783294 : }
     426             : 
     427      130549 : void ff_vc1_p_loop_filter(VC1Context *v)
     428             : {
     429      130549 :     MpegEncContext *s = &v->s;
     430      130549 :     int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
     431             :     uint8_t *dest;
     432             :     uint32_t *cbp;
     433             :     uint8_t *is_intra;
     434             :     int16_t (*uvmv)[2];
     435             :     int *ttblk;
     436             :     uint32_t flags;
     437             :     int i;
     438             : 
     439             :     /* Within a MB, the vertical loop filter always runs before the horizontal.
     440             :      * To accomplish that, we run the V loop filter on all applicable
     441             :      * horizontal borders of the MB above the last overlap filtered MB. Then,
     442             :      * we wait for the next loop filter iteration to do H loop filter on all
     443             :      * applicable vertical borders of this MB. Therefore, the loop filter
     444             :      * trails by one row and one column relative to the overlap filter and two
     445             :      * rows and two colums relative to the decoding loop. */
     446      130549 :     if (s->mb_y >= s->start_mb_y + 2) {
     447       82638 :         if (s->mb_x) {
     448       80141 :             dest = s->dest[0] - 32 * s->linesize - 16;
     449       80141 :             cbp = &v->cbp[s->mb_x - 2 * s->mb_stride - 1];
     450       80141 :             is_intra = &v->is_intra[s->mb_x - 2 * s->mb_stride - 1];
     451       80141 :             uvmv = &v->luma_mv[s->mb_x - 2 * s->mb_stride - 1];
     452       80141 :             ttblk = &v->ttblk[s->mb_x - 2 * s->mb_stride - 1];
     453       80141 :             flags = s->mb_y == s->start_mb_y + 2 ? TOP_EDGE : 0;
     454      560987 :             for (i = 0; i < block_count; i++)
     455     1442538 :                 vc1_p_v_loop_filter(v,
     456      160282 :                                     i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize - 8 : dest,
     457             :                                     cbp,
     458             :                                     is_intra,
     459             :                                     i > 3 ? uvmv :
     460      320564 :                                             &s->current_picture.motion_val[0][s->block_index[i] - 4 * s->b8_stride - 2 + v->blocks_off],
     461      160282 :                                     i > 3 ? &v->mv_f[0][s->block_index[i] - 2 * s->mb_stride - 1 + v->mb_off] :
     462      320564 :                                             &v->mv_f[0][s->block_index[i] - 4 * s->b8_stride - 2 + v->blocks_off],
     463             :                                     ttblk,
     464             :                                     flags,
     465             :                                     i);
     466             :         }
     467       82638 :         if (s->mb_x == s->mb_width - 1) {
     468        2497 :             dest = s->dest[0] - 32 * s->linesize;
     469        2497 :             cbp = &v->cbp[s->mb_x - 2 * s->mb_stride];
     470        2497 :             is_intra = &v->is_intra[s->mb_x - 2 * s->mb_stride];
     471        2497 :             uvmv = &v->luma_mv[s->mb_x - 2 * s->mb_stride];
     472        2497 :             ttblk = &v->ttblk[s->mb_x - 2 * s->mb_stride];
     473        2497 :             flags = s->mb_y == s->start_mb_y + 2 ? TOP_EDGE : 0;
     474       17479 :             for (i = 0; i < block_count; i++)
     475       44946 :                 vc1_p_v_loop_filter(v,
     476        4994 :                                     i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize : dest,
     477             :                                     cbp,
     478             :                                     is_intra,
     479             :                                     i > 3 ? uvmv :
     480        9988 :                                             &s->current_picture.motion_val[0][s->block_index[i] - 4 * s->b8_stride + v->blocks_off],
     481        4994 :                                     i > 3 ? &v->mv_f[0][s->block_index[i] - 2 * s->mb_stride + v->mb_off] :
     482        9988 :                                             &v->mv_f[0][s->block_index[i] - 4 * s->b8_stride + v->blocks_off],
     483             :                                     ttblk,
     484             :                                     flags,
     485             :                                     i);
     486             :         }
     487             :     }
     488      130549 :     if (s->mb_y == s->end_mb_y - 1) {
     489       33491 :         if (s->mb_x) {
     490       32628 :             if (s->mb_y >= s->start_mb_y + 1) {
     491       13988 :                 dest = s->dest[0] - 16 * s->linesize - 16;
     492       13988 :                 cbp = &v->cbp[s->mb_x - s->mb_stride - 1];
     493       13988 :                 is_intra = &v->is_intra[s->mb_x - s->mb_stride - 1];
     494       13988 :                 uvmv = &v->luma_mv[s->mb_x - s->mb_stride - 1];
     495       13988 :                 ttblk = &v->ttblk[s->mb_x - s->mb_stride - 1];
     496       13988 :                 flags = s->mb_y == s->start_mb_y + 1 ? TOP_EDGE : 0;
     497       97916 :                 for (i = 0; i < block_count; i++)
     498      251784 :                     vc1_p_v_loop_filter(v,
     499       27976 :                                         i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest,
     500             :                                         cbp,
     501             :                                         is_intra,
     502             :                                         i > 3 ? uvmv :
     503       55952 :                                                 &s->current_picture.motion_val[0][s->block_index[i] - 2 * s->b8_stride - 2 + v->blocks_off],
     504       27976 :                                         i > 3 ? &v->mv_f[0][s->block_index[i] - s->mb_stride - 1 + v->mb_off] :
     505       55952 :                                                 &v->mv_f[0][s->block_index[i] - 2 * s->b8_stride - 2 + v->blocks_off],
     506             :                                         ttblk,
     507             :                                         flags,
     508             :                                         i);
     509             :             }
     510       32628 :             dest = s->dest[0] - 16;
     511       32628 :             cbp = &v->cbp[s->mb_x - 1];
     512       32628 :             is_intra = &v->is_intra[s->mb_x - 1];
     513       32628 :             uvmv = &v->luma_mv[s->mb_x - 1];
     514       32628 :             ttblk = &v->ttblk[s->mb_x - 1];
     515       32628 :             flags = s->mb_y == s->start_mb_y ? TOP_EDGE | BOTTOM_EDGE : BOTTOM_EDGE;
     516      228396 :             for (i = 0; i < block_count; i++)
     517      587304 :                 vc1_p_v_loop_filter(v,
     518       65256 :                                     i > 3 ? s->dest[i - 3] - 8 : dest,
     519             :                                     cbp,
     520             :                                     is_intra,
     521             :                                     i > 3 ? uvmv :
     522      130512 :                                             &s->current_picture.motion_val[0][s->block_index[i] - 2 + v->blocks_off],
     523       65256 :                                     i > 3 ? &v->mv_f[0][s->block_index[i] - 1 + v->mb_off] :
     524      130512 :                                             &v->mv_f[0][s->block_index[i] - 2 + v->blocks_off],
     525             :                                     ttblk,
     526             :                                     flags,
     527             :                                     i);
     528             :         }
     529       33491 :         if (s->mb_x == s->mb_width - 1) {
     530         863 :             if (s->mb_y >= s->start_mb_y + 1) {
     531         432 :                 dest = s->dest[0] - 16 * s->linesize;
     532         432 :                 cbp = &v->cbp[s->mb_x - s->mb_stride];
     533         432 :                 is_intra = &v->is_intra[s->mb_x - s->mb_stride];
     534         432 :                 uvmv = &v->luma_mv[s->mb_x - s->mb_stride];
     535         432 :                 ttblk = &v->ttblk[s->mb_x - s->mb_stride];
     536         432 :                 flags = s->mb_y == s->start_mb_y + 1 ? TOP_EDGE : 0;
     537        3024 :                 for (i = 0; i < block_count; i++)
     538        7776 :                     vc1_p_v_loop_filter(v,
     539         864 :                                         i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest,
     540             :                                         cbp,
     541             :                                         is_intra,
     542             :                                         i > 3 ? uvmv :
     543        1728 :                                                 &s->current_picture.motion_val[0][s->block_index[i] - 2 * s->b8_stride + v->blocks_off],
     544         864 :                                         i > 3 ? &v->mv_f[0][s->block_index[i] - s->mb_stride + v->mb_off] :
     545        1728 :                                                 &v->mv_f[0][s->block_index[i] - 2 * s->b8_stride + v->blocks_off],
     546             :                                         ttblk,
     547             :                                         flags,
     548             :                                         i);
     549             :             }
     550         863 :             dest = s->dest[0];
     551         863 :             cbp = &v->cbp[s->mb_x];
     552         863 :             is_intra = &v->is_intra[s->mb_x];
     553         863 :             uvmv = &v->luma_mv[s->mb_x];
     554         863 :             ttblk = &v->ttblk[s->mb_x];
     555         863 :             flags = s->mb_y == s->start_mb_y ? TOP_EDGE | BOTTOM_EDGE : BOTTOM_EDGE;
     556        6041 :             for (i = 0; i < block_count; i++)
     557       15534 :                 vc1_p_v_loop_filter(v,
     558        1726 :                                     i > 3 ? s->dest[i - 3] : dest,
     559             :                                     cbp,
     560             :                                     is_intra,
     561             :                                     i > 3 ? uvmv :
     562        3452 :                                             &s->current_picture.motion_val[0][s->block_index[i] + v->blocks_off],
     563        1726 :                                     i > 3 ? &v->mv_f[0][s->block_index[i] + v->mb_off] :
     564        3452 :                                             &v->mv_f[0][s->block_index[i] + v->blocks_off],
     565             :                                     ttblk,
     566             :                                     flags,
     567             :                                     i);
     568             :         }
     569             :     }
     570             : 
     571      130549 :     if (s->mb_y >= s->start_mb_y + 2) {
     572       82638 :         if (s->mb_x >= 2) {
     573       77644 :             dest = s->dest[0] - 32 * s->linesize - 32;
     574       77644 :             cbp = &v->cbp[s->mb_x - 2 * s->mb_stride - 2];
     575       77644 :             is_intra = &v->is_intra[s->mb_x - 2 * s->mb_stride - 2];
     576       77644 :             uvmv = &v->luma_mv[s->mb_x - 2 * s->mb_stride - 2];
     577       77644 :             ttblk = &v->ttblk[s->mb_x - 2 * s->mb_stride - 2];
     578       77644 :             flags = s->mb_x == 2 ? LEFT_EDGE : 0;
     579      543508 :             for (i = 0; i < block_count; i++)
     580     1397592 :                 vc1_p_h_loop_filter(v,
     581      155288 :                                     i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize - 16 : dest,
     582             :                                     cbp,
     583             :                                     is_intra,
     584             :                                     i > 3 ? uvmv :
     585      310576 :                                             &s->current_picture.motion_val[0][s->block_index[i] - 4 * s->b8_stride - 4 + v->blocks_off],
     586      155288 :                                     i > 3 ? &v->mv_f[0][s->block_index[i] - 2 * s->mb_stride - 2 + v->mb_off] :
     587      310576 :                                             &v->mv_f[0][s->block_index[i] - 4 * s->b8_stride - 4 + v->blocks_off],
     588             :                                     ttblk,
     589             :                                     flags,
     590             :                                     i);
     591             :         }
     592       82638 :         if (s->mb_x == s->mb_width - 1) {
     593        2497 :             if (s->mb_x >= 1) {
     594        2497 :                 dest = s->dest[0] - 32 * s->linesize - 16;
     595        2497 :                 cbp = &v->cbp[s->mb_x - 2 * s->mb_stride - 1];
     596        2497 :                 is_intra = &v->is_intra[s->mb_x - 2 * s->mb_stride - 1];
     597        2497 :                 uvmv = &v->luma_mv[s->mb_x - 2 * s->mb_stride - 1];
     598        2497 :                 ttblk = &v->ttblk[s->mb_x - 2 * s->mb_stride - 1];
     599        2497 :                 flags = s->mb_x == 1 ? LEFT_EDGE : 0;
     600       17479 :                 for (i = 0; i < block_count; i++)
     601       44946 :                         vc1_p_h_loop_filter(v,
     602        4994 :                                             i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize - 8 : dest,
     603             :                                             cbp,
     604             :                                             is_intra,
     605             :                                             i > 3 ? uvmv :
     606        9988 :                                                     &s->current_picture.motion_val[0][s->block_index[i] - 4 * s->b8_stride - 2 + v->blocks_off],
     607        4994 :                                             i > 3 ? &v->mv_f[0][s->block_index[i] - 2 * s->mb_stride - 1 + v->mb_off] :
     608        9988 :                                                     &v->mv_f[0][s->block_index[i] - 4 * s->b8_stride - 2 + v->blocks_off],
     609             :                                             ttblk,
     610             :                                             flags,
     611             :                                             i);
     612             :             }
     613        2497 :             dest = s->dest[0] - 32 * s->linesize;
     614        2497 :             cbp = &v->cbp[s->mb_x - 2 * s->mb_stride];
     615        2497 :             is_intra = &v->is_intra[s->mb_x - 2 * s->mb_stride];
     616        2497 :             uvmv = &v->luma_mv[s->mb_x - 2 * s->mb_stride];
     617        2497 :             ttblk = &v->ttblk[s->mb_x - 2 * s->mb_stride];
     618        2497 :             flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
     619       17479 :             for (i = 0; i < block_count; i++)
     620       44946 :                 vc1_p_h_loop_filter(v,
     621        4994 :                                     i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize : dest,
     622             :                                     cbp,
     623             :                                     is_intra,
     624             :                                     i > 3 ? uvmv :
     625        9988 :                                             &s->current_picture.motion_val[0][s->block_index[i] - 4 * s->b8_stride + v->blocks_off],
     626        4994 :                                     i > 3 ? &v->mv_f[0][s->block_index[i] - 2 * s->mb_stride + v->mb_off] :
     627        9988 :                                             &v->mv_f[0][s->block_index[i] - 4 * s->b8_stride + v->blocks_off],
     628             :                                     ttblk,
     629             :                                     flags,
     630             :                                     i);
     631             :         }
     632             :     }
     633      130549 :     if (s->mb_y == s->end_mb_y - 1) {
     634       33491 :         if (s->mb_y >= s->start_mb_y + 1) {
     635       14420 :             if (s->mb_x >= 2) {
     636       13556 :                 dest = s->dest[0] - 16 * s->linesize - 32;
     637       13556 :                 cbp = &v->cbp[s->mb_x - s->mb_stride - 2];
     638       13556 :                 is_intra = &v->is_intra[s->mb_x - s->mb_stride - 2];
     639       13556 :                 uvmv = &v->luma_mv[s->mb_x - s->mb_stride - 2];
     640       13556 :                 ttblk = &v->ttblk[s->mb_x - s->mb_stride - 2];
     641       13556 :                 flags = s->mb_x == 2 ? LEFT_EDGE : 0;
     642       94892 :                 for (i = 0; i < block_count; i++)
     643      244008 :                     vc1_p_h_loop_filter(v,
     644       27112 :                                         i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 16 : dest,
     645             :                                         cbp,
     646             :                                         is_intra,
     647             :                                         i > 3 ? uvmv :
     648       54224 :                                                 &s->current_picture.motion_val[0][s->block_index[i] - 2 * s->b8_stride - 4 + v->blocks_off],
     649       27112 :                                         i > 3 ? &v->mv_f[0][s->block_index[i] - s->mb_stride - 2 + v->mb_off] :
     650       54224 :                                                 &v->mv_f[0][s->block_index[i] - 2 * s->b8_stride - 4 + v->blocks_off],
     651             :                                         ttblk,
     652             :                                         flags,
     653             :                                         i);
     654             :             }
     655       14420 :             if (s->mb_x == s->mb_width - 1) {
     656         432 :                 if (s->mb_x >= 1) {
     657         432 :                     dest = s->dest[0] - 16 * s->linesize - 16;
     658         432 :                     cbp = &v->cbp[s->mb_x - s->mb_stride - 1];
     659         432 :                     is_intra = &v->is_intra[s->mb_x - s->mb_stride - 1];
     660         432 :                     uvmv = &v->luma_mv[s->mb_x - s->mb_stride - 1];
     661         432 :                     ttblk = &v->ttblk[s->mb_x - s->mb_stride - 1];
     662         432 :                     flags = s->mb_x == 1 ? LEFT_EDGE : 0;
     663        3024 :                     for (i = 0; i < block_count; i++)
     664        7776 :                             vc1_p_h_loop_filter(v,
     665         864 :                                                 i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest,
     666             :                                                 cbp,
     667             :                                                 is_intra,
     668             :                                                 i > 3 ? uvmv :
     669        1728 :                                                         &s->current_picture.motion_val[0][s->block_index[i] - 2 * s->b8_stride - 2 + v->blocks_off],
     670         864 :                                                 i > 3 ? &v->mv_f[0][s->block_index[i] - s->mb_stride - 1 + v->mb_off] :
     671        1728 :                                                         &v->mv_f[0][s->block_index[i] - 2 * s->b8_stride - 2 + v->blocks_off],
     672             :                                                 ttblk,
     673             :                                                 flags,
     674             :                                                 i);
     675             :                 }
     676         432 :                 dest = s->dest[0] - 16 * s->linesize;
     677         432 :                 cbp = &v->cbp[s->mb_x - s->mb_stride];
     678         432 :                 is_intra = &v->is_intra[s->mb_x - s->mb_stride];
     679         432 :                 uvmv = &v->luma_mv[s->mb_x - s->mb_stride];
     680         432 :                 ttblk = &v->ttblk[s->mb_x - s->mb_stride];
     681         432 :                 flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
     682        3024 :                 for (i = 0; i < block_count; i++)
     683        7776 :                     vc1_p_h_loop_filter(v,
     684         864 :                                         i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest,
     685             :                                         cbp,
     686             :                                         is_intra,
     687             :                                         i > 3 ? uvmv :
     688        1728 :                                                 &s->current_picture.motion_val[0][s->block_index[i] - 2 * s->b8_stride + v->blocks_off],
     689         864 :                                         i > 3 ? &v->mv_f[0][s->block_index[i] - s->mb_stride + v->mb_off] :
     690        1728 :                                                 &v->mv_f[0][s->block_index[i] - 2 * s->b8_stride + v->blocks_off],
     691             :                                         ttblk,
     692             :                                         flags,
     693             :                                         i);
     694             :             }
     695             :         }
     696       33491 :         if (s->mb_x >= 2) {
     697       31765 :             dest = s->dest[0] - 32;
     698       31765 :             cbp = &v->cbp[s->mb_x - 2];
     699       31765 :             is_intra = &v->is_intra[s->mb_x - 2];
     700       31765 :             uvmv = &v->luma_mv[s->mb_x - 2];
     701       31765 :             ttblk = &v->ttblk[s->mb_x - 2];
     702       31765 :             flags = s->mb_x == 2 ? LEFT_EDGE : 0;
     703      222355 :             for (i = 0; i < block_count; i++)
     704      571770 :                 vc1_p_h_loop_filter(v,
     705       63530 :                                     i > 3 ? s->dest[i - 3] - 16 : dest,
     706             :                                     cbp,
     707             :                                     is_intra,
     708             :                                     i > 3 ? uvmv :
     709      127060 :                                             &s->current_picture.motion_val[0][s->block_index[i] - 4 + v->blocks_off],
     710       63530 :                                     i > 3 ? &v->mv_f[0][s->block_index[i] - 2 + v->mb_off] :
     711      127060 :                                             &v->mv_f[0][s->block_index[i] - 4 + v->blocks_off],
     712             :                                     ttblk,
     713             :                                     flags,
     714             :                                     i);
     715             :         }
     716       33491 :         if (s->mb_x == s->mb_width - 1) {
     717         863 :             if (s->mb_x >= 1) {
     718         863 :                 dest = s->dest[0] - 16;
     719         863 :                 cbp = &v->cbp[s->mb_x - 1];
     720         863 :                 is_intra = &v->is_intra[s->mb_x - 1];
     721         863 :                 uvmv = &v->luma_mv[s->mb_x - 1];
     722         863 :                 ttblk = &v->ttblk[s->mb_x - 1];
     723         863 :                 flags = s->mb_x == 1 ? LEFT_EDGE : 0;
     724        6041 :                 for (i = 0; i < block_count; i++)
     725       15534 :                     vc1_p_h_loop_filter(v,
     726        1726 :                                         i > 3 ? s->dest[i - 3] - 8 : dest,
     727             :                                         cbp,
     728             :                                         is_intra,
     729             :                                         i > 3 ? uvmv :
     730        3452 :                                                 &s->current_picture.motion_val[0][s->block_index[i] - 2 + v->blocks_off],
     731        1726 :                                         i > 3 ? &v->mv_f[0][s->block_index[i] - 1 + v->mb_off] :
     732        3452 :                                                 &v->mv_f[0][s->block_index[i] - 2 + v->blocks_off],
     733             :                                         ttblk,
     734             :                                         flags,
     735             :                                         i);
     736             :             }
     737         863 :             dest = s->dest[0];
     738         863 :             cbp = &v->cbp[s->mb_x];
     739         863 :             is_intra = &v->is_intra[s->mb_x];
     740         863 :             uvmv = &v->luma_mv[s->mb_x];
     741         863 :             ttblk = &v->ttblk[s->mb_x];
     742         863 :             flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
     743        6041 :             for (i = 0; i < block_count; i++)
     744       15534 :                 vc1_p_h_loop_filter(v,
     745        1726 :                                     i > 3 ? s->dest[i - 3] : dest,
     746             :                                     cbp,
     747             :                                     is_intra,
     748             :                                     i > 3 ? uvmv :
     749        3452 :                                             &s->current_picture.motion_val[0][s->block_index[i] + v->blocks_off],
     750        1726 :                                     i > 3 ? &v->mv_f[0][s->block_index[i] + v->mb_off] :
     751        3452 :                                             &v->mv_f[0][s->block_index[i] + v->blocks_off],
     752             :                                     ttblk,
     753             :                                     flags,
     754             :                                     i);
     755             :         }
     756             :     }
     757      130549 : }
     758             : 
     759      293760 : static av_always_inline void vc1_p_h_intfr_loop_filter(VC1Context *v, uint8_t *dest, int *ttblk,
     760             :                                                        uint32_t flags, uint8_t fieldtx, int block_num)
     761             : {
     762      293760 :     MpegEncContext *s  = &v->s;
     763      293760 :     int pq = v->pq;
     764             :     int tt;
     765      293760 :     int linesize  = block_num > 3 ? s->uvlinesize : s->linesize;
     766             :     uint8_t *dst;
     767             : 
     768      293760 :     if (block_num > 3)
     769       97920 :         dst = dest;
     770             :     else
     771      195840 :         dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) * 8;
     772             : 
     773      293760 :     tt = ttblk[0] >> (block_num * 4) & 0xf;
     774      293760 :     if (block_num < 4) {
     775      195840 :         if (fieldtx) {
     776       81784 :             if (block_num < 2) {
     777       40892 :                 if (tt == TT_4X4 || tt == TT_4X8)
     778        7421 :                     v->vc1dsp.vc1_h_loop_filter8(dst + 4, 2 * linesize, pq);
     779       40892 :                 if (!(flags & RIGHT_EDGE) || block_num == 0)
     780       40722 :                     v->vc1dsp.vc1_h_loop_filter8(dst + 8, 2 * linesize, pq);
     781             :             } else {
     782       40892 :                 if (tt == TT_4X4 || tt == TT_4X8)
     783        7266 :                     v->vc1dsp.vc1_h_loop_filter8(dst - 7 * linesize + 4, 2 * linesize, pq);
     784       40892 :                 if (!(flags & RIGHT_EDGE) || block_num == 2)
     785       40722 :                     v->vc1dsp.vc1_h_loop_filter8(dst - 7 * linesize + 8, 2 * linesize, pq);
     786             :             }
     787             :         } else {
     788      114056 :             if(tt == TT_4X4 || tt == TT_4X8) {
     789       22910 :                 v->vc1dsp.vc1_h_loop_filter4(dst + 4, 2 * linesize, pq);
     790       22910 :                 v->vc1dsp.vc1_h_loop_filter4(dst + linesize + 4, 2 * linesize, pq);
     791             :             }
     792      114056 :             if (!(flags & RIGHT_EDGE) || !(block_num & 5)) {
     793      113580 :                 v->vc1dsp.vc1_h_loop_filter4(dst + 8, 2 * linesize, pq);
     794      113580 :                 v->vc1dsp.vc1_h_loop_filter4(dst + linesize + 8, 2 * linesize, pq);
     795             :             }
     796             :         }
     797             :     } else {
     798       97920 :         if (tt == TT_4X4 || tt == TT_4X8) {
     799       12278 :             v->vc1dsp.vc1_h_loop_filter4(dst + 4, 2 * linesize, pq);
     800       12278 :             v->vc1dsp.vc1_h_loop_filter4(dst + linesize + 4, 2 * linesize, pq);
     801             :         }
     802       97920 :         if (!(flags & RIGHT_EDGE)) {
     803       97104 :             v->vc1dsp.vc1_h_loop_filter4(dst + 8, 2 * linesize, pq);
     804       97104 :             v->vc1dsp.vc1_h_loop_filter4(dst + linesize + 8, 2 * linesize, pq);
     805             :         }
     806             :     }
     807      293760 : }
     808             : 
     809      293760 : static av_always_inline void vc1_p_v_intfr_loop_filter(VC1Context *v, uint8_t *dest, int *ttblk,
     810             :                                                        uint32_t flags, uint8_t fieldtx, int block_num)
     811             : {
     812      293760 :     MpegEncContext *s  = &v->s;
     813      293760 :     int pq = v->pq;
     814             :     int tt;
     815      293760 :     int linesize  = block_num > 3 ? s->uvlinesize : s->linesize;
     816             :     uint8_t *dst;
     817             : 
     818      293760 :     if (block_num > 3)
     819       97920 :         dst = dest;
     820             :     else
     821      195840 :         dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) * 8;
     822             : 
     823      293760 :     tt = ttblk[0] >> (block_num * 4) & 0xf;
     824      293760 :     if (block_num < 4) {
     825      195840 :         if (fieldtx) {
     826       81784 :             if (block_num < 2) {
     827       40892 :                 if (tt == TT_4X4 || tt == TT_8X4)
     828        7902 :                     v->vc1dsp.vc1_v_loop_filter8(dst + 8 * linesize, 2 * linesize, pq);
     829       40892 :                 if (!(flags & BOTTOM_EDGE))
     830       40500 :                     v->vc1dsp.vc1_v_loop_filter8(dst + 16 * linesize, 2 * linesize, pq);
     831             :             } else {
     832       40892 :                 if (tt == TT_4X4 || tt == TT_8X4)
     833        7576 :                     v->vc1dsp.vc1_v_loop_filter8(dst + linesize, 2 * linesize, pq);
     834       40892 :                 if (!(flags & BOTTOM_EDGE))
     835       40500 :                     v->vc1dsp.vc1_v_loop_filter8(dst + 9 * linesize, 2 * linesize, pq);
     836             :             }
     837             :         } else {
     838      114056 :             if (block_num < 2) {
     839       57028 :                 if (!(flags & TOP_EDGE) && (tt == TT_4X4 || tt == TT_8X4)) {
     840        9647 :                     v->vc1dsp.vc1_v_loop_filter8(dst + 4 * linesize, 2 * linesize, pq);
     841        9647 :                     v->vc1dsp.vc1_v_loop_filter8(dst + 5 * linesize, 2 * linesize, pq);
     842             :                 }
     843       57028 :                 v->vc1dsp.vc1_v_loop_filter8(dst + 8 * linesize, 2 * linesize, pq);
     844       57028 :                 v->vc1dsp.vc1_v_loop_filter8(dst + 9 * linesize, 2 * linesize, pq);
     845       57028 :             } else if (!(flags & BOTTOM_EDGE)) {
     846       55980 :                 if (tt == TT_4X4 || tt == TT_8X4) {
     847        9613 :                     v->vc1dsp.vc1_v_loop_filter8(dst + 4 * linesize, 2 * linesize, pq);
     848        9613 :                     v->vc1dsp.vc1_v_loop_filter8(dst + 5 * linesize, 2 * linesize, pq);
     849             :                 }
     850       55980 :                 v->vc1dsp.vc1_v_loop_filter8(dst + 8 * linesize, 2 * linesize, pq);
     851       55980 :                 v->vc1dsp.vc1_v_loop_filter8(dst + 9 * linesize, 2 * linesize, pq);
     852             :             }
     853             :         }
     854             :     } else {
     855       97920 :         if (!(flags & BOTTOM_EDGE)) {
     856       96480 :             if (!(flags & TOP_EDGE) && (tt == TT_4X4 || tt == TT_8X4)) {
     857        9701 :                 v->vc1dsp.vc1_v_loop_filter8(dst + 4 * linesize, 2 * linesize, pq);
     858        9701 :                 v->vc1dsp.vc1_v_loop_filter8(dst + 5 * linesize, 2 * linesize, pq);
     859             :             }
     860       96480 :                 v->vc1dsp.vc1_v_loop_filter8(dst + 8 * linesize, 2 * linesize, pq);
     861       96480 :                 v->vc1dsp.vc1_v_loop_filter8(dst + 9 * linesize, 2 * linesize, pq);
     862             :         }
     863             :     }
     864      293760 : }
     865             : 
     866       48960 : void ff_vc1_p_intfr_loop_filter(VC1Context *v)
     867             : {
     868       48960 :     MpegEncContext *s = &v->s;
     869       48960 :     int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
     870       48960 :     int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
     871             :     uint8_t *dest;
     872             :     int *ttblk;
     873             :     uint32_t flags;
     874             :     uint8_t fieldtx;
     875             :     int i;
     876             : 
     877             :     /* Within a MB, the vertical loop filter always runs before the horizontal.
     878             :      * To accomplish that, we run the V loop filter on all applicable
     879             :      * horizontal borders of the MB above the last overlap filtered MB. Then,
     880             :      * we wait for the loop filter iteration on the next row and next column to
     881             :      * do H loop filter on all applicable vertical borders of this MB.
     882             :      * Therefore, the loop filter trails by two rows and one column relative to
     883             :      * the overlap filter and two rows and two colums relative to the decoding
     884             :      * loop. */
     885       48960 :     if (s->mb_x) {
     886       48552 :         if (s->mb_y >= s->start_mb_y + 1) {
     887       47838 :             dest = s->dest[0] - 16 * s->linesize - 16;
     888       47838 :             ttblk = &v->ttblk[s->mb_x - s->mb_stride - 1];
     889       47838 :             flags = s->mb_y == s->start_mb_y + 1 ? TOP_EDGE : 0;
     890       47838 :             fieldtx = v->fieldtx_plane[mb_pos - s->mb_stride - 1];
     891      334866 :             for (i = 0; i < block_count; i++)
     892      382704 :                 vc1_p_v_intfr_loop_filter(v,
     893       95676 :                                           i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest,
     894             :                                           ttblk,
     895             :                                           flags,
     896             :                                           fieldtx,
     897             :                                           i);
     898             :         }
     899             :     }
     900       48960 :     if (s->mb_x == s->mb_width - 1) {
     901         408 :         if (s->mb_y >= s->start_mb_y + 1) {
     902         402 :             dest = s->dest[0] - 16 * s->linesize;
     903         402 :             ttblk = &v->ttblk[s->mb_x - s->mb_stride];
     904         402 :             flags = s->mb_y == s->start_mb_y + 1 ? TOP_EDGE : 0;
     905         402 :             fieldtx = v->fieldtx_plane[mb_pos - s->mb_stride];
     906        2814 :             for (i = 0; i < block_count; i++)
     907        3216 :                 vc1_p_v_intfr_loop_filter(v,
     908         804 :                                           i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest,
     909             :                                           ttblk,
     910             :                                           flags,
     911             :                                           fieldtx,
     912             :                                           i);
     913             :         }
     914             :     }
     915       48960 :     if (s->mb_y == s->end_mb_y - 1) {
     916         720 :         if (s->mb_x) {
     917         714 :             dest = s->dest[0] - 16;
     918         714 :             ttblk = &v->ttblk[s->mb_x - 1];
     919         714 :             flags = s->mb_y == s->start_mb_y ? TOP_EDGE | BOTTOM_EDGE : BOTTOM_EDGE;
     920         714 :             fieldtx = v->fieldtx_plane[mb_pos - 1];
     921        4998 :             for (i = 0; i < block_count; i++)
     922        5712 :                 vc1_p_v_intfr_loop_filter(v,
     923        1428 :                                           i > 3 ? s->dest[i - 3] - 8 : dest,
     924             :                                           ttblk,
     925             :                                           flags,
     926             :                                           fieldtx,
     927             :                                           i);
     928             :         }
     929         720 :         if (s->mb_x == s->mb_width - 1) {
     930           6 :             dest = s->dest[0];
     931           6 :             ttblk = &v->ttblk[s->mb_x];
     932           6 :             flags = s->mb_y == s->start_mb_y ? TOP_EDGE | BOTTOM_EDGE : BOTTOM_EDGE;
     933           6 :             fieldtx = v->fieldtx_plane[mb_pos];
     934          42 :             for (i = 0; i < block_count; i++)
     935          48 :                 vc1_p_v_intfr_loop_filter(v,
     936          12 :                                           i > 3 ? s->dest[i - 3] : dest,
     937             :                                           ttblk,
     938             :                                           flags,
     939             :                                           fieldtx,
     940             :                                           i);
     941             :         }
     942             :     }
     943             : 
     944       48960 :     if (s->mb_y >= s->start_mb_y + 2) {
     945       47520 :         if (s->mb_x >= 2) {
     946       46728 :             dest = s->dest[0] - 32 * s->linesize - 32;
     947       46728 :             ttblk = &v->ttblk[s->mb_x - 2 * s->mb_stride - 2];
     948       46728 :             flags = s->mb_x == 2 ? LEFT_EDGE : 0;
     949       46728 :             fieldtx = v->fieldtx_plane[mb_pos - 2 * s->mb_stride - 2];
     950      327096 :             for (i = 0; i < block_count; i++)
     951      373824 :                 vc1_p_h_intfr_loop_filter(v,
     952       93456 :                                           i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize - 16 : dest,
     953             :                                           ttblk,
     954             :                                           flags,
     955             :                                           fieldtx,
     956             :                                           i);
     957             :         }
     958       47520 :         if (s->mb_x == s->mb_width - 1) {
     959         396 :             if (s->mb_x >= 1) {
     960         396 :                 dest = s->dest[0] - 32 * s->linesize - 16;
     961         396 :                 ttblk = &v->ttblk[s->mb_x - 2 * s->mb_stride - 1];
     962         396 :                 flags = s->mb_x == 1 ? LEFT_EDGE : 0;
     963         396 :                 fieldtx = v->fieldtx_plane[mb_pos - 2 * s->mb_stride - 1];
     964        2772 :                 for (i = 0; i < block_count; i++)
     965        3168 :                     vc1_p_h_intfr_loop_filter(v,
     966         792 :                                               i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize - 8 : dest,
     967             :                                               ttblk,
     968             :                                               flags,
     969             :                                               fieldtx,
     970             :                                               i);
     971             :             }
     972         396 :             dest = s->dest[0] - 32 * s->linesize;
     973         396 :             ttblk = &v->ttblk[s->mb_x - 2 * s->mb_stride];
     974         396 :             flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
     975         396 :             fieldtx = v->fieldtx_plane[mb_pos - 2 * s->mb_stride];
     976        2772 :             for (i = 0; i < block_count; i++)
     977        3168 :                 vc1_p_h_intfr_loop_filter(v,
     978         792 :                                           i > 3 ? s->dest[i - 3] - 16 * s->uvlinesize : dest,
     979             :                                           ttblk,
     980             :                                           flags,
     981             :                                           fieldtx,
     982             :                                           i);
     983             :         }
     984             :     }
     985       48960 :     if (s->mb_y == s->end_mb_y - 1) {
     986         720 :         if (s->mb_y >= s->start_mb_y + 1) {
     987         720 :             if (s->mb_x >= 2) {
     988         708 :                 dest = s->dest[0] - 16 * s->linesize - 32;
     989         708 :                 ttblk = &v->ttblk[s->mb_x - s->mb_stride - 2];
     990         708 :                 flags = s->mb_x == 2 ? LEFT_EDGE : 0;
     991         708 :                 fieldtx = v->fieldtx_plane[mb_pos - s->mb_stride - 2];
     992        4956 :                 for (i = 0; i < block_count; i++)
     993        5664 :                     vc1_p_h_intfr_loop_filter(v,
     994        1416 :                                               i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 16 : dest,
     995             :                                               ttblk,
     996             :                                               flags,
     997             :                                               fieldtx,
     998             :                                               i);
     999             :             }
    1000         720 :             if (s->mb_x == s->mb_width - 1) {
    1001           6 :                 if (s->mb_x >= 1) {
    1002           6 :                     dest = s->dest[0] - 16 * s->linesize - 16;
    1003           6 :                     ttblk = &v->ttblk[s->mb_x - s->mb_stride - 1];
    1004           6 :                     flags = s->mb_x == 1 ? LEFT_EDGE : 0;
    1005           6 :                     fieldtx = v->fieldtx_plane[mb_pos - s->mb_stride - 1];
    1006          42 :                     for (i = 0; i < block_count; i++)
    1007          48 :                         vc1_p_h_intfr_loop_filter(v,
    1008          12 :                                                   i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest,
    1009             :                                                   ttblk,
    1010             :                                                   flags,
    1011             :                                                   fieldtx,
    1012             :                                                   i);
    1013             :                 }
    1014           6 :                 dest = s->dest[0] - 16 * s->linesize;
    1015           6 :                 ttblk = &v->ttblk[s->mb_x - s->mb_stride];
    1016           6 :                 flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
    1017           6 :                 fieldtx = v->fieldtx_plane[mb_pos - s->mb_stride];
    1018          42 :                 for (i = 0; i < block_count; i++)
    1019          48 :                     vc1_p_h_intfr_loop_filter(v,
    1020          12 :                                               i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest,
    1021             :                                               ttblk,
    1022             :                                               flags,
    1023             :                                               fieldtx,
    1024             :                                               i);
    1025             :             }
    1026             :         }
    1027         720 :         if (s->mb_x >= 2) {
    1028         708 :             dest = s->dest[0] - 32;
    1029         708 :             ttblk = &v->ttblk[s->mb_x - 2];
    1030         708 :             flags = s->mb_x == 2 ? LEFT_EDGE : 0;
    1031         708 :             fieldtx = v->fieldtx_plane[mb_pos - 2];
    1032        4956 :             for (i = 0; i < block_count; i++)
    1033        5664 :                 vc1_p_h_intfr_loop_filter(v,
    1034        1416 :                                           i > 3 ? s->dest[i - 3] - 16 : dest,
    1035             :                                           ttblk,
    1036             :                                           flags,
    1037             :                                           fieldtx,
    1038             :                                           i);
    1039             :         }
    1040         720 :         if (s->mb_x == s->mb_width - 1) {
    1041           6 :             if (s->mb_x >= 1) {
    1042           6 :                 dest = s->dest[0] - 16;
    1043           6 :                 ttblk = &v->ttblk[s->mb_x - 1];
    1044           6 :                 flags = s->mb_x == 1 ? LEFT_EDGE : 0;
    1045           6 :                 fieldtx = v->fieldtx_plane[mb_pos - 1];
    1046          42 :                 for (i = 0; i < block_count; i++)
    1047          48 :                     vc1_p_h_intfr_loop_filter(v,
    1048          12 :                                               i > 3 ? s->dest[i - 3] - 8 : dest,
    1049             :                                               ttblk,
    1050             :                                               flags,
    1051             :                                               fieldtx,
    1052             :                                               i);
    1053             :             }
    1054           6 :             dest = s->dest[0];
    1055           6 :             ttblk = &v->ttblk[s->mb_x];
    1056           6 :             flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
    1057           6 :             fieldtx = v->fieldtx_plane[mb_pos];
    1058          42 :             for (i = 0; i < block_count; i++)
    1059          48 :                 vc1_p_h_intfr_loop_filter(v,
    1060          12 :                                           i > 3 ? s->dest[i - 3] : dest,
    1061             :                                           ttblk,
    1062             :                                           flags,
    1063             :                                           fieldtx,
    1064             :                                           i);
    1065             :         }
    1066             :     }
    1067       48960 : }
    1068             : 
    1069      309240 : static av_always_inline void vc1_b_h_intfi_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp,
    1070             :                                                        int *ttblk, uint32_t flags, int block_num)
    1071             : {
    1072      309240 :     MpegEncContext *s  = &v->s;
    1073      309240 :     int pq = v->pq;
    1074             :     uint8_t *dst;
    1075      309240 :     uint32_t block_cbp = cbp[0] >> (block_num * 4);
    1076             :     int tt;
    1077      309240 :     int idx, linesize  = block_num > 3 ? s->uvlinesize : s->linesize;
    1078             : 
    1079      309240 :     if (block_num > 3)
    1080      103080 :         dst = dest;
    1081             :     else
    1082      206160 :         dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) * 8;
    1083             : 
    1084      309240 :     if (!(flags & RIGHT_EDGE) || !(block_num & 5)) {
    1085      306472 :         if (block_num > 3)
    1086      101696 :             v->vc1dsp.vc1_h_loop_filter8(dst + 8, linesize, pq);
    1087             :         else
    1088      204776 :             v->vc1dsp.vc1_h_loop_filter8(dst + 8, linesize, pq);
    1089             :     }
    1090             : 
    1091      309240 :     tt = ttblk[0] >> (block_num * 4) & 0xf;
    1092      309240 :     if (tt == TT_4X4 || tt == TT_4X8) {
    1093       38649 :         idx = (block_cbp | (block_cbp >> 1)) & 5;
    1094       38649 :         if (idx & 1)
    1095       34919 :             v->vc1dsp.vc1_h_loop_filter4(dst + 4 * linesize + 4, linesize, pq);
    1096       38649 :         if (idx & 4)
    1097       34510 :             v->vc1dsp.vc1_h_loop_filter4(dst + 4, linesize, pq);
    1098             :     }
    1099      309240 : }
    1100             : 
    1101      309240 : static av_always_inline void vc1_b_v_intfi_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp,
    1102             :                                                        int *ttblk, uint32_t flags, int block_num)
    1103             : {
    1104      309240 :     MpegEncContext *s  = &v->s;
    1105      309240 :     int pq = v->pq;
    1106             :     uint8_t *dst;
    1107      309240 :     uint32_t block_cbp = cbp[0] >> (block_num * 4);
    1108             :     int tt;
    1109      309240 :     int idx, linesize  = block_num > 3 ? s->uvlinesize : s->linesize;
    1110             : 
    1111      309240 :     if (block_num > 3)
    1112      103080 :         dst = dest;
    1113             :     else
    1114      206160 :         dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) * 8;
    1115             : 
    1116      309240 :     if(!(flags & BOTTOM_EDGE) || block_num < 2)
    1117      300360 :         v->vc1dsp.vc1_v_loop_filter8(dst + 8 * linesize, linesize, pq);
    1118             : 
    1119      309240 :     tt = ttblk[0] >> (block_num * 4) & 0xf;
    1120      309240 :     if (tt == TT_4X4 || tt == TT_8X4) {
    1121       38249 :         idx = (block_cbp | (block_cbp >> 2)) & 3;
    1122       38249 :         if (idx & 1)
    1123       34613 :             v->vc1dsp.vc1_v_loop_filter4(dst + 4 * linesize + 4, linesize, pq);
    1124       38249 :         if (idx & 2)
    1125       34929 :             v->vc1dsp.vc1_v_loop_filter4(dst + 4 * linesize, linesize, pq);
    1126             :     }
    1127      309240 : }
    1128             : 
    1129       51540 : void ff_vc1_b_intfi_loop_filter(VC1Context *v)
    1130             : {
    1131       51540 :     MpegEncContext *s = &v->s;
    1132       51540 :     int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
    1133             :     uint8_t *dest;
    1134             :     uint32_t *cbp;
    1135             :     int *ttblk;
    1136       51540 :     uint32_t flags = 0;
    1137             :     int i;
    1138             : 
    1139             :     /* Within a MB, the vertical loop filter always runs before the horizontal.
    1140             :      * To accomplish that, we run the V loop filter on all applicable
    1141             :      * horizontal borders of the MB above the currently decoded MB. Then,
    1142             :      * we wait for the next loop filter iteration to do H loop filter on all
    1143             :      * applicable vertical borders of this MB. Therefore, the loop filter
    1144             :      * trails by one row and one column relative to the decoding loop. */
    1145       51540 :     if (!s->first_slice_line) {
    1146       49320 :         dest = s->dest[0] - 16 * s->linesize;
    1147       49320 :         cbp = &v->cbp[s->mb_x - s->mb_stride];
    1148       49320 :         ttblk = &v->ttblk[s->mb_x - s->mb_stride];
    1149       49320 :         flags = s->mb_y == s->start_mb_y + 1 ? TOP_EDGE : 0;
    1150      345240 :         for (i = 0; i < block_count; i++)
    1151      295920 :             vc1_b_v_intfi_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest, cbp, ttblk, flags, i);
    1152             :     }
    1153       51540 :     if (s->mb_y == s->end_mb_y - 1) {
    1154        2220 :         dest = s->dest[0];
    1155        2220 :         cbp = &v->cbp[s->mb_x];
    1156        2220 :         ttblk = &v->ttblk[s->mb_x];
    1157        2220 :         flags = s->first_slice_line ? TOP_EDGE | BOTTOM_EDGE : BOTTOM_EDGE;
    1158       15540 :         for (i = 0; i < block_count; i++)
    1159       13320 :             vc1_b_v_intfi_loop_filter(v, i > 3 ? s->dest[i - 3] : dest, cbp, ttblk, flags, i);
    1160             :     }
    1161             : 
    1162       51540 :     if (!s->first_slice_line) {
    1163       49320 :         dest = s->dest[0] - 16 * s->linesize - 16;
    1164       49320 :         cbp = &v->cbp[s->mb_x - s->mb_stride - 1];
    1165       49320 :         ttblk = &v->ttblk[s->mb_x - s->mb_stride - 1];
    1166       49320 :         if (s->mb_x) {
    1167       48664 :             flags = s->mb_x == 1 ? LEFT_EDGE : 0;
    1168      340648 :             for (i = 0; i < block_count; i++)
    1169      291984 :                 vc1_b_h_intfi_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest, cbp, ttblk, flags, i);
    1170             :         }
    1171       49320 :         if (s->mb_x == s->mb_width - 1) {
    1172         656 :             dest += 16;
    1173         656 :             cbp++;
    1174         656 :             ttblk++;
    1175         656 :             flags = s->mb_x == 0 ? LEFT_EDGE | RIGHT_EDGE : RIGHT_EDGE;
    1176        4592 :             for (i = 0; i < block_count; i++)
    1177        3936 :                 vc1_b_h_intfi_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest, cbp, ttblk, flags, i);
    1178             :         }
    1179             :     }
    1180       51540 :     if (s->mb_y == s->end_mb_y - 1) {
    1181        2220 :         dest = s->dest[0] - 16;
    1182        2220 :         cbp = &v->cbp[s->mb_x - 1];
    1183        2220 :         ttblk = &v->ttblk[s->mb_x - 1];
    1184        2220 :         if (s->mb_x) {
    1185        2184 :             flags = s->mb_x == 1 ? LEFT_EDGE : 0;
    1186       15288 :             for (i = 0; i < block_count; i++)
    1187       13104 :                 vc1_b_h_intfi_loop_filter(v, i > 3 ? s->dest[i - 3] - 8 : dest, cbp, ttblk, flags, i);
    1188             :         }
    1189        2220 :         if (s->mb_x == s->mb_width - 1) {
    1190          36 :             dest += 16;
    1191          36 :             cbp++;
    1192          36 :             ttblk++;
    1193          36 :             flags = s->mb_x == 0 ? LEFT_EDGE | RIGHT_EDGE : RIGHT_EDGE;
    1194         252 :             for (i = 0; i < block_count; i++)
    1195         216 :                 vc1_b_h_intfi_loop_filter(v, i > 3 ? s->dest[i - 3] : dest, cbp, ttblk, flags, i);
    1196             :         }
    1197             :     }
    1198       51540 : }

Generated by: LCOV version 1.13