FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mqc.c
Go to the documentation of this file.
1 /*
2  * MQ-coder encoder and decoder common functions
3  * Copyright (c) 2007 Kamil Nowosad
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  * MQ-coder common (decoder/encoder) functions
24  * @file
25  * @author Kamil Nowosad
26  */
27 
28 #include <string.h>
29 #include <stdint.h>
30 
31 #include "libavutil/attributes.h"
32 
33 #include "mqc.h"
34 
35 /* MQ coder context state structure */
36 typedef struct MqcCxState {
37  uint16_t qe;
41 } MqcCxState;
42 
43 static const MqcCxState cx_states[47] = {
44  { 0x5601, 1, 1, 1 },
45  { 0x3401, 2, 6, 0 },
46  { 0x1801, 3, 9, 0 },
47  { 0x0AC1, 4, 12, 0 },
48  { 0x0521, 5, 29, 0 },
49  { 0x0221, 38, 33, 0 },
50  { 0x5601, 7, 6, 1 },
51  { 0x5401, 8, 14, 0 },
52  { 0x4801, 9, 14, 0 },
53  { 0x3801, 10, 14, 0 },
54  { 0x3001, 11, 17, 0 },
55  { 0x2401, 12, 18, 0 },
56  { 0x1C01, 13, 20, 0 },
57  { 0x1601, 29, 21, 0 },
58  { 0x5601, 15, 14, 1 },
59  { 0x5401, 16, 14, 0 },
60  { 0x5101, 17, 15, 0 },
61  { 0x4801, 18, 16, 0 },
62  { 0x3801, 19, 17, 0 },
63  { 0x3401, 20, 18, 0 },
64  { 0x3001, 21, 19, 0 },
65  { 0x2801, 22, 19, 0 },
66  { 0x2401, 23, 20, 0 },
67  { 0x2201, 24, 21, 0 },
68  { 0x1C01, 25, 22, 0 },
69  { 0x1801, 26, 23, 0 },
70  { 0x1601, 27, 24, 0 },
71  { 0x1401, 28, 25, 0 },
72  { 0x1201, 29, 26, 0 },
73  { 0x1101, 30, 27, 0 },
74  { 0x0AC1, 31, 28, 0 },
75  { 0x09C1, 32, 29, 0 },
76  { 0x08A1, 33, 30, 0 },
77  { 0x0521, 34, 31, 0 },
78  { 0x0441, 35, 32, 0 },
79  { 0x02A1, 36, 33, 0 },
80  { 0x0221, 37, 34, 0 },
81  { 0x0141, 38, 35, 0 },
82  { 0x0111, 39, 36, 0 },
83  { 0x0085, 40, 37, 0 },
84  { 0x0049, 41, 38, 0 },
85  { 0x0025, 42, 39, 0 },
86  { 0x0015, 43, 40, 0 },
87  { 0x0009, 44, 41, 0 },
88  { 0x0005, 45, 42, 0 },
89  { 0x0001, 45, 43, 0 },
90  { 0x5601, 46, 46, 0 }
91 };
92 
93 uint16_t ff_mqc_qe [2 * 47];
96 
98 {
99  int i;
100  for (i = 0; i < 47; i++) {
101  ff_mqc_qe[2 * i] =
102  ff_mqc_qe[2 * i + 1] = cx_states[i].qe;
103 
104  ff_mqc_nlps[2 * i] = 2 * cx_states[i].nlps + cx_states[i].sw;
105  ff_mqc_nlps[2 * i + 1] = 2 * cx_states[i].nlps + 1 - cx_states[i].sw;
106  ff_mqc_nmps[2 * i] = 2 * cx_states[i].nmps;
107  ff_mqc_nmps[2 * i + 1] = 2 * cx_states[i].nmps + 1;
108  }
109 }
110 
112 {
113  memset(mqc->cx_states, 0, sizeof(mqc->cx_states));
114  mqc->cx_states[MQC_CX_UNI] = 2 * 46;
115  mqc->cx_states[MQC_CX_RL] = 2 * 3;
116  mqc->cx_states[0] = 2 * 4;
117 }