avutil/mastering_display_metadata: 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>
This commit is contained in:
parent
7f1b590480
commit
1044c09eca
@ -25,9 +25,20 @@
|
||||
#include "mastering_display_metadata.h"
|
||||
#include "mem.h"
|
||||
|
||||
static void get_defaults(AVMasteringDisplayMetadata *mastering)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
mastering->display_primaries[i][j] = (AVRational) { 0, 1 };
|
||||
mastering->white_point[0] =
|
||||
mastering->white_point[1] =
|
||||
mastering->min_luminance =
|
||||
mastering->max_luminance = (AVRational) { 0, 1 };
|
||||
}
|
||||
|
||||
AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(AVMasteringDisplayMetadata));
|
||||
return av_mastering_display_metadata_alloc_size(NULL);
|
||||
}
|
||||
|
||||
AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t *size)
|
||||
@ -36,6 +47,8 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t *siz
|
||||
if (!mastering)
|
||||
return NULL;
|
||||
|
||||
get_defaults(mastering);
|
||||
|
||||
if (size)
|
||||
*size = sizeof(*mastering);
|
||||
|
||||
@ -51,6 +64,7 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFra
|
||||
return NULL;
|
||||
|
||||
memset(side_data->data, 0, sizeof(AVMasteringDisplayMetadata));
|
||||
get_defaults((AVMasteringDisplayMetadata *)side_data->data);
|
||||
|
||||
return (AVMasteringDisplayMetadata *)side_data->data;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 59
|
||||
#define LIBAVUTIL_VERSION_MINOR 24
|
||||
#define LIBAVUTIL_VERSION_MICRO 101
|
||||
#define LIBAVUTIL_VERSION_MICRO 102
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
|
Loading…
Reference in New Issue
Block a user