LCOV - code coverage report
Current view: top level - libavcodec - vc1_mc.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 630 707 89.1 %
Date: 2018-05-20 11:54:08 Functions: 9 11 81.8 %

          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 block decoding routines
      27             :  */
      28             : 
      29             : #include "avcodec.h"
      30             : #include "h264chroma.h"
      31             : #include "mathops.h"
      32             : #include "mpegvideo.h"
      33             : #include "vc1.h"
      34             : 
      35           0 : static av_always_inline void vc1_scale_luma(uint8_t *srcY,
      36             :                                             int k, int linesize)
      37             : {
      38             :     int i, j;
      39           0 :     for (j = 0; j < k; j++) {
      40           0 :         for (i = 0; i < k; i++)
      41           0 :             srcY[i] = ((srcY[i] - 128) >> 1) + 128;
      42           0 :         srcY += linesize;
      43             :     }
      44           0 : }
      45             : 
      46           0 : static av_always_inline void vc1_scale_chroma(uint8_t *srcU, uint8_t *srcV,
      47             :                                               int k, int uvlinesize)
      48             : {
      49             :     int i, j;
      50           0 :     for (j = 0; j < k; j++) {
      51           0 :         for (i = 0; i < k; i++) {
      52           0 :             srcU[i] = ((srcU[i] - 128) >> 1) + 128;
      53           0 :             srcV[i] = ((srcV[i] - 128) >> 1) + 128;
      54             :         }
      55           0 :         srcU += uvlinesize;
      56           0 :         srcV += uvlinesize;
      57             :     }
      58           0 : }
      59             : 
      60        3813 : static av_always_inline void vc1_lut_scale_luma(uint8_t *srcY,
      61             :                                                 uint8_t *lut1, uint8_t *lut2,
      62             :                                                 int k, int linesize)
      63             : {
      64             :     int i, j;
      65             : 
      66       37708 :     for (j = 0; j < k; j += 2) {
      67      746564 :         for (i = 0; i < k; i++)
      68      708856 :             srcY[i] = lut1[srcY[i]];
      69       37708 :         srcY += linesize;
      70             : 
      71       37708 :         if (j + 1 == k)
      72        3813 :             break;
      73             : 
      74      671148 :         for (i = 0; i < k; i++)
      75      637253 :             srcY[i] = lut2[srcY[i]];
      76       33895 :         srcY += linesize;
      77             :     }
      78        3813 : }
      79             : 
      80        3813 : static av_always_inline void vc1_lut_scale_chroma(uint8_t *srcU, uint8_t *srcV,
      81             :                                                   uint8_t *lut1, uint8_t *lut2,
      82             :                                                   int k, int uvlinesize)
      83             : {
      84             :     int i, j;
      85             : 
      86       19065 :     for (j = 0; j < k; j += 2) {
      87      190650 :         for (i = 0; i < k; i++) {
      88      171585 :             srcU[i] = lut1[srcU[i]];
      89      171585 :             srcV[i] = lut1[srcV[i]];
      90             :         }
      91       19065 :         srcU += uvlinesize;
      92       19065 :         srcV += uvlinesize;
      93             : 
      94       19065 :         if (j + 1 == k)
      95        3813 :             break;
      96             : 
      97      152520 :         for (i = 0; i < k; i++) {
      98      137268 :             srcU[i] = lut2[srcU[i]];
      99      137268 :             srcV[i] = lut2[srcV[i]];
     100             :         }
     101       15252 :         srcU += uvlinesize;
     102       15252 :         srcV += uvlinesize;
     103             :     }
     104        3813 : }
     105             : 
     106             : static const uint8_t popcount4[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
     107             : 
     108       23108 : static av_always_inline int get_luma_mv(VC1Context *v, int dir, int16_t *tx, int16_t *ty)
     109             : {
     110       23108 :     MpegEncContext *s = &v->s;
     111       69324 :     int idx = v->mv_f[dir][s->block_index[0] + v->blocks_off] |
     112       46216 :              (v->mv_f[dir][s->block_index[1] + v->blocks_off] << 1) |
     113       23108 :              (v->mv_f[dir][s->block_index[2] + v->blocks_off] << 2) |
     114       23108 :              (v->mv_f[dir][s->block_index[3] + v->blocks_off] << 3);
     115             :     static const uint8_t index2[16] = { 0, 0, 0, 0x23, 0, 0x13, 0x03, 0, 0, 0x12, 0x02, 0, 0x01, 0, 0, 0 };
     116       23108 :     int opp_count = popcount4[idx];
     117             : 
     118       23108 :     switch (opp_count) {
     119       16111 :     case 0:
     120             :     case 4:
     121       16111 :         *tx = median4(s->mv[dir][0][0], s->mv[dir][1][0], s->mv[dir][2][0], s->mv[dir][3][0]);
     122       16111 :         *ty = median4(s->mv[dir][0][1], s->mv[dir][1][1], s->mv[dir][2][1], s->mv[dir][3][1]);
     123       16111 :         break;
     124        2829 :     case 1:
     125        2829 :         *tx = mid_pred(s->mv[dir][idx < 2][0], s->mv[dir][1 + (idx < 4)][0], s->mv[dir][2 + (idx < 8)][0]);
     126        2829 :         *ty = mid_pred(s->mv[dir][idx < 2][1], s->mv[dir][1 + (idx < 4)][1], s->mv[dir][2 + (idx < 8)][1]);
     127        2829 :         break;
     128        2560 :     case 3:
     129        2560 :         *tx = mid_pred(s->mv[dir][idx > 0xd][0], s->mv[dir][1 + (idx > 0xb)][0], s->mv[dir][2 + (idx > 0x7)][0]);
     130        2560 :         *ty = mid_pred(s->mv[dir][idx > 0xd][1], s->mv[dir][1 + (idx > 0xb)][1], s->mv[dir][2 + (idx > 0x7)][1]);
     131        2560 :         break;
     132        1608 :     case 2:
     133        1608 :         *tx = (s->mv[dir][index2[idx] >> 4][0] + s->mv[dir][index2[idx] & 0xf][0]) / 2;
     134        1608 :         *ty = (s->mv[dir][index2[idx] >> 4][1] + s->mv[dir][index2[idx] & 0xf][1]) / 2;
     135        1608 :         break;
     136             :     }
     137       23108 :     return opp_count;
     138             : }
     139             : 
     140       20967 : static av_always_inline int get_chroma_mv(VC1Context *v, int dir, int16_t *tx, int16_t *ty)
     141             : {
     142       20967 :     MpegEncContext *s = &v->s;
     143       62901 :     int idx = !v->mb_type[0][s->block_index[0]] |
     144       41934 :              (!v->mb_type[0][s->block_index[1]] << 1) |
     145       20967 :              (!v->mb_type[0][s->block_index[2]] << 2) |
     146       20967 :              (!v->mb_type[0][s->block_index[3]] << 3);
     147             :     static const uint8_t index2[16] = { 0, 0, 0, 0x01, 0, 0x02, 0x12, 0, 0, 0x03, 0x13, 0, 0x23, 0, 0, 0 };
     148       20967 :     int valid_count = popcount4[idx];
     149             : 
     150       20967 :     switch (valid_count) {
     151       16868 :     case 4:
     152       16868 :         *tx = median4(s->mv[dir][0][0], s->mv[dir][1][0], s->mv[dir][2][0], s->mv[dir][3][0]);
     153       16868 :         *ty = median4(s->mv[dir][0][1], s->mv[dir][1][1], s->mv[dir][2][1], s->mv[dir][3][1]);
     154       16868 :         break;
     155        1960 :     case 3:
     156        1960 :         *tx = mid_pred(s->mv[dir][idx > 0xd][0], s->mv[dir][1 + (idx > 0xb)][0], s->mv[dir][2 + (idx > 0x7)][0]);
     157        1960 :         *ty = mid_pred(s->mv[dir][idx > 0xd][1], s->mv[dir][1 + (idx > 0xb)][1], s->mv[dir][2 + (idx > 0x7)][1]);
     158        1960 :         break;
     159        1114 :     case 2:
     160        1114 :         *tx = (s->mv[dir][index2[idx] >> 4][0] + s->mv[dir][index2[idx] & 0xf][0]) / 2;
     161        1114 :         *ty = (s->mv[dir][index2[idx] >> 4][1] + s->mv[dir][index2[idx] & 0xf][1]) / 2;
     162        1114 :         break;
     163        1025 :     default:
     164        1025 :         return 0;
     165             :     }
     166       19942 :     return valid_count;
     167             : }
     168             : 
     169             : /** Do motion compensation over 1 macroblock
     170             :  * Mostly adapted hpel_motion and qpel_motion from mpegvideo.c
     171             :  */
     172      145326 : void ff_vc1_mc_1mv(VC1Context *v, int dir)
     173             : {
     174      145326 :     MpegEncContext *s = &v->s;
     175      145326 :     H264ChromaContext *h264chroma = &v->h264chroma;
     176             :     uint8_t *srcY, *srcU, *srcV;
     177             :     int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
     178      145326 :     int v_edge_pos = s->v_edge_pos >> v->field_mode;
     179             :     int i;
     180             :     uint8_t (*luty)[256], (*lutuv)[256];
     181             :     int use_ic;
     182             : 
     183      207815 :     if ((!v->field_mode ||
     184      167025 :          (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
     185       88748 :         !v->s.last_picture.f->data[0])
     186           0 :         return;
     187             : 
     188      145326 :     mx = s->mv[dir][0][0];
     189      145326 :     my = s->mv[dir][0][1];
     190             : 
     191             :     // store motion vectors for further use in B-frames
     192      145326 :     if (s->pict_type == AV_PICTURE_TYPE_P) {
     193      410335 :         for (i = 0; i < 4; i++) {
     194      328268 :             s->current_picture.motion_val[1][s->block_index[i] + v->blocks_off][0] = mx;
     195      328268 :             s->current_picture.motion_val[1][s->block_index[i] + v->blocks_off][1] = my;
     196             :         }
     197             :     }
     198             : 
     199      145326 :     uvmx = (mx + ((mx & 3) == 3)) >> 1;
     200      145326 :     uvmy = (my + ((my & 3) == 3)) >> 1;
     201      145326 :     v->luma_mv[s->mb_x][0] = uvmx;
     202      145326 :     v->luma_mv[s->mb_x][1] = uvmy;
     203             : 
     204      207815 :     if (v->field_mode &&
     205       62489 :         v->cur_field_type != v->ref_field_type[dir]) {
     206       35969 :         my   = my   - 2 + 4 * v->cur_field_type;
     207       35969 :         uvmy = uvmy - 2 + 4 * v->cur_field_type;
     208             :     }
     209             : 
     210             :     // fastuvmc shall be ignored for interlaced frame picture
     211      145326 :     if (v->fastuvmc && (v->fcm != ILACE_FRAME)) {
     212           0 :         uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
     213           0 :         uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
     214             :     }
     215      145326 :     if (!dir) {
     216      125098 :         if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
     217       24294 :             srcY = s->current_picture.f->data[0];
     218       24294 :             srcU = s->current_picture.f->data[1];
     219       24294 :             srcV = s->current_picture.f->data[2];
     220       24294 :             luty  = v->curr_luty;
     221       24294 :             lutuv = v->curr_lutuv;
     222       24294 :             use_ic = *v->curr_use_ic;
     223             :         } else {
     224      100804 :             srcY = s->last_picture.f->data[0];
     225      100804 :             srcU = s->last_picture.f->data[1];
     226      100804 :             srcV = s->last_picture.f->data[2];
     227      100804 :             luty  = v->last_luty;
     228      100804 :             lutuv = v->last_lutuv;
     229      100804 :             use_ic = v->last_use_ic;
     230             :         }
     231             :     } else {
     232       20228 :         srcY = s->next_picture.f->data[0];
     233       20228 :         srcU = s->next_picture.f->data[1];
     234       20228 :         srcV = s->next_picture.f->data[2];
     235       20228 :         luty  = v->next_luty;
     236       20228 :         lutuv = v->next_lutuv;
     237       20228 :         use_ic = v->next_use_ic;
     238             :     }
     239             : 
     240      145326 :     if (!srcY || !srcU) {
     241           0 :         av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
     242           0 :         return;
     243             :     }
     244             : 
     245      145326 :     src_x   = s->mb_x * 16 + (mx   >> 2);
     246      145326 :     src_y   = s->mb_y * 16 + (my   >> 2);
     247      145326 :     uvsrc_x = s->mb_x *  8 + (uvmx >> 2);
     248      145326 :     uvsrc_y = s->mb_y *  8 + (uvmy >> 2);
     249             : 
     250      145326 :     if (v->profile != PROFILE_ADVANCED) {
     251       26509 :         src_x   = av_clip(  src_x, -16, s->mb_width  * 16);
     252       26509 :         src_y   = av_clip(  src_y, -16, s->mb_height * 16);
     253       26509 :         uvsrc_x = av_clip(uvsrc_x,  -8, s->mb_width  *  8);
     254       26509 :         uvsrc_y = av_clip(uvsrc_y,  -8, s->mb_height *  8);
     255             :     } else {
     256      118817 :         src_x   = av_clip(  src_x, -17, s->avctx->coded_width);
     257      118817 :         uvsrc_x = av_clip(uvsrc_x,  -8, s->avctx->coded_width  >> 1);
     258      118817 :         if (v->fcm == ILACE_FRAME) {
     259       23152 :             src_y = av_clip(src_y, -18 + (src_y & 1), s->avctx->coded_height + (src_y & 1));
     260       23152 :             uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->avctx->coded_height >> 1) + (uvsrc_y & 1));
     261             :         } else {
     262       95665 :             src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
     263       95665 :             uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
     264             :         }
     265             :     }
     266             : 
     267      145326 :     srcY += src_y   * s->linesize   + src_x;
     268      145326 :     srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
     269      145326 :     srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
     270             : 
     271      145326 :     if (v->field_mode && v->ref_field_type[dir]) {
     272       15788 :         srcY += s->current_picture_ptr->f->linesize[0];
     273       15788 :         srcU += s->current_picture_ptr->f->linesize[1];
     274       15788 :         srcV += s->current_picture_ptr->f->linesize[2];
     275             :     }
     276             : 
     277             :     /* for grayscale we should not try to read from unknown area */
     278             :     if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) {
     279             :         srcU = s->sc.edge_emu_buffer + 18 * s->linesize;
     280             :         srcV = s->sc.edge_emu_buffer + 18 * s->linesize;
     281             :     }
     282             : 
     283      145326 :     if (v->rangeredfrm || use_ic
     284      141513 :         || s->h_edge_pos < 22 || v_edge_pos < 22
     285      141513 :         || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel * 3
     286      136021 :         || (unsigned)(src_y - 1)        > v_edge_pos    - (my&3) - 16 - 3) {
     287       20871 :         uint8_t *ubuf = s->sc.edge_emu_buffer + 19 * s->linesize;
     288       20871 :         uint8_t *vbuf = ubuf + 9 * s->uvlinesize;
     289       20871 :         const int k = 17 + s->mspel * 2;
     290             : 
     291       20871 :         srcY -= s->mspel * (1 + s->linesize);
     292       20871 :         if (v->fcm == ILACE_FRAME) {
     293        1531 :             if (src_y - s->mspel & 1) {
     294        6013 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
     295             :                                          srcY,
     296         859 :                                          2 * s->linesize,
     297         859 :                                          2 * s->linesize,
     298             :                                          k,
     299         859 :                                          k + 1 >> 1,
     300         859 :                                          src_x - s->mspel,
     301         859 :                                          src_y - s->mspel >> 1,
     302             :                                          s->h_edge_pos,
     303         859 :                                          v_edge_pos + 1 >> 1);
     304        5154 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + s->linesize,
     305         859 :                                          srcY + s->linesize,
     306         859 :                                          2 * s->linesize,
     307         859 :                                          2 * s->linesize,
     308             :                                          k,
     309             :                                          k >> 1,
     310         859 :                                          src_x - s->mspel,
     311         859 :                                          src_y - s->mspel + 1 >> 1,
     312             :                                          s->h_edge_pos,
     313             :                                          v_edge_pos >> 1);
     314             :             } else {
     315        4032 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
     316             :                                          srcY,
     317         672 :                                          2 * s->linesize,
     318         672 :                                          2 * s->linesize,
     319             :                                          k,
     320         672 :                                          k + 1 >> 1,
     321         672 :                                          src_x - s->mspel,
     322         672 :                                          src_y - s->mspel >> 1,
     323             :                                          s->h_edge_pos,
     324             :                                          v_edge_pos >> 1);
     325        4704 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + s->linesize,
     326         672 :                                          srcY + s->linesize,
     327         672 :                                          2 * s->linesize,
     328         672 :                                          2 * s->linesize,
     329             :                                          k,
     330             :                                          k >> 1,
     331         672 :                                          src_x - s->mspel,
     332         672 :                                          src_y - s->mspel + 1 >> 1,
     333             :                                          s->h_edge_pos,
     334         672 :                                          v_edge_pos + 1 >> 1);
     335             :             }
     336             :         } else
     337       58020 :             s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcY,
     338             :                                      s->linesize, s->linesize,
     339             :                                      k, k,
     340       38680 :                                      src_x - s->mspel, src_y - s->mspel,
     341             :                                      s->h_edge_pos, v_edge_pos);
     342       20871 :         srcY = s->sc.edge_emu_buffer;
     343       20871 :         if (v->fcm == ILACE_FRAME) {
     344        1531 :             if (uvsrc_y & 1) {
     345        3290 :                 s->vdsp.emulated_edge_mc(ubuf, srcU,
     346        1316 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
     347             :                                          8 + 1, 5,
     348             :                                          uvsrc_x, uvsrc_y >> 1,
     349        1316 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) + 1 >> 1);
     350        3290 :                 s->vdsp.emulated_edge_mc(ubuf + s->uvlinesize, srcU + s->uvlinesize,
     351        1316 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
     352             :                                          8 + 1, 4,
     353         658 :                                          uvsrc_x, uvsrc_y + 1 >> 1,
     354         658 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) >> 1);
     355        3290 :                 s->vdsp.emulated_edge_mc(vbuf, srcV,
     356        1316 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
     357             :                                          8 + 1, 5,
     358             :                                          uvsrc_x, uvsrc_y >> 1,
     359        1316 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) + 1 >> 1);
     360        3290 :                 s->vdsp.emulated_edge_mc(vbuf + s->uvlinesize, srcV + s->uvlinesize,
     361        1316 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
     362             :                                          8 + 1, 4,
     363         658 :                                          uvsrc_x, uvsrc_y + 1 >> 1,
     364         658 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) >> 1);
     365             :             } else {
     366        3492 :                 s->vdsp.emulated_edge_mc(ubuf, srcU,
     367        1746 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
     368             :                                          8 + 1, 5,
     369             :                                          uvsrc_x, uvsrc_y >> 1,
     370         873 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) >> 1);
     371        5238 :                 s->vdsp.emulated_edge_mc(ubuf + s->uvlinesize, srcU + s->uvlinesize,
     372        1746 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
     373             :                                          8 + 1, 4,
     374         873 :                                          uvsrc_x, uvsrc_y + 1 >> 1,
     375        1746 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) + 1 >> 1);
     376        3492 :                 s->vdsp.emulated_edge_mc(vbuf, srcV,
     377        1746 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
     378             :                                          8 + 1, 5,
     379             :                                          uvsrc_x, uvsrc_y >> 1,
     380         873 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) >> 1);
     381        5238 :                 s->vdsp.emulated_edge_mc(vbuf + s->uvlinesize, srcV + s->uvlinesize,
     382        1746 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
     383             :                                          8 + 1, 4,
     384         873 :                                          uvsrc_x, uvsrc_y + 1 >> 1,
     385        1746 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) + 1 >> 1);
     386             :             }
     387             :         } else {
     388       38680 :             s->vdsp.emulated_edge_mc(ubuf, srcU,
     389             :                                      s->uvlinesize, s->uvlinesize,
     390             :                                      8 + 1, 8 + 1,
     391             :                                      uvsrc_x, uvsrc_y,
     392       19340 :                                      s->h_edge_pos >> 1, v_edge_pos >> 1);
     393       38680 :             s->vdsp.emulated_edge_mc(vbuf, srcV,
     394             :                                      s->uvlinesize, s->uvlinesize,
     395             :                                      8 + 1, 8 + 1,
     396             :                                      uvsrc_x, uvsrc_y,
     397       19340 :                                      s->h_edge_pos >> 1, v_edge_pos >> 1);
     398             :         }
     399       20871 :         srcU = ubuf;
     400       20871 :         srcV = vbuf;
     401             :         /* if we deal with range reduction we need to scale source blocks */
     402       20871 :         if (v->rangeredfrm) {
     403           0 :             vc1_scale_luma(srcY, k, s->linesize);
     404           0 :             vc1_scale_chroma(srcU, srcV, 9, s->uvlinesize);
     405             :         }
     406             :         /* if we deal with intensity compensation we need to scale source blocks */
     407       20871 :         if (use_ic) {
     408        7626 :             vc1_lut_scale_luma(srcY,
     409        3813 :                                luty[v->field_mode ? v->ref_field_type[dir] : ((0 + src_y - s->mspel) & 1)],
     410        3813 :                                luty[v->field_mode ? v->ref_field_type[dir] : ((1 + src_y - s->mspel) & 1)],
     411        3813 :                                k, s->linesize);
     412        7626 :             vc1_lut_scale_chroma(srcU, srcV,
     413        3813 :                                  lutuv[v->field_mode ? v->ref_field_type[dir] : ((0 + uvsrc_y) & 1)],
     414        3813 :                                  lutuv[v->field_mode ? v->ref_field_type[dir] : ((1 + uvsrc_y) & 1)],
     415        3813 :                                  9, s->uvlinesize);
     416             :         }
     417       20871 :         srcY += s->mspel * (1 + s->linesize);
     418             :     }
     419             : 
     420      145326 :     if (s->mspel) {
     421       98958 :         dxy = ((my & 3) << 2) | (mx & 3);
     422       98958 :         v->vc1dsp.put_vc1_mspel_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, v->rnd);
     423             :     } else { // hpel mc - always used for luma
     424       46368 :         dxy = (my & 2) | ((mx & 2) >> 1);
     425       46368 :         if (!v->rnd)
     426       16435 :             s->hdsp.put_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
     427             :         else
     428       29933 :             s->hdsp.put_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
     429             :     }
     430             : 
     431             :     if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
     432             :         return;
     433             :     /* Chroma MC always uses qpel bilinear */
     434      145326 :     uvmx = (uvmx & 3) << 1;
     435      145326 :     uvmy = (uvmy & 3) << 1;
     436      145326 :     if (!v->rnd) {
     437       73237 :         h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
     438       73237 :         h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
     439             :     } else {
     440       72089 :         v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
     441       72089 :         v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
     442             :     }
     443      145326 :     if (v->field_mode) {
     444       62489 :         v->mv_f[dir][s->block_index[4] + v->mb_off] = v->cur_field_type != v->ref_field_type[dir];
     445       62489 :         v->mv_f[dir][s->block_index[5] + v->mb_off] = v->cur_field_type != v->ref_field_type[dir];
     446             :     }
     447             : }
     448             : 
     449             : /** Do motion compensation for 4-MV macroblock - luminance block
     450             :  */
     451      257598 : void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
     452             : {
     453      257598 :     MpegEncContext *s = &v->s;
     454             :     uint8_t *srcY;
     455             :     int dxy, mx, my, src_x, src_y;
     456             :     int off;
     457      257598 :     int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0;
     458      257598 :     int v_edge_pos = s->v_edge_pos >> v->field_mode;
     459             :     uint8_t (*luty)[256];
     460             :     int use_ic;
     461             : 
     462      322630 :     if ((!v->field_mode ||
     463      295058 :          (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
     464      205208 :         !v->s.last_picture.f->data[0])
     465           0 :         return;
     466             : 
     467      257598 :     mx = s->mv[dir][n][0];
     468      257598 :     my = s->mv[dir][n][1];
     469             : 
     470      257598 :     if (!dir) {
     471      200824 :         if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
     472       18181 :             srcY = s->current_picture.f->data[0];
     473       18181 :             luty = v->curr_luty;
     474       18181 :             use_ic = *v->curr_use_ic;
     475             :         } else {
     476      182643 :             srcY = s->last_picture.f->data[0];
     477      182643 :             luty = v->last_luty;
     478      182643 :             use_ic = v->last_use_ic;
     479             :         }
     480             :     } else {
     481       56774 :         srcY = s->next_picture.f->data[0];
     482       56774 :         luty = v->next_luty;
     483       56774 :         use_ic = v->next_use_ic;
     484             :     }
     485             : 
     486      257598 :     if (!srcY) {
     487           0 :         av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
     488           0 :         return;
     489             :     }
     490             : 
     491      257598 :     if (v->field_mode) {
     492       65032 :         if (v->cur_field_type != v->ref_field_type[dir])
     493       32438 :             my = my - 2 + 4 * v->cur_field_type;
     494             :     }
     495             : 
     496      257598 :     if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) {
     497       13700 :         int opp_count = get_luma_mv(v, 0,
     498        6850 :                                     &s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0],
     499        6850 :                                     &s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1]);
     500        6850 :         int k, f = opp_count > 2;
     501       34250 :         for (k = 0; k < 4; k++)
     502       27400 :             v->mv_f[1][s->block_index[k] + v->blocks_off] = f;
     503             :     }
     504             : 
     505      257598 :     if (v->fcm == ILACE_FRAME) {  // not sure if needed for other types of picture
     506             :         int qx, qy;
     507      116452 :         int width  = s->avctx->coded_width;
     508      116452 :         int height = s->avctx->coded_height >> 1;
     509      116452 :         if (s->pict_type == AV_PICTURE_TYPE_P) {
     510       26340 :             s->current_picture.motion_val[1][s->block_index[n] + v->blocks_off][0] = mx;
     511       26340 :             s->current_picture.motion_val[1][s->block_index[n] + v->blocks_off][1] = my;
     512             :         }
     513      116452 :         qx = (s->mb_x * 16) + (mx >> 2);
     514      116452 :         qy = (s->mb_y *  8) + (my >> 3);
     515             : 
     516      116452 :         if (qx < -17)
     517         244 :             mx -= 4 * (qx + 17);
     518      116208 :         else if (qx > width)
     519         704 :             mx -= 4 * (qx - width);
     520      116452 :         if (qy < -18)
     521          20 :             my -= 8 * (qy + 18);
     522      116432 :         else if (qy > height + 1)
     523         443 :             my -= 8 * (qy - height - 1);
     524             :     }
     525             : 
     526      257598 :     if ((v->fcm == ILACE_FRAME) && fieldmv)
     527      113636 :         off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8;
     528             :     else
     529      143962 :         off = s->linesize * 4 * (n & 2) + (n & 1) * 8;
     530             : 
     531      257598 :     src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2);
     532      257598 :     if (!fieldmv)
     533      143962 :         src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2);
     534             :     else
     535      113636 :         src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
     536             : 
     537      257598 :     if (v->profile != PROFILE_ADVANCED) {
     538           0 :         src_x = av_clip(src_x, -16, s->mb_width  * 16);
     539           0 :         src_y = av_clip(src_y, -16, s->mb_height * 16);
     540             :     } else {
     541      257598 :         src_x = av_clip(src_x, -17, s->avctx->coded_width);
     542      257598 :         if (v->fcm == ILACE_FRAME)
     543      116452 :             src_y = av_clip(src_y, -18 + (src_y & 1), s->avctx->coded_height + (src_y & 1));
     544             :         else
     545      141146 :             src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
     546             :     }
     547             : 
     548      257598 :     srcY += src_y * s->linesize + src_x;
     549      257598 :     if (v->field_mode && v->ref_field_type[dir])
     550       24818 :         srcY += s->current_picture_ptr->f->linesize[0];
     551             : 
     552      257598 :     if (v->rangeredfrm || use_ic
     553      257598 :         || s->h_edge_pos < 13 || v_edge_pos < 23
     554      257598 :         || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2
     555      251828 :         || (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) {
     556       15681 :         const int k = 9 + s->mspel * 2;
     557             : 
     558       15681 :         srcY -= s->mspel * (1 + (s->linesize << fieldmv));
     559             :         /* check emulate edge stride and offset */
     560       15681 :         if (v->fcm == ILACE_FRAME) {
     561        5922 :             if (src_y - (s->mspel << fieldmv) & 1) {
     562       21574 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcY,
     563        6164 :                                          2 * s->linesize, 2 * s->linesize,
     564        3082 :                                          k, (k << fieldmv) + 1 >> 1,
     565        6164 :                                          src_x - s->mspel, src_y - (s->mspel << fieldmv) >> 1,
     566        3082 :                                          s->h_edge_pos, v_edge_pos + 1 >> 1);
     567       18492 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + s->linesize, srcY + s->linesize,
     568        6164 :                                          2 * s->linesize, 2 * s->linesize,
     569        3082 :                                          k, (k << fieldmv) >> 1,
     570        6164 :                                          src_x - s->mspel, src_y - (s->mspel << fieldmv) + 1 >> 1,
     571             :                                          s->h_edge_pos, v_edge_pos >> 1);
     572             :             } else {
     573       17040 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcY,
     574        5680 :                                          2 * s->linesize, 2 * s->linesize,
     575        2840 :                                          k, (k << fieldmv) + 1 >> 1,
     576        5680 :                                          src_x - s->mspel, src_y - (s->mspel << fieldmv) >> 1,
     577             :                                          s->h_edge_pos, v_edge_pos >> 1);
     578       19880 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + s->linesize, srcY + s->linesize,
     579        5680 :                                          2 * s->linesize, 2 * s->linesize,
     580        2840 :                                          k, (k << fieldmv) >> 1,
     581        5680 :                                          src_x - s->mspel, src_y - (s->mspel << fieldmv) + 1 >> 1,
     582        2840 :                                          s->h_edge_pos, v_edge_pos + 1 >> 1);
     583             :             }
     584             :         } else
     585       29277 :             s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcY,
     586             :                                      s->linesize, s->linesize,
     587             :                                      k, k,
     588       19518 :                                      src_x - s->mspel, src_y - s->mspel,
     589             :                                      s->h_edge_pos, v_edge_pos);
     590       15681 :         srcY = s->sc.edge_emu_buffer;
     591             :         /* if we deal with range reduction we need to scale source blocks */
     592       15681 :         if (v->rangeredfrm) {
     593           0 :             vc1_scale_luma(srcY, k, s->linesize << fieldmv);
     594             :         }
     595             :         /* if we deal with intensity compensation we need to scale source blocks */
     596       15681 :         if (use_ic) {
     597           0 :             vc1_lut_scale_luma(srcY,
     598           0 :                                luty[v->field_mode ? v->ref_field_type[dir] : (((0<<fieldmv)+src_y - (s->mspel << fieldmv)) & 1)],
     599           0 :                                luty[v->field_mode ? v->ref_field_type[dir] : (((1<<fieldmv)+src_y - (s->mspel << fieldmv)) & 1)],
     600           0 :                                k, s->linesize << fieldmv);
     601             :         }
     602       15681 :         srcY += s->mspel * (1 + (s->linesize << fieldmv));
     603             :     }
     604             : 
     605      257598 :     if (s->mspel) {
     606      257598 :         dxy = ((my & 3) << 2) | (mx & 3);
     607      257598 :         if (avg)
     608       20328 :             v->vc1dsp.avg_vc1_mspel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
     609             :         else
     610      237270 :             v->vc1dsp.put_vc1_mspel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
     611             :     } else { // hpel mc - always used for luma
     612           0 :         dxy = (my & 2) | ((mx & 2) >> 1);
     613           0 :         if (!v->rnd)
     614           0 :             s->hdsp.put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
     615             :         else
     616           0 :             s->hdsp.put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
     617             :     }
     618             : }
     619             : 
     620             : /** Do motion compensation for 4-MV macroblock - both chroma blocks
     621             :  */
     622       37225 : void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir)
     623             : {
     624       37225 :     MpegEncContext *s = &v->s;
     625       37225 :     H264ChromaContext *h264chroma = &v->h264chroma;
     626             :     uint8_t *srcU, *srcV;
     627             :     int uvmx, uvmy, uvsrc_x, uvsrc_y;
     628             :     int16_t tx, ty;
     629             :     int chroma_ref_type;
     630       37225 :     int v_edge_pos = s->v_edge_pos >> v->field_mode;
     631             :     uint8_t (*lutuv)[256];
     632             :     int use_ic;
     633             : 
     634       37225 :     if (!v->field_mode && !v->s.last_picture.f->data[0])
     635        1025 :         return;
     636             :     if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
     637             :         return;
     638             : 
     639             :     /* calculate chroma MV vector from four luma MVs */
     640       57167 :     if (!v->field_mode || !v->numref) {
     641       20967 :         int valid_count = get_chroma_mv(v, dir, &tx, &ty);
     642       20967 :         if (!valid_count) {
     643        1025 :             s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
     644        1025 :             s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
     645        1025 :             v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
     646        1025 :             return; //no need to do MC for intra blocks
     647             :         }
     648       19942 :         chroma_ref_type = v->ref_field_type[dir];
     649             :     } else {
     650       16258 :         int opp_count = get_luma_mv(v, dir, &tx, &ty);
     651       16258 :         chroma_ref_type = v->cur_field_type ^ (opp_count > 2);
     652             :     }
     653       36200 :     if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f->data[0])
     654           0 :         return;
     655       36200 :     s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
     656       36200 :     s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
     657       36200 :     uvmx = (tx + ((tx & 3) == 3)) >> 1;
     658       36200 :     uvmy = (ty + ((ty & 3) == 3)) >> 1;
     659             : 
     660       36200 :     v->luma_mv[s->mb_x][0] = uvmx;
     661       36200 :     v->luma_mv[s->mb_x][1] = uvmy;
     662             : 
     663       36200 :     if (v->fastuvmc) {
     664           0 :         uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
     665           0 :         uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
     666             :     }
     667             :     // Field conversion bias
     668       36200 :     if (v->cur_field_type != chroma_ref_type)
     669        7493 :         uvmy += 2 - 4 * chroma_ref_type;
     670             : 
     671       36200 :     uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
     672       36200 :     uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
     673             : 
     674       36200 :     if (v->profile != PROFILE_ADVANCED) {
     675           0 :         uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width  * 8);
     676           0 :         uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
     677             :     } else {
     678       36200 :         uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width  >> 1);
     679       36200 :         uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
     680             :     }
     681             : 
     682       36200 :     if (!dir) {
     683       31684 :         if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) {
     684        4366 :             srcU = s->current_picture.f->data[1];
     685        4366 :             srcV = s->current_picture.f->data[2];
     686        4366 :             lutuv = v->curr_lutuv;
     687        4366 :             use_ic = *v->curr_use_ic;
     688             :         } else {
     689       27318 :             srcU = s->last_picture.f->data[1];
     690       27318 :             srcV = s->last_picture.f->data[2];
     691       27318 :             lutuv = v->last_lutuv;
     692       27318 :             use_ic = v->last_use_ic;
     693             :         }
     694             :     } else {
     695        4516 :         srcU = s->next_picture.f->data[1];
     696        4516 :         srcV = s->next_picture.f->data[2];
     697        4516 :         lutuv = v->next_lutuv;
     698        4516 :         use_ic = v->next_use_ic;
     699             :     }
     700             : 
     701       36200 :     if (!srcU) {
     702           0 :         av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
     703           0 :         return;
     704             :     }
     705             : 
     706       36200 :     srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
     707       36200 :     srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
     708             : 
     709       36200 :     if (v->field_mode) {
     710       16258 :         if (chroma_ref_type) {
     711        6083 :             srcU += s->current_picture_ptr->f->linesize[1];
     712        6083 :             srcV += s->current_picture_ptr->f->linesize[2];
     713             :         }
     714             :     }
     715             : 
     716       36200 :     if (v->rangeredfrm || use_ic
     717       36200 :         || s->h_edge_pos < 18 || v_edge_pos < 18
     718       36200 :         || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
     719       35332 :         || (unsigned)uvsrc_y > (v_edge_pos    >> 1) - 9) {
     720        5486 :         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcU,
     721             :                                  s->uvlinesize, s->uvlinesize,
     722             :                                  8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
     723        2743 :                                  s->h_edge_pos >> 1, v_edge_pos >> 1);
     724        5486 :         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16, srcV,
     725             :                                  s->uvlinesize, s->uvlinesize,
     726             :                                  8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
     727        2743 :                                  s->h_edge_pos >> 1, v_edge_pos >> 1);
     728        2743 :         srcU = s->sc.edge_emu_buffer;
     729        2743 :         srcV = s->sc.edge_emu_buffer + 16;
     730             : 
     731             :         /* if we deal with range reduction we need to scale source blocks */
     732        2743 :         if (v->rangeredfrm) {
     733           0 :             vc1_scale_chroma(srcU, srcV, 9, s->uvlinesize);
     734             :         }
     735             :         /* if we deal with intensity compensation we need to scale source blocks */
     736        2743 :         if (use_ic) {
     737           0 :             vc1_lut_scale_chroma(srcU, srcV,
     738           0 :                                  lutuv[v->field_mode ? chroma_ref_type : ((0 + uvsrc_y) & 1)],
     739           0 :                                  lutuv[v->field_mode ? chroma_ref_type : ((1 + uvsrc_y) & 1)],
     740           0 :                                  9, s->uvlinesize);
     741             :         }
     742             :     }
     743             : 
     744             :     /* Chroma MC always uses qpel bilinear */
     745       36200 :     uvmx = (uvmx & 3) << 1;
     746       36200 :     uvmy = (uvmy & 3) << 1;
     747       36200 :     if (!v->rnd) {
     748       19496 :         h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
     749       19496 :         h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
     750             :     } else {
     751       16704 :         v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
     752       16704 :         v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
     753             :     }
     754       36200 :     if (v->field_mode) {
     755       16258 :         v->mv_f[dir][s->block_index[4] + v->mb_off] = v->cur_field_type != chroma_ref_type;
     756       16258 :         v->mv_f[dir][s->block_index[5] + v->mb_off] = v->cur_field_type != chroma_ref_type;
     757             :     }
     758             : }
     759             : 
     760             : /** Do motion compensation for 4-MV interlaced frame chroma macroblock (both U and V)
     761             :  */
     762       29113 : void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
     763             : {
     764       29113 :     MpegEncContext *s = &v->s;
     765       29113 :     H264ChromaContext *h264chroma = &v->h264chroma;
     766             :     uint8_t *srcU, *srcV;
     767             :     int uvsrc_x, uvsrc_y;
     768             :     int uvmx_field[4], uvmy_field[4];
     769             :     int i, off, tx, ty;
     770       29113 :     int fieldmv = v->blk_mv_type[s->block_index[0]];
     771             :     static const uint8_t s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
     772       29113 :     int v_dist = fieldmv ? 1 : 4; // vertical offset for lower sub-blocks
     773       29113 :     int v_edge_pos = s->v_edge_pos >> 1;
     774             :     int use_ic;
     775             :     uint8_t (*lutuv)[256];
     776             : 
     777             :     if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
     778           0 :         return;
     779             : 
     780      145565 :     for (i = 0; i < 4; i++) {
     781      116452 :         int d = i < 2 ? dir: dir2;
     782      116452 :         tx = s->mv[d][i][0];
     783      116452 :         uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
     784      116452 :         ty = s->mv[d][i][1];
     785      116452 :         if (fieldmv)
     786      113636 :             uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
     787             :         else
     788        2816 :             uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
     789             :     }
     790             : 
     791      145565 :     for (i = 0; i < 4; i++) {
     792      116452 :         off = (i & 1) * 4 + ((i & 2) ? v_dist * s->uvlinesize : 0);
     793      116452 :         uvsrc_x = s->mb_x * 8 +  (i & 1) * 4           + (uvmx_field[i] >> 2);
     794      116452 :         uvsrc_y = s->mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
     795             :         // FIXME: implement proper pull-back (see vc1cropmv.c, vc1CROPMV_ChromaPullBack())
     796      116452 :         uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width  >> 1);
     797      116452 :         if (v->fcm == ILACE_FRAME)
     798      116452 :             uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->avctx->coded_height >> 1) + (uvsrc_y & 1));
     799             :         else
     800           0 :             uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
     801      116452 :         if (i < 2 ? dir : dir2) {
     802       38710 :             srcU = s->next_picture.f->data[1];
     803       38710 :             srcV = s->next_picture.f->data[2];
     804       38710 :             lutuv  = v->next_lutuv;
     805       38710 :             use_ic = v->next_use_ic;
     806             :         } else {
     807       77742 :             srcU = s->last_picture.f->data[1];
     808       77742 :             srcV = s->last_picture.f->data[2];
     809       77742 :             lutuv  = v->last_lutuv;
     810       77742 :             use_ic = v->last_use_ic;
     811             :         }
     812      116452 :         if (!srcU)
     813           0 :             return;
     814      116452 :         srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
     815      116452 :         srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
     816      116452 :         uvmx_field[i] = (uvmx_field[i] & 3) << 1;
     817      116452 :         uvmy_field[i] = (uvmy_field[i] & 3) << 1;
     818             : 
     819      116452 :         if (use_ic
     820      116452 :             || s->h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
     821      116452 :             || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5
     822      113912 :             || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
     823        5427 :             if (v->fcm == ILACE_FRAME) {
     824        5427 :                 if (uvsrc_y & 1) {
     825       17004 :                     s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcU,
     826        5668 :                                              2 * s->uvlinesize, 2 * s->uvlinesize,
     827        2834 :                                              5, (5 << fieldmv) + 1 >> 1, uvsrc_x, uvsrc_y >> 1,
     828        5668 :                                              s->h_edge_pos >> 1, v_edge_pos + 1 >> 1);
     829       17004 :                     s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + s->uvlinesize, srcU + s->uvlinesize,
     830        5668 :                                              2 * s->uvlinesize, 2 * s->uvlinesize,
     831        5668 :                                              5, (5 << fieldmv) >> 1, uvsrc_x, uvsrc_y + 1 >> 1,
     832        2834 :                                              s->h_edge_pos >> 1, v_edge_pos >> 1);
     833       17004 :                     s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16, srcV,
     834        5668 :                                              2 * s->uvlinesize, 2 * s->uvlinesize,
     835        2834 :                                              5, (5 << fieldmv) + 1 >> 1, uvsrc_x, uvsrc_y >> 1,
     836        5668 :                                              s->h_edge_pos >> 1, v_edge_pos + 1 >> 1);
     837       17004 :                     s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16 + s->uvlinesize, srcV + s->uvlinesize,
     838        5668 :                                              2 * s->uvlinesize, 2 * s->uvlinesize,
     839        5668 :                                              5, (5 << fieldmv) >> 1, uvsrc_x, uvsrc_y + 1 >> 1,
     840        2834 :                                              s->h_edge_pos >> 1, v_edge_pos >> 1);
     841             :                 } else {
     842       12965 :                     s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcU,
     843        5186 :                                              2 * s->uvlinesize, 2 * s->uvlinesize,
     844        2593 :                                              5, (5 << fieldmv) + 1 >> 1, uvsrc_x, uvsrc_y >> 1,
     845        2593 :                                              s->h_edge_pos >> 1, v_edge_pos >> 1);
     846       18151 :                     s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + s->uvlinesize, srcU + s->uvlinesize,
     847        5186 :                                              2 * s->uvlinesize, 2 * s->uvlinesize,
     848        5186 :                                              5, (5 << fieldmv) >> 1, uvsrc_x, uvsrc_y + 1 >> 1,
     849        5186 :                                              s->h_edge_pos >> 1, v_edge_pos + 1 >> 1);
     850       12965 :                     s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16, srcV,
     851        5186 :                                              2 * s->uvlinesize, 2 * s->uvlinesize,
     852        2593 :                                              5, (5 << fieldmv) + 1 >> 1, uvsrc_x, uvsrc_y >> 1,
     853        2593 :                                              s->h_edge_pos >> 1, v_edge_pos >> 1);
     854       18151 :                     s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16 + s->uvlinesize, srcV + s->uvlinesize,
     855        5186 :                                              2 * s->uvlinesize, 2 * s->uvlinesize,
     856        5186 :                                              5, (5 << fieldmv) + 1, uvsrc_x, uvsrc_y + 1 >> 1,
     857        5186 :                                              s->h_edge_pos >> 1, v_edge_pos + 1 >> 1);
     858             :                 }
     859             :             } else {
     860           0 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcU,
     861             :                                          s->uvlinesize, s->uvlinesize,
     862             :                                          5, 5, uvsrc_x, uvsrc_y,
     863           0 :                                          s->h_edge_pos >> 1, v_edge_pos);
     864           0 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16, srcV,
     865             :                                          s->uvlinesize, s->uvlinesize,
     866             :                                          5, 5, uvsrc_x, uvsrc_y,
     867           0 :                                          s->h_edge_pos >> 1, v_edge_pos);
     868             :             }
     869        5427 :             srcU = s->sc.edge_emu_buffer;
     870        5427 :             srcV = s->sc.edge_emu_buffer + 16;
     871             : 
     872             :             /* if we deal with intensity compensation we need to scale source blocks */
     873        5427 :             if (use_ic) {
     874           0 :                 vc1_lut_scale_chroma(srcU, srcV,
     875           0 :                                      lutuv[(uvsrc_y + (0 << fieldmv)) & 1],
     876           0 :                                      lutuv[(uvsrc_y + (1 << fieldmv)) & 1],
     877           0 :                                      5, s->uvlinesize << fieldmv);
     878             :             }
     879             :         }
     880      116452 :         if (avg) {
     881       20328 :             if (!v->rnd) {
     882       10832 :                 h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
     883       10832 :                 h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
     884             :             } else {
     885        9496 :                 v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
     886        9496 :                 v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
     887             :             }
     888             :         } else {
     889       96124 :             if (!v->rnd) {
     890       53028 :                 h264chroma->put_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
     891       53028 :                 h264chroma->put_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
     892             :             } else {
     893       43096 :                 v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
     894       43096 :                 v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
     895             :             }
     896             :         }
     897             :     }
     898             : }
     899             : 
     900             : /** Motion compensation for direct or interpolated blocks in B-frames
     901             :  */
     902       23100 : void ff_vc1_interp_mc(VC1Context *v)
     903             : {
     904       23100 :     MpegEncContext *s = &v->s;
     905       23100 :     H264ChromaContext *h264chroma = &v->h264chroma;
     906             :     uint8_t *srcY, *srcU, *srcV;
     907             :     int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
     908       23100 :     int v_edge_pos = s->v_edge_pos >> v->field_mode;
     909       23100 :     int use_ic = v->next_use_ic;
     910             : 
     911       23100 :     if (!v->field_mode && !v->s.next_picture.f->data[0])
     912           0 :         return;
     913             : 
     914       23100 :     mx   = s->mv[1][0][0];
     915       23100 :     my   = s->mv[1][0][1];
     916       23100 :     uvmx = (mx + ((mx & 3) == 3)) >> 1;
     917       23100 :     uvmy = (my + ((my & 3) == 3)) >> 1;
     918       23100 :     if (v->field_mode && v->cur_field_type != v->ref_field_type[1]) {
     919        5223 :         my   = my   - 2 + 4 * v->cur_field_type;
     920        5223 :         uvmy = uvmy - 2 + 4 * v->cur_field_type;
     921             :     }
     922       23100 :     if (v->fastuvmc) {
     923           0 :         uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
     924           0 :         uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
     925             :     }
     926       23100 :     srcY = s->next_picture.f->data[0];
     927       23100 :     srcU = s->next_picture.f->data[1];
     928       23100 :     srcV = s->next_picture.f->data[2];
     929             : 
     930       23100 :     src_x   = s->mb_x * 16 + (mx   >> 2);
     931       23100 :     src_y   = s->mb_y * 16 + (my   >> 2);
     932       23100 :     uvsrc_x = s->mb_x *  8 + (uvmx >> 2);
     933       23100 :     uvsrc_y = s->mb_y *  8 + (uvmy >> 2);
     934             : 
     935       23100 :     if (v->profile != PROFILE_ADVANCED) {
     936           0 :         src_x   = av_clip(  src_x, -16, s->mb_width  * 16);
     937           0 :         src_y   = av_clip(  src_y, -16, s->mb_height * 16);
     938           0 :         uvsrc_x = av_clip(uvsrc_x,  -8, s->mb_width  *  8);
     939           0 :         uvsrc_y = av_clip(uvsrc_y,  -8, s->mb_height *  8);
     940             :     } else {
     941       23100 :         src_x   = av_clip(  src_x, -17, s->avctx->coded_width);
     942       23100 :         uvsrc_x = av_clip(uvsrc_x,  -8, s->avctx->coded_width  >> 1);
     943       23100 :         if (v->fcm == ILACE_FRAME) {
     944        6884 :             src_y = av_clip(src_y, -18 + (src_y & 1), s->avctx->coded_height + (src_y & 1));
     945        6884 :             uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->avctx->coded_height >> 1) + (uvsrc_y & 1));
     946             :         } else {
     947       16216 :             src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
     948       16216 :             uvsrc_y = av_clip(uvsrc_y,  -8, s->avctx->coded_height >> 1);
     949             :         }
     950             :     }
     951             : 
     952       23100 :     srcY += src_y   * s->linesize   + src_x;
     953       23100 :     srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
     954       23100 :     srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
     955             : 
     956       23100 :     if (v->field_mode && v->ref_field_type[1]) {
     957        4716 :         srcY += s->current_picture_ptr->f->linesize[0];
     958        4716 :         srcU += s->current_picture_ptr->f->linesize[1];
     959        4716 :         srcV += s->current_picture_ptr->f->linesize[2];
     960             :     }
     961             : 
     962             :     /* for grayscale we should not try to read from unknown area */
     963             :     if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) {
     964             :         srcU = s->sc.edge_emu_buffer + 18 * s->linesize;
     965             :         srcV = s->sc.edge_emu_buffer + 18 * s->linesize;
     966             :     }
     967             : 
     968       23100 :     if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || use_ic
     969       23100 :         || (unsigned)(src_x - 1) > s->h_edge_pos - (mx & 3) - 16 - 3
     970       22160 :         || (unsigned)(src_y - 1) > v_edge_pos    - (my & 3) - 16 - 3) {
     971        3142 :         uint8_t *ubuf = s->sc.edge_emu_buffer + 19 * s->linesize;
     972        3142 :         uint8_t *vbuf = ubuf + 9 * s->uvlinesize;
     973        3142 :         const int k = 17 + s->mspel * 2;
     974             : 
     975        3142 :         srcY -= s->mspel * (1 + s->linesize);
     976        3142 :         if (v->fcm == ILACE_FRAME) {
     977         433 :             if (src_y - s->mspel & 1) {
     978        1554 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
     979             :                                          srcY,
     980         222 :                                          2 * s->linesize,
     981         222 :                                          2 * s->linesize,
     982             :                                          k,
     983         222 :                                          k + 1 >> 1,
     984         222 :                                          src_x - s->mspel,
     985         222 :                                          src_y - s->mspel >> 1,
     986             :                                          s->h_edge_pos,
     987         222 :                                          v_edge_pos + 1 >> 1);
     988        1332 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + s->linesize,
     989         222 :                                          srcY + s->linesize,
     990         222 :                                          2 * s->linesize,
     991         222 :                                          2 * s->linesize,
     992             :                                          k,
     993             :                                          k >> 1,
     994         222 :                                          src_x - s->mspel,
     995         222 :                                          src_y - s->mspel + 1 >> 1,
     996             :                                          s->h_edge_pos,
     997             :                                          v_edge_pos >> 1);
     998             :             } else {
     999        1266 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
    1000             :                                          srcY,
    1001         211 :                                          2 * s->linesize,
    1002         211 :                                          2 * s->linesize,
    1003             :                                          k,
    1004         211 :                                          k + 1 >> 1,
    1005         211 :                                          src_x - s->mspel,
    1006         211 :                                          src_y - s->mspel >> 1,
    1007             :                                          s->h_edge_pos,
    1008             :                                          v_edge_pos >> 1);
    1009        1477 :                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + s->linesize,
    1010         211 :                                          srcY + s->linesize,
    1011         211 :                                          2 * s->linesize,
    1012         211 :                                          2 * s->linesize,
    1013             :                                          k,
    1014             :                                          k >> 1,
    1015         211 :                                          src_x - s->mspel,
    1016         211 :                                          src_y - s->mspel + 1 >> 1,
    1017             :                                          s->h_edge_pos,
    1018         211 :                                          v_edge_pos + 1 >> 1);
    1019             :             }
    1020             :         } else
    1021        8127 :             s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcY,
    1022             :                                      s->linesize, s->linesize,
    1023             :                                      k, k,
    1024        5418 :                                      src_x - s->mspel, src_y - s->mspel,
    1025             :                                      s->h_edge_pos, v_edge_pos);
    1026        3142 :         srcY = s->sc.edge_emu_buffer;
    1027        3142 :         if (v->fcm == ILACE_FRAME) {
    1028         433 :             if (uvsrc_y & 1) {
    1029         900 :                 s->vdsp.emulated_edge_mc(ubuf, srcU,
    1030         360 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
    1031             :                                          8 + 1, 5,
    1032             :                                          uvsrc_x, uvsrc_y >> 1,
    1033         360 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) + 1 >> 1);
    1034         900 :                 s->vdsp.emulated_edge_mc(ubuf + s->uvlinesize, srcU + s->uvlinesize,
    1035         360 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
    1036             :                                          8 + 1, 4,
    1037         180 :                                          uvsrc_x, uvsrc_y + 1 >> 1,
    1038         180 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) >> 1);
    1039         900 :                 s->vdsp.emulated_edge_mc(vbuf, srcV,
    1040         360 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
    1041             :                                          8 + 1, 5,
    1042             :                                          uvsrc_x, uvsrc_y >> 1,
    1043         360 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) + 1 >> 1);
    1044         900 :                 s->vdsp.emulated_edge_mc(vbuf + s->uvlinesize, srcV + s->uvlinesize,
    1045         360 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
    1046             :                                          8 + 1, 4,
    1047         180 :                                          uvsrc_x, uvsrc_y + 1 >> 1,
    1048         180 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) >> 1);
    1049             :             } else {
    1050        1012 :                 s->vdsp.emulated_edge_mc(ubuf, srcU,
    1051         506 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
    1052             :                                          8 + 1, 5,
    1053             :                                          uvsrc_x, uvsrc_y >> 1,
    1054         253 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) >> 1);
    1055        1518 :                 s->vdsp.emulated_edge_mc(ubuf + s->uvlinesize, srcU + s->uvlinesize,
    1056         506 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
    1057             :                                          8 + 1, 4,
    1058         253 :                                          uvsrc_x, uvsrc_y + 1 >> 1,
    1059         506 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) + 1 >> 1);
    1060        1012 :                 s->vdsp.emulated_edge_mc(vbuf, srcV,
    1061         506 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
    1062             :                                          8 + 1, 5,
    1063             :                                          uvsrc_x, uvsrc_y >> 1,
    1064         253 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) >> 1);
    1065        1518 :                 s->vdsp.emulated_edge_mc(vbuf + s->uvlinesize, srcV + s->uvlinesize,
    1066         506 :                                          2 * s->uvlinesize, 2 * s->uvlinesize,
    1067             :                                          8 + 1, 4,
    1068         253 :                                          uvsrc_x, uvsrc_y + 1 >> 1,
    1069         506 :                                          s->h_edge_pos >> 1, (v_edge_pos >> 1) + 1 >> 1);
    1070             :             }
    1071             :         } else {
    1072        5418 :             s->vdsp.emulated_edge_mc(ubuf, srcU,
    1073             :                                      s->uvlinesize, s->uvlinesize,
    1074             :                                      8 + 1, 8 + 1,
    1075             :                                      uvsrc_x, uvsrc_y,
    1076        2709 :                                      s->h_edge_pos >> 1, v_edge_pos >> 1);
    1077        5418 :             s->vdsp.emulated_edge_mc(vbuf, srcV,
    1078             :                                      s->uvlinesize, s->uvlinesize,
    1079             :                                      8 + 1, 8 + 1,
    1080             :                                      uvsrc_x, uvsrc_y,
    1081        2709 :                                      s->h_edge_pos >> 1, v_edge_pos >> 1);
    1082             :         }
    1083        3142 :         srcU = ubuf;
    1084        3142 :         srcV = vbuf;
    1085             :         /* if we deal with range reduction we need to scale source blocks */
    1086        3142 :         if (v->rangeredfrm) {
    1087           0 :             vc1_scale_luma(srcY, k, s->linesize);
    1088           0 :             vc1_scale_chroma(srcU, srcV, 9, s->uvlinesize);
    1089             :         }
    1090             : 
    1091        3142 :         if (use_ic) {
    1092           0 :             uint8_t (*luty )[256] = v->next_luty;
    1093           0 :             uint8_t (*lutuv)[256] = v->next_lutuv;
    1094           0 :             vc1_lut_scale_luma(srcY,
    1095           0 :                                luty[v->field_mode ? v->ref_field_type[1] : ((0+src_y - s->mspel) & 1)],
    1096           0 :                                luty[v->field_mode ? v->ref_field_type[1] : ((1+src_y - s->mspel) & 1)],
    1097           0 :                                k, s->linesize);
    1098           0 :             vc1_lut_scale_chroma(srcU, srcV,
    1099           0 :                                  lutuv[v->field_mode ? v->ref_field_type[1] : ((0+uvsrc_y) & 1)],
    1100           0 :                                  lutuv[v->field_mode ? v->ref_field_type[1] : ((1+uvsrc_y) & 1)],
    1101           0 :                                  9, s->uvlinesize);
    1102             :         }
    1103        3142 :         srcY += s->mspel * (1 + s->linesize);
    1104             :     }
    1105             : 
    1106       23100 :     if (s->mspel) {
    1107       16451 :         dxy = ((my & 3) << 2) | (mx & 3);
    1108       16451 :         v->vc1dsp.avg_vc1_mspel_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, v->rnd);
    1109             :     } else { // hpel mc
    1110        6649 :         dxy = (my & 2) | ((mx & 2) >> 1);
    1111             : 
    1112        6649 :         if (!v->rnd)
    1113        3673 :             s->hdsp.avg_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
    1114             :         else
    1115        2976 :             s->hdsp.avg_no_rnd_pixels_tab[dxy](s->dest[0], srcY, s->linesize, 16);
    1116             :     }
    1117             : 
    1118             :     if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
    1119             :         return;
    1120             :     /* Chroma MC always uses qpel bilinear */
    1121       23100 :     uvmx = (uvmx & 3) << 1;
    1122       23100 :     uvmy = (uvmy & 3) << 1;
    1123       23100 :     if (!v->rnd) {
    1124       15141 :         h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
    1125       15141 :         h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
    1126             :     } else {
    1127        7959 :         v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
    1128        7959 :         v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
    1129             :     }
    1130             : }

Generated by: LCOV version 1.13