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 "mpegvideodec.h"
31 #include "msmpeg4.h"
32 #include "msmpeg4_vc1_data.h"
33 #include "msmpeg4dec.h"
34 #include "simple_idct.h"
35 #include "wmv2.h"
36 #include "wmv2data.h"
37 #include "wmv2dec.h"
38 
39 typedef struct WMV2DecContext {
44  int j_type;
45  int abt_flag;
46  int abt_type;
50  int mspel_bit;
54  int skip_type;
55 
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  H263DecContext *const h = &w->ms.h;
63 
64  if (h->c.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  h->c.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  h->c.bdsp.clear_block(w->abt_block2[n]);
78  break;
79  default:
80  av_log(h->c.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  H263DecContext *const h = &w->ms.h;
105  int coded_mb_count = 0;
106  uint32_t *const mb_type = h->c.cur_pic.mb_type;
107 
108  w->skip_type = get_bits(&h->gb, 2);
109  switch (w->skip_type) {
110  case SKIP_TYPE_NONE:
111  for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
112  for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
113  mb_type[mb_y * h->c.mb_stride + mb_x] =
115  break;
116  case SKIP_TYPE_MPEG:
117  if (get_bits_left(&h->gb) < h->c.mb_height * h->c.mb_width)
118  return AVERROR_INVALIDDATA;
119  for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
120  for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
121  mb_type[mb_y * h->c.mb_stride + mb_x] =
123  break;
124  case SKIP_TYPE_ROW:
125  for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++) {
126  if (get_bits_left(&h->gb) < 1)
127  return AVERROR_INVALIDDATA;
128  if (get_bits1(&h->gb)) {
129  for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
130  mb_type[mb_y * h->c.mb_stride + mb_x] =
132  } else {
133  for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
134  mb_type[mb_y * h->c.mb_stride + mb_x] =
136  }
137  }
138  break;
139  case SKIP_TYPE_COL:
140  for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++) {
141  if (get_bits_left(&h->gb) < 1)
142  return AVERROR_INVALIDDATA;
143  if (get_bits1(&h->gb)) {
144  for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
145  mb_type[mb_y * h->c.mb_stride + mb_x] =
147  } else {
148  for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
149  mb_type[mb_y * h->c.mb_stride + mb_x] =
151  }
152  }
153  break;
154  }
155 
156  for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
157  for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
158  coded_mb_count += !IS_SKIP(mb_type[mb_y * h->c.mb_stride + mb_x]);
159 
160  if (coded_mb_count > get_bits_left(&h->gb))
161  return AVERROR_INVALIDDATA;
162 
163  return 0;
164 }
165 
167 {
168  H263DecContext *const h = &w->ms.h;
169  GetBitContext gb;
170  int fps;
171  int code;
172 
173  if (h->c.avctx->extradata_size < 4)
174  return AVERROR_INVALIDDATA;
175 
176  init_get_bits(&gb, h->c.avctx->extradata, 32);
177 
178  fps = get_bits(&gb, 5);
179  w->ms.bit_rate = get_bits(&gb, 11) * 1024;
180  w->mspel_bit = get_bits1(&gb);
181  h->loop_filter = get_bits1(&gb);
182  w->abt_flag = get_bits1(&gb);
183  w->j_type_bit = get_bits1(&gb);
184  w->top_left_mv_flag = get_bits1(&gb);
185  w->per_mb_rl_bit = get_bits1(&gb);
186  code = get_bits(&gb, 3);
187 
188  if (code == 0)
189  return AVERROR_INVALIDDATA;
190 
191  h->slice_height = h->c.mb_height / code;
192 
193  if (h->c.avctx->debug & FF_DEBUG_PICT_INFO)
194  av_log(h->c.avctx, AV_LOG_DEBUG,
195  "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, "
196  "tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, "
197  "slices:%d\n",
198  fps, w->ms.bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit,
199  w->top_left_mv_flag, w->per_mb_rl_bit, code, h->loop_filter,
200  code);
201  return 0;
202 }
203 
205 {
206  int code;
207 
208  h->c.pict_type = get_bits1(&h->gb) + 1;
209  if (h->c.pict_type == AV_PICTURE_TYPE_I) {
210  code = get_bits(&h->gb, 7);
211  av_log(h->c.avctx, AV_LOG_DEBUG, "I7:%X/\n", code);
212  }
213  h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
214  if (h->c.qscale <= 0)
215  return AVERROR_INVALIDDATA;
216 
217  if (h->c.pict_type != AV_PICTURE_TYPE_I && show_bits(&h->gb, 1)) {
218  GetBitContext gb = h->gb;
219  int skip_type = get_bits(&gb, 2);
220  int run = skip_type == SKIP_TYPE_COL ? h->c.mb_width : h->c.mb_height;
221 
222  while (run > 0) {
223  int block = FFMIN(run, 25);
224  if (get_bits(&gb, block) + 1 != 1<<block)
225  break;
226  run -= block;
227  }
228  if (!run)
229  return FRAME_SKIPPED;
230  }
231 
232  return 0;
233 }
234 
236 {
237  WMV2DecContext *const w = (WMV2DecContext *)h;
238 
239  if (h->c.pict_type == AV_PICTURE_TYPE_I) {
240  /* Is filling with zeroes really the right thing to do? */
241  memset(h->c.cur_pic.mb_type, 0,
242  sizeof(*h->c.cur_pic.mb_type) * h->c.mb_height * h->c.mb_stride);
243  if (w->j_type_bit)
244  w->j_type = get_bits1(&h->gb);
245  else
246  w->j_type = 0; // FIXME check
247 
248  if (!w->j_type) {
249  if (w->per_mb_rl_bit)
250  w->ms.per_mb_rl_table = get_bits1(&h->gb);
251  else
252  w->ms.per_mb_rl_table = 0;
253 
254  if (!w->ms.per_mb_rl_table) {
255  w->ms.rl_chroma_table_index = decode012(&h->gb);
256  w->ms.rl_table_index = decode012(&h->gb);
257  }
258 
259  w->ms.dc_table_index = get_bits1(&h->gb);
260 
261  // at minimum one bit per macroblock is required at least in a valid frame,
262  // we discard frames much smaller than this. Frames smaller than 1/8 of the
263  // smallest "black/skip" frame generally contain not much recoverable content
264  // while at the same time they have the highest computational requirements
265  // per byte
266  if (get_bits_left(&h->gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
267  return AVERROR_INVALIDDATA;
268  }
269  h->c.inter_intra_pred = 0;
270  h->c.no_rounding = 1;
271  if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) {
272  av_log(h->c.avctx, AV_LOG_DEBUG,
273  "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",
274  h->c.qscale, w->ms.rl_chroma_table_index, w->ms.rl_table_index,
275  w->ms.dc_table_index, w->ms.per_mb_rl_table, w->j_type);
276  }
277  } else {
278  int cbp_index;
279  int ret;
280  w->j_type = 0;
281 
282  ret = parse_mb_skip(w);
283  if (ret < 0)
284  return ret;
285  cbp_index = decode012(&h->gb);
286  w->cbp_table_index = wmv2_get_cbp_table_index(h->c.qscale, cbp_index);
287 
288  if (w->mspel_bit)
289  h->c.mspel = get_bits1(&h->gb);
290  else
291  h->c.mspel = 0; // FIXME check
292 
293  if (w->abt_flag) {
294  w->per_mb_abt = get_bits1(&h->gb) ^ 1;
295  if (!w->per_mb_abt)
296  w->abt_type = decode012(&h->gb);
297  }
298 
299  if (w->per_mb_rl_bit)
300  w->ms.per_mb_rl_table = get_bits1(&h->gb);
301  else
302  w->ms.per_mb_rl_table = 0;
303 
304  if (!w->ms.per_mb_rl_table) {
305  w->ms.rl_table_index = decode012(&h->gb);
306  w->ms.rl_chroma_table_index = w->ms.rl_table_index;
307  }
308 
309  if (get_bits_left(&h->gb) < 2)
310  return AVERROR_INVALIDDATA;
311 
312  w->ms.dc_table_index = get_bits1(&h->gb);
313  w->ms.mv_table_index = get_bits1(&h->gb);
314 
315  h->c.inter_intra_pred = 0; // (h->c.width * h->c.height < 320 * 240 && w->ms.bit_rate <= II_BITRATE);
316  h->c.no_rounding ^= 1;
317 
318  if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) {
319  av_log(h->c.avctx, AV_LOG_DEBUG,
320  "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "
321  "per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",
322  w->ms.rl_table_index, w->ms.rl_chroma_table_index,
323  w->ms.dc_table_index, w->ms.mv_table_index,
324  w->ms.per_mb_rl_table, h->c.qscale, h->c.mspel,
325  w->per_mb_abt, w->abt_type, w->cbp_table_index,
326  h->c.inter_intra_pred);
327  }
328  }
329  w->ms.esc3_level_length = 0;
330  w->ms.esc3_run_length = 0;
331 
332  if (w->j_type) {
333  ff_intrax8_decode_picture(&w->x8, h->c.cur_pic.ptr,
334  &h->gb, &h->c.mb_x, &h->c.mb_y,
335  2 * h->c.qscale, (h->c.qscale - 1) | 1,
336  h->loop_filter, h->c.low_delay);
337 
338  ff_er_add_slice(&h->c.er, 0, 0,
339  (h->c.mb_x >> 1) - 1, (h->c.mb_y >> 1) - 1,
340  ER_MB_END);
341  return 1;
342  }
343 
344  return 0;
345 }
346 
347 static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr)
348 {
349  H263DecContext *const h = &w->ms.h;
350 
351  ff_msmpeg4_decode_motion(&w->ms, mx_ptr, my_ptr);
352 
353  if ((((*mx_ptr) | (*my_ptr)) & 1) && h->c.mspel)
354  w->common.hshift = get_bits1(&h->gb);
355  else
356  w->common.hshift = 0;
357 }
358 
359 static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py)
360 {
361  H263DecContext *const h = &w->ms.h;
362  int diff, type;
363 
364  int wrap = h->c.b8_stride;
365  int xy = h->c.block_index[0];
366 
367  int16_t *mot_val = h->c.cur_pic.motion_val[0][xy];
368 
369  const int16_t *A = h->c.cur_pic.motion_val[0][xy - 1];
370  const int16_t *B = h->c.cur_pic.motion_val[0][xy - wrap];
371  const int16_t *C = h->c.cur_pic.motion_val[0][xy + 2 - wrap];
372 
373  if (h->c.mb_x && !h->c.first_slice_line && !h->c.mspel && w->top_left_mv_flag)
374  diff = FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1]));
375  else
376  diff = 0;
377 
378  if (diff >= 8)
379  type = get_bits1(&h->gb);
380  else
381  type = 2;
382 
383  if (type == 0) {
384  *px = A[0];
385  *py = A[1];
386  } else if (type == 1) {
387  *px = B[0];
388  *py = B[1];
389  } else {
390  /* special case for first (slice) line */
391  if (h->c.first_slice_line) {
392  *px = A[0];
393  *py = A[1];
394  } else {
395  *px = mid_pred(A[0], B[0], C[0]);
396  *py = mid_pred(A[1], B[1], C[1]);
397  }
398  }
399 
400  return mot_val;
401 }
402 
403 static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block,
404  int n, int cbp)
405 {
406  H263DecContext *const h = &w->ms.h;
407  static const int sub_cbp_table[3] = { 2, 3, 1 };
408  int sub_cbp, ret;
409 
410  if (!cbp) {
411  h->c.block_last_index[n] = -1;
412  return 0;
413  }
414 
415  if (w->per_block_abt)
416  w->abt_type = decode012(&h->gb);
417  w->abt_type_table[n] = w->abt_type;
418 
419  if (w->abt_type) {
420  const uint8_t *scantable = w->abt_type == 1 ? ff_wmv2_scantableA : ff_wmv2_scantableB;
421 
422  sub_cbp = sub_cbp_table[decode012(&h->gb)];
423 
424  if (sub_cbp & 1) {
425  ret = ff_msmpeg4_decode_block(&w->ms, block, n, 1, scantable);
426  if (ret < 0)
427  return ret;
428  }
429 
430  if (sub_cbp & 2) {
431  ret = ff_msmpeg4_decode_block(&w->ms, w->abt_block2[n], n, 1, scantable);
432  if (ret < 0)
433  return ret;
434  }
435 
436  h->c.block_last_index[n] = 63;
437 
438  return 0;
439  } else {
440  return ff_msmpeg4_decode_block(&w->ms, block, n, 1,
441  h->c.inter_scantable.permutated);
442  }
443 }
444 
445 static int wmv2_decode_mb(H263DecContext *const h)
446 {
447  /* The following is only allowed because this decoder
448  * does not use slice threading. */
449  WMV2DecContext *const w = (WMV2DecContext *) h;
450  MSMP4DecContext *const ms = &w->ms;
451  int cbp, code, i, ret;
452  uint8_t *coded_val;
453 
454  if (w->j_type)
455  return 0;
456 
457  if (h->c.pict_type == AV_PICTURE_TYPE_P) {
458  if (IS_SKIP(h->c.cur_pic.mb_type[h->c.mb_y * h->c.mb_stride + h->c.mb_x])) {
459  /* skip mb */
460  h->c.mb_intra = 0;
461  for (i = 0; i < 6; i++)
462  h->c.block_last_index[i] = -1;
463  h->c.mv_dir = MV_DIR_FORWARD;
464  h->c.mv_type = MV_TYPE_16X16;
465  h->c.mv[0][0][0] = 0;
466  h->c.mv[0][0][1] = 0;
467  h->c.mb_skipped = 1;
468  w->common.hshift = 0;
469  return 0;
470  }
471  if (get_bits_left(&h->gb) <= 0)
472  return AVERROR_INVALIDDATA;
473 
474  code = get_vlc2(&h->gb, ff_mb_non_intra_vlc[w->cbp_table_index],
476  h->c.mb_intra = (~code & 0x40) >> 6;
477 
478  cbp = code & 0x3f;
479  } else {
480  h->c.mb_intra = 1;
481  if (get_bits_left(&h->gb) <= 0)
482  return AVERROR_INVALIDDATA;
485  /* predict coded block pattern */
486  cbp = 0;
487  for (i = 0; i < 6; i++) {
488  int val = ((code >> (5 - i)) & 1);
489  if (i < 4) {
490  int pred = ff_msmpeg4_coded_block_pred(&h->c, i, &coded_val);
491  val = val ^ pred;
492  *coded_val = val;
493  }
494  cbp |= val << (5 - i);
495  }
496  }
497 
498  if (!h->c.mb_intra) {
499  int mx, my;
500  wmv2_pred_motion(w, &mx, &my);
501 
502  if (cbp) {
503  h->c.bdsp.clear_blocks(h->block[0]);
504  if (ms->per_mb_rl_table) {
505  ms->rl_table_index = decode012(&h->gb);
507  }
508 
509  if (w->abt_flag && w->per_mb_abt) {
510  w->per_block_abt = get_bits1(&h->gb);
511  if (!w->per_block_abt)
512  w->abt_type = decode012(&h->gb);
513  } else
514  w->per_block_abt = 0;
515  }
516 
517  wmv2_decode_motion(w, &mx, &my);
518 
519  h->c.mv_dir = MV_DIR_FORWARD;
520  h->c.mv_type = MV_TYPE_16X16;
521  h->c.mv[0][0][0] = mx;
522  h->c.mv[0][0][1] = my;
523 
524  for (i = 0; i < 6; i++) {
525  if ((ret = wmv2_decode_inter_block(w, h->block[i], i, (cbp >> (5 - i)) & 1)) < 0) {
526  av_log(h->c.avctx, AV_LOG_ERROR,
527  "\nerror while decoding inter block: %d x %d (%d)\n",
528  h->c.mb_x, h->c.mb_y, i);
529  return ret;
530  }
531  }
532  } else {
533  if (h->c.pict_type == AV_PICTURE_TYPE_P)
534  ff_dlog(h->c.avctx, "%d%d ", h->c.inter_intra_pred, cbp);
535  ff_dlog(h->c.avctx, "I at %d %d %d %06X\n", h->c.mb_x, h->c.mb_y,
536  ((cbp & 3) ? 1 : 0) + ((cbp & 0x3C) ? 2 : 0),
537  show_bits(&h->gb, 24));
538  h->c.ac_pred = get_bits1(&h->gb);
539  if (h->c.inter_intra_pred) {
540  h->c.h263_aic_dir = get_vlc2(&h->gb, ff_inter_intra_vlc,
542  ff_dlog(h->c.avctx, "%d%d %d %d/",
543  h->c.ac_pred, h->c.h263_aic_dir, h->c.mb_x, h->c.mb_y);
544  }
545  if (ms->per_mb_rl_table && cbp) {
546  ms->rl_table_index = decode012(&h->gb);
548  }
549 
550  h->c.bdsp.clear_blocks(h->block[0]);
551  for (i = 0; i < 6; i++) {
552  ret = ff_msmpeg4_decode_block(ms, h->block[i], i, (cbp >> (5 - i)) & 1, NULL);
553  if (ret < 0) {
554  av_log(h->c.avctx, AV_LOG_ERROR,
555  "\nerror while decoding intra block: %d x %d (%d)\n",
556  h->c.mb_x, h->c.mb_y, i);
557  return ret;
558  }
559  }
560  }
561 
562  return 0;
563 }
564 
566 {
567  WMV2DecContext *const w = avctx->priv_data;
568  H263DecContext *const h = &w->ms.h;
569  MpegEncContext *const s = &h->c;
570  int ret;
571 
572  s->private_ctx = &w->common;
573 
574  if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
575  return ret;
576 
577  h->decode_header = wmv2_decode_picture_header;
578  h->decode_mb = wmv2_decode_mb;
579 
581 
583 
584  return ff_intrax8_common_init(avctx, &w->x8, h->block[0],
585  s->mb_width, s->mb_height);
586 }
587 
589 {
590  WMV2DecContext *const w = avctx->priv_data;
591 
592  ff_intrax8_common_end(&w->x8);
593  return ff_mpv_decode_close(avctx);
594 }
595 
597  .p.name = "wmv2",
598  CODEC_LONG_NAME("Windows Media Video 8"),
599  .p.type = AVMEDIA_TYPE_VIDEO,
600  .p.id = AV_CODEC_ID_WMV2,
601  .priv_data_size = sizeof(WMV2DecContext),
606  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
607 };
WMV2DecContext::abt_type_table
int abt_type_table[6]
Definition: wmv2dec.c:47
A
#define A(x)
Definition: vpx_arith.h:28
wmv2_decode_mb
static int wmv2_decode_mb(H263DecContext *const h)
Definition: wmv2dec.c:445
MV_TYPE_16X16
#define MV_TYPE_16X16
1 vector for the whole mb
Definition: mpegvideo.h:175
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:678
wmv2_get_cbp_table_index
static av_always_inline int wmv2_get_cbp_table_index(int qscale, int cbp_index)
Definition: wmv2.h:47
wmv2_decode_inter_block
static int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block, int n, int cbp)
Definition: wmv2dec.c:403
mem_internal.h
ff_intrax8_decode_picture
int ff_intrax8_decode_picture(IntraX8Context *w, MPVPicture *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:721
WMV2DecContext::abt_block2
int16_t abt_block2[6][64]
Definition: wmv2dec.c:56
ff_wmv2_decode_secondary_picture_header
int ff_wmv2_decode_secondary_picture_header(H263DecContext *const h)
Definition: wmv2dec.c:235
WMV2DecContext::skip_type
int skip_type
Definition: wmv2dec.c:54
ff_wmv2_decoder
const FFCodec ff_wmv2_decoder
Definition: wmv2dec.c:596
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:189
MSMP4_MB_INTRA_VLC_BITS
#define MSMP4_MB_INTRA_VLC_BITS
Definition: msmpeg4_vc1_data.h:36
wmv2_pred_motion
static int16_t * wmv2_pred_motion(WMV2DecContext *w, int *px, int *py)
Definition: wmv2dec.c:359
MB_TYPE_16x16
#define MB_TYPE_16x16
Definition: mpegutils.h:41
WMV2DecContext::mspel_bit
int mspel_bit
Definition: wmv2dec.c:50
WMV2DecContext::cbp_table_index
int cbp_table_index
Definition: wmv2dec.c:51
FFCodec
Definition: codec_internal.h:127
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:828
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:52
init_get_bits
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:497
wmv2_decode_end
static av_cold int wmv2_decode_end(AVCodecContext *avctx)
Definition: wmv2dec.c:588
WMV2Context
Definition: wmv2.h:33
FF_DEBUG_PICT_INFO
#define FF_DEBUG_PICT_INFO
Definition: avcodec.h:1375
MSMP4DecContext::rl_table_index
int rl_table_index
Definition: msmpeg4dec.h:37
close
static av_cold void close(AVCodecParserContext *s)
Definition: apv_parser.c:135
WMV2DecContext::per_block_abt
int per_block_abt
Definition: wmv2dec.c:49
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:318
mx
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
Definition: dsp.h:57
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
WMV2DecContext::ms
MSMP4DecContext ms
Definition: wmv2dec.c:40
WMV2DecContext
Definition: wmv2dec.c:39
wrap
#define wrap(func)
Definition: neontest.h:65
WMV2DecContext::x8
IntraX8Context x8
Definition: wmv2dec.c:42
WMV2DecContext::per_mb_rl_bit
int per_mb_rl_bit
Definition: wmv2dec.c:53
GetBitContext
Definition: get_bits.h:108
wmv2_decode_picture_header
static int wmv2_decode_picture_header(H263DecContext *const h)
Definition: wmv2dec.c:204
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
ff_msmpeg4_decode_motion
void ff_msmpeg4_decode_motion(MSMP4DecContext *const ms, int *mx_ptr, int *my_ptr)
Definition: msmpeg4dec.c:802
WMV2DecContext::abt_type
int abt_type
Definition: wmv2dec.c:46
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
mpegvideodec.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
h263dec.h
av_cold
#define av_cold
Definition: attributes.h:90
SKIP_TYPE_COL
#define SKIP_TYPE_COL
Definition: wmv2.h:30
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:341
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_intrax8_common_init
av_cold int ff_intrax8_common_init(AVCodecContext *avctx, IntraX8Context *w, int16_t block[64], int mb_width, int mb_height)
Initialize IntraX8 frame decoder.
Definition: intrax8.c:679
WMV2DecContext::per_mb_abt
int per_mb_abt
Definition: wmv2dec.c:48
ff_mb_non_intra_vlc
const VLCElem * ff_mb_non_intra_vlc[4]
Definition: msmpeg4dec.c:69
MSMP4DecContext::per_mb_rl_table
int per_mb_rl_table
Definition: msmpeg4dec.h:41
WMV2DecContext::common
WMV2Context common
Definition: wmv2dec.c:41
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:204
WMV2DecContext::j_type
int j_type
Definition: wmv2dec.c:44
B
#define B
Definition: huffyuv.h:42
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
IS_SKIP
#define IS_SKIP(a)
Definition: mpegutils.h:75
simple_idct.h
SKIP_TYPE_NONE
#define SKIP_TYPE_NONE
Definition: wmv2.h:27
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:326
IntraX8Context
Definition: intrax8.h:28
my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
Definition: dsp.h:57
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
if
if(ret)
Definition: filter_design.txt:179
NULL
#define NULL
Definition: coverity.c:32
run
uint8_t run
Definition: svq3.c:207
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:716
MSMP4DecContext
Definition: msmpeg4dec.h:32
ff_mpv_decode_close
av_cold int ff_mpv_decode_close(AVCodecContext *avctx)
Definition: mpegvideo_dec.c:125
decode_ext_header
static int decode_ext_header(WMV2DecContext *w)
Definition: wmv2dec.c:166
SKIP_TYPE_MPEG
#define SKIP_TYPE_MPEG
Definition: wmv2.h:28
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:278
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:371
INTER_INTRA_VLC_BITS
#define INTER_INTRA_VLC_BITS
Definition: msmpeg4dec.h:29
MSMP4DecContext::rl_chroma_table_index
int rl_chroma_table_index
Definition: msmpeg4dec.h:38
mathops.h
ff_h263_decode_frame
int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, int *got_frame, AVPacket *avpkt)
Definition: h263dec.c:428
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:635
wmv2.h
ff_inter_intra_vlc
VLCElem ff_inter_intra_vlc[8]
Definition: msmpeg4dec.c:74
intrax8.h
ff_dlog
#define ff_dlog(a,...)
Definition: tableprint_vlc.h:28
ff_msmp4_mb_i_vlc
VLCElem ff_msmp4_mb_i_vlc[536]
Definition: msmpeg4_vc1_data.c:35
wmv2_add_block
static void wmv2_add_block(WMV2DecContext *w, int16_t *block1, uint8_t *dst, int stride, int n)
Definition: wmv2dec.c:59
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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:30
AV_CODEC_FLAG_GRAY
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Definition: avcodec.h:302
codec_internal.h
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:104
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
ff_wmv2_scantableB
const uint8_t ff_wmv2_scantableB[64]
Definition: wmv2data.c:30
FRAME_SKIPPED
#define FRAME_SKIPPED
Frame is not coded.
Definition: h263dec.h:87
MB_TYPE_SKIP
#define MB_TYPE_SKIP
Definition: mpegutils.h:61
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:347
diff
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Definition: vf_paletteuse.c:166
block1
static int16_t block1[64]
Definition: dct.c:127
msmpeg4dec.h
SKIP_TYPE_ROW
#define SKIP_TYPE_ROW
Definition: wmv2.h:29
ff_msmpeg4_decode_block
int ff_msmpeg4_decode_block(MSMP4DecContext *const ms, int16_t *block, int n, int coded, const uint8_t *scan_table)
Definition: msmpeg4dec.c:612
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
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:354
decode012
static int BS_FUNC() decode012(BSCTX *bc)
Return decoded truncated unary code for the values 0, 1, 2.
Definition: bitstream_template.h:436
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
WMV2DecContext::j_type_bit
int j_type_bit
Definition: wmv2dec.c:43
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
avcodec.h
stride
#define stride
Definition: h264pred_template.c:536
msmpeg4.h
mid_pred
#define mid_pred
Definition: mathops.h:97
ret
ret
Definition: filter_design.txt:187
wmv2dec.h
pred
static const float pred[4]
Definition: siprdata.h:259
H263DecContext
Definition: h263dec.h:43
AVCodecContext
main external API structure.
Definition: avcodec.h:431
WMV2DecContext::abt_flag
int abt_flag
Definition: wmv2dec.c:45
wmv2_decode_init
static av_cold int wmv2_decode_init(AVCodecContext *avctx)
Definition: wmv2dec.c:565
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:279
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
msmpeg4_vc1_data.h
ER_MB_END
#define ER_MB_END
Definition: error_resilience.h:37
MV_DIR_FORWARD
#define MV_DIR_FORWARD
Definition: mpegvideo.h:171
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
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
h
h
Definition: vp9dsp_template.c:2070
ff_msmpeg4_decode_init
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
Definition: msmpeg4dec.c:834
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:63
ff_wmv2_common_init
av_cold void ff_wmv2_common_init(MpegEncContext *s)
Definition: wmv2.c:28
MB_TYPE_FORWARD_MV
#define MB_TYPE_FORWARD_MV
Definition: mpegutils.h:49
ff_msmpeg4_coded_block_pred
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
Definition: msmpeg4.c:157