Libav
truemotion2.c
Go to the documentation of this file.
1 /*
2  * Duck/ON2 TrueMotion 2 Decoder
3  * Copyright (c) 2005 Konstantin Shishkov
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
27 #include "avcodec.h"
28 #include "bytestream.h"
29 #include "get_bits.h"
30 #include "dsputil.h"
31 #include "internal.h"
32 
33 #define TM2_ESCAPE 0x80000000
34 #define TM2_DELTAS 64
35 
36 /* Huffman-coded streams of different types of blocks */
38  TM2_C_HI = 0,
46 };
47 
48 /* Block types */
49 enum TM2_BLOCKS {
57 };
58 
59 typedef struct TM2Context {
62 
65 
66  /* TM2 streams */
71  /* for blocks decoding */
72  int D[4];
73  int CD[4];
74  int *last;
75  int *clast;
76 
77  /* data for current and previous frame */
79  int *Y1, *U1, *V1, *Y2, *U2, *V2;
81  int cur;
82 } TM2Context;
83 
87 typedef struct TM2Codes {
88  VLC vlc;
89  int bits;
90  int *recode;
91  int length;
92 } TM2Codes;
93 
97 typedef struct TM2Huff {
98  int val_bits;
99  int max_bits;
100  int min_bits;
101  int nodes;
102  int num;
103  int max_num;
104  int *nums;
105  uint32_t *bits;
106  int *lens;
107 } TM2Huff;
108 
109 static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff *huff)
110 {
111  int ret;
112  if (length > huff->max_bits) {
113  av_log(ctx->avctx, AV_LOG_ERROR, "Tree exceeded its given depth (%i)\n",
114  huff->max_bits);
115  return AVERROR_INVALIDDATA;
116  }
117 
118  if (!get_bits1(&ctx->gb)) { /* literal */
119  if (length == 0) {
120  length = 1;
121  }
122  if (huff->num >= huff->max_num) {
123  av_log(ctx->avctx, AV_LOG_DEBUG, "Too many literals\n");
124  return AVERROR_INVALIDDATA;
125  }
126  huff->nums[huff->num] = get_bits_long(&ctx->gb, huff->val_bits);
127  huff->bits[huff->num] = prefix;
128  huff->lens[huff->num] = length;
129  huff->num++;
130  return 0;
131  } else { /* non-terminal node */
132  if ((ret = tm2_read_tree(ctx, prefix << 1, length + 1, huff)) < 0)
133  return ret;
134  if ((ret = tm2_read_tree(ctx, (prefix << 1) | 1, length + 1, huff)) < 0)
135  return ret;
136  }
137  return 0;
138 }
139 
140 static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
141 {
142  TM2Huff huff;
143  int res = 0;
144 
145  huff.val_bits = get_bits(&ctx->gb, 5);
146  huff.max_bits = get_bits(&ctx->gb, 5);
147  huff.min_bits = get_bits(&ctx->gb, 5);
148  huff.nodes = get_bits_long(&ctx->gb, 17);
149  huff.num = 0;
150 
151  /* check for correct codes parameters */
152  if ((huff.val_bits < 1) || (huff.val_bits > 32) ||
153  (huff.max_bits < 0) || (huff.max_bits > 25)) {
154  av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal "
155  "length: %i, max code length: %i\n", huff.val_bits, huff.max_bits);
156  return AVERROR_INVALIDDATA;
157  }
158  if ((huff.nodes <= 0) || (huff.nodes > 0x10000)) {
159  av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree "
160  "nodes: %i\n", huff.nodes);
161  return AVERROR_INVALIDDATA;
162  }
163  /* one-node tree */
164  if (huff.max_bits == 0)
165  huff.max_bits = 1;
166 
167  /* allocate space for codes - it is exactly ceil(nodes / 2) entries */
168  huff.max_num = (huff.nodes + 1) >> 1;
169  huff.nums = av_mallocz(huff.max_num * sizeof(int));
170  huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));
171  huff.lens = av_mallocz(huff.max_num * sizeof(int));
172 
173  res = tm2_read_tree(ctx, 0, 0, &huff);
174 
175  if (huff.num != huff.max_num) {
176  av_log(ctx->avctx, AV_LOG_ERROR, "Got less codes than expected: %i of %i\n",
177  huff.num, huff.max_num);
178  res = AVERROR_INVALIDDATA;
179  }
180 
181  /* convert codes to vlc_table */
182  if (res >= 0) {
183  int i;
184 
185  res = init_vlc(&code->vlc, huff.max_bits, huff.max_num,
186  huff.lens, sizeof(int), sizeof(int),
187  huff.bits, sizeof(uint32_t), sizeof(uint32_t), 0);
188  if (res < 0)
189  av_log(ctx->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
190  else {
191  code->bits = huff.max_bits;
192  code->length = huff.max_num;
193  code->recode = av_malloc(code->length * sizeof(int));
194  for (i = 0; i < code->length; i++)
195  code->recode[i] = huff.nums[i];
196  }
197  }
198  /* free allocated memory */
199  av_free(huff.nums);
200  av_free(huff.bits);
201  av_free(huff.lens);
202 
203  return res;
204 }
205 
206 static void tm2_free_codes(TM2Codes *code)
207 {
208  av_free(code->recode);
209  if (code->vlc.table)
210  ff_free_vlc(&code->vlc);
211 }
212 
213 static inline int tm2_get_token(GetBitContext *gb, TM2Codes *code)
214 {
215  int val;
216  val = get_vlc2(gb, code->vlc.table, code->bits, 1);
217  return code->recode[val];
218 }
219 
220 #define TM2_OLD_HEADER_MAGIC 0x00000100
221 #define TM2_NEW_HEADER_MAGIC 0x00000101
222 
223 static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf)
224 {
225  uint32_t magic = AV_RL32(buf);
226 
227  switch (magic) {
229  avpriv_request_sample(ctx->avctx, "Old TM2 header");
230  return 0;
232  return 0;
233  default:
234  av_log(ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08X\n", magic);
235  return AVERROR_INVALIDDATA;
236  }
237 }
238 
239 static int tm2_read_deltas(TM2Context *ctx, int stream_id)
240 {
241  int d, mb;
242  int i, v;
243 
244  d = get_bits(&ctx->gb, 9);
245  mb = get_bits(&ctx->gb, 5);
246 
247  if ((d < 1) || (d > TM2_DELTAS) || (mb < 1) || (mb > 32)) {
248  av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect delta table: %i deltas x %i bits\n", d, mb);
249  return AVERROR_INVALIDDATA;
250  }
251 
252  for (i = 0; i < d; i++) {
253  v = get_bits_long(&ctx->gb, mb);
254  if (v & (1 << (mb - 1)))
255  ctx->deltas[stream_id][i] = v - (1 << mb);
256  else
257  ctx->deltas[stream_id][i] = v;
258  }
259  for (; i < TM2_DELTAS; i++)
260  ctx->deltas[stream_id][i] = 0;
261 
262  return 0;
263 }
264 
265 static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, int buf_size)
266 {
267  int i, ret;
268  int skip = 0;
269  int len, toks, pos;
270  TM2Codes codes;
271  GetByteContext gb;
272 
273  /* get stream length in dwords */
274  bytestream2_init(&gb, buf, buf_size);
275  len = bytestream2_get_be32(&gb);
276  skip = len * 4 + 4;
277 
278  if (len == 0)
279  return 4;
280 
281  if (len >= INT_MAX/4-1 || len < 0 || len > buf_size) {
282  av_log(ctx->avctx, AV_LOG_ERROR, "Error, invalid stream size.\n");
283  return AVERROR_INVALIDDATA;
284  }
285 
286  toks = bytestream2_get_be32(&gb);
287  if (toks & 1) {
288  len = bytestream2_get_be32(&gb);
289  if (len == TM2_ESCAPE) {
290  len = bytestream2_get_be32(&gb);
291  }
292  if (len > 0) {
293  pos = bytestream2_tell(&gb);
294  if (skip <= pos)
295  return AVERROR_INVALIDDATA;
296  init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
297  if ((ret = tm2_read_deltas(ctx, stream_id)) < 0)
298  return ret;
299  bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2);
300  }
301  }
302  /* skip unused fields */
303  len = bytestream2_get_be32(&gb);
304  if (len == TM2_ESCAPE) { /* some unknown length - could be escaped too */
305  bytestream2_skip(&gb, 8); /* unused by decoder */
306  } else {
307  bytestream2_skip(&gb, 4); /* unused by decoder */
308  }
309 
310  pos = bytestream2_tell(&gb);
311  if (skip <= pos)
312  return AVERROR_INVALIDDATA;
313  init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
314  if ((ret = tm2_build_huff_table(ctx, &codes)) < 0)
315  return ret;
316  bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2);
317 
318  toks >>= 1;
319  /* check if we have sane number of tokens */
320  if ((toks < 0) || (toks > 0xFFFFFF)) {
321  av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
322  tm2_free_codes(&codes);
323  return AVERROR_INVALIDDATA;
324  }
325  ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
326  ctx->tok_lens[stream_id] = toks;
327  len = bytestream2_get_be32(&gb);
328  if (len > 0) {
329  pos = bytestream2_tell(&gb);
330  if (skip <= pos)
331  return AVERROR_INVALIDDATA;
332  init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
333  for (i = 0; i < toks; i++) {
334  if (get_bits_left(&ctx->gb) <= 0) {
335  av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
336  return AVERROR_INVALIDDATA;
337  }
338  ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes);
339  if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= TM2_DELTAS) {
340  av_log(ctx->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n",
341  ctx->tokens[stream_id][i], stream_id, i);
342  return AVERROR_INVALIDDATA;
343  }
344  }
345  } else {
346  for (i = 0; i < toks; i++) {
347  ctx->tokens[stream_id][i] = codes.recode[0];
348  if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= TM2_DELTAS) {
349  av_log(ctx->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n",
350  ctx->tokens[stream_id][i], stream_id, i);
351  return AVERROR_INVALIDDATA;
352  }
353  }
354  }
355  tm2_free_codes(&codes);
356 
357  return skip;
358 }
359 
360 static inline int GET_TOK(TM2Context *ctx,int type)
361 {
362  if (ctx->tok_ptrs[type] >= ctx->tok_lens[type]) {
363  av_log(ctx->avctx, AV_LOG_ERROR, "Read token from stream %i out of bounds (%i>=%i)\n", type, ctx->tok_ptrs[type], ctx->tok_lens[type]);
364  return 0;
365  }
366  if (type <= TM2_MOT)
367  return ctx->deltas[type][ctx->tokens[type][ctx->tok_ptrs[type]++]];
368  return ctx->tokens[type][ctx->tok_ptrs[type]++];
369 }
370 
371 /* blocks decoding routines */
372 
373 /* common Y, U, V pointers initialisation */
374 #define TM2_INIT_POINTERS() \
375  int *last, *clast; \
376  int *Y, *U, *V;\
377  int Ystride, Ustride, Vstride;\
378 \
379  Ystride = ctx->y_stride;\
380  Vstride = ctx->uv_stride;\
381  Ustride = ctx->uv_stride;\
382  Y = (ctx->cur?ctx->Y2:ctx->Y1) + by * 4 * Ystride + bx * 4;\
383  V = (ctx->cur?ctx->V2:ctx->V1) + by * 2 * Vstride + bx * 2;\
384  U = (ctx->cur?ctx->U2:ctx->U1) + by * 2 * Ustride + bx * 2;\
385  last = ctx->last + bx * 4;\
386  clast = ctx->clast + bx * 4;
387 
388 #define TM2_INIT_POINTERS_2() \
389  int *Yo, *Uo, *Vo;\
390  int oYstride, oUstride, oVstride;\
391 \
392  TM2_INIT_POINTERS();\
393  oYstride = Ystride;\
394  oVstride = Vstride;\
395  oUstride = Ustride;\
396  Yo = (ctx->cur?ctx->Y1:ctx->Y2) + by * 4 * oYstride + bx * 4;\
397  Vo = (ctx->cur?ctx->V1:ctx->V2) + by * 2 * oVstride + bx * 2;\
398  Uo = (ctx->cur?ctx->U1:ctx->U2) + by * 2 * oUstride + bx * 2;
399 
400 /* recalculate last and delta values for next blocks */
401 #define TM2_RECALC_BLOCK(CHR, stride, last, CD) {\
402  CD[0] = CHR[1] - last[1];\
403  CD[1] = (int)CHR[stride + 1] - (int)CHR[1];\
404  last[0] = (int)CHR[stride + 0];\
405  last[1] = (int)CHR[stride + 1];}
406 
407 /* common operations - add deltas to 4x4 block of luma or 2x2 blocks of chroma */
408 static inline void tm2_apply_deltas(TM2Context *ctx, int* Y, int stride, int *deltas, int *last)
409 {
410  int ct, d;
411  int i, j;
412 
413  for (j = 0; j < 4; j++){
414  ct = ctx->D[j];
415  for (i = 0; i < 4; i++){
416  d = deltas[i + j * 4];
417  ct += d;
418  last[i] += ct;
419  Y[i] = av_clip_uint8(last[i]);
420  }
421  Y += stride;
422  ctx->D[j] = ct;
423  }
424 }
425 
426 static inline void tm2_high_chroma(int *data, int stride, int *last, int *CD, int *deltas)
427 {
428  int i, j;
429  for (j = 0; j < 2; j++) {
430  for (i = 0; i < 2; i++) {
431  CD[j] += deltas[i + j * 2];
432  last[i] += CD[j];
433  data[i] = last[i];
434  }
435  data += stride;
436  }
437 }
438 
439 static inline void tm2_low_chroma(int *data, int stride, int *clast, int *CD, int *deltas, int bx)
440 {
441  int t;
442  int l;
443  int prev;
444 
445  if (bx > 0)
446  prev = clast[-3];
447  else
448  prev = 0;
449  t = (CD[0] + CD[1]) >> 1;
450  l = (prev - CD[0] - CD[1] + clast[1]) >> 1;
451  CD[1] = CD[0] + CD[1] - t;
452  CD[0] = t;
453  clast[0] = l;
454 
455  tm2_high_chroma(data, stride, clast, CD, deltas);
456 }
457 
458 static inline void tm2_hi_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
459 {
460  int i;
461  int deltas[16];
463 
464  /* hi-res chroma */
465  for (i = 0; i < 4; i++) {
466  deltas[i] = GET_TOK(ctx, TM2_C_HI);
467  deltas[i + 4] = GET_TOK(ctx, TM2_C_HI);
468  }
469  tm2_high_chroma(U, Ustride, clast, ctx->CD, deltas);
470  tm2_high_chroma(V, Vstride, clast + 2, ctx->CD + 2, deltas + 4);
471 
472  /* hi-res luma */
473  for (i = 0; i < 16; i++)
474  deltas[i] = GET_TOK(ctx, TM2_L_HI);
475 
476  tm2_apply_deltas(ctx, Y, Ystride, deltas, last);
477 }
478 
479 static inline void tm2_med_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
480 {
481  int i;
482  int deltas[16];
484 
485  /* low-res chroma */
486  deltas[0] = GET_TOK(ctx, TM2_C_LO);
487  deltas[1] = deltas[2] = deltas[3] = 0;
488  tm2_low_chroma(U, Ustride, clast, ctx->CD, deltas, bx);
489 
490  deltas[0] = GET_TOK(ctx, TM2_C_LO);
491  deltas[1] = deltas[2] = deltas[3] = 0;
492  tm2_low_chroma(V, Vstride, clast + 2, ctx->CD + 2, deltas, bx);
493 
494  /* hi-res luma */
495  for (i = 0; i < 16; i++)
496  deltas[i] = GET_TOK(ctx, TM2_L_HI);
497 
498  tm2_apply_deltas(ctx, Y, Ystride, deltas, last);
499 }
500 
501 static inline void tm2_low_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
502 {
503  int i;
504  int t1, t2;
505  int deltas[16];
507 
508  /* low-res chroma */
509  deltas[0] = GET_TOK(ctx, TM2_C_LO);
510  deltas[1] = deltas[2] = deltas[3] = 0;
511  tm2_low_chroma(U, Ustride, clast, ctx->CD, deltas, bx);
512 
513  deltas[0] = GET_TOK(ctx, TM2_C_LO);
514  deltas[1] = deltas[2] = deltas[3] = 0;
515  tm2_low_chroma(V, Vstride, clast + 2, ctx->CD + 2, deltas, bx);
516 
517  /* low-res luma */
518  for (i = 0; i < 16; i++)
519  deltas[i] = 0;
520 
521  deltas[ 0] = GET_TOK(ctx, TM2_L_LO);
522  deltas[ 2] = GET_TOK(ctx, TM2_L_LO);
523  deltas[ 8] = GET_TOK(ctx, TM2_L_LO);
524  deltas[10] = GET_TOK(ctx, TM2_L_LO);
525 
526  if (bx > 0)
527  last[0] = (last[-1] - ctx->D[0] - ctx->D[1] - ctx->D[2] - ctx->D[3] + last[1]) >> 1;
528  else
529  last[0] = (last[1] - ctx->D[0] - ctx->D[1] - ctx->D[2] - ctx->D[3])>> 1;
530  last[2] = (last[1] + last[3]) >> 1;
531 
532  t1 = ctx->D[0] + ctx->D[1];
533  ctx->D[0] = t1 >> 1;
534  ctx->D[1] = t1 - (t1 >> 1);
535  t2 = ctx->D[2] + ctx->D[3];
536  ctx->D[2] = t2 >> 1;
537  ctx->D[3] = t2 - (t2 >> 1);
538 
539  tm2_apply_deltas(ctx, Y, Ystride, deltas, last);
540 }
541 
542 static inline void tm2_null_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
543 {
544  int i;
545  int ct;
546  int left, right, diff;
547  int deltas[16];
549 
550  /* null chroma */
551  deltas[0] = deltas[1] = deltas[2] = deltas[3] = 0;
552  tm2_low_chroma(U, Ustride, clast, ctx->CD, deltas, bx);
553 
554  deltas[0] = deltas[1] = deltas[2] = deltas[3] = 0;
555  tm2_low_chroma(V, Vstride, clast + 2, ctx->CD + 2, deltas, bx);
556 
557  /* null luma */
558  for (i = 0; i < 16; i++)
559  deltas[i] = 0;
560 
561  ct = ctx->D[0] + ctx->D[1] + ctx->D[2] + ctx->D[3];
562 
563  if (bx > 0)
564  left = last[-1] - ct;
565  else
566  left = 0;
567 
568  right = last[3];
569  diff = right - left;
570  last[0] = left + (diff >> 2);
571  last[1] = left + (diff >> 1);
572  last[2] = right - (diff >> 2);
573  last[3] = right;
574  {
575  int tp = left;
576 
577  ctx->D[0] = (tp + (ct >> 2)) - left;
578  left += ctx->D[0];
579  ctx->D[1] = (tp + (ct >> 1)) - left;
580  left += ctx->D[1];
581  ctx->D[2] = ((tp + ct) - (ct >> 2)) - left;
582  left += ctx->D[2];
583  ctx->D[3] = (tp + ct) - left;
584  }
585  tm2_apply_deltas(ctx, Y, Ystride, deltas, last);
586 }
587 
588 static inline void tm2_still_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
589 {
590  int i, j;
592 
593  /* update chroma */
594  for (j = 0; j < 2; j++) {
595  for (i = 0; i < 2; i++){
596  U[i] = Uo[i];
597  V[i] = Vo[i];
598  }
599  U += Ustride; V += Vstride;
600  Uo += oUstride; Vo += oVstride;
601  }
602  U -= Ustride * 2;
603  V -= Vstride * 2;
604  TM2_RECALC_BLOCK(U, Ustride, clast, ctx->CD);
605  TM2_RECALC_BLOCK(V, Vstride, (clast + 2), (ctx->CD + 2));
606 
607  /* update deltas */
608  ctx->D[0] = Yo[3] - last[3];
609  ctx->D[1] = Yo[3 + oYstride] - Yo[3];
610  ctx->D[2] = Yo[3 + oYstride * 2] - Yo[3 + oYstride];
611  ctx->D[3] = Yo[3 + oYstride * 3] - Yo[3 + oYstride * 2];
612 
613  for (j = 0; j < 4; j++) {
614  for (i = 0; i < 4; i++) {
615  Y[i] = Yo[i];
616  last[i] = Yo[i];
617  }
618  Y += Ystride;
619  Yo += oYstride;
620  }
621 }
622 
623 static inline void tm2_update_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
624 {
625  int i, j;
626  int d;
628 
629  /* update chroma */
630  for (j = 0; j < 2; j++) {
631  for (i = 0; i < 2; i++) {
632  U[i] = Uo[i] + GET_TOK(ctx, TM2_UPD);
633  V[i] = Vo[i] + GET_TOK(ctx, TM2_UPD);
634  }
635  U += Ustride;
636  V += Vstride;
637  Uo += oUstride;
638  Vo += oVstride;
639  }
640  U -= Ustride * 2;
641  V -= Vstride * 2;
642  TM2_RECALC_BLOCK(U, Ustride, clast, ctx->CD);
643  TM2_RECALC_BLOCK(V, Vstride, (clast + 2), (ctx->CD + 2));
644 
645  /* update deltas */
646  ctx->D[0] = Yo[3] - last[3];
647  ctx->D[1] = Yo[3 + oYstride] - Yo[3];
648  ctx->D[2] = Yo[3 + oYstride * 2] - Yo[3 + oYstride];
649  ctx->D[3] = Yo[3 + oYstride * 3] - Yo[3 + oYstride * 2];
650 
651  for (j = 0; j < 4; j++) {
652  d = last[3];
653  for (i = 0; i < 4; i++) {
654  Y[i] = Yo[i] + GET_TOK(ctx, TM2_UPD);
655  last[i] = Y[i];
656  }
657  ctx->D[j] = last[3] - d;
658  Y += Ystride;
659  Yo += oYstride;
660  }
661 }
662 
663 static inline void tm2_motion_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
664 {
665  int i, j;
666  int mx, my;
668 
669  mx = GET_TOK(ctx, TM2_MOT);
670  my = GET_TOK(ctx, TM2_MOT);
671  mx = av_clip(mx, -(bx * 4 + 4), ctx->avctx->width - bx * 4);
672  my = av_clip(my, -(by * 4 + 4), ctx->avctx->height - by * 4);
673 
674  Yo += my * oYstride + mx;
675  Uo += (my >> 1) * oUstride + (mx >> 1);
676  Vo += (my >> 1) * oVstride + (mx >> 1);
677 
678  /* copy chroma */
679  for (j = 0; j < 2; j++) {
680  for (i = 0; i < 2; i++) {
681  U[i] = Uo[i];
682  V[i] = Vo[i];
683  }
684  U += Ustride;
685  V += Vstride;
686  Uo += oUstride;
687  Vo += oVstride;
688  }
689  U -= Ustride * 2;
690  V -= Vstride * 2;
691  TM2_RECALC_BLOCK(U, Ustride, clast, ctx->CD);
692  TM2_RECALC_BLOCK(V, Vstride, (clast + 2), (ctx->CD + 2));
693 
694  /* copy luma */
695  for (j = 0; j < 4; j++) {
696  for (i = 0; i < 4; i++) {
697  Y[i] = Yo[i];
698  }
699  Y += Ystride;
700  Yo += oYstride;
701  }
702  /* calculate deltas */
703  Y -= Ystride * 4;
704  ctx->D[0] = Y[3] - last[3];
705  ctx->D[1] = Y[3 + Ystride] - Y[3];
706  ctx->D[2] = Y[3 + Ystride * 2] - Y[3 + Ystride];
707  ctx->D[3] = Y[3 + Ystride * 3] - Y[3 + Ystride * 2];
708  for (i = 0; i < 4; i++)
709  last[i] = Y[i + Ystride * 3];
710 }
711 
713 {
714  int i, j;
715  int w = ctx->avctx->width, h = ctx->avctx->height, bw = w >> 2, bh = h >> 2, cw = w >> 1;
716  int type;
717  int keyframe = 1;
718  int *Y, *U, *V;
719  uint8_t *dst;
720 
721  for (i = 0; i < TM2_NUM_STREAMS; i++)
722  ctx->tok_ptrs[i] = 0;
723 
724  if (ctx->tok_lens[TM2_TYPE]<bw*bh) {
725  av_log(ctx->avctx,AV_LOG_ERROR,"Got %i tokens for %i blocks\n",ctx->tok_lens[TM2_TYPE],bw*bh);
726  return AVERROR_INVALIDDATA;
727  }
728 
729  memset(ctx->last, 0, 4 * bw * sizeof(int));
730  memset(ctx->clast, 0, 4 * bw * sizeof(int));
731 
732  for (j = 0; j < bh; j++) {
733  memset(ctx->D, 0, 4 * sizeof(int));
734  memset(ctx->CD, 0, 4 * sizeof(int));
735  for (i = 0; i < bw; i++) {
736  type = GET_TOK(ctx, TM2_TYPE);
737  switch(type) {
738  case TM2_HI_RES:
739  tm2_hi_res_block(ctx, p, i, j);
740  break;
741  case TM2_MED_RES:
742  tm2_med_res_block(ctx, p, i, j);
743  break;
744  case TM2_LOW_RES:
745  tm2_low_res_block(ctx, p, i, j);
746  break;
747  case TM2_NULL_RES:
748  tm2_null_res_block(ctx, p, i, j);
749  break;
750  case TM2_UPDATE:
751  tm2_update_block(ctx, p, i, j);
752  keyframe = 0;
753  break;
754  case TM2_STILL:
755  tm2_still_block(ctx, p, i, j);
756  keyframe = 0;
757  break;
758  case TM2_MOTION:
759  tm2_motion_block(ctx, p, i, j);
760  keyframe = 0;
761  break;
762  default:
763  av_log(ctx->avctx, AV_LOG_ERROR, "Skipping unknown block type %i\n", type);
764  }
765  }
766  }
767 
768  /* copy data from our buffer to AVFrame */
769  Y = (ctx->cur?ctx->Y2:ctx->Y1);
770  U = (ctx->cur?ctx->U2:ctx->U1);
771  V = (ctx->cur?ctx->V2:ctx->V1);
772  dst = p->data[0];
773  for (j = 0; j < h; j++) {
774  for (i = 0; i < w; i++) {
775  int y = Y[i], u = U[i >> 1], v = V[i >> 1];
776  dst[3*i+0] = av_clip_uint8(y + v);
777  dst[3*i+1] = av_clip_uint8(y);
778  dst[3*i+2] = av_clip_uint8(y + u);
779  }
780 
781  /* horizontal edge extension */
782  Y[-4] = Y[-3] = Y[-2] = Y[-1] = Y[0];
783  Y[w + 3] = Y[w + 2] = Y[w + 1] = Y[w] = Y[w - 1];
784 
785  /* vertical edge extension */
786  if (j == 0) {
787  memcpy(Y - 4 - 1 * ctx->y_stride, Y - 4, ctx->y_stride);
788  memcpy(Y - 4 - 2 * ctx->y_stride, Y - 4, ctx->y_stride);
789  memcpy(Y - 4 - 3 * ctx->y_stride, Y - 4, ctx->y_stride);
790  memcpy(Y - 4 - 4 * ctx->y_stride, Y - 4, ctx->y_stride);
791  } else if (j == h - 1) {
792  memcpy(Y - 4 + 1 * ctx->y_stride, Y - 4, ctx->y_stride);
793  memcpy(Y - 4 + 2 * ctx->y_stride, Y - 4, ctx->y_stride);
794  memcpy(Y - 4 + 3 * ctx->y_stride, Y - 4, ctx->y_stride);
795  memcpy(Y - 4 + 4 * ctx->y_stride, Y - 4, ctx->y_stride);
796  }
797 
798  Y += ctx->y_stride;
799  if (j & 1) {
800  /* horizontal edge extension */
801  U[-2] = U[-1] = U[0];
802  V[-2] = V[-1] = V[0];
803  U[cw + 1] = U[cw] = U[cw - 1];
804  V[cw + 1] = V[cw] = V[cw - 1];
805 
806  /* vertical edge extension */
807  if (j == 1) {
808  memcpy(U - 2 - 1 * ctx->uv_stride, U - 2, ctx->uv_stride);
809  memcpy(V - 2 - 1 * ctx->uv_stride, V - 2, ctx->uv_stride);
810  memcpy(U - 2 - 2 * ctx->uv_stride, U - 2, ctx->uv_stride);
811  memcpy(V - 2 - 2 * ctx->uv_stride, V - 2, ctx->uv_stride);
812  } else if (j == h - 1) {
813  memcpy(U - 2 + 1 * ctx->uv_stride, U - 2, ctx->uv_stride);
814  memcpy(V - 2 + 1 * ctx->uv_stride, V - 2, ctx->uv_stride);
815  memcpy(U - 2 + 2 * ctx->uv_stride, U - 2, ctx->uv_stride);
816  memcpy(V - 2 + 2 * ctx->uv_stride, V - 2, ctx->uv_stride);
817  }
818 
819  U += ctx->uv_stride;
820  V += ctx->uv_stride;
821  }
822  dst += p->linesize[0];
823  }
824 
825  return keyframe;
826 }
827 
828 static const int tm2_stream_order[TM2_NUM_STREAMS] = {
830 };
831 
832 #define TM2_HEADER_SIZE 40
833 
834 static int decode_frame(AVCodecContext *avctx,
835  void *data, int *got_frame,
836  AVPacket *avpkt)
837 {
838  TM2Context * const l = avctx->priv_data;
839  const uint8_t *buf = avpkt->data;
840  int buf_size = avpkt->size & ~3;
841  AVFrame * const p = l->pic;
842  int offset = TM2_HEADER_SIZE;
843  int i, t, ret;
844  uint8_t *swbuf;
845 
846  swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
847  if (!swbuf) {
848  av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
849  return AVERROR(ENOMEM);
850  }
851 
852  if ((ret = ff_reget_buffer(avctx, p)) < 0) {
853  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
854  av_free(swbuf);
855  return ret;
856  }
857 
858  l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)buf, buf_size >> 2);
859 
860  if ((ret = tm2_read_header(l, swbuf)) < 0) {
861  av_free(swbuf);
862  return ret;
863  }
864 
865  for (i = 0; i < TM2_NUM_STREAMS; i++) {
866  if (offset >= buf_size) {
867  av_free(swbuf);
868  return AVERROR_INVALIDDATA;
869  }
870  t = tm2_read_stream(l, swbuf + offset, tm2_stream_order[i],
871  buf_size - offset);
872  if (t < 0) {
873  av_free(swbuf);
874  return t;
875  }
876  offset += t;
877  }
878  p->key_frame = tm2_decode_blocks(l, p);
879  if (p->key_frame)
881  else
883 
884  l->cur = !l->cur;
885  *got_frame = 1;
886  ret = av_frame_ref(data, l->pic);
887  av_free(swbuf);
888 
889  return (ret < 0) ? ret : buf_size;
890 }
891 
893 {
894  TM2Context * const l = avctx->priv_data;
895  int i, w = avctx->width, h = avctx->height;
896 
897  if ((avctx->width & 3) || (avctx->height & 3)) {
898  av_log(avctx, AV_LOG_ERROR, "Width and height must be multiple of 4\n");
899  return AVERROR(EINVAL);
900  }
901 
902  l->avctx = avctx;
903  avctx->pix_fmt = AV_PIX_FMT_BGR24;
904 
905  l->pic = av_frame_alloc();
906  if (!l->pic)
907  return AVERROR(ENOMEM);
908 
909  ff_dsputil_init(&l->dsp, avctx);
910 
911  l->last = av_malloc(4 * sizeof(*l->last) * (w >> 2));
912  l->clast = av_malloc(4 * sizeof(*l->clast) * (w >> 2));
913 
914  for (i = 0; i < TM2_NUM_STREAMS; i++) {
915  l->tokens[i] = NULL;
916  l->tok_lens[i] = 0;
917  }
918 
919  w += 8;
920  h += 8;
921  l->Y1_base = av_malloc(sizeof(*l->Y1_base) * w * h);
922  l->Y2_base = av_malloc(sizeof(*l->Y2_base) * w * h);
923  l->y_stride = w;
924  w = (w + 1) >> 1;
925  h = (h + 1) >> 1;
926  l->U1_base = av_malloc(sizeof(*l->U1_base) * w * h);
927  l->V1_base = av_malloc(sizeof(*l->V1_base) * w * h);
928  l->U2_base = av_malloc(sizeof(*l->U2_base) * w * h);
929  l->V2_base = av_malloc(sizeof(*l->V1_base) * w * h);
930  l->uv_stride = w;
931  l->cur = 0;
932  if (!l->Y1_base || !l->Y2_base || !l->U1_base ||
933  !l->V1_base || !l->U2_base || !l->V2_base ||
934  !l->last || !l->clast) {
935  av_freep(&l->Y1_base);
936  av_freep(&l->Y2_base);
937  av_freep(&l->U1_base);
938  av_freep(&l->U2_base);
939  av_freep(&l->V1_base);
940  av_freep(&l->V2_base);
941  av_freep(&l->last);
942  av_freep(&l->clast);
943  return AVERROR(ENOMEM);
944  }
945  l->Y1 = l->Y1_base + l->y_stride * 4 + 4;
946  l->Y2 = l->Y2_base + l->y_stride * 4 + 4;
947  l->U1 = l->U1_base + l->uv_stride * 2 + 2;
948  l->U2 = l->U2_base + l->uv_stride * 2 + 2;
949  l->V1 = l->V1_base + l->uv_stride * 2 + 2;
950  l->V2 = l->V2_base + l->uv_stride * 2 + 2;
951 
952  return 0;
953 }
954 
956 {
957  TM2Context * const l = avctx->priv_data;
958  int i;
959 
960  av_free(l->last);
961  av_free(l->clast);
962  for (i = 0; i < TM2_NUM_STREAMS; i++)
963  av_free(l->tokens[i]);
964  if (l->Y1) {
965  av_free(l->Y1_base);
966  av_free(l->U1_base);
967  av_free(l->V1_base);
968  av_free(l->Y2_base);
969  av_free(l->U2_base);
970  av_free(l->V2_base);
971  }
972 
973  av_frame_free(&l->pic);
974 
975  return 0;
976 }
977 
979  .name = "truemotion2",
980  .long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0"),
981  .type = AVMEDIA_TYPE_VIDEO,
983  .priv_data_size = sizeof(TM2Context),
984  .init = decode_init,
985  .close = decode_end,
986  .decode = decode_frame,
987  .capabilities = CODEC_CAP_DR1,
988 };
static void tm2_low_chroma(int *data, int stride, int *clast, int *CD, int *deltas, int bx)
Definition: truemotion2.c:439
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:62
av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
Definition: dsputil.c:2440
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:54
This structure describes decoded (raw) audio or video data.
Definition: frame.h:107
int * V2
Definition: truemotion2.c:79
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:240
int * U1_base
Definition: truemotion2.c:78
int D[4]
Definition: truemotion2.c:72
int * last
Definition: truemotion2.c:74
int * recode
table for converting from code indexes to values
Definition: truemotion2.c:90
int size
Definition: avcodec.h:974
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1247
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:130
AVCodec ff_truemotion2_decoder
Definition: truemotion2.c:978
Definition: vf_drawbox.c:37
int stride
Definition: mace.c:144
AVCodec.
Definition: avcodec.h:2755
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
Definition: vf_drawbox.c:37
int num
current number filled
Definition: truemotion2.c:102
static int tm2_read_header(TM2Context *ctx, const uint8_t *buf)
Definition: truemotion2.c:223
#define TM2_HEADER_SIZE
Definition: truemotion2.c:832
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
Definition: mimic.c:269
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
structure for gathering Huffman codes information
Definition: truemotion2.c:97
uint8_t
#define av_cold
Definition: attributes.h:66
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:43
TM2_STREAMS
Definition: truemotion2.c:37
static const int tm2_stream_order[TM2_NUM_STREAMS]
Definition: truemotion2.c:828
AVCodecContext * avctx
Definition: truemotion2.c:60
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:174
int max_bits
maximum length of code
Definition: truemotion2.c:99
static int tm2_read_deltas(TM2Context *ctx, int stream_id)
Definition: truemotion2.c:239
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:711
const char data[16]
Definition: mxf.c:66
static void tm2_free_codes(TM2Codes *code)
Definition: truemotion2.c:206
uint8_t * data
Definition: avcodec.h:973
DSPContext dsp
Definition: truemotion2.c:64
int min_bits
minimum length of code
Definition: truemotion2.c:100
int * U2
Definition: truemotion2.c:79
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:194
static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff *huff)
Definition: truemotion2.c:109
VLC vlc
table for Libav bitstream reader
Definition: truemotion2.c:88
bitstream reader API header.
static void tm2_hi_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
Definition: truemotion2.c:458
static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, int buf_size)
Definition: truemotion2.c:265
static float t
Definition: output.c:52
static void tm2_update_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
Definition: truemotion2.c:623
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:555
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:123
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:186
int val_bits
length of literal
Definition: truemotion2.c:98
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
Definition: dsputil.h:202
#define AVERROR(e)
Definition: error.h:43
static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
Definition: truemotion2.c:140
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:159
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:55
static void tm2_low_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
Definition: truemotion2.c:501
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:142
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:144
static int tm2_decode_blocks(TM2Context *ctx, AVFrame *p)
Definition: truemotion2.c:712
int * tokens[TM2_NUM_STREAMS]
Definition: truemotion2.c:67
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:148
const char * name
Name of the codec implementation.
Definition: avcodec.h:2762
int * clast
Definition: truemotion2.c:75
Definition: get_bits.h:64
AVFrame * pic
Definition: truemotion2.c:61
int * V1
Definition: truemotion2.c:79
int * V2_base
Definition: truemotion2.c:78
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:509
int max_num
total number of codes
Definition: truemotion2.c:103
#define V
Definition: options_table.h:35
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
Definition: utils.c:755
int bits
Definition: truemotion2.c:89
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:168
static int GET_TOK(TM2Context *ctx, int type)
Definition: truemotion2.c:360
int width
picture width / height.
Definition: avcodec.h:1217
#define TM2_OLD_HEADER_MAGIC
Definition: truemotion2.c:220
int uv_stride
Definition: truemotion2.c:80
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
Definition: get_bits.h:522
#define AV_RL32
Definition: intreadwrite.h:146
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:68
static int tm2_get_token(GetBitContext *gb, TM2Codes *code)
Definition: truemotion2.c:213
int CD[4]
Definition: truemotion2.c:73
int * nums
literals
Definition: truemotion2.c:104
int nodes
total number of nodes in tree
Definition: truemotion2.c:101
if(ac->has_optimized_func)
static av_cold int decode_end(AVCodecContext *avctx)
Definition: truemotion2.c:955
int * Y1
Definition: truemotion2.c:79
int * V1_base
Definition: truemotion2.c:78
static av_always_inline int bytestream2_tell(GetByteContext *g)
Definition: bytestream.h:183
NULL
Definition: eval.c:55
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:125
#define TM2_INIT_POINTERS_2()
Definition: truemotion2.c:388
main external API structure.
Definition: avcodec.h:1054
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:489
static void tm2_still_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
Definition: truemotion2.c:588
#define TM2_DELTAS
Definition: truemotion2.c:34
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
Definition: get_bits.h:424
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:271
#define TM2_INIT_POINTERS()
Definition: truemotion2.c:374
int * Y1_base
Definition: truemotion2.c:78
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:375
static void tm2_med_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
Definition: truemotion2.c:479
static void tm2_motion_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
Definition: truemotion2.c:663
uint32_t * bits
codes
Definition: truemotion2.c:105
int length
Definition: truemotion2.c:91
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:304
static void tm2_apply_deltas(TM2Context *ctx, int *Y, int stride, int *deltas, int *last)
Definition: truemotion2.c:408
#define TM2_ESCAPE
Definition: truemotion2.c:33
#define TM2_RECALC_BLOCK(CHR, stride, last, CD)
Definition: truemotion2.c:401
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:113
int * U1
Definition: truemotion2.c:79
int * Y2
Definition: truemotion2.c:79
common internal api header.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
Definition: mem.c:117
int y_stride
Definition: truemotion2.c:80
static void tm2_null_res_block(TM2Context *ctx, AVFrame *pic, int bx, int by)
Definition: truemotion2.c:542
int deltas[TM2_NUM_STREAMS][TM2_DELTAS]
Definition: truemotion2.c:70
int * lens
codelengths
Definition: truemotion2.c:106
static av_cold int decode_init(AVCodecContext *avctx)
Definition: truemotion2.c:892
int * Y2_base
Definition: truemotion2.c:78
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:498
DSP utils.
#define TM2_NEW_HEADER_MAGIC
Definition: truemotion2.c:221
void * priv_data
Definition: avcodec.h:1090
int * U2_base
Definition: truemotion2.c:78
TM2_BLOCKS
Definition: truemotion2.c:49
GetBitContext gb
Definition: truemotion2.c:63
int len
VLC_TYPE(* table)[2]
code, bits
Definition: get_bits.h:66
int tok_lens[TM2_NUM_STREAMS]
Definition: truemotion2.c:68
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:163
static void tm2_high_chroma(int *data, int stride, int *last, int *CD, int *deltas)
Definition: truemotion2.c:426
Huffman codes for each of streams.
Definition: truemotion2.c:87
int tok_ptrs[TM2_NUM_STREAMS]
Definition: truemotion2.c:69
This structure stores compressed data.
Definition: avcodec.h:950
void ff_free_vlc(VLC *vlc)
Definition: bitstream.c:333
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:205
Predicted.
Definition: avutil.h:254
DSPContext.
Definition: dsputil.h:124
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: truemotion2.c:834