Mercurial > libavcodec.hg
comparison flacenc.c @ 12306:94e9dcf99f21 libavcodec
Pass FlacSubframe to output_subframe_* instead of channel number.
| author | jbr |
|---|---|
| date | Fri, 30 Jul 2010 20:09:14 +0000 |
| parents | 000218dd70aa |
| children | a2de400ccd30 |
comparison
equal
deleted
inserted
replaced
| 12305:000218dd70aa | 12306:94e9dcf99f21 |
|---|---|
| 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, int ch) | 1104 static void output_subframe_constant(FlacEncodeContext *s, FlacSubframe *sub) |
| 1105 { | 1105 { |
| 1106 FlacSubframe *sub; | |
| 1107 int32_t res; | 1106 int32_t res; |
| 1108 | 1107 |
| 1109 sub = &s->frame.subframes[ch]; | |
| 1110 res = sub->residual[0]; | 1108 res = sub->residual[0]; |
| 1111 put_sbits(&s->pb, sub->obits, res); | 1109 put_sbits(&s->pb, sub->obits, res); |
| 1112 } | 1110 } |
| 1113 | 1111 |
| 1114 | 1112 |
| 1115 static void output_subframe_verbatim(FlacEncodeContext *s, int ch) | 1113 static void output_subframe_verbatim(FlacEncodeContext *s, FlacSubframe *sub) |
| 1116 { | 1114 { |
| 1117 int i; | 1115 int i; |
| 1118 FlacFrame *frame; | 1116 FlacFrame *frame; |
| 1119 FlacSubframe *sub; | |
| 1120 int32_t res; | 1117 int32_t res; |
| 1121 | 1118 |
| 1122 frame = &s->frame; | 1119 frame = &s->frame; |
| 1123 sub = &frame->subframes[ch]; | |
| 1124 | 1120 |
| 1125 for (i = 0; i < frame->blocksize; i++) { | 1121 for (i = 0; i < frame->blocksize; i++) { |
| 1126 res = sub->residual[i]; | 1122 res = sub->residual[i]; |
| 1127 put_sbits(&s->pb, sub->obits, res); | 1123 put_sbits(&s->pb, sub->obits, res); |
| 1128 } | 1124 } |
| 1129 } | 1125 } |
| 1130 | 1126 |
| 1131 | 1127 |
| 1132 static void output_residual(FlacEncodeContext *s, int ch) | 1128 static void output_residual(FlacEncodeContext *s, FlacSubframe *sub) |
| 1133 { | 1129 { |
| 1134 int i, j, p, n, parts; | 1130 int i, j, p, n, parts; |
| 1135 int k, porder, psize, res_cnt; | 1131 int k, porder, psize, res_cnt; |
| 1136 FlacFrame *frame; | 1132 FlacFrame *frame; |
| 1137 FlacSubframe *sub; | |
| 1138 int32_t *res; | 1133 int32_t *res; |
| 1139 | 1134 |
| 1140 frame = &s->frame; | 1135 frame = &s->frame; |
| 1141 sub = &frame->subframes[ch]; | |
| 1142 res = sub->residual; | 1136 res = sub->residual; |
| 1143 n = frame->blocksize; | 1137 n = frame->blocksize; |
| 1144 | 1138 |
| 1145 /* rice-encoded block */ | 1139 /* rice-encoded block */ |
| 1146 put_bits(&s->pb, 2, 0); | 1140 put_bits(&s->pb, 2, 0); |
| 1163 set_sr_golomb_flac(&s->pb, res[j], k, INT32_MAX, 0); | 1157 set_sr_golomb_flac(&s->pb, res[j], k, INT32_MAX, 0); |
| 1164 } | 1158 } |
| 1165 } | 1159 } |
| 1166 | 1160 |
| 1167 | 1161 |
| 1168 static void output_subframe_fixed(FlacEncodeContext *s, int ch) | 1162 static void output_subframe_fixed(FlacEncodeContext *s, FlacSubframe *sub) |
| 1169 { | 1163 { |
| 1170 int i; | 1164 int i; |
| 1171 FlacFrame *frame; | |
| 1172 FlacSubframe *sub; | |
| 1173 | |
| 1174 frame = &s->frame; | |
| 1175 sub = &frame->subframes[ch]; | |
| 1176 | 1165 |
| 1177 /* warm-up samples */ | 1166 /* warm-up samples */ |
| 1178 for (i = 0; i < sub->order; i++) | 1167 for (i = 0; i < sub->order; i++) |
| 1179 put_sbits(&s->pb, sub->obits, sub->residual[i]); | 1168 put_sbits(&s->pb, sub->obits, sub->residual[i]); |
| 1180 | 1169 |
| 1181 /* residual */ | 1170 /* residual */ |
| 1182 output_residual(s, ch); | 1171 output_residual(s, sub); |
| 1183 } | 1172 } |
| 1184 | 1173 |
| 1185 | 1174 |
| 1186 static void output_subframe_lpc(FlacEncodeContext *s, int ch) | 1175 static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub) |
| 1187 { | 1176 { |
| 1188 int i, cbits; | 1177 int i, cbits; |
| 1189 FlacFrame *frame; | 1178 FlacFrame *frame; |
| 1190 FlacSubframe *sub; | |
| 1191 | 1179 |
| 1192 frame = &s->frame; | 1180 frame = &s->frame; |
| 1193 sub = &frame->subframes[ch]; | |
| 1194 | 1181 |
| 1195 /* warm-up samples */ | 1182 /* warm-up samples */ |
| 1196 for (i = 0; i < sub->order; i++) | 1183 for (i = 0; i < sub->order; i++) |
| 1197 put_sbits(&s->pb, sub->obits, sub->residual[i]); | 1184 put_sbits(&s->pb, sub->obits, sub->residual[i]); |
| 1198 | 1185 |
| 1202 put_sbits(&s->pb, 5, sub->shift); | 1189 put_sbits(&s->pb, 5, sub->shift); |
| 1203 for (i = 0; i < sub->order; i++) | 1190 for (i = 0; i < sub->order; i++) |
| 1204 put_sbits(&s->pb, cbits, sub->coefs[i]); | 1191 put_sbits(&s->pb, cbits, sub->coefs[i]); |
| 1205 | 1192 |
| 1206 /* residual */ | 1193 /* residual */ |
| 1207 output_residual(s, ch); | 1194 output_residual(s, sub); |
| 1208 } | 1195 } |
| 1209 | 1196 |
| 1210 | 1197 |
| 1211 static void output_subframes(FlacEncodeContext *s) | 1198 static void output_subframes(FlacEncodeContext *s) |
| 1212 { | 1199 { |
| 1224 put_bits(&s->pb, 6, sub->type_code); | 1211 put_bits(&s->pb, 6, sub->type_code); |
| 1225 put_bits(&s->pb, 1, 0); /* no wasted bits */ | 1212 put_bits(&s->pb, 1, 0); /* no wasted bits */ |
| 1226 | 1213 |
| 1227 /* subframe */ | 1214 /* subframe */ |
| 1228 if(sub->type == FLAC_SUBFRAME_CONSTANT) | 1215 if(sub->type == FLAC_SUBFRAME_CONSTANT) |
| 1229 output_subframe_constant(s, ch); | 1216 output_subframe_constant(s, sub); |
| 1230 else if(sub->type == FLAC_SUBFRAME_VERBATIM) | 1217 else if(sub->type == FLAC_SUBFRAME_VERBATIM) |
| 1231 output_subframe_verbatim(s, ch); | 1218 output_subframe_verbatim(s, sub); |
| 1232 else if(sub->type == FLAC_SUBFRAME_FIXED) | 1219 else if(sub->type == FLAC_SUBFRAME_FIXED) |
| 1233 output_subframe_fixed(s, ch); | 1220 output_subframe_fixed(s, sub); |
| 1234 else if(sub->type == FLAC_SUBFRAME_LPC) | 1221 else if(sub->type == FLAC_SUBFRAME_LPC) |
| 1235 output_subframe_lpc(s, ch); | 1222 output_subframe_lpc(s, sub); |
| 1236 } | 1223 } |
| 1237 } | 1224 } |
| 1238 | 1225 |
| 1239 | 1226 |
| 1240 static void output_frame_footer(FlacEncodeContext *s) | 1227 static void output_frame_footer(FlacEncodeContext *s) |
