On Thu, Jun 20, 2024 at 6:54 PM James Almer <jamr...@gmail.com> wrote: > > On 6/18/2024 4:20 PM, James Almer wrote: > > Prevent potential divisions by 0 when using them immediately after > > allocation. > > > > Signed-off-by: James Almer <jamr...@gmail.com> > > --- > > libavutil/ambient_viewing_environment.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > 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; > > } > > Will apply the set soon if nobody objectx.
In general I guess LGTM as I guess 0/0 is considered bad. But isn't the function more about setting the defaults to a struct rather than getting them? I just see that function being closer to "set_defaults" than "get_defaults". Jan _______________________________________________ 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".