Commit 6d263f41 authored by Justin Ruggles's avatar Justin Ruggles

Combine output_subframe_verbatim() and output_subframe_lpc().

Originally committed as revision 24608 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 6266cfb4
...@@ -1101,25 +1101,20 @@ static void output_frame_header(FlacEncodeContext *s) ...@@ -1101,25 +1101,20 @@ static void output_frame_header(FlacEncodeContext *s)
} }
static void output_subframe_verbatim(FlacEncodeContext *s, FlacSubframe *sub) static void output_subframe(FlacEncodeContext *s, FlacSubframe *sub)
{
put_sbits(&s->pb, sub->obits, sub->residual[0]);
if (sub->type == FLAC_SUBFRAME_VERBATIM) {
int i;
for (i = 0; i < s->frame.blocksize; i++)
put_sbits(&s->pb, sub->obits, sub->residual[i]);
}
}
static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub)
{ {
int i, p, porder, psize; int i, p, porder, psize;
int32_t *res, *part_end, *frame_end; int32_t *part_end;
int32_t *res = sub->residual;
int32_t *frame_end = &sub->residual[s->frame.blocksize];
if (sub->type == FLAC_SUBFRAME_CONSTANT) {
put_sbits(&s->pb, sub->obits, res[0]);
} else if (sub->type == FLAC_SUBFRAME_VERBATIM) {
while (res < frame_end)
put_sbits(&s->pb, sub->obits, *res++);
} else {
/* warm-up samples */ /* warm-up samples */
res = sub->residual;
for (i = 0; i < sub->order; i++) for (i = 0; i < sub->order; i++)
put_sbits(&s->pb, sub->obits, *res++); put_sbits(&s->pb, sub->obits, *res++);
...@@ -1142,7 +1137,6 @@ static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub) ...@@ -1142,7 +1137,6 @@ static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub)
/* residual */ /* residual */
part_end = &sub->residual[psize ]; part_end = &sub->residual[psize ];
frame_end = &sub->residual[s->frame.blocksize];
for (p = 0; p < 1 << porder; p++) { for (p = 0; p < 1 << porder; p++) {
int k = sub->rc.params[p]; int k = sub->rc.params[p];
put_bits(&s->pb, 4, k); put_bits(&s->pb, 4, k);
...@@ -1150,6 +1144,7 @@ static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub) ...@@ -1150,6 +1144,7 @@ static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub)
set_sr_golomb_flac(&s->pb, *res++, k, INT32_MAX, 0); set_sr_golomb_flac(&s->pb, *res++, k, INT32_MAX, 0);
part_end = FFMIN(frame_end, part_end + psize); part_end = FFMIN(frame_end, part_end + psize);
} }
}
} }
...@@ -1170,12 +1165,7 @@ static void output_subframes(FlacEncodeContext *s) ...@@ -1170,12 +1165,7 @@ static void output_subframes(FlacEncodeContext *s)
put_bits(&s->pb, 1, 0); /* no wasted bits */ put_bits(&s->pb, 1, 0); /* no wasted bits */
/* subframe */ /* subframe */
switch (sub->type) { output_subframe(s, sub);
case FLAC_SUBFRAME_CONSTANT:
case FLAC_SUBFRAME_VERBATIM: output_subframe_verbatim(s, sub); break;
case FLAC_SUBFRAME_FIXED:
case FLAC_SUBFRAME_LPC: output_subframe_lpc( s, sub); break;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment