[FFmpeg-cvslog] avutil/ambient_viewing_environment: set a sane default value for AVRational fields

James Almer git at videolan.org
Thu Jun 20 23:17:11 EEST 2024


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Jun 18 16:12:06 2024 -0300| [7f1b590480e7519e25ac9fcd99b0f9916fb03462] | committer: James Almer

avutil/ambient_viewing_environment: set a sane default value for AVRational fields

Prevent potential divisions by 0 when using them immediately after allocation.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f1b590480e7519e25ac9fcd99b0f9916fb03462
---

 libavutil/ambient_viewing_environment.c | 10 ++++++++++
 libavutil/version.h                     |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavutil/ambient_viewing_environment.c b/libavutil/ambient_viewing_environment.c
index c47458cfa8..e359727776 100644
--- a/libavutil/ambient_viewing_environment.c
+++ b/libavutil/ambient_viewing_environment.c
@@ -21,6 +21,13 @@
 #include "ambient_viewing_environment.h"
 #include "mem.h"
 
+static void get_defaults(AVAmbientViewingEnvironment *env)
+{
+    env->ambient_illuminance =
+    env->ambient_light_x     =
+    env->ambient_light_y     = (AVRational) { 0, 1 };
+}
+
 AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size)
 {
     AVAmbientViewingEnvironment *env =
@@ -28,6 +35,8 @@ AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size)
     if (!env)
         return NULL;
 
+    get_defaults(env);
+
      if (size)
         *size = sizeof(*env);
 
@@ -44,6 +53,7 @@ AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVF
         return NULL;
 
     memset(side_data->data, 0, side_data->size);
+    get_defaults((AVAmbientViewingEnvironment *)side_data->data);
 
     return (AVAmbientViewingEnvironment *)side_data->data;
 }
diff --git a/libavutil/version.h b/libavutil/version.h
index 8044fd3935..4f51d441fa 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR  59
 #define LIBAVUTIL_VERSION_MINOR  24
-#define LIBAVUTIL_VERSION_MICRO 100
+#define LIBAVUTIL_VERSION_MICRO 101
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list