diff mbox

[FFmpeg-devel] avformat/mxfdec: export operational pattern UL as file metadata

Message ID 20190403203504.6574-1-cus@passwd.hu
State Accepted
Commit 6ed7df5b20e46b30f16deca5b619a1cf88bd48b3
Headers show

Commit Message

Marton Balint April 3, 2019, 8:35 p.m. UTC
Can be useful for API users as ffmpeg/libavformat can't properly support some
operational patterns.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mxfdec.c           | 7 +++++++
 tests/ref/fate/mxf-probe-d10   | 1 +
 tests/ref/fate/mxf-probe-dnxhd | 1 +
 tests/ref/fate/mxf-probe-dv25  | 1 +
 4 files changed, 10 insertions(+)

Comments

Tomas Härdin April 8, 2019, 1:36 p.m. UTC | #1
On 2019-04-03 21:35, Marton Balint wrote:
> Can be useful for API users as ffmpeg/libavformat can't properly support some
> operational patterns.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>   libavformat/mxfdec.c           | 7 +++++++
>   tests/ref/fate/mxf-probe-d10   | 1 +
>   tests/ref/fate/mxf-probe-dnxhd | 1 +
>   tests/ref/fate/mxf-probe-dv25  | 1 +
>   4 files changed, 10 insertions(+)
>
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 1ba8ecd4a6..8c65a2bbcf 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -718,6 +719,12 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size
>       }
>       nb_essence_containers = avio_rb32(pb);
>   
> +    if (partition->type == Header) {
> +        char str[36];
> +        snprintf(str, sizeof(str), "%08x.%08x.%08x.%08x", AV_RB32(&op[0]), AV_RB32(&op[4]), AV_RB32(&op[8]), AV_RB32(&op[12]));

I was unsure wheter this was the official format for UL, so I went and 
checked. SMPTE uses the same in their XML registry: 
https://registry.smpte-ra.org/view/published/Labels.xml

Example: urn:smpte:ul:060e2b34.04010101.01010100.00000000

In other words: looks OK to me

/Tomas
Tomas Härdin April 10, 2019, 7:52 a.m. UTC | #2
mån 2019-04-08 klockan 14:36 +0100 skrev Tomas Härdin:
> On 2019-04-03 21:35, Marton Balint wrote:
> > Can be useful for API users as ffmpeg/libavformat can't properly
> > support some
> > operational patterns.
> > 
> > Signed-off-by: Marton Balint <cus@passwd.hu>
> > ---
> >   libavformat/mxfdec.c           | 7 +++++++
> >   tests/ref/fate/mxf-probe-d10   | 1 +
> >   tests/ref/fate/mxf-probe-dnxhd | 1 +
> >   tests/ref/fate/mxf-probe-dv25  | 1 +
> >   4 files changed, 10 insertions(+)
> > 
> > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > index 1ba8ecd4a6..8c65a2bbcf 100644
> > --- a/libavformat/mxfdec.c
> > +++ b/libavformat/mxfdec.c
> > @@ -718,6 +719,12 @@ static int mxf_read_partition_pack(void *arg,
> > AVIOContext *pb, int tag, int size
> >       }
> >       nb_essence_containers = avio_rb32(pb);
> >   
> > +    if (partition->type == Header) {
> > +        char str[36];
> > +        snprintf(str, sizeof(str), "%08x.%08x.%08x.%08x",
> > AV_RB32(&op[0]), AV_RB32(&op[4]), AV_RB32(&op[8]),
> > AV_RB32(&op[12]));
> 
> I was unsure wheter this was the official format for UL, so I went
> and 
> checked. SMPTE uses the same in their XML registry: 
> https://registry.smpte-ra.org/view/published/Labels.xml
> 
> Example: urn:smpte:ul:060e2b34.04010101.01010100.00000000
> 
> In other words: looks OK to me

I had a similar suspicion about mxf_umid_to_str(), whose output looks
like this:

  0x060A2B340101010501010D2313000000C3F75299A1824BEBAA8EA92ADFB7F522

But this is actually the format specified by S330m Annex C, so that's
good as well.

/Tomas
Marton Balint April 11, 2019, 7:48 p.m. UTC | #3
On Mon, 8 Apr 2019, Tomas Härdin wrote:

> On 2019-04-03 21:35, Marton Balint wrote:
>> Can be useful for API users as ffmpeg/libavformat can't properly support 
> some
>> operational patterns.
>>
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>   libavformat/mxfdec.c           | 7 +++++++
>>   tests/ref/fate/mxf-probe-d10   | 1 +
>>   tests/ref/fate/mxf-probe-dnxhd | 1 +
>>   tests/ref/fate/mxf-probe-dv25  | 1 +
>>   4 files changed, 10 insertions(+)
>>
>> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
>> index 1ba8ecd4a6..8c65a2bbcf 100644
>> --- a/libavformat/mxfdec.c
>> +++ b/libavformat/mxfdec.c
>> @@ -718,6 +719,12 @@ static int mxf_read_partition_pack(void *arg, 
> AVIOContext *pb, int tag, int size
>>       }
>>       nb_essence_containers = avio_rb32(pb);
>> 
>> +    if (partition->type == Header) {
>> +        char str[36];
>> +        snprintf(str, sizeof(str), "%08x.%08x.%08x.%08x", AV_RB32(&op[0]), 
> AV_RB32(&op[4]), AV_RB32(&op[8]), AV_RB32(&op[12]));
>
> I was unsure wheter this was the official format for UL, so I went and 
> checked. SMPTE uses the same in their XML registry: 
> https://registry.smpte-ra.org/view/published/Labels.xml
>
> Example: urn:smpte:ul:060e2b34.04010101.01010100.00000000
>
> In other words: looks OK to me

Thanks, applied.

Regards,
Marton
Marton Balint April 11, 2019, 8:20 p.m. UTC | #4
On Thu, 11 Apr 2019, Marton Balint wrote:

>
>
> On Mon, 8 Apr 2019, Tomas Härdin wrote:
>
>> On 2019-04-03 21:35, Marton Balint wrote:
>>> Can be useful for API users as ffmpeg/libavformat can't properly support 
>> some
>>> operational patterns.
>>>
>>> Signed-off-by: Marton Balint <cus@passwd.hu>
>>> ---
>>>   libavformat/mxfdec.c           | 7 +++++++
>>>   tests/ref/fate/mxf-probe-d10   | 1 +
>>>   tests/ref/fate/mxf-probe-dnxhd | 1 +
>>>   tests/ref/fate/mxf-probe-dv25  | 1 +
>>>   4 files changed, 10 insertions(+)
>>>
>>> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
>>> index 1ba8ecd4a6..8c65a2bbcf 100644
>>> --- a/libavformat/mxfdec.c
>>> +++ b/libavformat/mxfdec.c
>>> @@ -718,6 +719,12 @@ static int mxf_read_partition_pack(void *arg, 
>> AVIOContext *pb, int tag, int size
>>>       }
>>>       nb_essence_containers = avio_rb32(pb);
>>> 
>>> +    if (partition->type == Header) {
>>> +        char str[36];
>>> +        snprintf(str, sizeof(str), "%08x.%08x.%08x.%08x", 
> AV_RB32(&op[0]), 
>> AV_RB32(&op[4]), AV_RB32(&op[8]), AV_RB32(&op[12]));
>>
>> I was unsure wheter this was the official format for UL, so I went and 
>> checked. SMPTE uses the same in their XML registry: 
>> https://registry.smpte-ra.org/view/published/Labels.xml
>>
>> Example: urn:smpte:ul:060e2b34.04010101.01010100.00000000
>>
>> In other words: looks OK to me
>
> Thanks, applied.

The metadata tag name became "operational_pattern", I wonder if it might 
make more sense to use "operational_pattern_ul" instead, it feels a little 
more consistent with the other custom mxf metadata entries.

It is not too late to change, what do you think?

Thanks,
Marton
Tomas Härdin April 14, 2019, 2:57 p.m. UTC | #5
tor 2019-04-11 klockan 22:20 +0200 skrev Marton Balint:
> 
> The metadata tag name became "operational_pattern", I wonder if it might 
> make more sense to use "operational_pattern_ul" instead, it feels a little 
> more consistent with the other custom mxf metadata entries.
> 
> It is not too late to change, what do you think?

Sounds like a good idea. UMIDs use _umid after all. Assuming there
hasn't been a release tagged in the last few days :)

/Tomas
diff mbox

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 1ba8ecd4a6..8c65a2bbcf 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -654,6 +654,7 @@  static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, U
 static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 {
     MXFContext *mxf = arg;
+    AVFormatContext *s = mxf->fc;
     MXFPartition *partition, *tmp_part;
     UID op;
     uint64_t footer_partition;
@@ -718,6 +719,12 @@  static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size
     }
     nb_essence_containers = avio_rb32(pb);
 
+    if (partition->type == Header) {
+        char str[36];
+        snprintf(str, sizeof(str), "%08x.%08x.%08x.%08x", AV_RB32(&op[0]), AV_RB32(&op[4]), AV_RB32(&op[8]), AV_RB32(&op[12]));
+        av_dict_set(&s->metadata, "operational_pattern", str, 0);
+    }
+
     if (partition->this_partition &&
         partition->previous_partition == partition->this_partition) {
         av_log(mxf->fc, AV_LOG_ERROR,
diff --git a/tests/ref/fate/mxf-probe-d10 b/tests/ref/fate/mxf-probe-d10
index 30ceaaf421..9b8a6a688d 100644
--- a/tests/ref/fate/mxf-probe-d10
+++ b/tests/ref/fate/mxf-probe-d10
@@ -96,6 +96,7 @@  TAG:file_package_umid=0x060A2B340101010501010D1313000000AE86B2009131058000000800
 format_name=mxf
 duration=0.178375
 bit_rate=56419744
+TAG:operational_pattern=060e2b34.04010101.0d010201.01010900
 TAG:uid=0086b200-9131-0580-0000-080046a54011
 TAG:generation_uid=b486b200-9131-0580-0000-080046a54011
 TAG:company_name=SONY
diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd
index c4de291d32..0870270a95 100644
--- a/tests/ref/fate/mxf-probe-dnxhd
+++ b/tests/ref/fate/mxf-probe-dnxhd
@@ -167,6 +167,7 @@  TAG:timecode=01:00:00:00
 format_name=mxf
 duration=0.250250
 bit_rate=25340195
+TAG:operational_pattern=060e2b34.04010102.0d010201.10030000
 TAG:project_name=UHD
 TAG:uid=784c8132-ae36-ed4d-b0ff-2edf1f3f2d92
 TAG:generation_uid=b6bcfcab-70ff-7331-c47c-478869de11d2
diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25
index 6e02dd9802..a2e39c8057 100644
--- a/tests/ref/fate/mxf-probe-dv25
+++ b/tests/ref/fate/mxf-probe-dv25
@@ -137,6 +137,7 @@  TAG:file_package_umid=0x060A2B340101010501010D4313000000F2E2FCE98722F14F947F08DE
 format_name=mxf
 duration=1.000000
 bit_rate=30679040
+TAG:operational_pattern=060e2b34.04010101.0d010201.01010900
 TAG:uid=a741d0c7-244a-bc4a-bd36-3323d04f8954
 TAG:generation_uid=c1d7a0ee-89d6-754d-bd52-cdf42b53de9f
 TAG:company_name=AVID