diff mbox series

[FFmpeg-devel,v7,1/3] avformat/mxfdec: set toolkit version metadata

Message ID 1612270039-6379-1-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 3f8db7eea0bc22148f0e27906d85975708b842ea
Headers show
Series [FFmpeg-devel,v7,1/3] avformat/mxfdec: set toolkit version metadata | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Limin Wang Feb. 2, 2021, 12:47 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Please check the string of toolkit version with below command:
./ffmpeg -i ../fate-suite/mxf/Sony-00001.mxf -c:v copy -c:a copy out.mxf
./ffmpeg -i out.mxf
....
toolkit_version : 58.65.101.0.0

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/mxfdec.c                | 24 ++++++++++++++++++++++++
 tests/ref/fate/mxf-probe-applehdr10 |  1 +
 tests/ref/fate/mxf-probe-dnxhd      |  1 +
 3 files changed, 26 insertions(+)

Comments

Tomas Härdin Feb. 4, 2021, 6:34 p.m. UTC | #1
tis 2021-02-02 klockan 20:47 +0800 skrev lance.lmwang@gmail.com:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Please check the string of toolkit version with below command:
> ./ffmpeg -i ../fate-suite/mxf/Sony-00001.mxf -c:v copy -c:a copy out.mxf
> ./ffmpeg -i out.mxf
> ....
> toolkit_version : 58.65.101.0.0
> 
> Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavformat/mxfdec.c                | 24 ++++++++++++++++++++++++
>  tests/ref/fate/mxf-probe-applehdr10 |  1 +
>  tests/ref/fate/mxf-probe-dnxhd      |  1 +
>  3 files changed, 26 insertions(+)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 93fa7a9..18db056 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -1978,6 +1978,15 @@ static int mxf_umid_to_str(UID ul, UID uid, char **str)
>      return 0;
>  }
>  
> +static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t tertiary,
> +                              uint16_t patch, uint16_t release, char **str)
> +{
> +    *str = av_asprintf("%d.%d.%d.%d.%d", major, minor, tertiary, patch, release);
> +    if (!*str)
> +        return AVERROR(ENOMEM);
> +    return 0;
> +}
> +
>  static int mxf_add_umid_metadata(AVDictionary **pm, const char *key, MXFPackage* package)
>  {
>      char *str;
> @@ -2739,6 +2748,17 @@ static int64_t mxf_timestamp_to_int64(uint64_t timestamp)
>      av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
>  } while (0)
>  
> +#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str) do { \
> +    major = avio_rb16(pb); \
> +    minor = avio_rb16(pb); \
> +    tertiary = avio_rb16(pb); \
> +    patch = avio_rb16(pb); \
> +    release = avio_rb16(pb); \
> +    if ((ret = mxf_version_to_str(major, minor, tertiary, patch, release, &str)) < 0) \
> +        return ret; \
> +    av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
> +} while (0)

Looks OK

/Tomas
diff mbox series

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 93fa7a9..18db056 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1978,6 +1978,15 @@  static int mxf_umid_to_str(UID ul, UID uid, char **str)
     return 0;
 }
 
+static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t tertiary,
+                              uint16_t patch, uint16_t release, char **str)
+{
+    *str = av_asprintf("%d.%d.%d.%d.%d", major, minor, tertiary, patch, release);
+    if (!*str)
+        return AVERROR(ENOMEM);
+    return 0;
+}
+
 static int mxf_add_umid_metadata(AVDictionary **pm, const char *key, MXFPackage* package)
 {
     char *str;
@@ -2739,6 +2748,17 @@  static int64_t mxf_timestamp_to_int64(uint64_t timestamp)
     av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
 } while (0)
 
+#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str) do { \
+    major = avio_rb16(pb); \
+    minor = avio_rb16(pb); \
+    tertiary = avio_rb16(pb); \
+    patch = avio_rb16(pb); \
+    release = avio_rb16(pb); \
+    if ((ret = mxf_version_to_str(major, minor, tertiary, patch, release, &str)) < 0) \
+        return ret; \
+    av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
+} while (0)
+
 #define SET_UID_METADATA(pb, name, var, str) do { \
     avio_read(pb, var, 16); \
     if ((ret = mxf_uid_to_str(var, &str)) < 0) \
@@ -2760,6 +2780,7 @@  static int mxf_read_identification_metadata(void *arg, AVIOContext *pb, int tag,
     UID uid = { 0 };
     char *str = NULL;
     uint64_t ts;
+    uint16_t major, minor, tertiary, patch, release;
     switch (tag) {
     case 0x3C01:
         SET_STR_METADATA(pb, "company_name", str);
@@ -2776,6 +2797,9 @@  static int mxf_read_identification_metadata(void *arg, AVIOContext *pb, int tag,
     case 0x3C06:
         SET_TS_METADATA(pb, "modification_date", ts, str);
         break;
+    case 0x3C07:
+        SET_VERSION_METADATA(pb, "toolkit_version", major, minor, tertiary, patch, release, str);
+        break;
     case 0x3C08:
         SET_STR_METADATA(pb, "application_platform", str);
         break;
diff --git a/tests/ref/fate/mxf-probe-applehdr10 b/tests/ref/fate/mxf-probe-applehdr10
index 53a767c..0bf9bf1 100644
--- a/tests/ref/fate/mxf-probe-applehdr10
+++ b/tests/ref/fate/mxf-probe-applehdr10
@@ -164,6 +164,7 @@  TAG:product_name=Compressor
 TAG:product_version=4.4.7 (4.4.7)
 TAG:product_uid=00000000-0000-0000-0000-000000000000
 TAG:modification_date=2020-09-08T16:18:57.036000Z
+TAG:toolkit_version=3.8.0.171.1
 TAG:material_package_umid=0x060A2B340101010501010D201300000045843C9FE69D4B8FA90DDAAA1602A2E8
 TAG:timecode=00:01:15;26
 [/FORMAT]
diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd
index 5a6221b..74d1831 100644
--- a/tests/ref/fate/mxf-probe-dnxhd
+++ b/tests/ref/fate/mxf-probe-dnxhd
@@ -173,6 +173,7 @@  TAG:project_name=UHD
 TAG:uid=784c8132-ae36-ed4d-b0ff-2edf1f3f2d92
 TAG:generation_uid=b6bcfcab-70ff-7331-c47c-478869de11d2
 TAG:application_platform=AAFSDK (MacOS X)
+TAG:toolkit_version=1.1.0.0.0
 TAG:modification_date=2016-09-18T19:25:25.000000Z
 TAG:product_uid=acfbf03a-4f42-a231-d0b7-c06ecd3d4ad7
 TAG:product_version=Unknown version