FFmpeg
wmv2dec.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002 The FFmpeg Project
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/mem_internal.h"
22 
23 #include "avcodec.h"
24 #include "codec_internal.h"
25 #include "h263dec.h"
26 #include "intrax8.h"
27 #include "mathops.h"
28 #include "mpegutils.h"
29 #include "mpegvideo.h"
30 #include "msmpeg4.h"
31 #include "msmpeg4data.h"
32 #include "msmpeg4dec.h"
33 #include "simple_idct.h"
34 #include "wmv2.h"
35 #include "wmv2data.h"
36 #include "wmv2dec.h"
37 
38 typedef struct WMV2DecContext {
43  int j_type;
44  int abt_flag;
45  int abt_type;
49  int mspel_bit;
53  int skip_type;
54 
56  DECLARE_ALIGNED(32, int16_t, abt_block2)[6][64];
58 
59 static void wmv2_add_block(WMV2DecContext *w, int16_t *block1,
60  uint8_t *dst, int stride, int n)
61 {
62  MpegEncContext *const s = &w->s;
63 
64  if (s->block_last_index[n] >= 0) {
65  switch (w->abt_type_table[n]) {
66  case 0:
67  w->common.wdsp.idct_add(dst, stride, block1);
68  break;
69  case 1:
71  ff_simple_idct84_add(dst + 4 * stride, stride, w->abt_block2[n]);
72  s->bdsp.clear_block(w->abt_block2[n]);
73  break;
74  case 2:
76  ff_simple_idct48_add(dst + 4, stride, w->abt_block2[n]);
77  s->bdsp.clear_block(w->abt_block2[n]);
78  break;
79  default:
80  av_log(s->avctx, AV_LOG_ERROR, "internal error in WMV2 abt\n");
81  }
82  }
83 }
84 
85 void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64],
86  uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr)
87 {
88  WMV2DecContext *const w = (WMV2DecContext *) s;
89 
90  wmv2_add_block(w, block1[0], dest_y, s->linesize, 0);
91  wmv2_add_block(w, block1[1], dest_y + 8, s->linesize, 1);
92  wmv2_add_block(w, block1[2], dest_y + 8 * s->linesize, s->linesize, 2);
93  wmv2_add_block(w, block1[3], dest_y + 8 + 8 * s->linesize, s->linesize, 3);
94 
95  if (s->avctx->flags & AV_CODEC_FLAG_GRAY)
96  return;
97 
98  wmv2_add_block(w, block1[4], dest_cb, s->uvlinesize, 4);
99  wmv2_add_block(w, block1[5], dest_cr, s->uvlinesize, 5);
100 }
101 
103 {
104  int mb_x, mb_y;
105  int coded_mb_count = 0;
106  MpegEncContext *const s = &w->s;
107  uint32_t *const mb_type = s->current_picture_ptr->mb_type;
108 
109  w->skip_type = get_bits(&s->gb, 2);
110  switch (w->skip_type) {
111  case SKIP_TYPE_NONE:
112  for (mb_y = 0; mb_y < s->mb_height; mb_y++)
113  for (mb_x = 0; mb_x < s->mb_width; mb_x++)
114  mb_type[mb_y * s->mb_stride + mb_x] =
116  break;
117  case SKIP_TYPE_MPEG:
118  if (get_bits_left(&s->gb) < s->mb_height * s->mb_width)
119  return AVERROR_INVALIDDATA;
120  for (mb_y = 0; mb_y < s->mb_height; mb_y++)
121  for (mb_x = 0; mb_x < s->mb_width; mb_x++)
122  mb_type[mb_y * s->mb_stride + mb_x] =
123  (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
124  break;
125  case SKIP_TYPE_ROW:
126  for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
127  if (get_bits_left(&s->gb) < 1)
128  return AVERROR_INVALIDDATA;
129  if (get_bits1(&s->gb)) {
130  for (mb_x = 0; mb_x < s->mb_width; mb_x++)
131  mb_type[mb_y * s->mb_stride + mb_x] =
133  } else {
134  for (mb_x = 0; mb_x < s->mb_width; mb_x++)
135  mb_type[mb_y * s->mb_stride + mb_x] =
136  (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
137  }
138  }
139  break;
140  case SKIP_TYPE_COL:
141  for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
142  if (get_bits_left(&s->gb) < 1)
143  return AVERROR_INVALIDDATA;
144  if (get_bits1(&s->gb)) {
145  for (mb_y = 0; mb_y < s->mb_height; mb_y++)
146  mb_type[mb_y * s->mb_stride + mb_x] =
148  } else {
149  for (mb_y = 0; mb_y < s->mb_height; mb_y++)
150  mb_type[mb_y * s->mb_stride + mb_x] =
151  (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
152  }
153  }
154  break;
155  }
156 
157  for (mb_y = 0; mb_y < s->mb_height; mb_y++)
158  for (mb_x = 0; mb_x < s->mb_width; mb_x++)
159  coded_mb_count += !IS_SKIP(mb_type[mb_y * s->mb_stride + mb_x]);
160 
161  if (coded_mb_count > get_bits_left(&s->gb))
162  return AVERROR_INVALIDDATA;
163 
164  return 0;
165 }
166 
168 {
169  MpegEncContext *const s = &w->s;
170  GetBitContext gb;
171  int fps;
172  int code;
173 
174  if (s->avctx->extradata_size < 4)
175  return AVERROR_INVALIDDATA;
176 
177  init_get_bits(&gb, s->avctx->extradata, 32);
178 
179  fps = get_bits(&gb, 5);
180  s->bit_rate = get_bits(&gb, 11) * 1024;
181  w->mspel_bit = get_bits1(&gb);
182  s->loop_filter = get_bits1(&gb);
183  w->abt_flag = get_bits1(&gb);
184  w->j_type_bit = get_bits1(&gb);
185  w->top_left_mv_flag = get_bits1(&gb);
186  w->per_mb_rl_bit = get_bits1(&gb);
187  code = get_bits(&gb, 3);
188 
189  if (code == 0)
190  return AVERROR_INVALIDDATA;
191 
192  s->slice_height = s->mb_height / code;
193 
194  if (s->avctx->debug & FF_DEBUG_PICT_INFO)
195  av_log(s->avctx, AV_LOG_DEBUG,
196  "fps:%d, br:%"PRId64", qpbit:%d, abt_flag:%d, j_type_bit:%d, "
197  "tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, "
198  "slices:%d\n",
199  fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit,
200  w->top_left_mv_flag, w->per_mb_rl_bit, code, s->loop_filter,
201  code);
202  return 0;
203 }
204 
206 {
207  WMV2DecContext *const w = (WMV2DecContext *) s;
208  int code;
209 
210  if (s->picture_number == 0)
212 
213  s->pict_type = get_bits1(&s->gb) + 1;
214  if (s->pict_type == AV_PICTURE_TYPE_I) {
215  code = get_bits(&s->gb, 7);
216  av_log(s->avctx, AV_LOG_DEBUG, "I7:%X/\n", code);
217  }
218  s->chroma_qscale = s->qscale = get_bits(&s->gb, 5);
219  if (s->qscale <= 0)
220  return AVERROR_INVALIDDATA;
221 
222  if (s->pict_type != AV_PICTURE_TYPE_I && show_bits(&s->gb, 1)) {
223  GetBitContext gb = s->gb;
224  int skip_type = get_bits(&gb, 2);
225  int run = skip_type == SKIP_TYPE_COL ? s->mb_width : s->mb_height;
226 
227  while (run > 0) {
228  int block = FFMIN(run, 25);
229  if (get_bits(&gb, block) + 1 != 1<<block)
230  break;
231  run -= block;
232  }
233  if (!run)
234  return FRAME_SKIPPED;
235  }
236 
237  return 0;
238 }
239 
241 {
242  WMV2DecContext *const w = (WMV2DecContext *) s;
243 
244  if (s->pict_type == AV_PICTURE_TYPE_I) {
245  /* Is filling with zeroes really the right thing to do? */
246  memset(s->current_picture_ptr->mb_type, 0,
247  sizeof(*s->current_picture_ptr->mb_type) *
248  s->mb_height * s->mb_stride);
249  if (w->j_type_bit)
250  w->j_type = get_bits1(&s->gb);
251  else
252  w->j_type = 0; // FIXME check
253 
254  if (!w->j_type) {
255  if (w->per_mb_rl_bit)
256  s->per_mb_rl_table = get_bits1(&s->gb);
257  else
258  s->per_mb_rl_table = 0;
259 
260  if (!s->per_mb_rl_table) {
261  s->rl_chroma_table_index = decode012(&s->gb);
262  s->rl_table_index = decode012(&s->gb);
263  }
264 
265  s->dc_table_index = get_bits1(&s->gb);
266 
267  // at minimum one bit per macroblock is required at least in a valid frame,
268  // we discard frames much smaller than this. Frames smaller than 1/8 of the
269  // smallest "black/skip" frame generally contain not much recoverable content
270  // while at the same time they have the highest computational requirements
271  // per byte
272  if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
273  return AVERROR_INVALIDDATA;
274  }
275  s->inter_intra_pred = 0;
276  s->no_rounding = 1;
277  if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
278  av_log(s->avctx, AV_LOG_DEBUG,
279  "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",
280  s->qscale, s->rl_chroma_table_index, s->rl_table_index,
281  s->dc_table_index, s->per_mb_rl_table, w->j_type);
282  }
283  } else {
284  int cbp_index;
285  int ret;
286  w->j_type = 0;
287 
288  ret = parse_mb_skip(w);
289  if (ret < 0)
290  return ret;
291  cbp_index = decode012(&s->gb);
292  w->cbp_table_index = wmv2_get_cbp_table_index(s, cbp_index);
293 
294  if (w->mspel_bit)
295  s->mspel = get_bits1(&s->gb);
296  else
297  s->mspel = 0; // FIXME check
298 
299  if (w->abt_flag) {
300  w->per_mb_abt = get_bits1(&s->gb) ^ 1;
301  if (!w->per_mb_abt)
302  w->abt_type = decode012(&s->gb);
303  }
304 
305  if (w->per_mb_rl_bit)
306  s->per_mb_rl_table = get_bits1(&s->gb);
307  else
308  s->per_mb_rl_table = 0;
309 
310  if (!s->per_mb_rl_table) {
311  s->rl_table_index = decode012(&s->gb);
312  s->rl_chroma_table_index = s->rl_table_index;
313  }
314 
315  if (get_bits_left(&s->gb) < 2)
316  return AVERROR_INVALIDDATA;
317 
318  s->dc_table_index = get_bits1(&s->gb);
319  s->mv_table_index = get_bits1(&s->gb);
320 
321  s->inter_intra_pred = 0; // (s->width * s->height < 320 * 240 && s->bit_rate <= II_BITRATE);
322  s->no_rounding ^= 1;
323 
324  if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
325  av_log(s->avctx, AV_LOG_DEBUG,
326  "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "
327  "per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",
328  s->rl_table_index, s->rl_chroma_table_index,
329  s->dc_table_index, s->mv_table_index,
330  s->per_mb_rl_table, s->qscale, s->mspel,
331  w->per_mb_abt, w->abt_type, w->cbp_table_index,
332  s->inter_intra_pred);
333  }
334  }
335  s->esc3_level_length = 0;
336  s->esc3_run_length = 0;
337  s->picture_number++; // FIXME ?
338 
339  if (w->j_type) {
340  ff_intrax8_decode_picture(&w->x8, &s->current_picture,
341  &s->gb, &s->mb_x, &s->mb_y,
342  2 * s->qscale, (s->qscale - 1) | 1,
343  s->loop_filter, s->low_delay);
344 
345  ff_er_add_slice(&w->s.er, 0, 0,
346  (w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,
347  ER_MB_END);
348  return 1;
349  }
350 
351  return 0;
352 }
353 
354 static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr)
355 {
356  MpegEncContext *const s = &w->s;
357 
358  ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
359 
360  if ((((*mx_ptr) | (*my_ptr)) & 1) && s->mspel)
361  w->common.hshift = get_bits1(&s->gb);
362  else
363  w->common.hshift = 0;
364 }
365 
366 static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py)
367 {
368  MpegEncContext *const s = &w->s;
369  int xy, wrap, diff, type;
370  int16_t *A, *B, *C, *mot_val;
371 
372  wrap = s->b8_stride;
373  xy = s->block_index[0];
374 
375  mot_val = s->current_picture.motion_val[0][xy];
376 
377  A = s->current_picture.motion_val[0][xy - 1];
378  B = s->current_picture.motion_val[0][xy - wrap];
379  C = s->current_picture.motion_val[0][xy + 2 - wrap];
380 
381  if (s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag)
382  diff = FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1]));
383  else
384  diff = 0;
385 
386  if (diff >= 8)
387  type = get_bits1(&s->gb);
388  else
389  type = 2;
390 
391  if (type == 0) {
392  *px = A[0];
393  *py = A[1];
394  } else if (type == 1) {
395  *px = B[0];
396  *py = B[1];
397  } else {
398  /* special case for first (slice) line */
399  if (s->first_slice_line) {
400  *px = A[0];
401  *py = A[1];
402  } else {
403  *px = mid_pred(A[0], B[0], C[0]);
404  *py = mid_pred(A[1], B[1], C[1]);
405  }
406  }
407 
408  return mot_val;
409 }
410 
411 static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block,
412  int n, int cbp)
413 {
414  MpegEncContext *const s = &w->s;
415  static const int sub_cbp_table[3] = { 2, 3, 1 };
416  int sub_cbp, ret;
417 
418  if (!cbp) {
419  s->block_last_index[n] = -1;
420  return 0;
421  }
422 
423  if (w->per_block_abt)
424  w->abt_type = decode012(&s->gb);
425  w->abt_type_table[n] = w->abt_type;
426 
427  if (w->abt_type) {
428 // const uint8_t *scantable = w->abt_scantable[w->abt_type - 1].permutated;
429  const uint8_t *scantable = w->abt_scantable[w->abt_type - 1].scantable;
430 // const uint8_t *scantable = w->abt_type - 1 ? w->abt_scantable[1].permutated : w->abt_scantable[0].scantable;
431 
432  sub_cbp = sub_cbp_table[decode012(&s->gb)];
433 
434  if (sub_cbp & 1)
435  if ((ret = ff_msmpeg4_decode_block(s, block, n, 1, scantable)) < 0)
436  return ret;
437 
438  if (sub_cbp & 2)
439  if ((ret = ff_msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable)) < 0)
440  return ret;
441 
442  s->block_last_index[n] = 63;
443 
444  return 0;
445  } else {
446  return ff_msmpeg4_decode_block(s, block, n, 1,
447  s->inter_scantable.permutated);
448  }
449 }
450 
452 {
453  /* The following is only allowed because this encoder
454  * does not use slice threading. */
455  WMV2DecContext *const w = (WMV2DecContext *) s;
456  int cbp, code, i, ret;
457  uint8_t *coded_val;
458 
459  if (w->j_type)
460  return 0;
461 
462  if (s->pict_type == AV_PICTURE_TYPE_P) {
463  if (IS_SKIP(s->current_picture.mb_type[s->mb_y * s->mb_stride + s->mb_x])) {
464  /* skip mb */
465  s->mb_intra = 0;
466  for (i = 0; i < 6; i++)
467  s->block_last_index[i] = -1;
468  s->mv_dir = MV_DIR_FORWARD;
469  s->mv_type = MV_TYPE_16X16;
470  s->mv[0][0][0] = 0;
471  s->mv[0][0][1] = 0;
472  s->mb_skipped = 1;
473  w->common.hshift = 0;
474  return 0;
475  }
476  if (get_bits_left(&s->gb) <= 0)
477  return AVERROR_INVALIDDATA;
478 
479  code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table,
481  s->mb_intra = (~code & 0x40) >> 6;
482 
483  cbp = code & 0x3f;
484  } else {
485  s->mb_intra = 1;
486  if (get_bits_left(&s->gb) <= 0)
487  return AVERROR_INVALIDDATA;
489  /* predict coded block pattern */
490  cbp = 0;
491  for (i = 0; i < 6; i++) {
492  int val = ((code >> (5 - i)) & 1);
493  if (i < 4) {
494  int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
495  val = val ^ pred;
496  *coded_val = val;
497  }
498  cbp |= val << (5 - i);
499  }
500  }
501 
502  if (!s->mb_intra) {
503  int mx, my;
504  wmv2_pred_motion(w, &mx, &my);
505 
506  if (cbp) {
507  s->bdsp.clear_blocks(s->block[0]);
508  if (s->per_mb_rl_table) {
509  s->rl_table_index = decode012(&s->gb);
510  s->rl_chroma_table_index = s->rl_table_index;
511  }
512 
513  if (w->abt_flag && w->per_mb_abt) {
514  w->per_block_abt = get_bits1(&s->gb);
515  if (!w->per_block_abt)
516  w->abt_type = decode012(&s->gb);
517  } else
518  w->per_block_abt = 0;
519  }
520 
521  wmv2_decode_motion(w, &mx, &my);
522 
523  s->mv_dir = MV_DIR_FORWARD;
524  s->mv_type = MV_TYPE_16X16;
525  s->mv[0][0][0] = mx;
526  s->mv[0][0][1] = my;
527 
528  for (i = 0; i < 6; i++) {
529  if ((ret = wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1)) < 0) {
530  av_log(s->avctx, AV_LOG_ERROR,
531  "\nerror while decoding inter block: %d x %d (%d)\n",
532  s->mb_x, s->mb_y, i);
533  return ret;
534  }
535  }
536  } else {
537  if (s->pict_type == AV_PICTURE_TYPE_P)
538  ff_dlog(s->avctx, "%d%d ", s->inter_intra_pred, cbp);
539  ff_dlog(s->avctx, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
540  ((cbp & 3) ? 1 : 0) + ((cbp & 0x3C) ? 2 : 0),
541  show_bits(&s->gb, 24));
542  s->ac_pred = get_bits1(&s->gb);
543  if (s->inter_intra_pred) {
544  s->h263_aic_dir = get_vlc2(&s->gb, ff_inter_intra_vlc.table,
546  ff_dlog(s->avctx, "%d%d %d %d/",
547  s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
548  }
549  if (s->per_mb_rl_table && cbp) {
550  s->rl_table_index = decode012(&s->gb);
551  s->rl_chroma_table_index = s->rl_table_index;
552  }
553 
554  s->bdsp.clear_blocks(s->block[0]);
555  for (i = 0; i < 6; i++) {
556  if ((ret = ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL)) < 0) {
557  av_log(s->avctx, AV_LOG_ERROR,
558  "\nerror while decoding intra block: %d x %d (%d)\n",
559  s->mb_x, s->mb_y, i);
560  return ret;
561  }
562  }
563  }
564 
565  return 0;
566 }
567 
569 {
570  WMV2DecContext *const w = avctx->priv_data;
571  MpegEncContext *const s = &w->s;
572  int ret;
573 
574  s->private_ctx = &w->common;
575 
576  if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
577  return ret;
578 
580  ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0],
582  ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[1],
584 
585  return ff_intrax8_common_init(avctx, &w->x8,
586  w->s.block, w->s.block_last_index,
587  w->s.mb_width, w->s.mb_height);
588 }
589 
591 {
592  WMV2DecContext *const w = avctx->priv_data;
593 
594  ff_intrax8_common_end(&w->x8);
595  return ff_h263_decode_end(avctx);
596 }
597 
599  .p.name = "wmv2",
600  CODEC_LONG_NAME("Windows Media Video 8"),
601  .p.type = AVMEDIA_TYPE_VIDEO,
602  .p.id = AV_CODEC_ID_WMV2,
603  .priv_data_size = sizeof(WMV2DecContext),
605  .close = wmv2_decode_end,
608  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
609  .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
610  AV_PIX_FMT_NONE },
611 };
WMV2DecContext::abt_type_table
int abt_type_table[6]
Definition: wmv2dec.c:46
A
#define A(x)
Definition: vpx_arith.h:28
MB_TYPE_L0
#define MB_TYPE_L0
Definition: mpegutils.h:60
MV_TYPE_16X16
#define MV_TYPE_16X16
1 vector for the whole mb
Definition: mpegvideo.h:255
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:839
wmv2_decode_inter_block
static int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block, int n, int cbp)
Definition: wmv2dec.c:411
mem_internal.h
WMV2DecContext::abt_block2
int16_t abt_block2[6][64]
Definition: wmv2dec.c:56
WMV2DecContext::skip_type
int skip_type
Definition: wmv2dec.c:53
ff_wmv2_decoder
const FFCodec ff_wmv2_decoder
Definition: wmv2dec.c:598
w
uint8_t w
Definition: llviddspenc.c:38
ff_simple_idct84_add
void ff_simple_idct84_add(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
Definition: simple_idct.c:194
wmv2_pred_motion
static int16_t * wmv2_pred_motion(WMV2DecContext *w, int *px, int *py)
Definition: wmv2dec.c:366
MB_TYPE_16x16
#define MB_TYPE_16x16
Definition: mpegutils.h:47
WMV2DecContext::mspel_bit
int mspel_bit
Definition: wmv2dec.c:49
WMV2DecContext::cbp_table_index
int cbp_table_index
Definition: wmv2dec.c:50
FFCodec
Definition: codec_internal.h:119
ff_er_add_slice
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
Definition: error_resilience.c:822
mpegvideo.h
ff_wmv2_add_mb
void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr)
Definition: wmv2dec.c:85
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
mpegutils.h
WMV2DecContext::top_left_mv_flag
int top_left_mv_flag
Definition: wmv2dec.c:51
init_get_bits
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:649
wmv2_decode_end
static av_cold int wmv2_decode_end(AVCodecContext *avctx)
Definition: wmv2dec.c:590
WMV2Context
Definition: wmv2.h:33
FF_DEBUG_PICT_INFO
#define FF_DEBUG_PICT_INFO
Definition: avcodec.h:1332
init
static int init
Definition: av_tx.c:47
ff_wmv2_decode_secondary_picture_header
int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)
Definition: wmv2dec.c:240
WMV2DecContext::per_block_abt
int per_block_abt
Definition: wmv2dec.c:48
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:123
WMV2DecContext
Definition: wmv2dec.c:38
wrap
#define wrap(func)
Definition: neontest.h:65
ff_intrax8_decode_picture
int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict, GetBitContext *gb, int *mb_x, int *mb_y, int dquant, int quant_offset, int loopfilter, int lowdelay)
Decode single IntraX8 frame.
Definition: intrax8.c:737
WMV2DecContext::x8
IntraX8Context x8
Definition: wmv2dec.c:41
WMV2DecContext::per_mb_rl_bit
int per_mb_rl_bit
Definition: wmv2dec.c:52
GetBitContext
Definition: get_bits.h:61
ff_mb_non_intra_vlc
VLC ff_mb_non_intra_vlc[4]
Definition: msmpeg4dec.c:69
ff_msmpeg4_decode_motion
void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
Definition: msmpeg4dec.c:835
val
static double val(void *priv, double ch)
Definition: aeval.c:77
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
WMV2DecContext::abt_type
int abt_type
Definition: wmv2dec.c:45
C
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
Definition: writing_filters.txt:58
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
h263dec.h
av_cold
#define av_cold
Definition: attributes.h:90
SKIP_TYPE_COL
#define SKIP_TYPE_COL
Definition: wmv2.h:30
ff_wmv2_decode_picture_header
int ff_wmv2_decode_picture_header(MpegEncContext *s)
Definition: wmv2dec.c:205
wmv2_get_cbp_table_index
static av_always_inline int wmv2_get_cbp_table_index(MpegEncContext *s, int cbp_index)
Definition: wmv2.h:46
msmpeg4data.h
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:279
s
#define s(width, name)
Definition: cbs_vp9.c:256
WMV2DecContext::per_mb_abt
int per_mb_abt
Definition: wmv2dec.c:47
WMV2DecContext::common
WMV2Context common
Definition: wmv2dec.c:40
AV_CODEC_ID_WMV2
@ AV_CODEC_ID_WMV2
Definition: codec_id.h:70
wmv2data.h
ff_simple_idct48_add
void ff_simple_idct48_add(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
Definition: simple_idct.c:209
WMV2DecContext::j_type
int j_type
Definition: wmv2dec.c:43
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
IS_SKIP
#define IS_SKIP(a)
Definition: mpegutils.h:74
simple_idct.h
SKIP_TYPE_NONE
#define SKIP_TYPE_NONE
Definition: wmv2.h:27
decode012
static int decode012(GetBitContext *gb)
Definition: get_bits.h:821
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
ff_intrax8_common_init
av_cold int ff_intrax8_common_init(AVCodecContext *avctx, IntraX8Context *w, int16_t(*block)[64], int block_last_index[12], int mb_width, int mb_height)
Initialize IntraX8 frame decoder.
Definition: intrax8.c:693
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:264
IntraX8Context
Definition: intrax8.h:29
WMV2DecContext::abt_scantable
ScanTable abt_scantable[2]
Definition: wmv2dec.c:55
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:64
if
if(ret)
Definition: filter_design.txt:179
FRAME_SKIPPED
#define FRAME_SKIPPED
Return value for header parsers if frame is not coded.
Definition: mpegutils.h:33
NULL
#define NULL
Definition: coverity.c:32
run
uint8_t run
Definition: svq3.c:203
parse_mb_skip
static int parse_mb_skip(WMV2DecContext *w)
Definition: wmv2dec.c:102
ff_intrax8_common_end
av_cold void ff_intrax8_common_end(IntraX8Context *w)
Destroy IntraX8 frame structure.
Definition: intrax8.c:732
decode_ext_header
static int decode_ext_header(WMV2DecContext *w)
Definition: wmv2dec.c:167
SKIP_TYPE_MPEG
#define SKIP_TYPE_MPEG
Definition: wmv2.h:28
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
INTER_INTRA_VLC_BITS
#define INTER_INTRA_VLC_BITS
Definition: msmpeg4dec.h:28
WMV2DecContext::s
MpegEncContext s
Definition: wmv2dec.c:39
mathops.h
ff_h263_decode_frame
int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, int *got_frame, AVPacket *avpkt)
Definition: h263dec.c:430
get_vlc2
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
Definition: get_bits.h:787
wmv2.h
ff_h263_decode_end
av_cold int ff_h263_decode_end(AVCodecContext *avctx)
Definition: h263dec.c:161
intrax8.h
ff_dlog
#define ff_dlog(a,...)
Definition: tableprint_vlc.h:28
wmv2_add_block
static void wmv2_add_block(WMV2DecContext *w, int16_t *block1, uint8_t *dst, int stride, int n)
Definition: wmv2dec.c:59
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
MB_NON_INTRA_VLC_BITS
#define MB_NON_INTRA_VLC_BITS
Definition: msmpeg4dec.h:29
AV_CODEC_FLAG_GRAY
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Definition: avcodec.h:259
codec_internal.h
ff_wmv2_scantableB
const uint8_t ff_wmv2_scantableB[64]
Definition: wmv2data.c:30
ff_inter_intra_vlc
VLC ff_inter_intra_vlc
Definition: msmpeg4dec.c:74
MB_TYPE_SKIP
#define MB_TYPE_SKIP
Definition: mpegutils.h:55
ff_wmv2_scantableA
const uint8_t ff_wmv2_scantableA[64]
Definition: wmv2data.c:23
wmv2_decode_motion
static void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr)
Definition: wmv2dec.c:354
msmpeg4dec.h
SKIP_TYPE_ROW
#define SKIP_TYPE_ROW
Definition: wmv2.h:29
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:116
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
show_bits
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:446
ff_init_scantable
av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
Definition: idctdsp.c:30
ff_msmpeg4_decode_block
int ff_msmpeg4_decode_block(MpegEncContext *s, int16_t *block, int n, int coded, const uint8_t *scan_table)
Definition: msmpeg4dec.c:648
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
WMV2DecContext::j_type_bit
int j_type_bit
Definition: wmv2dec.c:42
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:211
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
msmpeg4.h
mid_pred
#define mid_pred
Definition: mathops.h:98
ret
ret
Definition: filter_design.txt:187
wmv2dec.h
pred
static const float pred[4]
Definition: siprdata.h:259
B
#define B
Definition: huffyuvdsp.h:32
AVCodecContext
main external API structure.
Definition: avcodec.h:398
MB_INTRA_VLC_BITS
#define MB_INTRA_VLC_BITS
Definition: msmpeg4dec.h:30
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
WMV2DecContext::abt_flag
int abt_flag
Definition: wmv2dec.c:44
VLC::table
VLCElem * table
Definition: vlc.h:33
wmv2_decode_init
static av_cold int wmv2_decode_init(AVCodecContext *avctx)
Definition: wmv2dec.c:568
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ER_MB_END
#define ER_MB_END
Definition: error_resilience.h:39
ScanTable
Scantable.
Definition: idctdsp.h:31
diff
static av_always_inline int diff(const uint32_t a, const uint32_t b)
Definition: vf_palettegen.c:139
MV_DIR_FORWARD
#define MV_DIR_FORWARD
Definition: mpegvideo.h:251
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:425
ff_wmv2_decode_mb
int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
Definition: wmv2dec.c:451
AV_CODEC_CAP_DRAW_HORIZ_BAND
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
Definition: codec.h:44
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
ff_msmpeg4_decode_init
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
Definition: msmpeg4dec.c:370
ff_msmp4_mb_i_vlc
VLC ff_msmp4_mb_i_vlc
Definition: msmpeg4data.c:37
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:62
block1
static int16_t block1[64]
Definition: dct.c:118
ff_wmv2_common_init
av_cold void ff_wmv2_common_init(MpegEncContext *s)
Definition: wmv2.c:28
ff_msmpeg4_coded_block_pred
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
Definition: msmpeg4.c:163