History

avcodec/flacenc: Avoid shift where possible

Andreas Rheinhardt committed 2 years ago

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

Unified · Split

libavcodec/flacenc.c+4−5
@@ -525,11 +525,10 @@ static void copy_samples(FlacEncodeContext *s, const void *samples) · 524 unmodified lines
525{525{
526 int i, j, ch;526 int i, j, ch;
527 FlacFrame *frame;527 FlacFrame *frame;
528 int shift = av_get_bytes_per_sample(s->avctx->sample_fmt) * 8 -
529 s->avctx->bits_per_raw_sample;
530 528
531#define COPY_SAMPLES(bits) do { \529#define COPY_SAMPLES(bits, shift0) do { \
532 const int ## bits ## _t *samples0 = samples; \530 const int ## bits ## _t *samples0 = samples; \
531 const int shift = shift0; \
533 frame = &s->frame; \532 frame = &s->frame; \
534 for (i = 0, j = 0; i < frame->blocksize; i++) \533 for (i = 0, j = 0; i < frame->blocksize; i++) \
535 for (ch = 0; ch < s->channels; ch++, j++) \534 for (ch = 0; ch < s->channels; ch++, j++) \
@@ -537,9 +536,9 @@ static void copy_samples(FlacEncodeContext *s, const void *samples) · 1 unmodified line
537} while (0)536} while (0)
538 537
539 if (s->avctx->sample_fmt == AV_SAMPLE_FMT_S16)538 if (s->avctx->sample_fmt == AV_SAMPLE_FMT_S16)
540 COPY_SAMPLES(16);539 COPY_SAMPLES(16, 0);
541 else540 else
542 COPY_SAMPLES(32);541 COPY_SAMPLES(32, 32 - s->avctx->bits_per_raw_sample);
543}542}
544 543
545 544

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