FFmpeg  2.8.17
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mss12.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Konstantin Shishkov
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 /**
22  * @file
23  * Common functions for Microsoft Screen 1 and 2
24  */
25 
26 #include <inttypes.h>
27 
28 #include "libavutil/intfloat.h"
29 #include "libavutil/intreadwrite.h"
30 #include "avcodec.h"
31 #include "mss12.h"
32 
33 enum SplitMode {
37 };
38 
39 static const int sec_order_sizes[4] = { 1, 7, 6, 1 };
40 
42  TOP_LEFT = 0,
43  TOP,
46 };
47 
49 {
50  int thr;
51 
52  thr = 2 * m->weights[m->num_syms] - 1;
53  thr = ((thr >> 1) + 4 * m->cum_prob[0]) / thr;
54 
55  return FFMIN(thr, 0x3FFF);
56 }
57 
58 static void model_reset(Model *m)
59 {
60  int i;
61 
62  for (i = 0; i <= m->num_syms; i++) {
63  m->weights[i] = 1;
64  m->cum_prob[i] = m->num_syms - i;
65  }
66  m->weights[0] = 0;
67  for (i = 0; i < m->num_syms; i++)
68  m->idx2sym[i + 1] = i;
69 }
70 
71 static av_cold void model_init(Model *m, int num_syms, int thr_weight)
72 {
73  m->num_syms = num_syms;
74  m->thr_weight = thr_weight;
75  m->threshold = num_syms * thr_weight;
76 }
77 
79 {
80  int i;
81  int cum_prob;
82 
83  if (m->thr_weight == THRESH_ADAPTIVE)
85  while (m->cum_prob[0] > m->threshold) {
86  cum_prob = 0;
87  for (i = m->num_syms; i >= 0; i--) {
88  m->cum_prob[i] = cum_prob;
89  m->weights[i] = (m->weights[i] + 1) >> 1;
90  cum_prob += m->weights[i];
91  }
92  }
93 }
94 
96 {
97  int i;
98 
99  if (m->weights[val] == m->weights[val - 1]) {
100  for (i = val; m->weights[i - 1] == m->weights[val]; i--);
101  if (i != val) {
102  int sym1, sym2;
103 
104  sym1 = m->idx2sym[val];
105  sym2 = m->idx2sym[i];
106 
107  m->idx2sym[val] = sym2;
108  m->idx2sym[i] = sym1;
109 
110  val = i;
111  }
112  }
113  m->weights[val]++;
114  for (i = val - 1; i >= 0; i--)
115  m->cum_prob[i]++;
117 }
118 
119 static void pixctx_reset(PixContext *ctx)
120 {
121  int i, j;
122 
123  if (!ctx->special_initial_cache)
124  for (i = 0; i < ctx->cache_size; i++)
125  ctx->cache[i] = i;
126  else {
127  ctx->cache[0] = 1;
128  ctx->cache[1] = 2;
129  ctx->cache[2] = 4;
130  }
131 
132  model_reset(&ctx->cache_model);
133  model_reset(&ctx->full_model);
134 
135  for (i = 0; i < 15; i++)
136  for (j = 0; j < 4; j++)
137  model_reset(&ctx->sec_models[i][j]);
138 }
139 
140 static av_cold void pixctx_init(PixContext *ctx, int cache_size,
141  int full_model_syms, int special_initial_cache)
142 {
143  int i, j, k, idx;
144 
145  ctx->cache_size = cache_size + 4;
146  ctx->num_syms = cache_size;
147  ctx->special_initial_cache = special_initial_cache;
148 
149  model_init(&ctx->cache_model, ctx->num_syms + 1, THRESH_LOW);
150  model_init(&ctx->full_model, full_model_syms, THRESH_HIGH);
151 
152  for (i = 0, idx = 0; i < 4; i++)
153  for (j = 0; j < sec_order_sizes[i]; j++, idx++)
154  for (k = 0; k < 4; k++)
155  model_init(&ctx->sec_models[idx][k], 2 + i,
157 }
158 
160  uint8_t *ngb, int num_ngb, int any_ngb)
161 {
162  int i, val, pix;
163 
164  if (acoder->overread > MAX_OVERREAD)
165  return AVERROR_INVALIDDATA;
166  val = acoder->get_model_sym(acoder, &pctx->cache_model);
167  if (val < pctx->num_syms) {
168  if (any_ngb) {
169  int idx, j;
170 
171  idx = 0;
172  for (i = 0; i < pctx->cache_size; i++) {
173  for (j = 0; j < num_ngb; j++)
174  if (pctx->cache[i] == ngb[j])
175  break;
176  if (j == num_ngb) {
177  if (idx == val)
178  break;
179  idx++;
180  }
181  }
182  val = FFMIN(i, pctx->cache_size - 1);
183  }
184  pix = pctx->cache[val];
185  } else {
186  pix = acoder->get_model_sym(acoder, &pctx->full_model);
187  for (i = 0; i < pctx->cache_size - 1; i++)
188  if (pctx->cache[i] == pix)
189  break;
190  val = i;
191  }
192  if (val) {
193  for (i = val; i > 0; i--)
194  pctx->cache[i] = pctx->cache[i - 1];
195  pctx->cache[0] = pix;
196  }
197 
198  return pix;
199 }
200 
202  uint8_t *src, int stride, int x, int y,
203  int has_right)
204 {
205  uint8_t neighbours[4];
206  uint8_t ref_pix[4];
207  int nlen;
208  int layer = 0, sub;
209  int pix;
210  int i, j;
211 
212  if (!y) {
213  memset(neighbours, src[-1], 4);
214  } else {
215  neighbours[TOP] = src[-stride];
216  if (!x) {
217  neighbours[TOP_LEFT] = neighbours[LEFT] = neighbours[TOP];
218  } else {
219  neighbours[TOP_LEFT] = src[-stride - 1];
220  neighbours[ LEFT] = src[-1];
221  }
222  if (has_right)
223  neighbours[TOP_RIGHT] = src[-stride + 1];
224  else
225  neighbours[TOP_RIGHT] = neighbours[TOP];
226  }
227 
228  sub = 0;
229  if (x >= 2 && src[-2] == neighbours[LEFT])
230  sub = 1;
231  if (y >= 2 && src[-2 * stride] == neighbours[TOP])
232  sub |= 2;
233 
234  nlen = 1;
235  ref_pix[0] = neighbours[0];
236  for (i = 1; i < 4; i++) {
237  for (j = 0; j < nlen; j++)
238  if (ref_pix[j] == neighbours[i])
239  break;
240  if (j == nlen)
241  ref_pix[nlen++] = neighbours[i];
242  }
243 
244  switch (nlen) {
245  case 1:
246  layer = 0;
247  break;
248  case 2:
249  if (neighbours[TOP] == neighbours[TOP_LEFT]) {
250  if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT])
251  layer = 1;
252  else if (neighbours[LEFT] == neighbours[TOP_LEFT])
253  layer = 2;
254  else
255  layer = 3;
256  } else if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT]) {
257  if (neighbours[LEFT] == neighbours[TOP_LEFT])
258  layer = 4;
259  else
260  layer = 5;
261  } else if (neighbours[LEFT] == neighbours[TOP_LEFT]) {
262  layer = 6;
263  } else {
264  layer = 7;
265  }
266  break;
267  case 3:
268  if (neighbours[TOP] == neighbours[TOP_LEFT])
269  layer = 8;
270  else if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT])
271  layer = 9;
272  else if (neighbours[LEFT] == neighbours[TOP_LEFT])
273  layer = 10;
274  else if (neighbours[TOP_RIGHT] == neighbours[TOP])
275  layer = 11;
276  else if (neighbours[TOP] == neighbours[LEFT])
277  layer = 12;
278  else
279  layer = 13;
280  break;
281  case 4:
282  layer = 14;
283  break;
284  }
285 
286  pix = acoder->get_model_sym(acoder,
287  &pctx->sec_models[layer][sub]);
288  if (pix < nlen)
289  return ref_pix[pix];
290  else
291  return decode_pixel(acoder, pctx, ref_pix, nlen, 1);
292 }
293 
294 static int decode_region(ArithCoder *acoder, uint8_t *dst, uint8_t *rgb_pic,
295  int x, int y, int width, int height, int stride,
296  int rgb_stride, PixContext *pctx, const uint32_t *pal)
297 {
298  int i, j, p;
299  uint8_t *rgb_dst = rgb_pic + x * 3 + y * rgb_stride;
300 
301  dst += x + y * stride;
302 
303  for (j = 0; j < height; j++) {
304  for (i = 0; i < width; i++) {
305  if (!i && !j)
306  p = decode_pixel(acoder, pctx, NULL, 0, 0);
307  else
308  p = decode_pixel_in_context(acoder, pctx, dst + i, stride,
309  i, j, width - i - 1);
310  if (p < 0)
311  return p;
312  dst[i] = p;
313 
314  if (rgb_pic)
315  AV_WB24(rgb_dst + i * 3, pal[p]);
316  }
317  dst += stride;
318  rgb_dst += rgb_stride;
319  }
320 
321  return 0;
322 }
323 
324 static void copy_rectangles(MSS12Context const *c,
325  int x, int y, int width, int height)
326 {
327  int j;
328 
329  if (c->last_rgb_pic)
330  for (j = y; j < y + height; j++) {
331  memcpy(c->rgb_pic + j * c->rgb_stride + x * 3,
332  c->last_rgb_pic + j * c->rgb_stride + x * 3,
333  width * 3);
334  memcpy(c->pal_pic + j * c->pal_stride + x,
335  c->last_pal_pic + j * c->pal_stride + x,
336  width);
337  }
338 }
339 
341  int x, int y, int width, int height)
342 {
343  if (x + c->mvX < 0 || x + c->mvX + width > c->avctx->width ||
344  y + c->mvY < 0 || y + c->mvY + height > c->avctx->height ||
345  !c->rgb_pic)
346  return -1;
347  else {
348  uint8_t *dst = c->pal_pic + x + y * c->pal_stride;
349  uint8_t *rgb_dst = c->rgb_pic + x * 3 + y * c->rgb_stride;
350  uint8_t *src;
351  uint8_t *rgb_src;
352  int j;
353  x += c->mvX;
354  y += c->mvY;
355  if (c->last_rgb_pic) {
356  src = c->last_pal_pic + x + y * c->pal_stride;
357  rgb_src = c->last_rgb_pic + x * 3 + y * c->rgb_stride;
358  } else {
359  src = c->pal_pic + x + y * c->pal_stride;
360  rgb_src = c->rgb_pic + x * 3 + y * c->rgb_stride;
361  }
362  for (j = 0; j < height; j++) {
363  memmove(dst, src, width);
364  memmove(rgb_dst, rgb_src, width * 3);
365  dst += c->pal_stride;
366  src += c->pal_stride;
367  rgb_dst += c->rgb_stride;
368  rgb_src += c->rgb_stride;
369  }
370  }
371  return 0;
372 }
373 
374 static int decode_region_masked(MSS12Context const *c, ArithCoder *acoder,
375  uint8_t *dst, int stride, uint8_t *mask,
376  int mask_stride, int x, int y,
377  int width, int height,
378  PixContext *pctx)
379 {
380  int i, j, p;
381  uint8_t *rgb_dst = c->rgb_pic + x * 3 + y * c->rgb_stride;
382 
383  dst += x + y * stride;
384  mask += x + y * mask_stride;
385 
386  for (j = 0; j < height; j++) {
387  for (i = 0; i < width; i++) {
388  if (c->avctx->err_recognition & AV_EF_EXPLODE &&
389  ( c->rgb_pic && mask[i] != 0x01 && mask[i] != 0x02 && mask[i] != 0x04 ||
390  !c->rgb_pic && mask[i] != 0x80 && mask[i] != 0xFF))
391  return -1;
392 
393  if (mask[i] == 0x02) {
394  copy_rectangles(c, x + i, y + j, 1, 1);
395  } else if (mask[i] == 0x04) {
396  if (motion_compensation(c, x + i, y + j, 1, 1))
397  return -1;
398  } else if (mask[i] != 0x80) {
399  if (!i && !j)
400  p = decode_pixel(acoder, pctx, NULL, 0, 0);
401  else
402  p = decode_pixel_in_context(acoder, pctx, dst + i, stride,
403  i, j, width - i - 1);
404  if (p < 0)
405  return p;
406  dst[i] = p;
407  if (c->rgb_pic)
408  AV_WB24(rgb_dst + i * 3, c->pal[p]);
409  }
410  }
411  dst += stride;
412  mask += mask_stride;
413  rgb_dst += c->rgb_stride;
414  }
415 
416  return 0;
417 }
418 
420  int version, int full_model_syms)
421 {
425  model_init(&sc->edge_mode, 2, THRESH_HIGH);
426  model_init(&sc->pivot, 3, THRESH_LOW);
427 
428  pixctx_init(&sc->intra_pix_ctx, 8, full_model_syms, 0);
429 
430  pixctx_init(&sc->inter_pix_ctx, version ? 3 : 2,
431  full_model_syms, version ? 1 : 0);
432 }
433 
435 {
438  model_reset(&sc->split_mode);
439  model_reset(&sc->edge_mode);
440  model_reset(&sc->pivot);
443 }
444 
445 static int decode_pivot(SliceContext *sc, ArithCoder *acoder, int base)
446 {
447  int val, inv;
448 
449  inv = acoder->get_model_sym(acoder, &sc->edge_mode);
450  val = acoder->get_model_sym(acoder, &sc->pivot) + 1;
451 
452  if (val > 2) {
453  if ((base + 1) / 2 - 2 <= 0)
454  return -1;
455 
456  val = acoder->get_number(acoder, (base + 1) / 2 - 2) + 3;
457  }
458 
459  if ((unsigned)val >= base)
460  return -1;
461 
462  return inv ? base - val : val;
463 }
464 
466  int x, int y, int width, int height)
467 {
468  MSS12Context const *c = sc->c;
469  int mode;
470 
471  mode = acoder->get_model_sym(acoder, &sc->intra_region);
472 
473  if (!mode) {
474  int i, j, pix, rgb_pix;
475  int stride = c->pal_stride;
476  int rgb_stride = c->rgb_stride;
477  uint8_t *dst = c->pal_pic + x + y * stride;
478  uint8_t *rgb_dst = c->rgb_pic + x * 3 + y * rgb_stride;
479 
480  pix = decode_pixel(acoder, &sc->intra_pix_ctx, NULL, 0, 0);
481  if (pix < 0)
482  return pix;
483  rgb_pix = c->pal[pix];
484  for (i = 0; i < height; i++, dst += stride, rgb_dst += rgb_stride) {
485  memset(dst, pix, width);
486  if (c->rgb_pic)
487  for (j = 0; j < width * 3; j += 3)
488  AV_WB24(rgb_dst + j, rgb_pix);
489  }
490  } else {
491  return decode_region(acoder, c->pal_pic, c->rgb_pic,
492  x, y, width, height, c->pal_stride, c->rgb_stride,
493  &sc->intra_pix_ctx, &c->pal[0]);
494  }
495 
496  return 0;
497 }
498 
500  int x, int y, int width, int height)
501 {
502  MSS12Context const *c = sc->c;
503  int mode;
504 
505  mode = acoder->get_model_sym(acoder, &sc->inter_region);
506 
507  if (!mode) {
508  mode = decode_pixel(acoder, &sc->inter_pix_ctx, NULL, 0, 0);
509  if (mode < 0)
510  return mode;
511 
512  if (c->avctx->err_recognition & AV_EF_EXPLODE &&
513  ( c->rgb_pic && mode != 0x01 && mode != 0x02 && mode != 0x04 ||
514  !c->rgb_pic && mode != 0x80 && mode != 0xFF))
515  return -1;
516 
517  if (mode == 0x02)
518  copy_rectangles(c, x, y, width, height);
519  else if (mode == 0x04)
520  return motion_compensation(c, x, y, width, height);
521  else if (mode != 0x80)
522  return decode_region_intra(sc, acoder, x, y, width, height);
523  } else {
524  if (decode_region(acoder, c->mask, NULL,
525  x, y, width, height, c->mask_stride, 0,
526  &sc->inter_pix_ctx, &c->pal[0]) < 0)
527  return -1;
528  return decode_region_masked(c, acoder, c->pal_pic,
529  c->pal_stride, c->mask,
530  c->mask_stride,
531  x, y, width, height,
532  &sc->intra_pix_ctx);
533  }
534 
535  return 0;
536 }
537 
539  int x, int y, int width, int height)
540 {
541  int mode, pivot;
542  if (acoder->overread > MAX_OVERREAD)
543  return AVERROR_INVALIDDATA;
544 
545  mode = acoder->get_model_sym(acoder, &sc->split_mode);
546 
547  switch (mode) {
548  case SPLIT_VERT:
549  if ((pivot = decode_pivot(sc, acoder, height)) < 1)
550  return -1;
551  if (ff_mss12_decode_rect(sc, acoder, x, y, width, pivot))
552  return -1;
553  if (ff_mss12_decode_rect(sc, acoder, x, y + pivot, width, height - pivot))
554  return -1;
555  break;
556  case SPLIT_HOR:
557  if ((pivot = decode_pivot(sc, acoder, width)) < 1)
558  return -1;
559  if (ff_mss12_decode_rect(sc, acoder, x, y, pivot, height))
560  return -1;
561  if (ff_mss12_decode_rect(sc, acoder, x + pivot, y, width - pivot, height))
562  return -1;
563  break;
564  case SPLIT_NONE:
565  if (sc->c->keyframe)
566  return decode_region_intra(sc, acoder, x, y, width, height);
567  else
568  return decode_region_inter(sc, acoder, x, y, width, height);
569  default:
570  return -1;
571  }
572 
573  return 0;
574 }
575 
577  SliceContext* sc1, SliceContext *sc2)
578 {
579  AVCodecContext *avctx = c->avctx;
580  int i;
581 
582  if (avctx->extradata_size < 52 + 256 * 3) {
583  av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d\n",
584  avctx->extradata_size);
585  return AVERROR_INVALIDDATA;
586  }
587 
588  if (AV_RB32(avctx->extradata) < avctx->extradata_size) {
589  av_log(avctx, AV_LOG_ERROR,
590  "Insufficient extradata size: expected %"PRIu32" got %d\n",
591  AV_RB32(avctx->extradata),
592  avctx->extradata_size);
593  return AVERROR_INVALIDDATA;
594  }
595 
596  avctx->coded_width = AV_RB32(avctx->extradata + 20);
597  avctx->coded_height = AV_RB32(avctx->extradata + 24);
598  if (avctx->coded_width > 4096 || avctx->coded_height > 4096) {
599  av_log(avctx, AV_LOG_ERROR, "Frame dimensions %dx%d too large",
600  avctx->coded_width, avctx->coded_height);
601  return AVERROR_INVALIDDATA;
602  }
603  if (avctx->coded_width < 1 || avctx->coded_height < 1) {
604  av_log(avctx, AV_LOG_ERROR, "Frame dimensions %dx%d too small",
605  avctx->coded_width, avctx->coded_height);
606  return AVERROR_INVALIDDATA;
607  }
608 
609  av_log(avctx, AV_LOG_DEBUG, "Encoder version %"PRIu32".%"PRIu32"\n",
610  AV_RB32(avctx->extradata + 4), AV_RB32(avctx->extradata + 8));
611  if (version != AV_RB32(avctx->extradata + 4) > 1) {
612  av_log(avctx, AV_LOG_ERROR,
613  "Header version doesn't match codec tag\n");
614  return -1;
615  }
616 
617  c->free_colours = AV_RB32(avctx->extradata + 48);
618  if ((unsigned)c->free_colours > 256) {
619  av_log(avctx, AV_LOG_ERROR,
620  "Incorrect number of changeable palette entries: %d\n",
621  c->free_colours);
622  return AVERROR_INVALIDDATA;
623  }
624  av_log(avctx, AV_LOG_DEBUG, "%d free colour(s)\n", c->free_colours);
625 
626  av_log(avctx, AV_LOG_DEBUG, "Display dimensions %"PRIu32"x%"PRIu32"\n",
627  AV_RB32(avctx->extradata + 12), AV_RB32(avctx->extradata + 16));
628  av_log(avctx, AV_LOG_DEBUG, "Coded dimensions %dx%d\n",
629  avctx->coded_width, avctx->coded_height);
630  av_log(avctx, AV_LOG_DEBUG, "%g frames per second\n",
631  av_int2float(AV_RB32(avctx->extradata + 28)));
632  av_log(avctx, AV_LOG_DEBUG, "Bitrate %"PRIu32" bps\n",
633  AV_RB32(avctx->extradata + 32));
634  av_log(avctx, AV_LOG_DEBUG, "Max. lead time %g ms\n",
635  av_int2float(AV_RB32(avctx->extradata + 36)));
636  av_log(avctx, AV_LOG_DEBUG, "Max. lag time %g ms\n",
637  av_int2float(AV_RB32(avctx->extradata + 40)));
638  av_log(avctx, AV_LOG_DEBUG, "Max. seek time %g ms\n",
639  av_int2float(AV_RB32(avctx->extradata + 44)));
640 
641  if (version) {
642  if (avctx->extradata_size < 60 + 256 * 3) {
643  av_log(avctx, AV_LOG_ERROR,
644  "Insufficient extradata size %d for v2\n",
645  avctx->extradata_size);
646  return AVERROR_INVALIDDATA;
647  }
648 
649  c->slice_split = AV_RB32(avctx->extradata + 52);
650  av_log(avctx, AV_LOG_DEBUG, "Slice split %d\n", c->slice_split);
651 
652  c->full_model_syms = AV_RB32(avctx->extradata + 56);
653  if (c->full_model_syms < 2 || c->full_model_syms > 256) {
654  av_log(avctx, AV_LOG_ERROR,
655  "Incorrect number of used colours %d\n",
656  c->full_model_syms);
657  return AVERROR_INVALIDDATA;
658  }
659  av_log(avctx, AV_LOG_DEBUG, "Used colours %d\n",
660  c->full_model_syms);
661  } else {
662  c->slice_split = 0;
663  c->full_model_syms = 256;
664  }
665 
666  for (i = 0; i < 256; i++)
667  c->pal[i] = 0xFFU << 24 | AV_RB24(avctx->extradata + 52 +
668  (version ? 8 : 0) + i * 3);
669 
670  c->mask_stride = FFALIGN(avctx->width, 16);
671  c->mask = av_malloc_array(c->mask_stride, avctx->height);
672  if (!c->mask) {
673  av_log(avctx, AV_LOG_ERROR, "Cannot allocate mask plane\n");
674  return AVERROR(ENOMEM);
675  }
676 
677  sc1->c = c;
678  slicecontext_init(sc1, version, c->full_model_syms);
679  if (c->slice_split) {
680  sc2->c = c;
681  slicecontext_init(sc2, version, c->full_model_syms);
682  }
683  c->corrupted = 1;
684 
685  return 0;
686 }
687 
689 {
690  av_freep(&c->mask);
691 
692  return 0;
693 }
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:634
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
PixContext inter_pix_ctx
Definition: mss12.h:74
int overread
Definition: mss12.h:50
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:1706
av_cold int ff_mss12_decode_init(MSS12Context *c, int version, SliceContext *sc1, SliceContext *sc2)
Definition: mss12.c:576
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
Definition: intfloat.h:40
Definition: mss12.h:40
int corrupted
Definition: mss12.h:91
static void pixctx_reset(PixContext *ctx)
Definition: mss12.c:119
#define AV_RB24
Definition: intreadwrite.h:64
static int decode_region_inter(SliceContext *sc, ArithCoder *acoder, int x, int y, int width, int height)
Definition: mss12.c:499
int16_t weights[MODEL_MAX_SYMS+1]
Definition: mss12.h:42
int version
Definition: avisynth_c.h:629
uint8_t * rgb_pic
Definition: mss12.h:85
int mask_stride
Definition: mss12.h:84
int thr_weight
Definition: mss12.h:45
int ff_mss12_decode_rect(SliceContext *sc, ArithCoder *acoder, int x, int y, int width, int height)
Definition: mss12.c:538
#define FFALIGN(x, a)
Definition: common.h:97
static const int sec_order_sizes[4]
Definition: mss12.c:39
int slice_split
Definition: mss12.h:92
uint32_t pal[256]
Definition: mss12.h:79
uint8_t
uint8_t * last_pal_pic
Definition: mss12.h:81
#define av_cold
Definition: attributes.h:74
int rgb_stride
Definition: mss12.h:87
mode
Definition: f_perms.c:27
int keyframe
Definition: mss12.h:89
#define AV_RB32
Definition: intreadwrite.h:130
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1627
Model inter_region
Definition: mss12.h:72
Model full_model
Definition: mss12.h:63
#define av_log(a,...)
int(* get_model_sym)(struct ArithCoder *c, Model *m)
Definition: mss12.h:56
unsigned m
Definition: audioconvert.c:187
Model sec_models[15][4]
Definition: mss12.h:64
static av_cold void slicecontext_init(SliceContext *sc, int version, int full_model_syms)
Definition: mss12.c:419
static int decode_region_intra(SliceContext *sc, ArithCoder *acoder, int x, int y, int width, int height)
Definition: mss12.c:465
Model pivot
Definition: mss12.h:73
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
static const uint16_t mask[17]
Definition: lzw.c:38
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition: avcodec.h:2911
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
static void model_rescale_weights(Model *m)
Definition: mss12.c:78
int full_model_syms
Definition: mss12.h:93
int mvY
Definition: mss12.h:90
int cache_size
Definition: mss12.h:61
Libavcodec external API header.
int pal_stride
Definition: mss12.h:82
AVCodecContext * avctx
Definition: mss12.h:78
Model edge_mode
Definition: mss12.h:73
static int decode_pivot(SliceContext *sc, ArithCoder *acoder, int base)
Definition: mss12.c:445
static av_cold void pixctx_init(PixContext *ctx, int cache_size, int full_model_syms, int special_initial_cache)
Definition: mss12.c:140
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:2900
#define FFMIN(a, b)
Definition: common.h:92
static int model_calc_threshold(Model *m)
Definition: mss12.c:48
float y
PixContext intra_pix_ctx
Definition: mss12.h:74
Definition: mss12.c:45
static int motion_compensation(MSS12Context const *c, int x, int y, int width, int height)
Definition: mss12.c:340
int width
picture width / height.
Definition: avcodec.h:1691
Definition: mss12.c:43
#define AV_WB24(p, d)
Definition: intreadwrite.h:450
static int decode_pixel_in_context(ArithCoder *acoder, PixContext *pctx, uint8_t *src, int stride, int x, int y, int has_right)
Definition: mss12.c:201
struct MSS12Context * c
Definition: mss12.h:71
#define MAX_OVERREAD
Definition: mss12.h:51
static int decode_region(ArithCoder *acoder, uint8_t *dst, uint8_t *rgb_pic, int x, int y, int width, int height, int stride, int rgb_stride, PixContext *pctx, const uint32_t *pal)
Definition: mss12.c:294
av_cold int ff_mss12_decode_end(MSS12Context *c)
Definition: mss12.c:688
AVS_Value src
Definition: avisynth_c.h:482
static int decode_region_masked(MSS12Context const *c, ArithCoder *acoder, uint8_t *dst, int stride, uint8_t *mask, int mask_stride, int x, int y, int width, int height, PixContext *pctx)
Definition: mss12.c:374
ContextDirection
Definition: mss12.c:41
uint8_t * mask
Definition: mss12.h:83
main external API structure.
Definition: avcodec.h:1512
int num_syms
Definition: mss12.h:44
Model cache_model
Definition: mss12.h:63
#define THRESH_ADAPTIVE
Definition: mss12.h:36
int extradata_size
Definition: avcodec.h:1628
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
int coded_height
Definition: avcodec.h:1706
uint8_t idx2sym[MODEL_MAX_SYMS+1]
Definition: mss12.h:43
int special_initial_cache
Definition: mss12.h:65
Definition: mss12.c:42
static av_cold void model_init(Model *m, int num_syms, int thr_weight)
Definition: mss12.c:71
Model split_mode
Definition: mss12.h:73
static void model_reset(Model *m)
Definition: mss12.c:58
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
void ff_mss12_slicecontext_reset(SliceContext *sc)
Definition: mss12.c:434
static double c[64]
static av_always_inline int decode_pixel(ArithCoder *acoder, PixContext *pctx, uint8_t *ngb, int num_ngb, int any_ngb)
Definition: mss12.c:159
int threshold
Definition: mss12.h:45
void ff_mss12_model_update(Model *m, int val)
Definition: mss12.c:95
int free_colours
Definition: mss12.h:88
uint8_t * last_rgb_pic
Definition: mss12.h:86
Model intra_region
Definition: mss12.h:72
#define THRESH_HIGH
Definition: mss12.h:38
#define av_freep(p)
#define av_always_inline
Definition: attributes.h:37
SplitMode
Definition: mss12.c:33
#define av_malloc_array(a, b)
int mvX
Definition: mss12.h:90
#define stride
uint8_t cache[12]
Definition: mss12.h:62
#define THRESH_LOW
Definition: mss12.h:37
int(* get_number)(struct ArithCoder *c, int n)
Definition: mss12.h:57
int num_syms
Definition: mss12.h:61
uint8_t * pal_pic
Definition: mss12.h:80
static void copy_rectangles(MSS12Context const *c, int x, int y, int width, int height)
Definition: mss12.c:324
int16_t cum_prob[MODEL_MAX_SYMS+1]
Definition: mss12.h:41
Common header for Microsoft Screen 1 and 2.
static int width