Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6148 serge 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 
29
#include 
30
 
31
#include "mqc.h"
32
 
33
/* MQ coder context state structure */
34
typedef struct MqcCxState {
35
    uint16_t qe;
36
    uint8_t  nmps;
37
    uint8_t  nlps;
38
    uint8_t  sw;
39
} MqcCxState;
40
 
41
static const MqcCxState cx_states[47] = {
42
    { 0x5601,  1,  1, 1 },
43
    { 0x3401,  2,  6, 0 },
44
    { 0x1801,  3,  9, 0 },
45
    { 0x0AC1,  4, 12, 0 },
46
    { 0x0521,  5, 29, 0 },
47
    { 0x0221, 38, 33, 0 },
48
    { 0x5601,  7,  6, 1 },
49
    { 0x5401,  8, 14, 0 },
50
    { 0x4801,  9, 14, 0 },
51
    { 0x3801, 10, 14, 0 },
52
    { 0x3001, 11, 17, 0 },
53
    { 0x2401, 12, 18, 0 },
54
    { 0x1C01, 13, 20, 0 },
55
    { 0x1601, 29, 21, 0 },
56
    { 0x5601, 15, 14, 1 },
57
    { 0x5401, 16, 14, 0 },
58
    { 0x5101, 17, 15, 0 },
59
    { 0x4801, 18, 16, 0 },
60
    { 0x3801, 19, 17, 0 },
61
    { 0x3401, 20, 18, 0 },
62
    { 0x3001, 21, 19, 0 },
63
    { 0x2801, 22, 19, 0 },
64
    { 0x2401, 23, 20, 0 },
65
    { 0x2201, 24, 21, 0 },
66
    { 0x1C01, 25, 22, 0 },
67
    { 0x1801, 26, 23, 0 },
68
    { 0x1601, 27, 24, 0 },
69
    { 0x1401, 28, 25, 0 },
70
    { 0x1201, 29, 26, 0 },
71
    { 0x1101, 30, 27, 0 },
72
    { 0x0AC1, 31, 28, 0 },
73
    { 0x09C1, 32, 29, 0 },
74
    { 0x08A1, 33, 30, 0 },
75
    { 0x0521, 34, 31, 0 },
76
    { 0x0441, 35, 32, 0 },
77
    { 0x02A1, 36, 33, 0 },
78
    { 0x0221, 37, 34, 0 },
79
    { 0x0141, 38, 35, 0 },
80
    { 0x0111, 39, 36, 0 },
81
    { 0x0085, 40, 37, 0 },
82
    { 0x0049, 41, 38, 0 },
83
    { 0x0025, 42, 39, 0 },
84
    { 0x0015, 43, 40, 0 },
85
    { 0x0009, 44, 41, 0 },
86
    { 0x0005, 45, 42, 0 },
87
    { 0x0001, 45, 43, 0 },
88
    { 0x5601, 46, 46, 0 }
89
};
90
 
91
uint16_t ff_mqc_qe [2 * 47];
92
uint8_t ff_mqc_nlps[2 * 47];
93
uint8_t ff_mqc_nmps[2 * 47];
94
 
95
void ff_mqc_init_context_tables(void)
96
{
97
    int i;
98
    for (i = 0; i < 47; i++) {
99
        ff_mqc_qe[2 * i]     =
100
        ff_mqc_qe[2 * i + 1] = cx_states[i].qe;
101
 
102
        ff_mqc_nlps[2 * i]     = 2 * cx_states[i].nlps + cx_states[i].sw;
103
        ff_mqc_nlps[2 * i + 1] = 2 * cx_states[i].nlps + 1 - cx_states[i].sw;
104
        ff_mqc_nmps[2 * i]     = 2 * cx_states[i].nmps;
105
        ff_mqc_nmps[2 * i + 1] = 2 * cx_states[i].nmps + 1;
106
    }
107
}
108
 
109
void ff_mqc_init_contexts(MqcState *mqc)
110
{
111
    memset(mqc->cx_states, 0, sizeof(mqc->cx_states));
112
    mqc->cx_states[MQC_CX_UNI] = 2 * 46;
113
    mqc->cx_states[MQC_CX_RL]  = 2 * 3;
114
    mqc->cx_states[0]          = 2 * 4;
115
}