Mercurial > libavcodec.hg
comparison flacenc.c @ 12308:7bb34d5cb22f libavcodec
Combine and simplify output_subframe_fixed() and output_subframe_lpc().
author | jbr |
---|---|
date | Fri, 30 Jul 2010 20:28:46 +0000 |
parents | a2de400ccd30 |
children | 0a496c73c434 |
comparison
equal
deleted
inserted
replaced
12307:a2de400ccd30 | 12308:7bb34d5cb22f |
---|---|
1145 set_sr_golomb_flac(&s->pb, res[j], k, INT32_MAX, 0); | 1145 set_sr_golomb_flac(&s->pb, res[j], k, INT32_MAX, 0); |
1146 } | 1146 } |
1147 } | 1147 } |
1148 | 1148 |
1149 | 1149 |
1150 static void output_subframe_fixed(FlacEncodeContext *s, FlacSubframe *sub) | 1150 static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub) |
1151 { | 1151 { |
1152 int i; | 1152 int i; |
1153 | 1153 |
1154 /* warm-up samples */ | 1154 /* warm-up samples */ |
1155 for (i = 0; i < sub->order; i++) | 1155 for (i = 0; i < sub->order; i++) |
1156 put_sbits(&s->pb, sub->obits, sub->residual[i]); | 1156 put_sbits(&s->pb, sub->obits, sub->residual[i]); |
1157 | 1157 |
1158 /* residual */ | |
1159 output_residual(s, sub); | |
1160 } | |
1161 | |
1162 | |
1163 static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub) | |
1164 { | |
1165 int i, cbits; | |
1166 FlacFrame *frame; | |
1167 | |
1168 frame = &s->frame; | |
1169 | |
1170 /* warm-up samples */ | |
1171 for (i = 0; i < sub->order; i++) | |
1172 put_sbits(&s->pb, sub->obits, sub->residual[i]); | |
1173 | |
1174 /* LPC coefficients */ | 1158 /* LPC coefficients */ |
1175 cbits = s->options.lpc_coeff_precision; | 1159 if (sub->type == FLAC_SUBFRAME_LPC) { |
1160 int cbits = s->options.lpc_coeff_precision; | |
1176 put_bits( &s->pb, 4, cbits-1); | 1161 put_bits( &s->pb, 4, cbits-1); |
1177 put_sbits(&s->pb, 5, sub->shift); | 1162 put_sbits(&s->pb, 5, sub->shift); |
1178 for (i = 0; i < sub->order; i++) | 1163 for (i = 0; i < sub->order; i++) |
1179 put_sbits(&s->pb, cbits, sub->coefs[i]); | 1164 put_sbits(&s->pb, cbits, sub->coefs[i]); |
1165 } | |
1180 | 1166 |
1181 /* residual */ | 1167 /* residual */ |
1182 output_residual(s, sub); | 1168 output_residual(s, sub); |
1183 } | 1169 } |
1184 | 1170 |
1201 | 1187 |
1202 /* subframe */ | 1188 /* subframe */ |
1203 switch (sub->type) { | 1189 switch (sub->type) { |
1204 case FLAC_SUBFRAME_CONSTANT: | 1190 case FLAC_SUBFRAME_CONSTANT: |
1205 case FLAC_SUBFRAME_VERBATIM: output_subframe_verbatim(s, sub); break; | 1191 case FLAC_SUBFRAME_VERBATIM: output_subframe_verbatim(s, sub); break; |
1206 case FLAC_SUBFRAME_FIXED: output_subframe_fixed( s, sub); break; | 1192 case FLAC_SUBFRAME_FIXED: |
1207 case FLAC_SUBFRAME_LPC: output_subframe_lpc( s, sub); break; | 1193 case FLAC_SUBFRAME_LPC: output_subframe_lpc( s, sub); break; |
1208 } | 1194 } |
1209 } | 1195 } |
1210 } | 1196 } |
1211 | 1197 |