FFmpeg
mss3.c
Go to the documentation of this file.
1 /*
2  * Microsoft Screen 3 (aka Microsoft ATC Screen) decoder
3  * Copyright (c) 2012 Konstantin Shishkov
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg 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  * FFmpeg 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 FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * Microsoft Screen 3 (aka Microsoft ATC Screen) decoder
25  */
26 
27 #include "avcodec.h"
28 #include "bytestream.h"
29 #include "codec_internal.h"
30 #include "internal.h"
31 #include "mathops.h"
32 #include "mss34dsp.h"
33 
34 #define HEADER_SIZE 27
35 
36 #define MODEL2_SCALE 13
37 #define MODEL_SCALE 15
38 #define MODEL256_SEC_SCALE 9
39 
40 typedef struct Model2 {
44 } Model2;
45 
46 typedef struct Model {
47  int weights[16], freqs[16];
48  int num_syms;
51 } Model;
52 
53 typedef struct Model256 {
54  int weights[256], freqs[256];
56  int secondary[68];
57  int sec_size;
59 } Model256;
60 
61 #define RAC_BOTTOM 0x01000000
62 typedef struct RangeCoder {
63  const uint8_t *src, *src_end;
64 
65  uint32_t range, low;
66  int got_error;
67 } RangeCoder;
68 
69 enum BlockType {
75 };
76 
77 typedef struct BlockTypeContext {
78  int last_type;
81 
82 typedef struct FillBlockCoder {
83  int fill_val;
86 
87 typedef struct ImageBlockCoder {
92 
93 typedef struct DCTBlockCoder {
94  int *prev_dc;
95  ptrdiff_t prev_dc_stride;
97  int quality;
98  uint16_t qmat[64];
102 } DCTBlockCoder;
103 
104 typedef struct HaarBlockCoder {
109 
110 typedef struct MSS3Context {
113 
121 
122  int dctblock[64];
123  int hblock[16 * 16];
124 } MSS3Context;
125 
126 
127 static void model2_reset(Model2 *m)
128 {
129  m->zero_weight = 1;
130  m->total_weight = 2;
131  m->zero_freq = 0x1000;
132  m->total_freq = 0x2000;
133  m->upd_val = 4;
134  m->till_rescale = 4;
135 }
136 
137 static void model2_update(Model2 *m, int bit)
138 {
139  unsigned scale;
140 
141  if (!bit)
142  m->zero_weight++;
143  m->till_rescale--;
144  if (m->till_rescale)
145  return;
146 
147  m->total_weight += m->upd_val;
148  if (m->total_weight > 0x2000) {
149  m->total_weight = (m->total_weight + 1) >> 1;
150  m->zero_weight = (m->zero_weight + 1) >> 1;
151  if (m->total_weight == m->zero_weight)
152  m->total_weight = m->zero_weight + 1;
153  }
154  m->upd_val = m->upd_val * 5 >> 2;
155  if (m->upd_val > 64)
156  m->upd_val = 64;
157  scale = 0x80000000u / m->total_weight;
158  m->zero_freq = m->zero_weight * scale >> 18;
159  m->total_freq = m->total_weight * scale >> 18;
160  m->till_rescale = m->upd_val;
161 }
162 
163 static void model_update(Model *m, int val)
164 {
165  int i, sum = 0;
166  unsigned scale;
167 
168  m->weights[val]++;
169  m->till_rescale--;
170  if (m->till_rescale)
171  return;
172  m->tot_weight += m->upd_val;
173 
174  if (m->tot_weight > 0x8000) {
175  m->tot_weight = 0;
176  for (i = 0; i < m->num_syms; i++) {
177  m->weights[i] = (m->weights[i] + 1) >> 1;
178  m->tot_weight += m->weights[i];
179  }
180  }
181  scale = 0x80000000u / m->tot_weight;
182  for (i = 0; i < m->num_syms; i++) {
183  m->freqs[i] = sum * scale >> 16;
184  sum += m->weights[i];
185  }
186 
187  m->upd_val = m->upd_val * 5 >> 2;
188  if (m->upd_val > m->max_upd_val)
189  m->upd_val = m->max_upd_val;
190  m->till_rescale = m->upd_val;
191 }
192 
193 static void model_reset(Model *m)
194 {
195  int i;
196 
197  m->tot_weight = 0;
198  for (i = 0; i < m->num_syms - 1; i++)
199  m->weights[i] = 1;
200  m->weights[m->num_syms - 1] = 0;
201 
202  m->upd_val = m->num_syms;
203  m->till_rescale = 1;
204  model_update(m, m->num_syms - 1);
205  m->till_rescale =
206  m->upd_val = (m->num_syms + 6) >> 1;
207 }
208 
209 static av_cold void model_init(Model *m, int num_syms)
210 {
211  m->num_syms = num_syms;
212  m->max_upd_val = 8 * num_syms + 48;
213 
214  model_reset(m);
215 }
216 
217 static void model256_update(Model256 *m, int val)
218 {
219  int i, sum = 0;
220  unsigned scale;
221  int send, sidx = 1;
222 
223  m->weights[val]++;
224  m->till_rescale--;
225  if (m->till_rescale)
226  return;
227  m->tot_weight += m->upd_val;
228 
229  if (m->tot_weight > 0x8000) {
230  m->tot_weight = 0;
231  for (i = 0; i < 256; i++) {
232  m->weights[i] = (m->weights[i] + 1) >> 1;
233  m->tot_weight += m->weights[i];
234  }
235  }
236  scale = 0x80000000u / m->tot_weight;
237  m->secondary[0] = 0;
238  for (i = 0; i < 256; i++) {
239  m->freqs[i] = sum * scale >> 16;
240  sum += m->weights[i];
241  send = m->freqs[i] >> MODEL256_SEC_SCALE;
242  while (sidx <= send)
243  m->secondary[sidx++] = i - 1;
244  }
245  while (sidx < m->sec_size)
246  m->secondary[sidx++] = 255;
247 
248  m->upd_val = m->upd_val * 5 >> 2;
249  if (m->upd_val > m->max_upd_val)
250  m->upd_val = m->max_upd_val;
251  m->till_rescale = m->upd_val;
252 }
253 
254 static void model256_reset(Model256 *m)
255 {
256  int i;
257 
258  for (i = 0; i < 255; i++)
259  m->weights[i] = 1;
260  m->weights[255] = 0;
261 
262  m->tot_weight = 0;
263  m->upd_val = 256;
264  m->till_rescale = 1;
265  model256_update(m, 255);
266  m->till_rescale =
267  m->upd_val = (256 + 6) >> 1;
268 }
269 
271 {
272  m->max_upd_val = 8 * 256 + 48;
273  m->sec_size = (1 << 6) + 2;
274 
275  model256_reset(m);
276 }
277 
278 static void rac_init(RangeCoder *c, const uint8_t *src, int size)
279 {
280  int i;
281 
282  c->src = src;
283  c->src_end = src + size;
284  c->low = 0;
285  for (i = 0; i < FFMIN(size, 4); i++)
286  c->low = (c->low << 8) | *c->src++;
287  c->range = 0xFFFFFFFF;
288  c->got_error = 0;
289 }
290 
292 {
293  for (;;) {
294  c->range <<= 8;
295  c->low <<= 8;
296  if (c->src < c->src_end) {
297  c->low |= *c->src++;
298  } else if (!c->low) {
299  c->got_error = 1;
300  c->low = 1;
301  }
302  if (c->low > c->range) {
303  c->got_error = 1;
304  c->low = 1;
305  }
306  if (c->range >= RAC_BOTTOM)
307  return;
308  }
309 }
310 
312 {
313  int bit;
314 
315  c->range >>= 1;
316 
317  bit = (c->range <= c->low);
318  if (bit)
319  c->low -= c->range;
320 
321  if (c->range < RAC_BOTTOM)
322  rac_normalise(c);
323 
324  return bit;
325 }
326 
327 static int rac_get_bits(RangeCoder *c, int nbits)
328 {
329  int val;
330 
331  c->range >>= nbits;
332  val = c->low / c->range;
333  c->low -= c->range * val;
334 
335  if (c->range < RAC_BOTTOM)
336  rac_normalise(c);
337 
338  return val;
339 }
340 
342 {
343  int bit, helper;
344 
345  helper = m->zero_freq * (c->range >> MODEL2_SCALE);
346  bit = (c->low >= helper);
347  if (bit) {
348  c->low -= helper;
349  c->range -= helper;
350  } else {
351  c->range = helper;
352  }
353 
354  if (c->range < RAC_BOTTOM)
355  rac_normalise(c);
356 
357  model2_update(m, bit);
358 
359  return bit;
360 }
361 
363 {
364  int val;
365  int end, end2;
366  unsigned prob, prob2, helper;
367 
368  prob = 0;
369  prob2 = c->range;
370  c->range >>= MODEL_SCALE;
371  val = 0;
372  end = m->num_syms >> 1;
373  end2 = m->num_syms;
374  do {
375  helper = m->freqs[end] * c->range;
376  if (helper <= c->low) {
377  val = end;
378  prob = helper;
379  } else {
380  end2 = end;
381  prob2 = helper;
382  }
383  end = (end2 + val) >> 1;
384  } while (end != val);
385  c->low -= prob;
386  c->range = prob2 - prob;
387  if (c->range < RAC_BOTTOM)
388  rac_normalise(c);
389 
390  model_update(m, val);
391 
392  return val;
393 }
394 
396 {
397  int val;
398  int start, end;
399  int ssym;
400  unsigned prob, prob2, helper;
401 
402  prob2 = c->range;
403  c->range >>= MODEL_SCALE;
404 
405  helper = c->low / c->range;
406  ssym = helper >> MODEL256_SEC_SCALE;
407  val = m->secondary[ssym];
408 
409  end = start = m->secondary[ssym + 1] + 1;
410  while (end > val + 1) {
411  ssym = (end + val) >> 1;
412  if (m->freqs[ssym] <= helper) {
413  end = start;
414  val = ssym;
415  } else {
416  end = (end + val) >> 1;
417  start = ssym;
418  }
419  }
420  prob = m->freqs[val] * c->range;
421  if (val != 255)
422  prob2 = m->freqs[val + 1] * c->range;
423 
424  c->low -= prob;
425  c->range = prob2 - prob;
426  if (c->range < RAC_BOTTOM)
427  rac_normalise(c);
428 
429  model256_update(m, val);
430 
431  return val;
432 }
433 
435 {
436  bt->last_type = rac_get_model_sym(c, &bt->bt_model[bt->last_type]);
437 
438  return bt->last_type;
439 }
440 
441 static int decode_coeff(RangeCoder *c, Model *m)
442 {
443  int val, sign;
444 
445  val = rac_get_model_sym(c, m);
446  if (val) {
447  sign = rac_get_bit(c);
448  if (val > 1) {
449  val--;
450  val = (1 << val) + rac_get_bits(c, val);
451  }
452  if (!sign)
453  val = -val;
454  }
455 
456  return val;
457 }
458 
460  uint8_t *dst, ptrdiff_t stride, int block_size)
461 {
462  int i;
463 
464  fc->fill_val += decode_coeff(c, &fc->coef_model);
465 
466  for (i = 0; i < block_size; i++, dst += stride)
467  memset(dst, fc->fill_val, block_size);
468 }
469 
471  uint8_t *dst, ptrdiff_t stride, int block_size)
472 {
473  int i, j;
474  int vec_size;
475  int vec[4];
476  int prev_line[16];
477  int A, B, C;
478 
479  vec_size = rac_get_model_sym(c, &ic->vec_size_model) + 2;
480  for (i = 0; i < vec_size; i++)
481  vec[i] = rac_get_model256_sym(c, &ic->vec_entry_model);
482  for (; i < 4; i++)
483  vec[i] = 0;
484  memset(prev_line, 0, sizeof(prev_line));
485 
486  for (j = 0; j < block_size; j++) {
487  A = 0;
488  B = 0;
489  for (i = 0; i < block_size; i++) {
490  C = B;
491  B = prev_line[i];
492  A = rac_get_model_sym(c, &ic->vq_model[A + B * 5 + C * 25]);
493 
494  prev_line[i] = A;
495  if (A < 4)
496  dst[i] = vec[A];
497  else
498  dst[i] = rac_get_model256_sym(c, &ic->esc_model);
499  }
500  dst += stride;
501  }
502 }
503 
504 static int decode_dct(RangeCoder *c, DCTBlockCoder *bc, int *block,
505  int bx, int by)
506 {
507  int skip, val, sign, pos = 1, zz_pos, dc;
508  int blk_pos = bx + by * bc->prev_dc_stride;
509 
510  memset(block, 0, sizeof(*block) * 64);
511 
512  dc = decode_coeff(c, &bc->dc_model);
513  if (by) {
514  if (bx) {
515  int l, tl, t;
516 
517  l = bc->prev_dc[blk_pos - 1];
518  tl = bc->prev_dc[blk_pos - 1 - bc->prev_dc_stride];
519  t = bc->prev_dc[blk_pos - bc->prev_dc_stride];
520 
521  if (FFABS(t - tl) <= FFABS(l - tl))
522  dc += l;
523  else
524  dc += t;
525  } else {
526  dc += bc->prev_dc[blk_pos - bc->prev_dc_stride];
527  }
528  } else if (bx) {
529  dc += bc->prev_dc[bx - 1];
530  }
531  bc->prev_dc[blk_pos] = dc;
532  block[0] = dc * bc->qmat[0];
533 
534  while (pos < 64) {
536  if (!val)
537  return 0;
538  if (val == 0xF0) {
539  pos += 16;
540  continue;
541  }
542  skip = val >> 4;
543  val = val & 0xF;
544  if (!val)
545  return -1;
546  pos += skip;
547  if (pos >= 64)
548  return -1;
549 
550  sign = rac_get_model2_sym(c, &bc->sign_model);
551  if (val > 1) {
552  val--;
553  val = (1 << val) + rac_get_bits(c, val);
554  }
555  if (!sign)
556  val = -val;
557 
558  zz_pos = ff_zigzag_direct[pos];
559  block[zz_pos] = val * bc->qmat[zz_pos];
560  pos++;
561  }
562 
563  return pos == 64 ? 0 : -1;
564 }
565 
567  uint8_t *dst, ptrdiff_t stride, int block_size,
568  int *block, int mb_x, int mb_y)
569 {
570  int i, j;
571  int bx, by;
572  int nblocks = block_size >> 3;
573 
574  bx = mb_x * nblocks;
575  by = mb_y * nblocks;
576 
577  for (j = 0; j < nblocks; j++) {
578  for (i = 0; i < nblocks; i++) {
579  if (decode_dct(c, bc, block, bx + i, by + j)) {
580  c->got_error = 1;
581  return;
582  }
583  ff_mss34_dct_put(dst + i * 8, stride, block);
584  }
585  dst += 8 * stride;
586  }
587 }
588 
590  uint8_t *dst, ptrdiff_t stride,
591  int block_size, int *block)
592 {
593  const int hsize = block_size >> 1;
594  int A, B, C, D, t1, t2, t3, t4;
595  int i, j;
596 
597  for (j = 0; j < block_size; j++) {
598  for (i = 0; i < block_size; i++) {
599  if (i < hsize && j < hsize)
601  else
602  block[i] = decode_coeff(c, &hc->coef_hi_model);
603  block[i] *= hc->scale;
604  }
605  block += block_size;
606  }
607  block -= block_size * block_size;
608 
609  for (j = 0; j < hsize; j++) {
610  for (i = 0; i < hsize; i++) {
611  A = block[i];
612  B = block[i + hsize];
613  C = block[i + hsize * block_size];
614  D = block[i + hsize * block_size + hsize];
615 
616  t1 = A - B;
617  t2 = C - D;
618  t3 = A + B;
619  t4 = C + D;
620  dst[i * 2] = av_clip_uint8(t1 - t2);
621  dst[i * 2 + stride] = av_clip_uint8(t1 + t2);
622  dst[i * 2 + 1] = av_clip_uint8(t3 - t4);
623  dst[i * 2 + 1 + stride] = av_clip_uint8(t3 + t4);
624  }
625  block += block_size;
626  dst += stride * 2;
627  }
628 }
629 
631 {
632  int i, j;
633 
634  for (i = 0; i < 3; i++) {
635  ctx->btype[i].last_type = SKIP_BLOCK;
636  for (j = 0; j < 5; j++)
637  model_reset(&ctx->btype[i].bt_model[j]);
638  ctx->fill_coder[i].fill_val = 0;
639  model_reset(&ctx->fill_coder[i].coef_model);
640  model256_reset(&ctx->image_coder[i].esc_model);
641  model256_reset(&ctx->image_coder[i].vec_entry_model);
642  model_reset(&ctx->image_coder[i].vec_size_model);
643  for (j = 0; j < 125; j++)
644  model_reset(&ctx->image_coder[i].vq_model[j]);
645  if (ctx->dct_coder[i].quality != quality) {
646  ctx->dct_coder[i].quality = quality;
647  ff_mss34_gen_quant_mat(ctx->dct_coder[i].qmat, quality, !i);
648  }
649  memset(ctx->dct_coder[i].prev_dc, 0,
650  sizeof(*ctx->dct_coder[i].prev_dc) *
651  ctx->dct_coder[i].prev_dc_stride *
652  ctx->dct_coder[i].prev_dc_height);
653  model_reset(&ctx->dct_coder[i].dc_model);
654  model2_reset(&ctx->dct_coder[i].sign_model);
655  model256_reset(&ctx->dct_coder[i].ac_model);
656  if (ctx->haar_coder[i].quality != quality) {
657  ctx->haar_coder[i].quality = quality;
658  ctx->haar_coder[i].scale = 17 - 7 * quality / 50;
659  }
660  model_reset(&ctx->haar_coder[i].coef_hi_model);
661  model256_reset(&ctx->haar_coder[i].coef_model);
662  }
663 }
664 
666 {
667  int i, j;
668 
669  for (i = 0; i < 3; i++) {
670  for (j = 0; j < 5; j++)
671  model_init(&ctx->btype[i].bt_model[j], 5);
672  model_init(&ctx->fill_coder[i].coef_model, 12);
673  model256_init(&ctx->image_coder[i].esc_model);
674  model256_init(&ctx->image_coder[i].vec_entry_model);
675  model_init(&ctx->image_coder[i].vec_size_model, 3);
676  for (j = 0; j < 125; j++)
677  model_init(&ctx->image_coder[i].vq_model[j], 5);
678  model_init(&ctx->dct_coder[i].dc_model, 12);
679  model256_init(&ctx->dct_coder[i].ac_model);
680  model_init(&ctx->haar_coder[i].coef_hi_model, 12);
681  model256_init(&ctx->haar_coder[i].coef_model);
682  }
683 }
684 
685 static int mss3_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
686  int *got_frame, AVPacket *avpkt)
687 {
688  const uint8_t *buf = avpkt->data;
689  int buf_size = avpkt->size;
690  MSS3Context *c = avctx->priv_data;
691  RangeCoder *acoder = &c->coder;
692  GetByteContext gb;
693  uint8_t *dst[3];
694  int dec_width, dec_height, dec_x, dec_y, quality, keyframe;
695  int x, y, i, mb_width, mb_height, blk_size, btype;
696  int ret;
697 
698  if (buf_size < HEADER_SIZE) {
699  av_log(avctx, AV_LOG_ERROR,
700  "Frame should have at least %d bytes, got %d instead\n",
701  HEADER_SIZE, buf_size);
702  return AVERROR_INVALIDDATA;
703  }
704 
705  bytestream2_init(&gb, buf, buf_size);
706  keyframe = bytestream2_get_be32(&gb);
707  if (keyframe & ~0x301) {
708  av_log(avctx, AV_LOG_ERROR, "Invalid frame type %X\n", keyframe);
709  return AVERROR_INVALIDDATA;
710  }
711  keyframe = !(keyframe & 1);
712  bytestream2_skip(&gb, 6);
713  dec_x = bytestream2_get_be16(&gb);
714  dec_y = bytestream2_get_be16(&gb);
715  dec_width = bytestream2_get_be16(&gb);
716  dec_height = bytestream2_get_be16(&gb);
717 
718  if (dec_x + dec_width > avctx->width ||
719  dec_y + dec_height > avctx->height ||
720  (dec_width | dec_height) & 0xF) {
721  av_log(avctx, AV_LOG_ERROR, "Invalid frame dimensions %dx%d +%d,%d\n",
722  dec_width, dec_height, dec_x, dec_y);
723  return AVERROR_INVALIDDATA;
724  }
725  bytestream2_skip(&gb, 4);
726  quality = bytestream2_get_byte(&gb);
727  if (quality < 1 || quality > 100) {
728  av_log(avctx, AV_LOG_ERROR, "Invalid quality setting %d\n", quality);
729  return AVERROR_INVALIDDATA;
730  }
731  bytestream2_skip(&gb, 4);
732 
733  if (keyframe && !bytestream2_get_bytes_left(&gb)) {
734  av_log(avctx, AV_LOG_ERROR, "Keyframe without data found\n");
735  return AVERROR_INVALIDDATA;
736  }
737  if (!keyframe && c->got_error)
738  return buf_size;
739  c->got_error = 0;
740 
741  if ((ret = ff_reget_buffer(avctx, c->pic, 0)) < 0)
742  return ret;
743  c->pic->key_frame = keyframe;
744  c->pic->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
745  if (!bytestream2_get_bytes_left(&gb)) {
746  if ((ret = av_frame_ref(rframe, c->pic)) < 0)
747  return ret;
748  *got_frame = 1;
749 
750  return buf_size;
751  }
752 
754 
755  rac_init(acoder, buf + HEADER_SIZE, buf_size - HEADER_SIZE);
756 
757  mb_width = dec_width >> 4;
758  mb_height = dec_height >> 4;
759  dst[0] = c->pic->data[0] + dec_x + dec_y * c->pic->linesize[0];
760  dst[1] = c->pic->data[1] + dec_x / 2 + (dec_y / 2) * c->pic->linesize[1];
761  dst[2] = c->pic->data[2] + dec_x / 2 + (dec_y / 2) * c->pic->linesize[2];
762  for (y = 0; y < mb_height; y++) {
763  for (x = 0; x < mb_width; x++) {
764  for (i = 0; i < 3; i++) {
765  blk_size = 8 << !i;
766 
767  btype = decode_block_type(acoder, c->btype + i);
768  switch (btype) {
769  case FILL_BLOCK:
770  decode_fill_block(acoder, c->fill_coder + i,
771  dst[i] + x * blk_size,
772  c->pic->linesize[i], blk_size);
773  break;
774  case IMAGE_BLOCK:
775  decode_image_block(acoder, c->image_coder + i,
776  dst[i] + x * blk_size,
777  c->pic->linesize[i], blk_size);
778  break;
779  case DCT_BLOCK:
780  decode_dct_block(acoder, c->dct_coder + i,
781  dst[i] + x * blk_size,
782  c->pic->linesize[i], blk_size,
783  c->dctblock, x, y);
784  break;
785  case HAAR_BLOCK:
786  decode_haar_block(acoder, c->haar_coder + i,
787  dst[i] + x * blk_size,
788  c->pic->linesize[i], blk_size,
789  c->hblock);
790  break;
791  }
792  if (c->got_error || acoder->got_error) {
793  av_log(avctx, AV_LOG_ERROR, "Error decoding block %d,%d\n",
794  x, y);
795  c->got_error = 1;
796  return AVERROR_INVALIDDATA;
797  }
798  }
799  }
800  dst[0] += c->pic->linesize[0] * 16;
801  dst[1] += c->pic->linesize[1] * 8;
802  dst[2] += c->pic->linesize[2] * 8;
803  }
804 
805  if ((ret = av_frame_ref(rframe, c->pic)) < 0)
806  return ret;
807 
808  *got_frame = 1;
809 
810  return buf_size;
811 }
812 
814 {
815  MSS3Context * const c = avctx->priv_data;
816  int i;
817 
818  av_frame_free(&c->pic);
819  for (i = 0; i < 3; i++)
820  av_freep(&c->dct_coder[i].prev_dc);
821 
822  return 0;
823 }
824 
826 {
827  MSS3Context * const c = avctx->priv_data;
828  int i;
829 
830  c->avctx = avctx;
831 
832  if ((avctx->width & 0xF) || (avctx->height & 0xF)) {
833  av_log(avctx, AV_LOG_ERROR,
834  "Image dimensions should be a multiple of 16.\n");
835  return AVERROR_INVALIDDATA;
836  }
837 
838  c->got_error = 0;
839  for (i = 0; i < 3; i++) {
840  int b_width = avctx->width >> (2 + !!i);
841  int b_height = avctx->height >> (2 + !!i);
842  c->dct_coder[i].prev_dc_stride = b_width;
843  c->dct_coder[i].prev_dc_height = b_height;
844  c->dct_coder[i].prev_dc = av_malloc(sizeof(*c->dct_coder[i].prev_dc) *
845  b_width * b_height);
846  if (!c->dct_coder[i].prev_dc) {
847  av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
848  return AVERROR(ENOMEM);
849  }
850  }
851 
852  c->pic = av_frame_alloc();
853  if (!c->pic)
854  return AVERROR(ENOMEM);
855 
856  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
857 
858  init_coders(c);
859 
860  return 0;
861 }
862 
864  .p.name = "msa1",
865  .p.long_name = NULL_IF_CONFIG_SMALL("MS ATC Screen"),
866  .p.type = AVMEDIA_TYPE_VIDEO,
867  .p.id = AV_CODEC_ID_MSA1,
868  .priv_data_size = sizeof(MSS3Context),
870  .close = mss3_decode_end,
872  .p.capabilities = AV_CODEC_CAP_DR1,
874 };
RangeCoder::range
uint32_t range
Definition: mss3.c:65
HEADER_SIZE
#define HEADER_SIZE
Definition: mss3.c:34
ff_mss34_gen_quant_mat
void ff_mss34_gen_quant_mat(uint16_t *qmat, int quality, int luma)
Generate quantisation matrix for given quality.
Definition: mss34dsp.c:48
Model256::upd_val
int upd_val
Definition: mss3.c:58
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:39
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
Model2
Definition: mss3.c:40
ImageBlockCoder::esc_model
Model256 esc_model
Definition: mss3.c:88
ImageBlockCoder::vq_model
Model vq_model[125]
Definition: mss3.c:90
DCTBlockCoder::prev_dc_stride
ptrdiff_t prev_dc_stride
Definition: mss3.c:95
Model256::secondary
int secondary[68]
Definition: mss3.c:56
GetByteContext
Definition: bytestream.h:33
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:262
HaarBlockCoder::coef_hi_model
Model coef_hi_model
Definition: mss3.c:107
DCTBlockCoder::dc_model
Model dc_model
Definition: mss3.c:99
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:111
DCTBlockCoder::ac_model
Model256 ac_model
Definition: mss3.c:101
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
MSS3Context
Definition: mss3.c:110
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:374
ImageBlockCoder::vec_entry_model
Model256 vec_entry_model
Definition: mss3.c:88
FillBlockCoder
Definition: mss3.c:82
MSS3Context::got_error
int got_error
Definition: mss3.c:114
BlockType
BlockType
Definition: mss3.c:69
FFCodec
Definition: codec_internal.h:112
DCTBlockCoder::qmat
uint16_t qmat[64]
Definition: mss3.c:98
DCTBlockCoder::quality
int quality
Definition: mss3.c:97
fc
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:551
t1
#define t1
Definition: regdef.h:29
Model::weights
int16_t weights[MODEL_MAX_SYMS+1]
Definition: mss12.h:42
Model256::till_rescale
int till_rescale
Definition: mss3.c:58
MSS3Context::haar_coder
HaarBlockCoder haar_coder[3]
Definition: mss3.c:120
model2_update
static void model2_update(Model2 *m, int bit)
Definition: mss3.c:137
quality
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
Definition: rate_distortion.txt:12
MSS3Context::avctx
AVCodecContext * avctx
Definition: mss3.c:111
D
D(D(float, sse)
Definition: rematrix_init.c:29
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
MODEL256_SEC_SCALE
#define MODEL256_SEC_SCALE
Definition: mss3.c:38
init
static int init
Definition: av_tx.c:47
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:58
HaarBlockCoder::quality
int quality
Definition: mss3.c:105
A
#define A(x)
Definition: vp56_arith.h:28
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:116
MSS3Context::dct_coder
DCTBlockCoder dct_coder[3]
Definition: mss3.c:119
val
static double val(void *priv, double ch)
Definition: aeval.c:77
Model256::max_upd_val
int max_upd_val
Definition: mss3.c:58
DCTBlockCoder::prev_dc
int * prev_dc
Definition: mss3.c:94
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1389
init_coders
static av_cold void init_coders(MSS3Context *ctx)
Definition: mss3.c:665
decode_image_block
static void decode_image_block(RangeCoder *c, ImageBlockCoder *ic, uint8_t *dst, ptrdiff_t stride, int block_size)
Definition: mss3.c:470
MSS3Context::btype
BlockTypeContext btype[3]
Definition: mss3.c:116
decode_block_type
static int decode_block_type(RangeCoder *c, BlockTypeContext *bt)
Definition: mss3.c:434
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:99
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
model2_reset
static void model2_reset(Model2 *m)
Definition: mss3.c:127
av_cold
#define av_cold
Definition: attributes.h:90
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:254
HaarBlockCoder::scale
int scale
Definition: mss3.c:105
rac_get_model2_sym
static int rac_get_model2_sym(RangeCoder *c, Model2 *m)
Definition: mss3.c:341
rac_get_model_sym
static int rac_get_model_sym(RangeCoder *c, Model *m)
Definition: mss3.c:362
mss3_decode_init
static av_cold int mss3_decode_init(AVCodecContext *avctx)
Definition: mss3.c:825
RangeCoder::got_error
int got_error
Definition: mss3.c:66
RangeCoder::src_end
const uint8_t * src_end
Definition: mss3.c:63
MODEL_SCALE
#define MODEL_SCALE
Definition: mss3.c:37
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FillBlockCoder::fill_val
int fill_val
Definition: mss3.c:83
rac_get_bit
static int rac_get_bit(RangeCoder *c)
Definition: mss3.c:311
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
SKIP_BLOCK
@ SKIP_BLOCK
Definition: mss3.c:74
HAAR_BLOCK
@ HAAR_BLOCK
Definition: mss3.c:73
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:64
decode_haar_block
static void decode_haar_block(RangeCoder *c, HaarBlockCoder *hc, uint8_t *dst, ptrdiff_t stride, int block_size, int *block)
Definition: mss3.c:589
Model2::upd_val
int upd_val
Definition: mss3.c:41
rac_get_model256_sym
static int rac_get_model256_sym(RangeCoder *c, Model256 *m)
Definition: mss3.c:395
MODEL2_SCALE
#define MODEL2_SCALE
Definition: mss3.c:36
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
mathops.h
Model256
Definition: mss3.c:53
mss3_decode_end
static av_cold int mss3_decode_end(AVCodecContext *avctx)
Definition: mss3.c:813
MSS3Context::hblock
int hblock[16 *16]
Definition: mss3.c:123
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
decode_coeff
static int decode_coeff(RangeCoder *c, Model *m)
Definition: mss3.c:441
Model::upd_val
int upd_val
Definition: mss3.c:50
decode_dct
static int decode_dct(RangeCoder *c, DCTBlockCoder *bc, int *block, int bx, int by)
Definition: mss3.c:504
bytestream2_get_bytes_left
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
FILL_BLOCK
@ FILL_BLOCK
Definition: mss3.c:70
mss34dsp.h
BlockTypeContext::last_type
int last_type
Definition: mss3.c:78
MSS3Context::fill_coder
FillBlockCoder fill_coder[3]
Definition: mss3.c:117
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
AVPacket::size
int size
Definition: packet.h:375
dc
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled top and top right vectors is used as motion vector prediction the used motion vector is the sum of the predictor and(mvx_diff, mvy_diff) *mv_scale Intra DC Prediction block[y][x] dc[1]
Definition: snow.txt:400
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
RangeCoder::src
const uint8_t * src
Definition: mss3.c:63
av_frame_ref
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:343
codec_internal.h
size
int size
Definition: twinvq_data.h:10344
RAC_BOTTOM
#define RAC_BOTTOM
Definition: mss3.c:61
model256_init
static av_cold void model256_init(Model256 *m)
Definition: mss3.c:270
BlockTypeContext
Definition: mss3.c:77
MSS3Context::coder
RangeCoder coder
Definition: mss3.c:115
IMAGE_BLOCK
@ IMAGE_BLOCK
Definition: mss3.c:71
HaarBlockCoder::coef_model
Model256 coef_model
Definition: mss3.c:106
rac_normalise
static void rac_normalise(RangeCoder *c)
Definition: mss3.c:291
DCTBlockCoder::prev_dc_height
int prev_dc_height
Definition: mss3.c:96
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
t4
#define t4
Definition: regdef.h:32
t3
#define t3
Definition: regdef.h:31
FillBlockCoder::coef_model
Model coef_model
Definition: mss3.c:84
Model::tot_weight
int tot_weight
Definition: mss3.c:49
Model2::total_freq
unsigned total_freq
Definition: mss3.c:43
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
Model256::freqs
int freqs[256]
Definition: mss3.c:54
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: codec_internal.h:31
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:203
MSS3Context::pic
AVFrame * pic
Definition: mss3.c:112
Model::num_syms
int num_syms
Definition: mss12.h:44
AVCodecContext::height
int height
Definition: avcodec.h:562
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:599
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
ff_zigzag_direct
const uint8_t ff_zigzag_direct[64]
Definition: mathtables.c:98
ff_msa1_decoder
const FFCodec ff_msa1_decoder
Definition: mss3.c:863
ff_reget_buffer
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
Definition: decode.c:1521
ret
ret
Definition: filter_design.txt:187
model_reset
static void model_reset(Model *m)
Definition: mss3.c:193
prob
#define prob(name, subs,...)
Definition: cbs_vp9.c:372
pos
unsigned int pos
Definition: spdifenc.c:412
B
#define B
Definition: huffyuvdsp.h:32
AVCodecContext
main external API structure.
Definition: avcodec.h:389
t2
#define t2
Definition: regdef.h:30
decode_dct_block
static void decode_dct_block(RangeCoder *c, DCTBlockCoder *bc, uint8_t *dst, ptrdiff_t stride, int block_size, int *block, int mb_x, int mb_y)
Definition: mss3.c:566
Model256::tot_weight
int tot_weight
Definition: mss3.c:55
DCTBlockCoder::sign_model
Model2 sign_model
Definition: mss3.c:100
DCTBlockCoder
Definition: mss3.c:93
MSS3Context::dctblock
int dctblock[64]
Definition: mss3.c:122
AV_CODEC_ID_MSA1
@ AV_CODEC_ID_MSA1
Definition: codec_id.h:213
Model::max_upd_val
int max_upd_val
Definition: mss3.c:50
av_clip_uint8
#define av_clip_uint8
Definition: common.h:101
model256_reset
static void model256_reset(Model256 *m)
Definition: mss3.c:254
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
Model::till_rescale
int till_rescale
Definition: mss3.c:50
RangeCoder::low
uint32_t low
Definition: mss3.c:65
Model2::total_weight
unsigned total_weight
Definition: mss3.c:43
reset_coders
static void reset_coders(MSS3Context *ctx, int quality)
Definition: mss3.c:630
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:416
AVPacket
This structure stores compressed data.
Definition: packet.h:351
Model2::zero_freq
unsigned zero_freq
Definition: mss3.c:42
Model
Definition: mss12.h:40
Model256::sec_size
int sec_size
Definition: mss3.c:57
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
HaarBlockCoder
Definition: mss3.c:104
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:562
Model2::zero_weight
unsigned zero_weight
Definition: mss3.c:42
bytestream.h
model256_update
static void model256_update(Model256 *m, int val)
Definition: mss3.c:217
Model2::till_rescale
int till_rescale
Definition: mss3.c:41
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
Model::freqs
int freqs[16]
Definition: mss3.c:47
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
decode_fill_block
static void decode_fill_block(RangeCoder *c, FillBlockCoder *fc, uint8_t *dst, ptrdiff_t stride, int block_size)
Definition: mss3.c:459
ImageBlockCoder::vec_size_model
Model vec_size_model
Definition: mss3.c:89
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
rac_get_bits
static int rac_get_bits(RangeCoder *c, int nbits)
Definition: mss3.c:327
RangeCoder
Definition: mss3.c:62
ImageBlockCoder
Definition: mss3.c:87
mss3_decode_frame
static int mss3_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
Definition: mss3.c:685
DCT_BLOCK
@ DCT_BLOCK
Definition: mss3.c:72
Model256::weights
int weights[256]
Definition: mss3.c:54
ff_mss34_dct_put
void ff_mss34_dct_put(uint8_t *dst, ptrdiff_t stride, int *block)
Transform and output DCT block.
Definition: mss34dsp.c:90
MSS3Context::image_coder
ImageBlockCoder image_coder[3]
Definition: mss3.c:118
model_update
static void model_update(Model *m, int val)
Definition: mss3.c:163
model_init
static av_cold void model_init(Model *m, int num_syms)
Definition: mss3.c:209
BlockTypeContext::bt_model
Model bt_model[5]
Definition: mss3.c:79
rac_init
static void rac_init(RangeCoder *c, const uint8_t *src, int size)
Definition: mss3.c:278