Revision 02c63a10 libavcodec/libopencore-amr.c

View differences:

libavcodec/libopencore-amr.c
50 50
} AMR_bitrates;
51 51

  
52 52
/* Match desired bitrate */
53
static int getBitrateMode(int bitrate)
53
static int get_bitrate_mode(int bitrate)
54 54
{
55 55
    /* make the correspondance between bitrate and mode */
56 56
    static const AMR_bitrates rates[] = {{ 4750, MR475},
......
71 71
}
72 72

  
73 73
typedef struct AMRContext {
74
    int   frameCount;
75
    void *decState;
76
    void *enstate;
74
    int   frame_count;
75
    void *dec_state;
76
    void *enc_state;
77 77
    int   enc_bitrate;
78 78
} AMRContext;
79 79

  
......
81 81
{
82 82
    AMRContext *s = avctx->priv_data;
83 83

  
84
    s->frameCount = 0;
85
    s->decState   = Decoder_Interface_init();
86
    if (!s->decState) {
84
    s->frame_count = 0;
85
    s->dec_state   = Decoder_Interface_init();
86
    if (!s->dec_state) {
87 87
        av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\n");
88 88
        return -1;
89 89
    }
......
102 102
{
103 103
    AMRContext *s = avctx->priv_data;
104 104

  
105
    Decoder_Interface_exit(s->decState);
105
    Decoder_Interface_exit(s->dec_state);
106 106
    return 0;
107 107
}
108 108

  
......
116 116
    enum Mode dec_mode;
117 117
    int packet_size;
118 118

  
119
    av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",
120
            buf, buf_size, s->frameCount);
119
    av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n",
120
            buf, buf_size, s->frame_count);
121 121

  
122 122
    dec_mode = (buf[0] >> 3) & 0x000F;
123 123
    packet_size = block_size[dec_mode] + 1;
......
128 128
        return AVERROR_INVALIDDATA;
129 129
    }
130 130

  
131
    s->frameCount++;
131
    s->frame_count++;
132 132
    av_dlog(avctx, "packet_size=%d buf= 0x%X %X %X %X\n",
133 133
              packet_size, buf[0], buf[1], buf[2], buf[3]);
134 134
    /* call decoder */
135
    Decoder_Interface_Decode(s->decState, buf, data, 0);
135
    Decoder_Interface_Decode(s->dec_state, buf, data, 0);
136 136
    *data_size = 160 * 2;
137 137

  
138 138
    return packet_size;
......
154 154
{
155 155
    AMRContext *s = avctx->priv_data;
156 156

  
157
    s->frameCount = 0;
157
    s->frame_count = 0;
158 158

  
159 159
    if (avctx->sample_rate != 8000) {
160 160
        av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
......
169 169
    avctx->frame_size  = 160;
170 170
    avctx->coded_frame = avcodec_alloc_frame();
171 171

  
172
    s->enstate=Encoder_Interface_init(0);
173
    if (!s->enstate) {
172
    s->enc_state = Encoder_Interface_init(0);
173
    if (!s->enc_state) {
174 174
        av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
175 175
        return -1;
176 176
    }
177 177

  
178
    if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
178
    if ((s->enc_bitrate = get_bitrate_mode(avctx->bit_rate)) < 0) {
179 179
        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
180 180
        return AVERROR(ENOSYS);
181 181
    }
......
187 187
{
188 188
    AMRContext *s = avctx->priv_data;
189 189

  
190
    Encoder_Interface_exit(s->enstate);
190
    Encoder_Interface_exit(s->enc_state);
191 191
    av_freep(&avctx->coded_frame);
192 192
    return 0;
193 193
}
......
199 199
    AMRContext *s = avctx->priv_data;
200 200
    int written;
201 201

  
202
    if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
202
    if ((s->enc_bitrate = get_bitrate_mode(avctx->bit_rate)) < 0) {
203 203
        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
204 204
        return AVERROR(ENOSYS);
205 205
    }
206 206

  
207
    written = Encoder_Interface_Encode(s->enstate, s->enc_bitrate, data,
207
    written = Encoder_Interface_Encode(s->enc_state, s->enc_bitrate, data,
208 208
                                       frame, 0);
209 209
    av_dlog(avctx, "amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n",
210 210
            written, s->enc_bitrate, frame[0]);

Also available in: Unified diff