Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/mov: don't abort on duplicate Mastering Display Metadata boxes
@ 2024-03-27  0:11 James Almer
  2024-03-27  0:13 ` Andreas Rheinhardt
  0 siblings, 1 reply; 3+ messages in thread
From: James Almer @ 2024-03-27  0:11 UTC (permalink / raw)
  To: ffmpeg-devel

The VP9 spec defines a SmDm box for this information, and the ISOBMFF spec defines a
mdvc one. If both are present, just ignore one of them.
This is in line with clli and CoLL boxes.

Fixes ticket #10711.

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index e7aa8d1833..5463f36770 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6140,8 +6140,10 @@ static int mov_read_smdm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         av_log(c->fc, AV_LOG_WARNING, "Unsupported Mastering Display Metadata box version %d\n", version);
         return 0;
     }
-    if (sc->mastering)
-        return AVERROR_INVALIDDATA;
+    if (sc->mastering) {
+        av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate Mastering Display Metadata\n");
+        return 0;
+    }
 
     avio_skip(pb, 3); /* flags */
 
@@ -6178,11 +6180,16 @@ static int mov_read_mdcv(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data;
 
-    if (atom.size < 24 || sc->mastering) {
+    if (atom.size < 24) {
         av_log(c->fc, AV_LOG_ERROR, "Invalid Mastering Display Color Volume box\n");
         return AVERROR_INVALIDDATA;
     }
 
+    if (sc->mastering) {
+        av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate Mastering Display Color Volume\n");
+        return 0;
+    }
+
     sc->mastering = av_mastering_display_metadata_alloc();
     if (!sc->mastering)
         return AVERROR(ENOMEM);
-- 
2.44.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/mov: don't abort on duplicate Mastering Display Metadata boxes
  2024-03-27  0:11 [FFmpeg-devel] [PATCH] avformat/mov: don't abort on duplicate Mastering Display Metadata boxes James Almer
@ 2024-03-27  0:13 ` Andreas Rheinhardt
  2024-03-27  0:16   ` James Almer
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-03-27  0:13 UTC (permalink / raw)
  To: ffmpeg-devel

James Almer:
> The VP9 spec defines a SmDm box for this information, and the ISOBMFF spec defines a
> mdvc one. If both are present, just ignore one of them.
> This is in line with clli and CoLL boxes.
> 
> Fixes ticket #10711.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/mov.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index e7aa8d1833..5463f36770 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -6140,8 +6140,10 @@ static int mov_read_smdm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>          av_log(c->fc, AV_LOG_WARNING, "Unsupported Mastering Display Metadata box version %d\n", version);
>          return 0;
>      }
> -    if (sc->mastering)
> -        return AVERROR_INVALIDDATA;
> +    if (sc->mastering) {
> +        av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate Mastering Display Metadata\n");

If this is expected (and maybe even encouraged/required by some spec),
then why is this a warning?

> +        return 0;
> +    }
>  
>      avio_skip(pb, 3); /* flags */
>  
> @@ -6178,11 +6180,16 @@ static int mov_read_mdcv(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>  
>      sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data;
>  
> -    if (atom.size < 24 || sc->mastering) {
> +    if (atom.size < 24) {
>          av_log(c->fc, AV_LOG_ERROR, "Invalid Mastering Display Color Volume box\n");
>          return AVERROR_INVALIDDATA;
>      }
>  
> +    if (sc->mastering) {
> +        av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate Mastering Display Color Volume\n");
> +        return 0;
> +    }
> +
>      sc->mastering = av_mastering_display_metadata_alloc();
>      if (!sc->mastering)
>          return AVERROR(ENOMEM);

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/mov: don't abort on duplicate Mastering Display Metadata boxes
  2024-03-27  0:13 ` Andreas Rheinhardt
@ 2024-03-27  0:16   ` James Almer
  0 siblings, 0 replies; 3+ messages in thread
From: James Almer @ 2024-03-27  0:16 UTC (permalink / raw)
  To: ffmpeg-devel

On 3/26/2024 9:13 PM, Andreas Rheinhardt wrote:
> James Almer:
>> The VP9 spec defines a SmDm box for this information, and the ISOBMFF spec defines a
>> mdvc one. If both are present, just ignore one of them.
>> This is in line with clli and CoLL boxes.
>>
>> Fixes ticket #10711.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavformat/mov.c | 13 ++++++++++---
>>   1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index e7aa8d1833..5463f36770 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -6140,8 +6140,10 @@ static int mov_read_smdm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>>           av_log(c->fc, AV_LOG_WARNING, "Unsupported Mastering Display Metadata box version %d\n", version);
>>           return 0;
>>       }
>> -    if (sc->mastering)
>> -        return AVERROR_INVALIDDATA;
>> +    if (sc->mastering) {
>> +        av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate Mastering Display Metadata\n");
> 
> If this is expected (and maybe even encouraged/required by some spec),
> then why is this a warning?

I don't know if it's expected. I'd expect VP9 streams would not come 
with mdvc and CoLL boxes at all, but apparently Youtube ones now do 
(Guess they are phasing out webm-dash and so now VP9 is served on mp4). 
I just copied the existing behavior from clli and CoLL.

> 
>> +        return 0;
>> +    }
>>   
>>       avio_skip(pb, 3); /* flags */
>>   
>> @@ -6178,11 +6180,16 @@ static int mov_read_mdcv(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>>   
>>       sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data;
>>   
>> -    if (atom.size < 24 || sc->mastering) {
>> +    if (atom.size < 24) {
>>           av_log(c->fc, AV_LOG_ERROR, "Invalid Mastering Display Color Volume box\n");
>>           return AVERROR_INVALIDDATA;
>>       }
>>   
>> +    if (sc->mastering) {
>> +        av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate Mastering Display Color Volume\n");
>> +        return 0;
>> +    }
>> +
>>       sc->mastering = av_mastering_display_metadata_alloc();
>>       if (!sc->mastering)
>>           return AVERROR(ENOMEM);
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-27  0:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27  0:11 [FFmpeg-devel] [PATCH] avformat/mov: don't abort on duplicate Mastering Display Metadata boxes James Almer
2024-03-27  0:13 ` Andreas Rheinhardt
2024-03-27  0:16   ` James Almer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git