diff mbox series

[FFmpeg-devel,4/6] avcodec/huffyuv: Return proper error code

Message ID GV1P250MB0737BADF0AE437E56A92F38D8F3C2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 0e5af493fc139d057a0d81cbfb2e963d4976ebe2
Headers show
Series [FFmpeg-devel,1/6] avcodec/huffyuvdec: Don't zero unnecessarily | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt April 4, 2024, 5:02 a.m. UTC
Also forward said error code in the encoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/huffyuv.c    | 3 ++-
 libavcodec/huffyuvenc.c | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 723ab6b92b..f22c5ebc59 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -31,6 +31,7 @@ 
 #include <stddef.h>
 #include <stdint.h>
 
+#include "libavutil/error.h"
 #include "libavutil/log.h"
 #include "libavutil/macros.h"
 
@@ -48,7 +49,7 @@  int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int
     for (int i = FF_ARRAY_ELEMS(lens) - 1; i > 0; i--) {
         if ((lens[i] + codes[i]) & 1) {
             av_log(NULL, AV_LOG_ERROR, "Error generating huffman table\n");
-            return -1;
+            return AVERROR_INVALIDDATA;
         }
         codes[i - 1] = (lens[i] + codes[i]) >> 1;
     }
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 4f709143a2..152f94cefb 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -232,9 +232,9 @@  static int store_huffman_tables(HYuvEncContext *s, uint8_t *buf)
         if ((ret = ff_huff_gen_len_table(s->len[i], s->stats[i], s->vlc_n, 0)) < 0)
             return ret;
 
-        if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n) < 0) {
-            return -1;
-        }
+        ret = ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n);
+        if (ret < 0)
+            return ret;
 
         size += store_table(s, s->len[i], buf + size);
     }