[FFmpeg-devel] [PATCH 3/3] wavpackenc: use put_sbits()
Ronald S. Bultje
rsbultje at gmail.com
Sat Apr 18 04:33:52 CEST 2015
Hi,
On Fri, Apr 17, 2015 at 10:29 PM, James Almer <jamrial at gmail.com> wrote:
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> libavcodec/wavpackenc.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
> index c174950..87f1445 100644
> --- a/libavcodec/wavpackenc.c
> +++ b/libavcodec/wavpackenc.c
> @@ -2143,7 +2143,6 @@ static void pack_int32(WavPackEncodeContext *s,
> int nb_samples)
> {
> const int sent_bits = s->int32_sent_bits;
> - int32_t value, mask = (1 << sent_bits) - 1;
> PutBitContext *pb = &s->pb;
> int i, pre_shift;
>
> @@ -2154,15 +2153,12 @@ static void pack_int32(WavPackEncodeContext *s,
>
> if (s->flags & WV_MONO_DATA) {
> for (i = 0; i < nb_samples; i++) {
> - value = (samples_l[i] >> pre_shift) & mask;
> - put_bits(pb, sent_bits, value);
> + put_sbits(pb, sent_bits, samples_l[i] >> pre_shift);
> }
> } else {
> for (i = 0; i < nb_samples; i++) {
> - value = (samples_l[i] >> pre_shift) & mask;
> - put_bits(pb, sent_bits, value);
> - value = (samples_r[i] >> pre_shift) & mask;
> - put_bits(pb, sent_bits, value);
> + put_sbits(pb, sent_bits, samples_l[i] >> pre_shift);
> + put_sbits(pb, sent_bits, samples_r[i] >> pre_shift);
>From a bit coder's perspective, you could just as well write a
put_(s)bits_upper() which doesn't write until the final lowest (1) bit.
(You don't have to do that, just pointing it out.)
Ronald
More information about the ffmpeg-devel
mailing list