diff mbox series

[FFmpeg-devel,2/3] avcodec/dynamic_hdr10_plus: use AVERROR_INVALIDDATA instead of AVERROR(EINVAL)

Message ID 1631616638-20151-2-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 4c079636abf059a54b84d3da015dcd8669ef6471
Headers show
Series [FFmpeg-devel,1/3] avcodec/hevc_sei: check size before using it
Related show

Checks

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

Commit Message

Limin Wang Sept. 14, 2021, 10:50 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/dynamic_hdr10_plus.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dynamic_hdr10_plus.c b/libavcodec/dynamic_hdr10_plus.c
index a602e60..854e70d 100644
--- a/libavcodec/dynamic_hdr10_plus.c
+++ b/libavcodec/dynamic_hdr10_plus.c
@@ -76,7 +76,7 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
     }
 
     if (get_bits_left(gb) < 28)
-        return AVERROR(EINVAL);
+        return AVERROR_INVALIDDATA;
 
     s->targeted_system_display_maximum_luminance =
         (AVRational){get_bits_long(gb, 27), luminance_den};
@@ -85,7 +85,7 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
     if (s->targeted_system_display_actual_peak_luminance_flag) {
         int rows, cols;
         if (get_bits_left(gb) < 10)
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
         rows = get_bits(gb, 5);
         cols = get_bits(gb, 5);
         if (((rows < 2) || (rows > 25)) || ((cols < 2) || (cols > 25))) {
@@ -95,7 +95,7 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
         s->num_cols_targeted_system_display_actual_peak_luminance = cols;
 
         if (get_bits_left(gb) < (rows * cols * 4))
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
 
         for (int i = 0; i < rows; i++) {
             for (int j = 0; j < cols; j++) {
@@ -107,7 +107,7 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
     for (int w = 0; w < s->num_windows; w++) {
         AVHDRPlusColorTransformParams *params = &s->params[w];
         if (get_bits_left(gb) < (3 * 17 + 17 + 4))
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
 
         for (int i = 0; i < 3; i++) {
             params->maxscl[i] =
@@ -119,7 +119,7 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
 
         if (get_bits_left(gb) <
             (params->num_distribution_maxrgb_percentiles * 24))
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
 
         for (int i = 0; i < params->num_distribution_maxrgb_percentiles; i++) {
             params->distribution_maxrgb[i].percentage = get_bits(gb, 7);
@@ -128,17 +128,17 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
         }
 
         if (get_bits_left(gb) < 10)
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
 
         params->fraction_bright_pixels = (AVRational){get_bits(gb, 10), fraction_pixel_den};
     }
     if (get_bits_left(gb) < 1)
-        return AVERROR(EINVAL);
+        return AVERROR_INVALIDDATA;
     s->mastering_display_actual_peak_luminance_flag = get_bits1(gb);
     if (s->mastering_display_actual_peak_luminance_flag) {
         int rows, cols;
         if (get_bits_left(gb) < 10)
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
         rows = get_bits(gb, 5);
         cols = get_bits(gb, 5);
         if (((rows < 2) || (rows > 25)) || ((cols < 2) || (cols > 25))) {
@@ -148,7 +148,7 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
         s->num_cols_mastering_display_actual_peak_luminance = cols;
 
         if (get_bits_left(gb) < (rows * cols * 4))
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
 
         for (int i = 0; i < rows; i++) {
             for (int j = 0; j < cols; j++) {
@@ -161,12 +161,12 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
     for (int w = 0; w < s->num_windows; w++) {
         AVHDRPlusColorTransformParams *params = &s->params[w];
         if (get_bits_left(gb) < 1)
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
 
         params->tone_mapping_flag = get_bits1(gb);
         if (params->tone_mapping_flag) {
             if (get_bits_left(gb) < 28)
-                return AVERROR(EINVAL);
+                return AVERROR_INVALIDDATA;
 
             params->knee_point_x =
                 (AVRational){get_bits(gb, 12), knee_point_den};
@@ -175,7 +175,7 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
             params->num_bezier_curve_anchors = get_bits(gb, 4);
 
             if (get_bits_left(gb) < (params->num_bezier_curve_anchors * 10))
-                return AVERROR(EINVAL);
+                return AVERROR_INVALIDDATA;
 
             for (int i = 0; i < params->num_bezier_curve_anchors; i++) {
                 params->bezier_curve_anchors[i] =
@@ -184,11 +184,11 @@  int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t
         }
 
         if (get_bits_left(gb) < 1)
-            return AVERROR(EINVAL);
+            return AVERROR_INVALIDDATA;
         params->color_saturation_mapping_flag = get_bits1(gb);
         if (params->color_saturation_mapping_flag) {
             if (get_bits_left(gb) < 6)
-                return AVERROR(EINVAL);
+                return AVERROR_INVALIDDATA;
             params->color_saturation_weight =
                 (AVRational){get_bits(gb, 6), saturation_weight_den};
         }