@@ -1574,23 +1574,24 @@ static int write_frame(FlacEncodeContext *s, AVPacket *avpkt)
static int update_md5_sum(FlacEncodeContext *s, const void *samples)
{
const uint8_t *buf = samples;
+ int bits_per_raw_sample = s->avctx->bits_per_raw_sample;
int buf_size = s->frame.blocksize * s->channels *
- ((s->avctx->bits_per_raw_sample + 7) / 8);
+ ((bits_per_raw_sample + 7) / 8);
if (HAVE_BIGENDIAN ||
- s->avctx->bits_per_raw_sample > 16 && s->avctx->bits_per_raw_sample <= 24) {
+ bits_per_raw_sample > 16 && bits_per_raw_sample <= 24) {
av_fast_malloc(&s->md5_buffer, &s->md5_buffer_size, buf_size);
if (!s->md5_buffer)
return AVERROR(ENOMEM);
buf = s->md5_buffer;
}
- if (s->avctx->bits_per_raw_sample <= 16) {
+ if (bits_per_raw_sample <= 16) {
#if HAVE_BIGENDIAN
s->bdsp.bswap16_buf((uint16_t *) s->md5_buffer,
samples, buf_size / 2);
#endif
- } else if (s->avctx->bits_per_raw_sample <= 24) {
+ } else if (bits_per_raw_sample <= 24) {
int i;
const int32_t *samples0 = samples;
uint8_t *tmp = s->md5_buffer;
@@ -1600,7 +1601,7 @@ static int update_md5_sum(FlacEncodeContext *s, const void *samples)
AV_WL24(tmp + 3*i, v);
}
} else {
- /* s->avctx->bits_per_raw_sample <= 32 */
+ /* bits_per_raw_sample <= 32 */
#if HAVE_BIGENDIAN
s->bdsp.bswap_buf((uint32_t *) s->md5_buffer,
samples, s->frame.blocksize * s->channels);
This has the advantage of allowing the compiler to check bits_per_raw_sample only once on little-endian hardware. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/flacenc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)