aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJai Luthra <me@jailuthra.in>2020-01-24 16:03:31 +0530
committerPaul B Mahol <onemda@gmail.com>2020-02-04 11:19:12 +0100
commit990990ed5d72b531cf5cc605af89830d8d42e7d0 (patch)
treed3fcebbad73811fe36d1456e6dad2a1db11b1fa0 /libavcodec
parentc1c3916cec9ca627b9bff4a34683f66664ff787d (diff)
downloadffmpeg-990990ed5d72b531cf5cc605af89830d8d42e7d0.tar.gz
mlpenc: fix huff offset calculation
huff offset wasn't always within the bounds before, which lead to corrupt encoding that didn't always trigger lossless check failures Signed-off-by: Jai Luthra <me@jailuthra.in>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mlpenc.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index f4948451f1..1cee38c82f 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1699,7 +1699,7 @@ static inline void codebook_bits(MLPEncodeContext *ctx,
offset_min = FFMAX(min, HUFF_OFFSET_MIN);
offset_max = FFMIN(max, HUFF_OFFSET_MAX);
- for (;;) {
+ while (offset <= offset_max && offset >= offset_min) {
BestOffset temp_bo;
codebook_bits_offset(ctx, channel, codebook,
@@ -1718,12 +1718,8 @@ static inline void codebook_bits(MLPEncodeContext *ctx,
if (direction) {
offset = temp_bo.max + 1;
- if (offset > offset_max)
- break;
} else {
offset = temp_bo.min - 1;
- if (offset < offset_min)
- break;
}
}
}