Libav
vc1_mc.c
Go to the documentation of this file.
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 Libav.
8  *
9  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
29 #include "avcodec.h"
30 #include "h264chroma.h"
31 #include "mathops.h"
32 #include "mpegvideo.h"
33 #include "vc1.h"
34 
38 void ff_vc1_mc_1mv(VC1Context *v, int dir)
39 {
40  MpegEncContext *s = &v->s;
41  H264ChromaContext *h264chroma = &v->h264chroma;
42  uint8_t *srcY, *srcU, *srcV;
43  int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
44  int v_edge_pos = s->v_edge_pos >> v->field_mode;
45  int i;
46  uint8_t (*luty)[256], (*lutuv)[256];
47  int use_ic;
48 
49  if ((!v->field_mode ||
50  (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
51  !v->s.last_picture.f->data[0])
52  return;
53 
54  mx = s->mv[dir][0][0];
55  my = s->mv[dir][0][1];
56 
57  // store motion vectors for further use in B-frames
58  if (s->pict_type == AV_PICTURE_TYPE_P) {
59  for (i = 0; i < 4; i++) {
60  s->current_picture.motion_val[1][s->block_index[i] + v->blocks_off][0] = mx;
61  s->current_picture.motion_val[1][s->block_index[i] + v->blocks_off][1] = my;
62  }
63  }
64 
65  uvmx = (mx + ((mx & 3) == 3)) >> 1;
66  uvmy = (my + ((my & 3) == 3)) >> 1;
67  v->luma_mv[s->mb_x][0] = uvmx;
68  v->luma_mv[s->mb_x][1] = uvmy;
69 
70  if (v->field_mode &&
71  v->cur_field_type != v->ref_field_type[dir]) {
72  my = my - 2 + 4 * v->cur_field_type;
73  uvmy = uvmy - 2 + 4 * v->cur_field_type;
74  }
75 
76  // fastuvmc shall be ignored for interlaced frame picture
77  if (v->fastuvmc && (v->fcm != ILACE_FRAME)) {
78  uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
79  uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
80  }
81  if (!dir) {
82  if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
83  srcY = s->current_picture.f->data[0];
84  srcU = s->current_picture.f->data[1];
85  srcV = s->current_picture.f->data[2];
86  luty = v->curr_luty;
87  lutuv = v->curr_lutuv;
88  use_ic = v->curr_use_ic;
89  } else {
90  srcY = s->last_picture.f->data[0];
91  srcU = s->last_picture.f->data[1];
92  srcV = s->last_picture.f->data[2];
93  luty = v->last_luty;
94  lutuv = v->last_lutuv;
95  use_ic = v->last_use_ic;
96  }
97  } else {
98  srcY = s->next_picture.f->data[0];
99  srcU = s->next_picture.f->data[1];
100  srcV = s->next_picture.f->data[2];
101  luty = v->next_luty;
102  lutuv = v->next_lutuv;
103  use_ic = v->next_use_ic;
104  }
105 
106  if (!srcY || !srcU) {
107  av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
108  return;
109  }
110 
111  src_x = s->mb_x * 16 + (mx >> 2);
112  src_y = s->mb_y * 16 + (my >> 2);
113  uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
114  uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
115 
116  if (v->profile != PROFILE_ADVANCED) {
117  src_x = av_clip( src_x, -16, s->mb_width * 16);
118  src_y = av_clip( src_y, -16, s->mb_height * 16);
119  uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
120  uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
121  } else {
122  src_x = av_clip( src_x, -17, s->avctx->coded_width);
123  src_y = av_clip( src_y, -18, s->avctx->coded_height + 1);
124  uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
125  uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
126  }
127 
128  srcY += src_y * s->linesize + src_x;
129  srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
130  srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
131 
132  if (v->field_mode && v->ref_field_type[dir]) {
133  srcY += s->current_picture_ptr->f->linesize[0];
134  srcU += s->current_picture_ptr->f->linesize[1];
135  srcV += s->current_picture_ptr->f->linesize[2];
136  }
137 
138  /* for grayscale we should not try to read from unknown area */
139  if (s->avctx->flags & AV_CODEC_FLAG_GRAY) {
140  srcU = s->sc.edge_emu_buffer + 18 * s->linesize;
141  srcV = s->sc.edge_emu_buffer + 18 * s->linesize;
142  }
143 
144  if (v->rangeredfrm || use_ic
145  || s->h_edge_pos < 22 || v_edge_pos < 22
146  || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel * 3
147  || (unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
148  uint8_t *uvbuf = s->sc.edge_emu_buffer + 19 * s->linesize;
149 
150  srcY -= s->mspel * (1 + s->linesize);
152  s->linesize, s->linesize,
153  17 + s->mspel * 2, 17 + s->mspel * 2,
154  src_x - s->mspel, src_y - s->mspel,
155  s->h_edge_pos, v_edge_pos);
156  srcY = s->sc.edge_emu_buffer;
157  s->vdsp.emulated_edge_mc(uvbuf, srcU,
158  s->uvlinesize, s->uvlinesize,
159  8 + 1, 8 + 1,
160  uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
161  s->vdsp.emulated_edge_mc(uvbuf + 16, srcV,
162  s->uvlinesize, s->uvlinesize,
163  8 + 1, 8 + 1,
164  uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
165  srcU = uvbuf;
166  srcV = uvbuf + 16;
167  /* if we deal with range reduction we need to scale source blocks */
168  if (v->rangeredfrm) {
169  int i, j;
170  uint8_t *src, *src2;
171 
172  src = srcY;
173  for (j = 0; j < 17 + s->mspel * 2; j++) {
174  for (i = 0; i < 17 + s->mspel * 2; i++)
175  src[i] = ((src[i] - 128) >> 1) + 128;
176  src += s->linesize;
177  }
178  src = srcU;
179  src2 = srcV;
180  for (j = 0; j < 9; j++) {
181  for (i = 0; i < 9; i++) {
182  src[i] = ((src[i] - 128) >> 1) + 128;
183  src2[i] = ((src2[i] - 128) >> 1) + 128;
184  }
185  src += s->uvlinesize;
186  src2 += s->uvlinesize;
187  }
188  }
189  /* if we deal with intensity compensation we need to scale source blocks */
190  if (use_ic) {
191  int i, j;
192  uint8_t *src, *src2;
193 
194  src = srcY;
195  for (j = 0; j < 17 + s->mspel * 2; j++) {
196  int f = v->field_mode ? v->ref_field_type[dir] : ((j + src_y - s->mspel) & 1) ;
197  for (i = 0; i < 17 + s->mspel * 2; i++)
198  src[i] = luty[f][src[i]];
199  src += s->linesize;
200  }
201  src = srcU;
202  src2 = srcV;
203  for (j = 0; j < 9; j++) {
204  int f = v->field_mode ? v->ref_field_type[dir] : ((j + uvsrc_y) & 1);
205  for (i = 0; i < 9; i++) {
206  src[i] = lutuv[f][src[i]];
207  src2[i] = lutuv[f][src2[i]];
208  }
209  src += s->uvlinesize;
210  src2 += s->uvlinesize;
211  }
212  }
213  srcY += s->mspel * (1 + s->linesize);
214  }
215 
216  if (s->mspel) {
217  dxy = ((my & 3) << 2) | (mx & 3);
218  v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd);
219  v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd);
220  srcY += s->linesize * 8;
221  v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd);
222  v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
223  } else { // hpel mc - always used for luma
224  dxy = (my & 2) | ((mx & 2) >> 1);
225  if (!v->rnd)
226  s->hdsp.put_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
227  else
228  s->hdsp.put_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
229  }
230 
231  if (s->avctx->flags & AV_CODEC_FLAG_GRAY)
232  return;
233  /* Chroma MC always uses qpel bilinear */
234  uvmx = (uvmx & 3) << 1;
235  uvmy = (uvmy & 3) << 1;
236  if (!v->rnd) {
237  h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
238  h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
239  } else {
240  v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
241  v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
242  }
243 }
244 
245 static inline int median4(int a, int b, int c, int d)
246 {
247  if (a < b) {
248  if (c < d) return (FFMIN(b, d) + FFMAX(a, c)) / 2;
249  else return (FFMIN(b, c) + FFMAX(a, d)) / 2;
250  } else {
251  if (c < d) return (FFMIN(a, d) + FFMAX(b, c)) / 2;
252  else return (FFMIN(a, c) + FFMAX(b, d)) / 2;
253  }
254 }
255 
258 void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
259 {
260  MpegEncContext *s = &v->s;
261  uint8_t *srcY;
262  int dxy, mx, my, src_x, src_y;
263  int off;
264  int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0;
265  int v_edge_pos = s->v_edge_pos >> v->field_mode;
266  uint8_t (*luty)[256];
267  int use_ic;
268 
269  if ((!v->field_mode ||
270  (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
271  !v->s.last_picture.f->data[0])
272  return;
273 
274  mx = s->mv[dir][n][0];
275  my = s->mv[dir][n][1];
276 
277  if (!dir) {
278  if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
279  srcY = s->current_picture.f->data[0];
280  luty = v->curr_luty;
281  use_ic = v->curr_use_ic;
282  } else {
283  srcY = s->last_picture.f->data[0];
284  luty = v->last_luty;
285  use_ic = v->last_use_ic;
286  }
287  } else {
288  srcY = s->next_picture.f->data[0];
289  luty = v->next_luty;
290  use_ic = v->next_use_ic;
291  }
292 
293  if (!srcY) {
294  av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
295  return;
296  }
297 
298  if (v->field_mode) {
299  if (v->cur_field_type != v->ref_field_type[dir])
300  my = my - 2 + 4 * v->cur_field_type;
301  }
302 
303  if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) {
304  int same_count = 0, opp_count = 0, k;
305  int chosen_mv[2][4][2], f;
306  int tx = 0, ty = 0;
307  for (k = 0; k < 4; k++) {
308  f = v->mv_f[0][s->block_index[k] + v->blocks_off];
309  chosen_mv[f][f ? opp_count : same_count][0] = s->mv[0][k][0];
310  chosen_mv[f][f ? opp_count : same_count][1] = s->mv[0][k][1];
311  opp_count += f;
312  same_count += 1 - f;
313  }
314  f = opp_count > same_count;
315  switch (f ? opp_count : same_count) {
316  case 4:
317  tx = median4(chosen_mv[f][0][0], chosen_mv[f][1][0],
318  chosen_mv[f][2][0], chosen_mv[f][3][0]);
319  ty = median4(chosen_mv[f][0][1], chosen_mv[f][1][1],
320  chosen_mv[f][2][1], chosen_mv[f][3][1]);
321  break;
322  case 3:
323  tx = mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]);
324  ty = mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]);
325  break;
326  case 2:
327  tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2;
328  ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2;
329  break;
330  }
331  s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
332  s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
333  for (k = 0; k < 4; k++)
334  v->mv_f[1][s->block_index[k] + v->blocks_off] = f;
335  }
336 
337  if (v->fcm == ILACE_FRAME) { // not sure if needed for other types of picture
338  int qx, qy;
339  int width = s->avctx->coded_width;
340  int height = s->avctx->coded_height >> 1;
341  if (s->pict_type == AV_PICTURE_TYPE_P) {
342  s->current_picture.motion_val[1][s->block_index[n] + v->blocks_off][0] = mx;
343  s->current_picture.motion_val[1][s->block_index[n] + v->blocks_off][1] = my;
344  }
345  qx = (s->mb_x * 16) + (mx >> 2);
346  qy = (s->mb_y * 8) + (my >> 3);
347 
348  if (qx < -17)
349  mx -= 4 * (qx + 17);
350  else if (qx > width)
351  mx -= 4 * (qx - width);
352  if (qy < -18)
353  my -= 8 * (qy + 18);
354  else if (qy > height + 1)
355  my -= 8 * (qy - height - 1);
356  }
357 
358  if ((v->fcm == ILACE_FRAME) && fieldmv)
359  off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8;
360  else
361  off = s->linesize * 4 * (n & 2) + (n & 1) * 8;
362 
363  src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2);
364  if (!fieldmv)
365  src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2);
366  else
367  src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
368 
369  if (v->profile != PROFILE_ADVANCED) {
370  src_x = av_clip(src_x, -16, s->mb_width * 16);
371  src_y = av_clip(src_y, -16, s->mb_height * 16);
372  } else {
373  src_x = av_clip(src_x, -17, s->avctx->coded_width);
374  if (v->fcm == ILACE_FRAME) {
375  if (src_y & 1)
376  src_y = av_clip(src_y, -17, s->avctx->coded_height + 1);
377  else
378  src_y = av_clip(src_y, -18, s->avctx->coded_height);
379  } else {
380  src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
381  }
382  }
383 
384  srcY += src_y * s->linesize + src_x;
385  if (v->field_mode && v->ref_field_type[dir])
386  srcY += s->current_picture_ptr->f->linesize[0];
387 
388  if (fieldmv && !(src_y & 1))
389  v_edge_pos--;
390  if (fieldmv && (src_y & 1) && src_y < 4)
391  src_y--;
392  if (v->rangeredfrm || use_ic
393  || s->h_edge_pos < 13 || v_edge_pos < 23
394  || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2
395  || (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) {
396  srcY -= s->mspel * (1 + (s->linesize << fieldmv));
397  /* check emulate edge stride and offset */
399  s->linesize, s->linesize,
400  9 + s->mspel * 2, (9 + s->mspel * 2) << fieldmv,
401  src_x - s->mspel, src_y - (s->mspel << fieldmv),
402  s->h_edge_pos, v_edge_pos);
403  srcY = s->sc.edge_emu_buffer;
404  /* if we deal with range reduction we need to scale source blocks */
405  if (v->rangeredfrm) {
406  int i, j;
407  uint8_t *src;
408 
409  src = srcY;
410  for (j = 0; j < 9 + s->mspel * 2; j++) {
411  for (i = 0; i < 9 + s->mspel * 2; i++)
412  src[i] = ((src[i] - 128) >> 1) + 128;
413  src += s->linesize << fieldmv;
414  }
415  }
416  /* if we deal with intensity compensation we need to scale source blocks */
417  if (use_ic) {
418  int i, j;
419  uint8_t *src;
420 
421  src = srcY;
422  for (j = 0; j < 9 + s->mspel * 2; j++) {
423  int f = v->field_mode ? v->ref_field_type[dir] : (((j<<fieldmv)+src_y - (s->mspel << fieldmv)) & 1);
424  for (i = 0; i < 9 + s->mspel * 2; i++)
425  src[i] = luty[f][src[i]];
426  src += s->linesize << fieldmv;
427  }
428  }
429  srcY += s->mspel * (1 + (s->linesize << fieldmv));
430  }
431 
432  if (s->mspel) {
433  dxy = ((my & 3) << 2) | (mx & 3);
434  if (avg)
435  v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
436  else
437  v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
438  } else { // hpel mc - always used for luma
439  dxy = (my & 2) | ((mx & 2) >> 1);
440  if (!v->rnd)
441  s->hdsp.put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
442  else
443  s->hdsp.put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
444  }
445 }
446 
447 static av_always_inline int get_chroma_mv(int *mvx, int *mvy, int *a, int flag, int *tx, int *ty)
448 {
449  int idx, i;
450  static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
451 
452  idx = ((a[3] != flag) << 3)
453  | ((a[2] != flag) << 2)
454  | ((a[1] != flag) << 1)
455  | (a[0] != flag);
456  if (!idx) {
457  *tx = median4(mvx[0], mvx[1], mvx[2], mvx[3]);
458  *ty = median4(mvy[0], mvy[1], mvy[2], mvy[3]);
459  return 4;
460  } else if (count[idx] == 1) {
461  switch (idx) {
462  case 0x1:
463  *tx = mid_pred(mvx[1], mvx[2], mvx[3]);
464  *ty = mid_pred(mvy[1], mvy[2], mvy[3]);
465  return 3;
466  case 0x2:
467  *tx = mid_pred(mvx[0], mvx[2], mvx[3]);
468  *ty = mid_pred(mvy[0], mvy[2], mvy[3]);
469  return 3;
470  case 0x4:
471  *tx = mid_pred(mvx[0], mvx[1], mvx[3]);
472  *ty = mid_pred(mvy[0], mvy[1], mvy[3]);
473  return 3;
474  case 0x8:
475  *tx = mid_pred(mvx[0], mvx[1], mvx[2]);
476  *ty = mid_pred(mvy[0], mvy[1], mvy[2]);
477  return 3;
478  }
479  } else if (count[idx] == 2) {
480  int t1 = 0, t2 = 0;
481  for (i = 0; i < 3; i++)
482  if (!a[i]) {
483  t1 = i;
484  break;
485  }
486  for (i = t1 + 1; i < 4; i++)
487  if (!a[i]) {
488  t2 = i;
489  break;
490  }
491  *tx = (mvx[t1] + mvx[t2]) / 2;
492  *ty = (mvy[t1] + mvy[t2]) / 2;
493  return 2;
494  } else {
495  return 0;
496  }
497  return -1;
498 }
499 
503 {
504  MpegEncContext *s = &v->s;
505  H264ChromaContext *h264chroma = &v->h264chroma;
506  uint8_t *srcU, *srcV;
507  int uvmx, uvmy, uvsrc_x, uvsrc_y;
508  int k, tx = 0, ty = 0;
509  int mvx[4], mvy[4], intra[4], mv_f[4];
510  int valid_count;
511  int chroma_ref_type = v->cur_field_type;
512  int v_edge_pos = s->v_edge_pos >> v->field_mode;
513  uint8_t (*lutuv)[256];
514  int use_ic;
515 
516  if (!v->field_mode && !v->s.last_picture.f->data[0])
517  return;
518  if (s->avctx->flags & AV_CODEC_FLAG_GRAY)
519  return;
520 
521  for (k = 0; k < 4; k++) {
522  mvx[k] = s->mv[dir][k][0];
523  mvy[k] = s->mv[dir][k][1];
524  intra[k] = v->mb_type[0][s->block_index[k]];
525  if (v->field_mode)
526  mv_f[k] = v->mv_f[dir][s->block_index[k] + v->blocks_off];
527  }
528 
529  /* calculate chroma MV vector from four luma MVs */
530  if (!v->field_mode || (v->field_mode && !v->numref)) {
531  valid_count = get_chroma_mv(mvx, mvy, intra, 0, &tx, &ty);
532  chroma_ref_type = v->reffield;
533  if (!valid_count) {
534  s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
535  s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
536  v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
537  return; //no need to do MC for intra blocks
538  }
539  } else {
540  int dominant = 0;
541  if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)
542  dominant = 1;
543  valid_count = get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);
544  if (dominant)
545  chroma_ref_type = !v->cur_field_type;
546  }
547  if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f->data[0])
548  return;
549  s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
550  s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
551  uvmx = (tx + ((tx & 3) == 3)) >> 1;
552  uvmy = (ty + ((ty & 3) == 3)) >> 1;
553 
554  v->luma_mv[s->mb_x][0] = uvmx;
555  v->luma_mv[s->mb_x][1] = uvmy;
556 
557  if (v->fastuvmc) {
558  uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
559  uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
560  }
561  // Field conversion bias
562  if (v->cur_field_type != chroma_ref_type)
563  uvmy += 2 - 4 * chroma_ref_type;
564 
565  uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
566  uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
567 
568  if (v->profile != PROFILE_ADVANCED) {
569  uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
570  uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
571  } else {
572  uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
573  uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
574  }
575 
576  if (!dir) {
577  if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) {
578  srcU = s->current_picture.f->data[1];
579  srcV = s->current_picture.f->data[2];
580  lutuv = v->curr_lutuv;
581  use_ic = v->curr_use_ic;
582  } else {
583  srcU = s->last_picture.f->data[1];
584  srcV = s->last_picture.f->data[2];
585  lutuv = v->last_lutuv;
586  use_ic = v->last_use_ic;
587  }
588  } else {
589  srcU = s->next_picture.f->data[1];
590  srcV = s->next_picture.f->data[2];
591  lutuv = v->next_lutuv;
592  use_ic = v->next_use_ic;
593  }
594 
595  if (!srcU) {
596  av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
597  return;
598  }
599 
600  srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
601  srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
602 
603  if (v->field_mode) {
604  if (chroma_ref_type) {
605  srcU += s->current_picture_ptr->f->linesize[1];
606  srcV += s->current_picture_ptr->f->linesize[2];
607  }
608  }
609 
610  if (v->rangeredfrm || use_ic
611  || s->h_edge_pos < 18 || v_edge_pos < 18
612  || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
613  || (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
615  s->uvlinesize, s->uvlinesize,
616  8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
617  s->h_edge_pos >> 1, v_edge_pos >> 1);
618  s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16, srcV,
619  s->uvlinesize, s->uvlinesize,
620  8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
621  s->h_edge_pos >> 1, v_edge_pos >> 1);
622  srcU = s->sc.edge_emu_buffer;
623  srcV = s->sc.edge_emu_buffer + 16;
624 
625  /* if we deal with range reduction we need to scale source blocks */
626  if (v->rangeredfrm) {
627  int i, j;
628  uint8_t *src, *src2;
629 
630  src = srcU;
631  src2 = srcV;
632  for (j = 0; j < 9; j++) {
633  for (i = 0; i < 9; i++) {
634  src[i] = ((src[i] - 128) >> 1) + 128;
635  src2[i] = ((src2[i] - 128) >> 1) + 128;
636  }
637  src += s->uvlinesize;
638  src2 += s->uvlinesize;
639  }
640  }
641  /* if we deal with intensity compensation we need to scale source blocks */
642  if (use_ic) {
643  int i, j;
644  uint8_t *src, *src2;
645 
646  src = srcU;
647  src2 = srcV;
648  for (j = 0; j < 9; j++) {
649  int f = v->field_mode ? chroma_ref_type : ((j + uvsrc_y) & 1);
650  for (i = 0; i < 9; i++) {
651  src[i] = lutuv[f][src[i]];
652  src2[i] = lutuv[f][src2[i]];
653  }
654  src += s->uvlinesize;
655  src2 += s->uvlinesize;
656  }
657  }
658  }
659 
660  /* Chroma MC always uses qpel bilinear */
661  uvmx = (uvmx & 3) << 1;
662  uvmy = (uvmy & 3) << 1;
663  if (!v->rnd) {
664  h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
665  h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
666  } else {
667  v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
668  v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
669  }
670 }
671 
674 void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
675 {
676  MpegEncContext *s = &v->s;
677  H264ChromaContext *h264chroma = &v->h264chroma;
678  uint8_t *srcU, *srcV;
679  int uvsrc_x, uvsrc_y;
680  int uvmx_field[4], uvmy_field[4];
681  int i, off, tx, ty;
682  int fieldmv = v->blk_mv_type[s->block_index[0]];
683  static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
684  int v_dist = fieldmv ? 1 : 4; // vertical offset for lower sub-blocks
685  int v_edge_pos = s->v_edge_pos >> 1;
686  int use_ic;
687  uint8_t (*lutuv)[256];
688 
689  if (s->avctx->flags & AV_CODEC_FLAG_GRAY)
690  return;
691 
692  for (i = 0; i < 4; i++) {
693  int d = i < 2 ? dir: dir2;
694  tx = s->mv[d][i][0];
695  uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
696  ty = s->mv[d][i][1];
697  if (fieldmv)
698  uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
699  else
700  uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
701  }
702 
703  for (i = 0; i < 4; i++) {
704  off = (i & 1) * 4 + ((i & 2) ? v_dist * s->uvlinesize : 0);
705  uvsrc_x = s->mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2);
706  uvsrc_y = s->mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
707  // FIXME: implement proper pull-back (see vc1cropmv.c, vc1CROPMV_ChromaPullBack())
708  uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
709  uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
710  if (i < 2 ? dir : dir2) {
711  srcU = s->next_picture.f->data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
712  srcV = s->next_picture.f->data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
713  lutuv = v->next_lutuv;
714  use_ic = v->next_use_ic;
715  } else {
716  srcU = s->last_picture.f->data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
717  srcV = s->last_picture.f->data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
718  lutuv = v->last_lutuv;
719  use_ic = v->last_use_ic;
720  }
721  uvmx_field[i] = (uvmx_field[i] & 3) << 1;
722  uvmy_field[i] = (uvmy_field[i] & 3) << 1;
723 
724  if (fieldmv && !(uvsrc_y & 1))
725  v_edge_pos--;
726  if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2)
727  uvsrc_y--;
728  if (use_ic
729  || s->h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
730  || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5
731  || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
733  s->uvlinesize, s->uvlinesize,
734  5, (5 << fieldmv), uvsrc_x, uvsrc_y,
735  s->h_edge_pos >> 1, v_edge_pos);
736  s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16, srcV,
737  s->uvlinesize, s->uvlinesize,
738  5, (5 << fieldmv), uvsrc_x, uvsrc_y,
739  s->h_edge_pos >> 1, v_edge_pos);
740  srcU = s->sc.edge_emu_buffer;
741  srcV = s->sc.edge_emu_buffer + 16;
742 
743  /* if we deal with intensity compensation we need to scale source blocks */
744  if (use_ic) {
745  int i, j;
746  uint8_t *src, *src2;
747 
748  src = srcU;
749  src2 = srcV;
750  for (j = 0; j < 5; j++) {
751  int f = (uvsrc_y + (j << fieldmv)) & 1;
752  for (i = 0; i < 5; i++) {
753  src[i] = lutuv[f][src[i]];
754  src2[i] = lutuv[f][src2[i]];
755  }
756  src += s->uvlinesize << fieldmv;
757  src2 += s->uvlinesize << fieldmv;
758  }
759  }
760  }
761  if (avg) {
762  if (!v->rnd) {
763  h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
764  h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
765  } else {
766  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]);
767  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]);
768  }
769  } else {
770  if (!v->rnd) {
771  h264chroma->put_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
772  h264chroma->put_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
773  } else {
774  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]);
775  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]);
776  }
777  }
778  }
779 }
780 
784 {
785  MpegEncContext *s = &v->s;
786  H264ChromaContext *h264chroma = &v->h264chroma;
787  uint8_t *srcY, *srcU, *srcV;
788  int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
789  int off, off_uv;
790  int v_edge_pos = s->v_edge_pos >> v->field_mode;
791  int use_ic = v->next_use_ic;
792 
793  if (!v->field_mode && !v->s.next_picture.f->data[0])
794  return;
795 
796  mx = s->mv[1][0][0];
797  my = s->mv[1][0][1];
798  uvmx = (mx + ((mx & 3) == 3)) >> 1;
799  uvmy = (my + ((my & 3) == 3)) >> 1;
800  if (v->field_mode && v->cur_field_type != v->ref_field_type[1]) {
801  my = my - 2 + 4 * v->cur_field_type;
802  uvmy = uvmy - 2 + 4 * v->cur_field_type;
803  }
804  if (v->fastuvmc) {
805  uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
806  uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
807  }
808  srcY = s->next_picture.f->data[0];
809  srcU = s->next_picture.f->data[1];
810  srcV = s->next_picture.f->data[2];
811 
812  src_x = s->mb_x * 16 + (mx >> 2);
813  src_y = s->mb_y * 16 + (my >> 2);
814  uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
815  uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
816 
817  if (v->profile != PROFILE_ADVANCED) {
818  src_x = av_clip( src_x, -16, s->mb_width * 16);
819  src_y = av_clip( src_y, -16, s->mb_height * 16);
820  uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
821  uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
822  } else {
823  src_x = av_clip( src_x, -17, s->avctx->coded_width);
824  src_y = av_clip( src_y, -18, s->avctx->coded_height + 1);
825  uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
826  uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
827  }
828 
829  srcY += src_y * s->linesize + src_x;
830  srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
831  srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
832 
833  if (v->field_mode && v->ref_field_type[1]) {
834  srcY += s->current_picture_ptr->f->linesize[0];
835  srcU += s->current_picture_ptr->f->linesize[1];
836  srcV += s->current_picture_ptr->f->linesize[2];
837  }
838 
839  /* for grayscale we should not try to read from unknown area */
840  if (s->avctx->flags & AV_CODEC_FLAG_GRAY) {
841  srcU = s->sc.edge_emu_buffer + 18 * s->linesize;
842  srcV = s->sc.edge_emu_buffer + 18 * s->linesize;
843  }
844 
845  if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || use_ic
846  || (unsigned)(src_x - 1) > s->h_edge_pos - (mx & 3) - 16 - 3
847  || (unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) {
848  uint8_t *uvbuf = s->sc.edge_emu_buffer + 19 * s->linesize;
849 
850  srcY -= s->mspel * (1 + s->linesize);
852  s->linesize, s->linesize,
853  17 + s->mspel * 2, 17 + s->mspel * 2,
854  src_x - s->mspel, src_y - s->mspel,
855  s->h_edge_pos, v_edge_pos);
856  srcY = s->sc.edge_emu_buffer;
857  s->vdsp.emulated_edge_mc(uvbuf, srcU,
858  s->uvlinesize, s->uvlinesize,
859  8 + 1, 8 + 1,
860  uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
861  s->vdsp.emulated_edge_mc(uvbuf + 16, srcV,
862  s->uvlinesize, s->uvlinesize,
863  8 + 1, 8 + 1,
864  uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
865  srcU = uvbuf;
866  srcV = uvbuf + 16;
867  /* if we deal with range reduction we need to scale source blocks */
868  if (v->rangeredfrm) {
869  int i, j;
870  uint8_t *src, *src2;
871 
872  src = srcY;
873  for (j = 0; j < 17 + s->mspel * 2; j++) {
874  for (i = 0; i < 17 + s->mspel * 2; i++)
875  src[i] = ((src[i] - 128) >> 1) + 128;
876  src += s->linesize;
877  }
878  src = srcU;
879  src2 = srcV;
880  for (j = 0; j < 9; j++) {
881  for (i = 0; i < 9; i++) {
882  src[i] = ((src[i] - 128) >> 1) + 128;
883  src2[i] = ((src2[i] - 128) >> 1) + 128;
884  }
885  src += s->uvlinesize;
886  src2 += s->uvlinesize;
887  }
888  }
889 
890  if (use_ic) {
891  uint8_t (*luty )[256] = v->next_luty;
892  uint8_t (*lutuv)[256] = v->next_lutuv;
893  int i, j;
894  uint8_t *src, *src2;
895 
896  src = srcY;
897  for (j = 0; j < 17 + s->mspel * 2; j++) {
898  int f = v->field_mode ? v->ref_field_type[1] : ((j+src_y - s->mspel) & 1);
899  for (i = 0; i < 17 + s->mspel * 2; i++)
900  src[i] = luty[f][src[i]];
901  src += s->linesize;
902  }
903  src = srcU;
904  src2 = srcV;
905  for (j = 0; j < 9; j++) {
906  int f = v->field_mode ? v->ref_field_type[1] : ((j+uvsrc_y) & 1);
907  for (i = 0; i < 9; i++) {
908  src[i] = lutuv[f][src[i]];
909  src2[i] = lutuv[f][src2[i]];
910  }
911  src += s->uvlinesize;
912  src2 += s->uvlinesize;
913  }
914  }
915  srcY += s->mspel * (1 + s->linesize);
916  }
917 
918  off = 0;
919  off_uv = 0;
920 
921  if (s->mspel) {
922  dxy = ((my & 3) << 2) | (mx & 3);
923  v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off , srcY , s->linesize, v->rnd);
924  v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd);
925  srcY += s->linesize * 8;
926  v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize , srcY , s->linesize, v->rnd);
927  v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
928  } else { // hpel mc
929  dxy = (my & 2) | ((mx & 2) >> 1);
930 
931  if (!v->rnd)
932  s->hdsp.avg_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16);
933  else
934  s->hdsp.avg_no_rnd_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, 16);
935  }
936 
937  if (s->avctx->flags & AV_CODEC_FLAG_GRAY)
938  return;
939  /* Chroma MC always uses qpel bilinear */
940  uvmx = (uvmx & 3) << 1;
941  uvmy = (uvmy & 3) << 1;
942  if (!v->rnd) {
943  h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy);
944  h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy);
945  } else {
946  v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy);
947  v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy);
948  }
949 }
op_pixels_func avg_vc1_mspel_pixels_tab[16]
Definition: vc1dsp.h:58
The VC1 Context.
Definition: vc1.h:158
int reffield
if numref = 0 (1 reference) then reffield decides which
Definition: vc1.h:342
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
Definition: mpegpicture.h:36
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:1595
op_pixels_func avg_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
Definition: hpeldsp.h:68
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
Definition: mpegvideo.h:127
int next_use_ic
Definition: vc1.h:281
int flag
Definition: cpu.c:35
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
Definition: vc1.h:286
mpegvideo header.
uint8_t * mv_f[2]
0: MV obtained from same field, 1: opposite field
Definition: vc1.h:334
int last_use_ic
Definition: vc1.h:281
int fastuvmc
Rounding of qpel vector to hpel ? (not in Simple)
Definition: vc1.h:206
ScratchpadContext sc
Definition: mpegvideo.h:197
uint8_t
#define b
Definition: input.c:52
int second_field
Definition: vc1.h:338
void ff_vc1_interp_mc(VC1Context *v)
Motion compensation for direct or interpolated blocks in B-frames.
Definition: vc1_mc.c:783
Picture current_picture
copy of the current picture structure.
Definition: mpegvideo.h:175
int16_t((* luma_mv)[2]
Definition: vc1.h:372
int profile
Sequence header data for all Profiles TODO: choose between ints, uint8_ts and monobit flags...
Definition: vc1.h:203
void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
Do motion compensation for 4-MV macroblock - luminance block.
Definition: vc1_mc.c:258
uint8_t last_luty[2][256]
Definition: vc1.h:277
int mb_height
number of MBs horizontally & vertically
Definition: mpegvideo.h:124
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Definition: avcodec.h:763
uint8_t last_lutuv[2][256]
lookup tables used for intensity compensation
Definition: vc1.h:277
#define src
Definition: vp8dsp.c:254
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:124
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:1503
#define FFMAX(a, b)
Definition: common.h:64
uint8_t * blk_mv_type
0: frame MV, 1: field MV (interlaced frame)
Definition: vc1.h:333
int cur_field_type
0: top, 1: bottom
Definition: vc1.h:346
#define FFMIN(a, b)
Definition: common.h:66
int field_mode
1 for interlaced field pictures
Definition: vc1.h:336
int16_t(*[2] motion_val)[2]
Definition: mpegpicture.h:53
Picture * current_picture_ptr
pointer to the current picture
Definition: mpegvideo.h:179
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
Definition: videodsp.h:52
static av_always_inline int get_chroma_mv(int *mvx, int *mvy, int *a, int flag, int *tx, int *ty)
Definition: vc1_mc.c:447
h264_chroma_mc_func avg_h264_chroma_pixels_tab[3]
Definition: h264chroma.h:28
int block_index[6]
index to current MB in block based arrays with edges
Definition: mpegvideo.h:287
h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3]
Definition: vc1dsp.h:62
static int width
Definition: utils.c:156
Libavcodec external API header.
ptrdiff_t linesize
line size, in bytes, may be different from width
Definition: mpegvideo.h:129
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:158
int curr_use_ic
Definition: vc1.h:281
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
Definition: hpeldsp.h:56
int coded_height
Definition: avcodec.h:1595
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
Definition: hpeldsp.h:82
struct AVFrame * f
Definition: mpegpicture.h:46
void ff_vc1_mc_1mv(VC1Context *v, int dir)
Do motion compensation over 1 macroblock Mostly adapted hpel_motion and qpel_motion from mpegvideo...
Definition: vc1_mc.c:38
void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
Do motion compensation for 4-MV interlaced frame chroma macroblock (both U and V) ...
Definition: vc1_mc.c:674
#define mid_pred
Definition: mathops.h:99
ptrdiff_t uvlinesize
line size, for chroma in bytes, may be different from width
Definition: mpegvideo.h:130
uint8_t next_lutuv[2][256]
lookup tables used for intensity compensation
Definition: vc1.h:279
int ref_field_type[2]
forward and backward reference field type (top or bottom)
Definition: vc1.h:347
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
Definition: mpegvideo.h:206
int numref
number of past field pictures used as reference
Definition: vc1.h:340
int blocks_off
Definition: vc1.h:348
h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3]
Definition: vc1dsp.h:61
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:146
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
Definition: mpegvideo.h:270
MpegEncContext s
Definition: vc1.h:159
int height
Definition: gxfenc.c:72
in the bitstream is reported as 10b
Definition: vc1.h:150
MpegEncContext.
Definition: mpegvideo.h:76
struct AVCodecContext * avctx
Definition: mpegvideo.h:93
uint8_t * dest[3]
Definition: mpegvideo.h:289
enum FrameCodingMode fcm
Frame decoding info for Advanced profile.
Definition: vc1.h:292
Picture last_picture
copy of the previous picture structure.
Definition: mpegvideo.h:157
uint8_t next_luty[2][256]
Definition: vc1.h:279
h264_chroma_mc_func put_h264_chroma_pixels_tab[3]
Definition: h264chroma.h:27
int rnd
rounding control
Definition: vc1.h:282
VideoDSPContext vdsp
Definition: mpegvideo.h:227
op_pixels_func avg_no_rnd_pixels_tab[4]
Halfpel motion compensation with no rounding (a+b)>>1.
Definition: hpeldsp.h:94
uint8_t(* curr_luty)[256]
Definition: vc1.h:280
Picture next_picture
copy of the next picture structure.
Definition: mpegvideo.h:163
static int median4(int a, int b, int c, int d)
Definition: vc1_mc.c:245
H264ChromaContext h264chroma
Definition: vc1.h:161
void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir)
Do motion compensation for 4-MV macroblock - both chroma blocks.
Definition: vc1_mc.c:502
#define av_always_inline
Definition: attributes.h:40
uint8_t * mb_type[3]
Definition: vc1.h:248
VC1DSPContext vc1dsp
Definition: vc1.h:162
Predicted.
Definition: avutil.h:261
uint8_t((* curr_lutuv)[256]
Definition: vc1.h:280
op_pixels_func put_vc1_mspel_pixels_tab[16]
Definition: vc1dsp.h:57
HpelDSPContext hdsp
Definition: mpegvideo.h:220