53 thr = ((thr >> 1) + 4 * m->
cum_prob[0]) / thr;
55 return FFMIN(thr, 0x3FFF);
114 for (i = val - 1; i >= 0; i--)
135 for (i = 0; i < 15; i++)
136 for (j = 0; j < 4; j++)
141 int full_model_syms,
int special_initial_cache)
152 for (i = 0, idx = 0; i < 4; i++)
154 for (k = 0; k < 4; k++)
160 uint8_t *ngb,
int num_ngb,
int any_ngb)
167 if (val < pctx->num_syms) {
173 for (j = 0; j < num_ngb; j++)
174 if (pctx->
cache[i] == ngb[j])
188 if (pctx->
cache[i] == pix)
193 for (i = val; i > 0; i--)
195 pctx->
cache[0] = pix;
213 memset(neighbours, src[-1], 4);
219 neighbours[
TOP_LEFT] = src[-stride - 1];
220 neighbours[
LEFT] = src[-1];
223 neighbours[
TOP_RIGHT] = src[-stride + 1];
229 if (x >= 2 && src[-2] == neighbours[
LEFT])
231 if (y >= 2 && src[-2 * stride] == neighbours[
TOP])
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])
241 ref_pix[nlen++] = neighbours[i];
249 if (neighbours[TOP] == neighbours[
TOP_LEFT]) {
250 if (neighbours[
TOP_RIGHT] == neighbours[TOP_LEFT])
252 else if (neighbours[LEFT] == neighbours[TOP_LEFT])
256 }
else if (neighbours[
TOP_RIGHT] == neighbours[TOP_LEFT]) {
257 if (neighbours[LEFT] == neighbours[TOP_LEFT])
261 }
else if (neighbours[LEFT] == neighbours[TOP_LEFT]) {
268 if (neighbours[TOP] == neighbours[TOP_LEFT])
270 else if (neighbours[
TOP_RIGHT] == neighbours[TOP_LEFT])
272 else if (neighbours[LEFT] == neighbours[TOP_LEFT])
274 else if (neighbours[
TOP_RIGHT] == neighbours[TOP])
276 else if (neighbours[TOP] == neighbours[LEFT])
296 int rgb_stride,
PixContext *pctx,
const uint32_t *pal)
299 uint8_t *rgb_dst = rgb_pic + x * 3 + y * rgb_stride;
303 for (j = 0; j <
height; j++) {
304 for (i = 0; i <
width; i++) {
309 i, j, width - i - 1);
315 AV_WB24(rgb_dst + i * 3, pal[p]);
318 rgb_dst += rgb_stride;
330 for (j = y; j < y +
height; j++) {
362 for (j = 0; j <
height; j++) {
363 memmove(dst, src, width);
364 memmove(rgb_dst, rgb_src, width * 3);
376 int mask_stride,
int x,
int y,
384 mask += x + y * mask_stride;
386 for (j = 0; j <
height; j++) {
387 for (i = 0; i <
width; i++) {
389 ( c->
rgb_pic && mask[i] != 0x01 && mask[i] != 0x02 && mask[i] != 0x04 ||
390 !c->
rgb_pic && mask[i] != 0x80 && mask[i] != 0xFF))
393 if (mask[i] == 0x02) {
395 }
else if (mask[i] == 0x04) {
398 }
else if (mask[i] != 0x80) {
403 i, j, width - i - 1);
420 int version,
int full_model_syms)
431 full_model_syms, version ? 1 : 0);
453 if ((base + 1) / 2 - 2 <= 0)
456 val = acoder->
get_number(acoder, (base + 1) / 2 - 2) + 3;
459 if ((
unsigned)val >= base)
462 return inv ? base - val :
val;
474 int i, j, pix, rgb_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);
487 for (j = 0; j < width * 3; j += 3)
513 ( c->
rgb_pic && mode != 0x01 && mode != 0x02 && mode != 0x04 ||
514 !c->
rgb_pic && mode != 0x80 && mode != 0xFF))
519 else if (mode == 0x04)
521 else if (mode != 0x80)
590 "Insufficient extradata size: expected %"PRIu32
" got %d\n",
613 "Header version doesn't match codec tag\n");
620 "Incorrect number of changeable palette entries: %d\n",
644 "Insufficient extradata size %d for v2\n",
655 "Incorrect number of used colours %d\n",
666 for (i = 0; i < 256; i++)
668 (version ? 8 : 0) + i * 3);
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int coded_width
Bitstream width / height, may be different from width/height e.g.
av_cold int ff_mss12_decode_init(MSS12Context *c, int version, SliceContext *sc1, SliceContext *sc2)
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static void pixctx_reset(PixContext *ctx)
static int decode_region_inter(SliceContext *sc, ArithCoder *acoder, int x, int y, int width, int height)
int16_t weights[MODEL_MAX_SYMS+1]
int ff_mss12_decode_rect(SliceContext *sc, ArithCoder *acoder, int x, int y, int width, int height)
static const int sec_order_sizes[4]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int(* get_model_sym)(struct ArithCoder *c, Model *m)
static av_cold void slicecontext_init(SliceContext *sc, int version, int full_model_syms)
static int decode_region_intra(SliceContext *sc, ArithCoder *acoder, int x, int y, int width, int height)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static void model_rescale_weights(Model *m)
Libavcodec external API header.
static int decode_pivot(SliceContext *sc, ArithCoder *acoder, int base)
static av_cold void pixctx_init(PixContext *ctx, int cache_size, int full_model_syms, int special_initial_cache)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static int model_calc_threshold(Model *m)
static int motion_compensation(MSS12Context const *c, int x, int y, int width, int height)
int width
picture width / height.
static int decode_pixel_in_context(ArithCoder *acoder, PixContext *pctx, uint8_t *src, int stride, int x, int y, int has_right)
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)
av_cold int ff_mss12_decode_end(MSS12Context *c)
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)
main external API structure.
BYTE int const BYTE int int int height
uint8_t idx2sym[MODEL_MAX_SYMS+1]
int special_initial_cache
static av_cold void model_init(Model *m, int num_syms, int thr_weight)
static void model_reset(Model *m)
GLint GLenum GLboolean GLsizei stride
void ff_mss12_slicecontext_reset(SliceContext *sc)
static av_always_inline int decode_pixel(ArithCoder *acoder, PixContext *pctx, uint8_t *ngb, int num_ngb, int any_ngb)
void ff_mss12_model_update(Model *m, int val)
#define av_malloc_array(a, b)
int(* get_number)(struct ArithCoder *c, int n)
static void copy_rectangles(MSS12Context const *c, int x, int y, int width, int height)
int16_t cum_prob[MODEL_MAX_SYMS+1]
Common header for Microsoft Screen 1 and 2.