[FFmpeg-devel] [PATCH 2/5] mlpenc: fix huff offset calculation

2020-01-24 Thread Jai Luthra
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 
---
 libavcodec/mlpenc.c | 6 +-
 1 file changed, 1 insertion(+), 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;
 }
 }
 }
-- 
2.25.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/5] mlpenc: fix huff offset calculation

2019-07-09 Thread Jai Luthra
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 
---
 libavcodec/mlpenc.c | 6 +-
 1 file changed, 1 insertion(+), 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;
 }
 }
 }
-- 
2.22.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".