FFmpeg
mqc.h
Go to the documentation of this file.
1 /*
2  * MQ-coder: structures, common and decoder 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 #ifndef AVCODEC_MQC_H
23 #define AVCODEC_MQC_H
24 
25 /**
26  * MQ-coder
27  * @file
28  * @author Kamil Nowosad
29  */
30 
31 #include <stdint.h>
32 
33 #define MQC_CX_UNI 17
34 #define MQC_CX_RL 18
35 
36 extern uint16_t ff_mqc_qe[2 * 47];
37 extern uint8_t ff_mqc_nlps[2 * 47];
38 extern uint8_t ff_mqc_nmps[2 * 47];
39 
40 typedef struct MqcState {
42  unsigned int a;
43  unsigned int c;
44  unsigned int ct;
46  int raw;
47 } MqcState;
48 
49 /* encoder */
50 
51 /** initialize the encoder */
52 void ff_mqc_initenc(MqcState *mqc, uint8_t *bp);
53 
54 /** code bit d with context cx */
55 void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d);
56 
57 /** number of encoded bytes */
58 int ff_mqc_length(MqcState *mqc);
59 
60 /** flush the encoder [returns number of bytes encoded] */
61 int ff_mqc_flush(MqcState *mqc);
62 int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len);
63 
64 /* decoder */
65 
66 /**
67  * Initialize MQ-decoder.
68  * @param mqc MQ decoder state
69  * @param bp byte pointer
70  * @param raw raw mode
71  * @param reset reset states
72  */
73 void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset);
74 
75 /**
76  * MQ decoder.
77  * @param mqc MQ decoder state
78  * @param cxstate Context
79  * @return Decision (0 to 1)
80  */
81 int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate);
82 
83 /* common */
84 
85 /**
86  * MQ-coder Initialize context tables (QE, NLPS, NMPS)
87  */
89 
90 /**
91  * MQ-coder context initialisations.
92  * @param mqc MQ-coder context
93  */
95 
96 #endif /* AVCODEC_MQC_H */
MqcState::bpstart
uint8_t * bpstart
Definition: mqc.h:41
ff_mqc_length
int ff_mqc_length(MqcState *mqc)
number of encoded bytes
Definition: mqcenc.c:105
ff_mqc_initdec
void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset)
Initialize MQ-decoder.
Definition: mqcdec.c:71
ff_mqc_nlps
uint8_t ff_mqc_nlps[2 *47]
Definition: mqc.c:94
MqcState::bp
uint8_t * bp
Definition: mqc.h:41
ff_mqc_nmps
uint8_t ff_mqc_nmps[2 *47]
Definition: mqc.c:95
ff_mqc_qe
uint16_t ff_mqc_qe[2 *47]
Definition: mqc.c:93
MqcState::ct
unsigned int ct
Definition: mqc.h:44
ff_mqc_initenc
void ff_mqc_initenc(MqcState *mqc, uint8_t *bp)
initialize the encoder
Definition: mqcenc.c:69
uint8_t
uint8_t
Definition: audio_convert.c:194
ff_mqc_flush
int ff_mqc_flush(MqcState *mqc)
flush the encoder [returns number of bytes encoded]
Definition: mqcenc.c:110
ff_mqc_init_context_tables
void ff_mqc_init_context_tables(void)
MQ-coder Initialize context tables (QE, NLPS, NMPS)
Definition: mqc.c:97
MqcState::c
unsigned int c
Definition: mqc.h:43
ff_mqc_decode
int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate)
MQ decoder.
Definition: mqcdec.c:93
ff_mqc_flush_to
int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len)
Definition: mqcenc.c:122
MqcState::cx_states
uint8_t cx_states[19]
Definition: mqc.h:45
MqcState::a
unsigned int a
Definition: mqc.h:42
ff_mqc_init_contexts
void ff_mqc_init_contexts(MqcState *mqc)
MQ-coder context initialisations.
Definition: mqc.c:111
MqcState::raw
int raw
Definition: mqc.h:46
ff_mqc_encode
void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d)
code bit d with context cx
Definition: mqcenc.c:79
MqcState
Definition: mqc.h:40