comparison flacenc.c @ 12314:46b00f7710da libavcodec

Combine output_subframe() and output_subframes().
author jbr
date Fri, 30 Jul 2010 21:32:19 +0000
parents c1918adb174b
children f903ba955ae7
comparison
equal deleted inserted replaced
12313:c1918adb174b 12314:46b00f7710da
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(FlacEncodeContext *s, FlacSubframe *sub) 1104 static void output_subframes(FlacEncodeContext *s)
1105 { 1105 {
1106 int ch;
1107
1108 for (ch = 0; ch < s->channels; ch++) {
1109 FlacSubframe *sub = &s->frame.subframes[ch];
1106 int i, p, porder, psize; 1110 int i, p, porder, psize;
1107 int32_t *part_end; 1111 int32_t *part_end;
1108 int32_t *res = sub->residual; 1112 int32_t *res = sub->residual;
1109 int32_t *frame_end = &sub->residual[s->frame.blocksize]; 1113 int32_t *frame_end = &sub->residual[s->frame.blocksize];
1110 1114
1115 /* subframe header */
1116 put_bits(&s->pb, 1, 0);
1117 put_bits(&s->pb, 6, sub->type_code);
1118 put_bits(&s->pb, 1, 0); /* no wasted bits */
1119
1120 /* subframe */
1111 if (sub->type == FLAC_SUBFRAME_CONSTANT) { 1121 if (sub->type == FLAC_SUBFRAME_CONSTANT) {
1112 put_sbits(&s->pb, sub->obits, res[0]); 1122 put_sbits(&s->pb, sub->obits, res[0]);
1113 } else if (sub->type == FLAC_SUBFRAME_VERBATIM) { 1123 } else if (sub->type == FLAC_SUBFRAME_VERBATIM) {
1114 while (res < frame_end) 1124 while (res < frame_end)
1115 put_sbits(&s->pb, sub->obits, *res++); 1125 put_sbits(&s->pb, sub->obits, *res++);
1143 while (res < part_end) 1153 while (res < part_end)
1144 set_sr_golomb_flac(&s->pb, *res++, k, INT32_MAX, 0); 1154 set_sr_golomb_flac(&s->pb, *res++, k, INT32_MAX, 0);
1145 part_end = FFMIN(frame_end, part_end + psize); 1155 part_end = FFMIN(frame_end, part_end + psize);
1146 } 1156 }
1147 } 1157 }
1148 }
1149
1150
1151 static void output_subframes(FlacEncodeContext *s)
1152 {
1153 FlacSubframe *sub;
1154 int ch;
1155
1156 for (ch = 0; ch < s->channels; ch++) {
1157 sub = &s->frame.subframes[ch];
1158
1159 /* subframe header */
1160 put_bits(&s->pb, 1, 0);
1161 put_bits(&s->pb, 6, sub->type_code);
1162 put_bits(&s->pb, 1, 0); /* no wasted bits */
1163
1164 /* subframe */
1165 output_subframe(s, sub);
1166 } 1158 }
1167 } 1159 }
1168 1160
1169 1161
1170 static void output_frame_footer(FlacEncodeContext *s) 1162 static void output_frame_footer(FlacEncodeContext *s)