Mercurial > libavcodec.hg
comparison g729dec.c @ 9824:7679262f1459 libavcodec
K&R formatting of already submitted G.729 code
author | voroshil |
---|---|
date | Sat, 06 Jun 2009 17:40:33 +0000 |
parents | 4a5f2453973d |
children | af3cc583501e |
comparison
equal
deleted
inserted
replaced
9823:4a5f2453973d | 9824:7679262f1459 |
---|---|
69 * 13107 in (1.14), but reference C code uses | 69 * 13107 in (1.14), but reference C code uses |
70 * 13017 (equals to 0.7945) instead of it. | 70 * 13017 (equals to 0.7945) instead of it. |
71 */ | 71 */ |
72 #define SHARP_MAX 13017 | 72 #define SHARP_MAX 13017 |
73 | 73 |
74 typedef struct | 74 typedef struct { |
75 { | |
76 int sample_rate; | 75 int sample_rate; |
77 uint8_t packed_frame_size; ///< input frame size(in bytes) | 76 uint8_t packed_frame_size; ///< input frame size(in bytes) |
78 uint8_t unpacked_frame_size;///< output frame size (in bytes) | 77 uint8_t unpacked_frame_size;///< output frame size (in bytes) |
79 uint8_t fc_indexes_bits; ///< size (in bits) of fixed-codebook index entry | 78 uint8_t fc_indexes_bits; ///< size (in bits) of fixed-codebook index entry |
80 | 79 |
96 static inline int get_parity(uint8_t value) | 95 static inline int get_parity(uint8_t value) |
97 { | 96 { |
98 return (0x6996966996696996ULL >> (value >> 2)) & 1; | 97 return (0x6996966996696996ULL >> (value >> 2)) & 1; |
99 } | 98 } |
100 | 99 |
101 if(avctx->channels != 1) | 100 if (avctx->channels != 1) { |
102 { | |
103 av_log(avctx, AV_LOG_ERROR, "Only mono sound is supported (requested channels: %d).\n", avctx->channels); | 101 av_log(avctx, AV_LOG_ERROR, "Only mono sound is supported (requested channels: %d).\n", avctx->channels); |
104 return AVERROR_NOFMT; | 102 return AVERROR_NOFMT; |
105 } | 103 } |
106 | 104 |
107 ff_acelp_weighted_vector_sum( | 105 ff_acelp_weighted_vector_sum(fc + pitch_delay_int[i], |
108 fc + pitch_delay_int[i], | 106 fc + pitch_delay_int[i], |
109 fc + pitch_delay_int[i], | 107 fc, 1 << 14, |
110 fc, | 108 av_clip(ctx->gain_pitch, SHARP_MIN, SHARP_MAX), |
111 1 << 14, | 109 0, 14, |
112 av_clip(ctx->gain_pitch, SHARP_MIN, SHARP_MAX), | 110 ctx->subframe_size - pitch_delay_int[i]); |
113 0, | |
114 14, | |
115 ctx->subframe_size - pitch_delay_int[i]); | |
116 | 111 |
117 if(ctx->frame_erasure) | 112 if (ctx->frame_erasure) { |
118 { | 113 ctx->gain_pitch = (29491 * ctx->gain_pitch) >> 15; // 0.90 (0.15) |
119 ctx->gain_pitch = (29491 * ctx->gain_pitch) >> 15; // 0.9 (0.15) | 114 ctx->gain_code = ( 2007 * ctx->gain_code ) >> 11; // 0.98 (0.11) |
120 ctx->gain_code = (2007 * ctx->gain_code) >> 11; // 0.98 in (0.11) | |
121 | 115 |
122 gain_corr_factor = 0; | 116 gain_corr_factor = 0; |
123 } | 117 } else { |
124 else | |
125 { | |
126 ctx->gain_pitch = cb_gain_1st_8k[parm->gc_1st_index[i]][0] + | 118 ctx->gain_pitch = cb_gain_1st_8k[parm->gc_1st_index[i]][0] + |
127 cb_gain_2nd_8k[parm->gc_2nd_index[i]][0]; | 119 cb_gain_2nd_8k[parm->gc_2nd_index[i]][0]; |
128 gain_corr_factor = cb_gain_1st_8k[parm->gc_1st_index[i]][1] + | 120 gain_corr_factor = cb_gain_1st_8k[parm->gc_1st_index[i]][1] + |
129 cb_gain_2nd_8k[parm->gc_2nd_index[i]][1]; | 121 cb_gain_2nd_8k[parm->gc_2nd_index[i]][1]; |
130 | 122 |
131 ff_acelp_weighted_vector_sum( | 123 ff_acelp_weighted_vector_sum(ctx->exc + i * ctx->subframe_size, |
132 ctx->exc + i * ctx->subframe_size, | 124 ctx->exc + i * ctx->subframe_size, fc, |
133 ctx->exc + i * ctx->subframe_size, | 125 (!voicing && ctx->frame_erasure) ? 0 : ctx->gain_pitch, |
134 fc, | 126 ( voicing && ctx->frame_erasure) ? 0 : ctx->gain_code, |
135 (!voicing && ctx->frame_erasure) ? 0 : ctx->gain_pitch, | 127 1<<13, 14, ctx->subframe_size); |
136 ( voicing && ctx->frame_erasure) ? 0 : ctx->gain_code, | |
137 1<<13, | |
138 14, | |
139 ctx->subframe_size); | |
140 | 128 |
141 if (buf_size<packed_frame_size) | 129 if (buf_size < packed_frame_size) { |
142 { | |
143 av_log(avctx, AV_LOG_ERROR, "Error processing packet: packet size too small\n"); | 130 av_log(avctx, AV_LOG_ERROR, "Error processing packet: packet size too small\n"); |
144 return AVERROR(EIO); | 131 return AVERROR(EIO); |
145 } | 132 } |
146 if (*data_size<unpacked_frame_size) | 133 if (*data_size < unpacked_frame_size) { |
147 { | |
148 av_log(avctx, AV_LOG_ERROR, "Error processing packet: output buffer too small\n"); | 134 av_log(avctx, AV_LOG_ERROR, "Error processing packet: output buffer too small\n"); |
149 return AVERROR(EIO); | 135 return AVERROR(EIO); |
150 } | 136 } |
151 | 137 |
152 AVCodec g729_decoder = | 138 AVCodec g729_decoder = |