[FFmpeg-cvslog] avformat/matroskadec: don't rescale mastering display values
James Almer
git at videolan.org
Sun Oct 6 04:38:22 EEST 2019
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Oct 3 20:52:20 2019 -0300| [3b4e9a31ea263830d6dfbc402c02e3c8d017094f] | committer: James Almer
avformat/matroskadec: don't rescale mastering display values
Simplifies code.
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3b4e9a31ea263830d6dfbc402c02e3c8d017094f
---
libavformat/matroskadec.c | 33 ++++++++++-----------------------
1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index a5f120b54d..c224c3447a 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2116,9 +2116,6 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) {
}
if (has_mastering_primaries || has_mastering_luminance) {
- // Use similar rationals as other standards.
- const int chroma_den = 50000;
- const int luma_den = 10000;
AVMasteringDisplayMetadata *metadata =
(AVMasteringDisplayMetadata*) av_stream_new_side_data(
st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
@@ -2128,29 +2125,19 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) {
}
memset(metadata, 0, sizeof(AVMasteringDisplayMetadata));
if (has_mastering_primaries) {
- metadata->display_primaries[0][0] = av_make_q(
- round(mastering_meta->r_x * chroma_den), chroma_den);
- metadata->display_primaries[0][1] = av_make_q(
- round(mastering_meta->r_y * chroma_den), chroma_den);
- metadata->display_primaries[1][0] = av_make_q(
- round(mastering_meta->g_x * chroma_den), chroma_den);
- metadata->display_primaries[1][1] = av_make_q(
- round(mastering_meta->g_y * chroma_den), chroma_den);
- metadata->display_primaries[2][0] = av_make_q(
- round(mastering_meta->b_x * chroma_den), chroma_den);
- metadata->display_primaries[2][1] = av_make_q(
- round(mastering_meta->b_y * chroma_den), chroma_den);
- metadata->white_point[0] = av_make_q(
- round(mastering_meta->white_x * chroma_den), chroma_den);
- metadata->white_point[1] = av_make_q(
- round(mastering_meta->white_y * chroma_den), chroma_den);
+ metadata->display_primaries[0][0] = av_d2q(mastering_meta->r_x, INT_MAX);
+ metadata->display_primaries[0][1] = av_d2q(mastering_meta->r_y, INT_MAX);
+ metadata->display_primaries[1][0] = av_d2q(mastering_meta->g_x, INT_MAX);
+ metadata->display_primaries[1][1] = av_d2q(mastering_meta->g_y, INT_MAX);
+ metadata->display_primaries[2][0] = av_d2q(mastering_meta->b_x, INT_MAX);
+ metadata->display_primaries[2][1] = av_d2q(mastering_meta->b_y, INT_MAX);
+ metadata->white_point[0] = av_d2q(mastering_meta->white_x, INT_MAX);
+ metadata->white_point[1] = av_d2q(mastering_meta->white_y, INT_MAX);
metadata->has_primaries = 1;
}
if (has_mastering_luminance) {
- metadata->max_luminance = av_make_q(
- round(mastering_meta->max_luminance * luma_den), luma_den);
- metadata->min_luminance = av_make_q(
- round(mastering_meta->min_luminance * luma_den), luma_den);
+ metadata->max_luminance = av_d2q(mastering_meta->max_luminance, INT_MAX);
+ metadata->min_luminance = av_d2q(mastering_meta->min_luminance, INT_MAX);
metadata->has_luminance = 1;
}
}
More information about the ffmpeg-cvslog
mailing list