@@ -168,7 +168,7 @@ typedef struct MatroskaMasteringMeta {
double white_x;
double white_y;
double max_luminance;
- double min_luminance;
+ CountedElement min_luminance;
} MatroskaMasteringMeta;
typedef struct MatroskaTrackVideoColor {
@@ -452,7 +452,7 @@ static EbmlSyntax matroska_mastering_meta[] = {
{ MATROSKA_ID_VIDEOCOLOR_BY, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, b_y) },
{ MATROSKA_ID_VIDEOCOLOR_WHITEX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, white_x) },
{ MATROSKA_ID_VIDEOCOLOR_WHITEY, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, white_y) },
- { MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, min_luminance), { .f=-1 } },
+ { MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN, EBML_FLOAT, 1, 0, offsetof(MatroskaMasteringMeta, min_luminance) },
{ MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, max_luminance) },
CHILD_OF(matroska_track_video_color)
};
@@ -2110,7 +2110,10 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) {
mastering_meta->g_x > 0 && mastering_meta->g_y > 0 &&
mastering_meta->b_x > 0 && mastering_meta->b_y > 0 &&
mastering_meta->white_x > 0 && mastering_meta->white_y > 0;
- has_mastering_luminance = mastering_meta->max_luminance > 0;
+ has_mastering_luminance = mastering_meta->max_luminance >
+ mastering_meta->min_luminance.el.f &&
+ mastering_meta->min_luminance.el.f >= 0 &&
+ mastering_meta->min_luminance.count;
if (color->matrix_coefficients != AVCOL_SPC_RESERVED)
st->codecpar->color_space = color->matrix_coefficients;
@@ -2169,7 +2172,7 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) {
}
if (has_mastering_luminance) {
metadata->max_luminance = av_d2q(mastering_meta->max_luminance, INT_MAX);
- metadata->min_luminance = av_d2q(mastering_meta->min_luminance, INT_MAX);
+ metadata->min_luminance = av_d2q(mastering_meta->min_luminance.el.f, INT_MAX);
metadata->has_luminance = 1;
}
}
In the absence of an explicitly coded minimal luminance, the current code inferred it to be -1, an invalid value. Yet it did not check the value lateron at all, so that if a valid maximum luminance is encountered, but no minimal luminance, an invalid minimal luminance of -1 is exported. If an minimal luminance element with a negative value is present, it is exported, too. This can be simply fixed by adding a check for the value of the element. Yet given that a minimal luminance of zero Cd/m² is legal and can be coded with a length of zero, we must not use a fake default value to find out whether the element is present or not. Therefore this patch uses an explicit counter for it. While just at it, also check for max_luminance > min_luminance. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavformat/matroskadec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)