History

avcodec/flacenc: Avoid shift where possible

Andreas Rheinhardt committed 2 years ago

Commit 15333511 parent 0458fdb1 file · +4 −5Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/flacenc.c+4−5
@@ -525,11 +525,10 @@ static void copy_samples(FlacEncodeContext *s, const void *samples) · 524 unmodified lines
525525 {
526526 int i, j, ch;
527527 FlacFrame *frame;
528− int shift = av_get_bytes_per_sample(s->avctx->sample_fmt) * 8 -
529− s->avctx->bits_per_raw_sample;
530528
531−#define COPY_SAMPLES(bits) do { \
529+#define COPY_SAMPLES(bits, shift0) do { \
532530 const int ## bits ## _t *samples0 = samples; \
531+ const int shift = shift0; \
533532 frame = &s->frame; \
534533 for (i = 0, j = 0; i < frame->blocksize; i++) \
535534 for (ch = 0; ch < s->channels; ch++, j++) \
@@ -537,9 +536,9 @@ static void copy_samples(FlacEncodeContext *s, const void *samples) · 1 unmodified line
537536 } while (0)
538537
539538 if (s->avctx->sample_fmt == AV_SAMPLE_FMT_S16)
540− COPY_SAMPLES(16);
539+ COPY_SAMPLES(16, 0);
541540 else
542− COPY_SAMPLES(32);
541+ COPY_SAMPLES(32, 32 - s->avctx->bits_per_raw_sample);
543542 }
544543
545544

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t