aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2024-06-18 16:20:24 -0300
committerJames Almer <jamrial@gmail.com>2024-06-20 17:03:55 -0300
commitc3606cad9cffded4620af07287606d4d97f29bf1 (patch)
tree6d22b3b98bf2e139afaccf349b2e5b62e8247fd8
parent1044c09ecae478fea33f80c13f94c7381a8f0a24 (diff)
downloadffmpeg-c3606cad9cffded4620af07287606d4d97f29bf1.tar.gz
avutil/stereo3d: 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@gmail.com>
-rw-r--r--libavutil/stereo3d.c14
-rw-r--r--libavutil/version.h2
-rw-r--r--tests/ref/fate/matroska-spherical-mono2
-rw-r--r--tests/ref/fate/matroska-spherical-mono-remux4
-rw-r--r--tests/ref/fate/matroska-stereo_mode8
-rw-r--r--tests/ref/fate/matroska-vp8-alpha-remux2
-rw-r--r--tests/ref/fate/mov-spherical-mono2
7 files changed, 23 insertions, 11 deletions
diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index a40a9439bb..19e81e4124 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -26,9 +26,20 @@
#include "mem.h"
#include "stereo3d.h"
+static void get_defaults(AVStereo3D *stereo)
+{
+ stereo->horizontal_disparity_adjustment = (AVRational) { 0, 1 };
+}
+
AVStereo3D *av_stereo3d_alloc(void)
{
- return av_mallocz(sizeof(AVStereo3D));
+ AVStereo3D *stereo = av_mallocz(sizeof(AVStereo3D));
+ if (!stereo)
+ return NULL;
+
+ get_defaults(stereo);
+
+ return stereo;
}
AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame)
@@ -40,6 +51,7 @@ AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame)
return NULL;
memset(side_data->data, 0, sizeof(AVStereo3D));
+ get_defaults((AVStereo3D *)side_data->data);
return (AVStereo3D *)side_data->data;
}
diff --git a/libavutil/version.h b/libavutil/version.h
index 9c24b64032..145fe634b3 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 102
+#define LIBAVUTIL_VERSION_MICRO 103
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
diff --git a/tests/ref/fate/matroska-spherical-mono b/tests/ref/fate/matroska-spherical-mono
index c52ca8e7ee..b108596350 100644
--- a/tests/ref/fate/matroska-spherical-mono
+++ b/tests/ref/fate/matroska-spherical-mono
@@ -6,7 +6,7 @@ inverted=0
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[SIDE_DATA]
diff --git a/tests/ref/fate/matroska-spherical-mono-remux b/tests/ref/fate/matroska-spherical-mono-remux
index 10b92d5f2e..eec41b77f3 100644
--- a/tests/ref/fate/matroska-spherical-mono-remux
+++ b/tests/ref/fate/matroska-spherical-mono-remux
@@ -30,7 +30,7 @@ inverted=0
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[SIDE_DATA]
@@ -59,7 +59,7 @@ inverted=0
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[SIDE_DATA]
diff --git a/tests/ref/fate/matroska-stereo_mode b/tests/ref/fate/matroska-stereo_mode
index a1aab1e38e..26c325b20e 100644
--- a/tests/ref/fate/matroska-stereo_mode
+++ b/tests/ref/fate/matroska-stereo_mode
@@ -135,7 +135,7 @@ inverted=0
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[/STREAM]
@@ -155,7 +155,7 @@ inverted=1
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[/STREAM]
@@ -173,7 +173,7 @@ inverted=1
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[/STREAM]
@@ -192,7 +192,7 @@ inverted=1
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[/STREAM]
diff --git a/tests/ref/fate/matroska-vp8-alpha-remux b/tests/ref/fate/matroska-vp8-alpha-remux
index ea8a089cec..06bcc4b4ba 100644
--- a/tests/ref/fate/matroska-vp8-alpha-remux
+++ b/tests/ref/fate/matroska-vp8-alpha-remux
@@ -38,7 +38,7 @@ inverted=0
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[/STREAM]
diff --git a/tests/ref/fate/mov-spherical-mono b/tests/ref/fate/mov-spherical-mono
index c52ca8e7ee..b108596350 100644
--- a/tests/ref/fate/mov-spherical-mono
+++ b/tests/ref/fate/mov-spherical-mono
@@ -6,7 +6,7 @@ inverted=0
view=packed
primary_eye=none
baseline=0
-horizontal_disparity_adjustment=0/0
+horizontal_disparity_adjustment=0/1
horizontal_field_of_view=0
[/SIDE_DATA]
[SIDE_DATA]