FFmpeg  2.8.17
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mss12.h
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 header for Microsoft Screen 1 and 2
24  */
25 
26 #ifndef AVCODEC_MSS12_H
27 #define AVCODEC_MSS12_H
28 
29 #include "libavutil/intreadwrite.h"
30 #include "avcodec.h"
31 #include "get_bits.h"
32 #include "bytestream.h"
33 
34 #define MODEL_MIN_SYMS 2
35 #define MODEL_MAX_SYMS 256
36 #define THRESH_ADAPTIVE -1
37 #define THRESH_LOW 15
38 #define THRESH_HIGH 50
39 
40 typedef struct Model {
41  int16_t cum_prob[MODEL_MAX_SYMS + 1];
42  int16_t weights[MODEL_MAX_SYMS + 1];
44  int num_syms;
46 } Model;
47 
48 typedef struct ArithCoder {
49  int low, high, value;
50  int overread;
51 #define MAX_OVERREAD 16
52  union {
55  } gbc;
56  int (*get_model_sym)(struct ArithCoder *c, Model *m);
57  int (*get_number) (struct ArithCoder *c, int n);
58 } ArithCoder;
59 
60 typedef struct PixContext {
64  Model sec_models[15][4];
66 } PixContext;
67 
68 struct MSS12Context;
69 
70 typedef struct SliceContext {
71  struct MSS12Context *c;
75 } SliceContext;
76 
77 typedef struct MSS12Context {
79  uint32_t pal[256];
89  int keyframe;
90  int mvX, mvY;
91  int corrupted;
94 } MSS12Context;
95 
97  int x, int y, int width, int height);
98 void ff_mss12_model_update(Model *m, int val);
101  SliceContext *sc1, SliceContext *sc2);
103 
104 #define ARITH_GET_BIT(prefix) \
105 static int prefix ## _get_bit(ArithCoder *c) \
106 { \
107  int range = c->high - c->low + 1; \
108  int bit = 2 * c->value - c->low >= c->high; \
109  \
110  if (bit) \
111  c->low += range >> 1; \
112  else \
113  c->high = c->low + (range >> 1) - 1; \
114  \
115  prefix ## _normalise(c); \
116  \
117  return bit; \
118 }
119 
120 #define ARITH_GET_MODEL_SYM(prefix) \
121 static int prefix ## _get_model_sym(ArithCoder *c, Model *m) \
122 { \
123  int idx, val; \
124  \
125  idx = prefix ## _get_prob(c, m->cum_prob); \
126  \
127  val = m->idx2sym[idx]; \
128  ff_mss12_model_update(m, idx); \
129  \
130  prefix ## _normalise(c); \
131  \
132  return val; \
133 }
134 
135 #endif /* AVCODEC_MSS12_H */
const char const char void * val
Definition: avisynth_c.h:634
PixContext inter_pix_ctx
Definition: mss12.h:74
int overread
Definition: mss12.h:50
int high
Definition: mss12.h:49
Definition: mss12.h:40
int value
Definition: mss12.h:49
int corrupted
Definition: mss12.h:91
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 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
int rgb_stride
Definition: mss12.h:87
int keyframe
Definition: mss12.h:89
Model inter_region
Definition: mss12.h:72
GetByteContext * gB
Definition: mss12.h:54
bitstream reader API header.
Model full_model
Definition: mss12.h:63
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
Model pivot
Definition: mss12.h:73
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
float y
PixContext intra_pix_ctx
Definition: mss12.h:74
#define MODEL_MAX_SYMS
Definition: mss12.h:35
int n
Definition: avisynth_c.h:547
struct MSS12Context * c
Definition: mss12.h:71
union ArithCoder::@74 gbc
int ff_mss12_decode_end(MSS12Context *ctx)
Definition: mss12.c:688
int ff_mss12_decode_rect(SliceContext *ctx, ArithCoder *acoder, int x, int y, int width, int height)
Definition: mss12.c:538
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
int ff_mss12_decode_init(MSS12Context *c, int version, SliceContext *sc1, SliceContext *sc2)
Definition: mss12.c:576
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
uint8_t idx2sym[MODEL_MAX_SYMS+1]
Definition: mss12.h:43
int special_initial_cache
Definition: mss12.h:65
Model split_mode
Definition: mss12.h:73
void ff_mss12_slicecontext_reset(SliceContext *sc)
Definition: mss12.c:434
static double c[64]
int threshold
Definition: mss12.h:45
int free_colours
Definition: mss12.h:88
int low
Definition: mss12.h:49
uint8_t * last_rgb_pic
Definition: mss12.h:86
Model intra_region
Definition: mss12.h:72
int mvX
Definition: mss12.h:90
uint8_t cache[12]
Definition: mss12.h:62
GetBitContext * gb
Definition: mss12.h:53
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
void ff_mss12_model_update(Model *m, int val)
Definition: mss12.c:95
int16_t cum_prob[MODEL_MAX_SYMS+1]
Definition: mss12.h:41
static int width