diff mbox

[FFmpeg-devel,7/7] avformat/dashenc: fix writting the AV1 codec string in mp4 mode

Message ID 20190730201951.2033-7-jamrial@gmail.com
State Accepted
Commit 1cf2f040e34bbfedde60ff3d91b2f7b770aca85b
Headers show

Commit Message

James Almer July 30, 2019, 8:19 p.m. UTC
From https://aomediacodec.github.io/av1-isobmff/#codecsparam, the parameters
sample entry 4CC, profile, level, tier, and bitDepth are all mandatory fields.
All the other fields are optional, mutually inclusive (all or none).

Fixes ticket #8049

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/dashenc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

James Almer Aug. 2, 2019, 2:13 p.m. UTC | #1
On 7/30/2019 5:19 PM, James Almer wrote:
> From https://aomediacodec.github.io/av1-isobmff/#codecsparam, the parameters
> sample entry 4CC, profile, level, tier, and bitDepth are all mandatory fields.
> All the other fields are optional, mutually inclusive (all or none).
> 
> Fixes ticket #8049
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/dashenc.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 50eba370d9..a3d8168110 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -35,6 +35,7 @@
>  #include "libavutil/time.h"
>  #include "libavutil/time_internal.h"
>  
> +#include "av1.h"
>  #include "avc.h"
>  #include "avformat.h"
>  #include "avio_internal.h"
> @@ -389,6 +390,21 @@ static void set_codec_str(AVFormatContext *s, AVCodecParameters *par,
>              av_strlcatf(str, size, ".%02x%02x%02x",
>                          extradata[1], extradata[2], extradata[3]);
>          av_free(tmpbuf);
> +    } else if (!strcmp(str, "av01")) {
> +        AV1SequenceParameters seq;
> +        if (!par->extradata_size)
> +            return;
> +        if (ff_av1_parse_seq_header(&seq, par->extradata, par->extradata_size) < 0)
> +            return;
> +
> +        av_strlcatf(str, size, ".%01u.%02u%s.%02u",
> +                    seq.profile, seq.level, seq.tier ? "H" : "M", seq.bitdepth);
> +        if (seq.color_description_present_flag)
> +            av_strlcatf(str, size, ".%01u.%01u%01u%01u.%02u.%02u.%02u.%01u",
> +                        seq.monochrome,
> +                        seq.chroma_subsampling_x, seq.chroma_subsampling_y, seq.chroma_sample_position,
> +                        seq.color_primaries, seq.transfer_characteristics, seq.matrix_coefficients,
> +                        seq.color_range);
>      }
>  }

Will push the set soon.
James Almer Aug. 3, 2019, 3:49 p.m. UTC | #2
On 8/2/2019 11:13 AM, James Almer wrote:
> On 7/30/2019 5:19 PM, James Almer wrote:
>> From https://aomediacodec.github.io/av1-isobmff/#codecsparam, the parameters
>> sample entry 4CC, profile, level, tier, and bitDepth are all mandatory fields.
>> All the other fields are optional, mutually inclusive (all or none).
>>
>> Fixes ticket #8049
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>  libavformat/dashenc.c | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index 50eba370d9..a3d8168110 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -35,6 +35,7 @@
>>  #include "libavutil/time.h"
>>  #include "libavutil/time_internal.h"
>>  
>> +#include "av1.h"
>>  #include "avc.h"
>>  #include "avformat.h"
>>  #include "avio_internal.h"
>> @@ -389,6 +390,21 @@ static void set_codec_str(AVFormatContext *s, AVCodecParameters *par,
>>              av_strlcatf(str, size, ".%02x%02x%02x",
>>                          extradata[1], extradata[2], extradata[3]);
>>          av_free(tmpbuf);
>> +    } else if (!strcmp(str, "av01")) {
>> +        AV1SequenceParameters seq;
>> +        if (!par->extradata_size)
>> +            return;
>> +        if (ff_av1_parse_seq_header(&seq, par->extradata, par->extradata_size) < 0)
>> +            return;
>> +
>> +        av_strlcatf(str, size, ".%01u.%02u%s.%02u",
>> +                    seq.profile, seq.level, seq.tier ? "H" : "M", seq.bitdepth);
>> +        if (seq.color_description_present_flag)
>> +            av_strlcatf(str, size, ".%01u.%01u%01u%01u.%02u.%02u.%02u.%01u",
>> +                        seq.monochrome,
>> +                        seq.chroma_subsampling_x, seq.chroma_subsampling_y, seq.chroma_sample_position,
>> +                        seq.color_primaries, seq.transfer_characteristics, seq.matrix_coefficients,
>> +                        seq.color_range);
>>      }
>>  }
> 
> Will push the set soon.

Pushed with the suggested changes.

Thanks.
diff mbox

Patch

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 50eba370d9..a3d8168110 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -35,6 +35,7 @@ 
 #include "libavutil/time.h"
 #include "libavutil/time_internal.h"
 
+#include "av1.h"
 #include "avc.h"
 #include "avformat.h"
 #include "avio_internal.h"
@@ -389,6 +390,21 @@  static void set_codec_str(AVFormatContext *s, AVCodecParameters *par,
             av_strlcatf(str, size, ".%02x%02x%02x",
                         extradata[1], extradata[2], extradata[3]);
         av_free(tmpbuf);
+    } else if (!strcmp(str, "av01")) {
+        AV1SequenceParameters seq;
+        if (!par->extradata_size)
+            return;
+        if (ff_av1_parse_seq_header(&seq, par->extradata, par->extradata_size) < 0)
+            return;
+
+        av_strlcatf(str, size, ".%01u.%02u%s.%02u",
+                    seq.profile, seq.level, seq.tier ? "H" : "M", seq.bitdepth);
+        if (seq.color_description_present_flag)
+            av_strlcatf(str, size, ".%01u.%01u%01u%01u.%02u.%02u.%02u.%01u",
+                        seq.monochrome,
+                        seq.chroma_subsampling_x, seq.chroma_subsampling_y, seq.chroma_sample_position,
+                        seq.color_primaries, seq.transfer_characteristics, seq.matrix_coefficients,
+                        seq.color_range);
     }
 }