Mercurial > libavcodec.hg
comparison flacenc.c @ 12307:a2de400ccd30 libavcodec
Combine and simplify output_subframe_constant() and output_subframe_verbatim().
author | jbr |
---|---|
date | Fri, 30 Jul 2010 20:24:15 +0000 |
parents | 94e9dcf99f21 |
children | 7bb34d5cb22f |
comparison
equal
deleted
inserted
replaced
12306:94e9dcf99f21 | 12307:a2de400ccd30 |
---|---|
1099 put_bits_count(&s->pb) >> 3); | 1099 put_bits_count(&s->pb) >> 3); |
1100 put_bits(&s->pb, 8, crc); | 1100 put_bits(&s->pb, 8, crc); |
1101 } | 1101 } |
1102 | 1102 |
1103 | 1103 |
1104 static void output_subframe_constant(FlacEncodeContext *s, FlacSubframe *sub) | |
1105 { | |
1106 int32_t res; | |
1107 | |
1108 res = sub->residual[0]; | |
1109 put_sbits(&s->pb, sub->obits, res); | |
1110 } | |
1111 | |
1112 | |
1113 static void output_subframe_verbatim(FlacEncodeContext *s, FlacSubframe *sub) | 1104 static void output_subframe_verbatim(FlacEncodeContext *s, FlacSubframe *sub) |
1114 { | 1105 { |
1115 int i; | 1106 put_sbits(&s->pb, sub->obits, sub->residual[0]); |
1116 FlacFrame *frame; | 1107 |
1117 int32_t res; | 1108 if (sub->type == FLAC_SUBFRAME_VERBATIM) { |
1118 | 1109 int i; |
1119 frame = &s->frame; | 1110 for (i = 0; i < s->frame.blocksize; i++) |
1120 | 1111 put_sbits(&s->pb, sub->obits, sub->residual[i]); |
1121 for (i = 0; i < frame->blocksize; i++) { | |
1122 res = sub->residual[i]; | |
1123 put_sbits(&s->pb, sub->obits, res); | |
1124 } | 1112 } |
1125 } | 1113 } |
1126 | 1114 |
1127 | 1115 |
1128 static void output_residual(FlacEncodeContext *s, FlacSubframe *sub) | 1116 static void output_residual(FlacEncodeContext *s, FlacSubframe *sub) |
1210 put_bits(&s->pb, 1, 0); | 1198 put_bits(&s->pb, 1, 0); |
1211 put_bits(&s->pb, 6, sub->type_code); | 1199 put_bits(&s->pb, 6, sub->type_code); |
1212 put_bits(&s->pb, 1, 0); /* no wasted bits */ | 1200 put_bits(&s->pb, 1, 0); /* no wasted bits */ |
1213 | 1201 |
1214 /* subframe */ | 1202 /* subframe */ |
1215 if(sub->type == FLAC_SUBFRAME_CONSTANT) | 1203 switch (sub->type) { |
1216 output_subframe_constant(s, sub); | 1204 case FLAC_SUBFRAME_CONSTANT: |
1217 else if(sub->type == FLAC_SUBFRAME_VERBATIM) | 1205 case FLAC_SUBFRAME_VERBATIM: output_subframe_verbatim(s, sub); break; |
1218 output_subframe_verbatim(s, sub); | 1206 case FLAC_SUBFRAME_FIXED: output_subframe_fixed( s, sub); break; |
1219 else if(sub->type == FLAC_SUBFRAME_FIXED) | 1207 case FLAC_SUBFRAME_LPC: output_subframe_lpc( s, sub); break; |
1220 output_subframe_fixed(s, sub); | 1208 } |
1221 else if(sub->type == FLAC_SUBFRAME_LPC) | |
1222 output_subframe_lpc(s, sub); | |
1223 } | 1209 } |
1224 } | 1210 } |
1225 | 1211 |
1226 | 1212 |
1227 static void output_frame_footer(FlacEncodeContext *s) | 1213 static void output_frame_footer(FlacEncodeContext *s) |