On 2/24/2023 6:08 PM, Zhao Zhili wrote:
From: Zhao Zhili <zhiliz...@tencent.com>

Signed-off-by: Zhao Zhili <zhiliz...@tencent.com>
---
  libavcodec/dynamic_hdr_vivid.c | 34 +++++++++++++++++++++++-----------
  1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index d689669dec..35be6f5e2b 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -98,26 +98,38 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
                              return AVERROR_INVALIDDATA;
                          tm_params->three_Spline_enable_flag = get_bits(gb, 1);
                          if (tm_params->three_Spline_enable_flag) {
+                            AVHDRVivid3SplineParams *three_spline;
+
                              if (get_bits_left(gb) < 1 + 
tm_params->three_Spline_num * (2 + 12 + 28 + 1))
                                  return AVERROR_INVALIDDATA;
                              tm_params->three_Spline_num = get_bits(gb, 1) + 1;
+                            if (tm_params->three_Spline_num > 
FF_ARRAY_ELEMS(tm_params->three_spline))
+                                return AVERROR_INVALIDDATA;
                              for (int j = 0; j < tm_params->three_Spline_num; 
j++) {
-                                tm_params->three_Spline_TH_mode = get_bits(gb, 
2);
-                                if (tm_params->three_Spline_TH_mode == 0 || 
tm_params->three_Spline_TH_mode == 2) {
+                                three_spline = tm_params->three_spline + j;

Preferably do:

three_spline = &tm_params->three_spline[j];

+                                three_spline->th_mode = get_bits(gb, 2);
+                                if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
                                      if (get_bits_left(gb) < 8)
                                          return AVERROR_INVALIDDATA;
-                                    tm_params->three_Spline_TH_enable_MB = 
(AVRational){get_bits(gb, 8),  255};
+                                    three_spline->th_enable_mb = 
(AVRational){get_bits(gb, 8),  255};
                                  }
-                                tm_params->three_Spline_TH_enable = 
(AVRational){get_bits(gb, 12),  4095};
-                                tm_params->three_Spline_TH_Delta1 = 
(AVRational){get_bits(gb, 10),  1023};
-                                tm_params->three_Spline_TH_Delta2 = 
(AVRational){get_bits(gb, 10),  1023};
-                                tm_params->three_Spline_enable_Strength = 
(AVRational){get_bits(gb,  8),  255};
+                                three_spline->th_enable = 
(AVRational){get_bits(gb, 12),  4095};
+                                three_spline->th_delta1 = 
(AVRational){get_bits(gb, 10),  1023};
+                                three_spline->th_delta2 = 
(AVRational){get_bits(gb, 10),  1023};
+                                three_spline->enable_strength = 
(AVRational){get_bits(gb,  8),  255};
                              }
-                        } else {
-                            tm_params->three_Spline_num     = 1;
-                            tm_params->three_Spline_TH_mode = 0;
+#if FF_API_HDR_VIVID_THREE_SPLINE
+                            three_spline = tm_params->three_spline;

Also here:

three_spline = &tm_params->three_spline[0];

Same in every other case in this patchset.

+                            AV_NOWARN_DEPRECATED(

This is an internal file, so use the FF_DISABLE_DEPRECATION_WARNINGS and FF_ENABLE_DEPRECATION_WARNINGS wrappers instead of the public one.

+                            tm_params->three_Spline_TH_mode = 
three_spline->th_mode;
+                            tm_params->three_Spline_TH_enable_MB = 
three_spline->th_enable_mb;
+                            tm_params->three_Spline_TH_enable = 
three_spline->th_enable;
+                            tm_params->three_Spline_TH_Delta1 = 
three_spline->th_delta1;
+                            tm_params->three_Spline_TH_Delta2 = 
three_spline->th_delta2;
+                            tm_params->three_Spline_enable_Strength = 
three_spline->enable_strength;
+                            )
+#endif
                          }
-
                      }
                  }
              }
_______________________________________________
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".

Reply via email to