[FFmpeg-devel] avformat/mov: don't rescale mastering display values from the SmDm atom

Submitted by James Almer on Feb. 9, 2019, 11:21 p.m.

Details

Message ID 20190209232141.5680-1-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Feb. 9, 2019, 11:21 p.m.
Simplifies code.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/mov.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

Comments

Michael Niedermayer Feb. 11, 2019, 5:58 p.m.
On Sat, Feb 09, 2019 at 08:21:41PM -0300, James Almer wrote:
> Simplifies code.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/mov.c | 21 ++++++++-------------
>  1 file changed, 8 insertions(+), 13 deletions(-)

probably ok

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9b9739f788..986c54e74e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5268,9 +5268,7 @@  static int mov_read_vpcc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 static int mov_read_smdm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     MOVStreamContext *sc;
-    const int chroma_den = 50000;
-    const int luma_den = 10000;
-    int i, j, version;
+    int i, version;
 
     if (c->fc->nb_streams < 1)
         return AVERROR_INVALIDDATA;
@@ -5293,17 +5291,14 @@  static int mov_read_smdm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     if (!sc->mastering)
         return AVERROR(ENOMEM);
 
-    for (i = 0; i < 3; i++)
-        for (j = 0; j < 2; j++)
-            sc->mastering->display_primaries[i][j] =
-                av_make_q(lrint(((double)avio_rb16(pb) / (1 << 16)) * chroma_den), chroma_den);
+    for (i = 0; i < 3; i++) {
+        sc->mastering->display_primaries[i][0] = av_make_q(avio_rb16(pb), 1 << 16);
+        sc->mastering->display_primaries[i][1] = av_make_q(avio_rb16(pb), 1 << 16);
+    }
     for (i = 0; i < 2; i++)
-        sc->mastering->white_point[i] =
-            av_make_q(lrint(((double)avio_rb16(pb) / (1 << 16)) * chroma_den), chroma_den);
-    sc->mastering->max_luminance =
-        av_make_q(lrint(((double)avio_rb32(pb) / (1 <<  8)) * luma_den), luma_den);
-    sc->mastering->min_luminance =
-        av_make_q(lrint(((double)avio_rb32(pb) / (1 << 14)) * luma_den), luma_den);
+        sc->mastering->white_point[i] = av_make_q(avio_rb16(pb), 1 << 16);
+    sc->mastering->max_luminance = av_make_q(avio_rb32(pb), 1 << 8);
+    sc->mastering->min_luminance = av_make_q(avio_rb32(pb), 1 << 14);
 
     sc->mastering->has_primaries = 1;
     sc->mastering->has_luminance = 1;