diff mbox

[FFmpeg-devel,1/4] lavf/mov: add AVCodecTag entry for GoPro metadata

Message ID 20180827195709.25396-1-jstebbins@jetheaddev.com
State Accepted
Commit c9a992d931440f87882771532b7178477c5b0ebe
Headers show

Commit Message

John Stebbins Aug. 27, 2018, 7:57 p.m. UTC
This allows for validation of the track type
---
 libavformat/isom.c | 5 +++++
 libavformat/isom.h | 1 +
 libavformat/mov.c  | 3 +++
 3 files changed, 9 insertions(+)

Comments

Michael Niedermayer Aug. 30, 2018, 10:59 p.m. UTC | #1
On Mon, Aug 27, 2018 at 12:57:07PM -0700, John Stebbins wrote:
> This allows for validation of the track type
> ---
>  libavformat/isom.c | 5 +++++
>  libavformat/isom.h | 1 +
>  libavformat/mov.c  | 3 +++
>  3 files changed, 9 insertions(+)
> 
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index ce66d1bcd4..ca9d22e4f7 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -374,6 +374,11 @@ const AVCodecTag ff_codec_movsubtitle_tags[] = {
>      { AV_CODEC_ID_NONE, 0 },
>  };
>  
> +const AVCodecTag ff_codec_movdata_tags[] = {
> +    { AV_CODEC_ID_BIN_DATA, MKTAG('g', 'p', 'm', 'd') },
> +    { AV_CODEC_ID_NONE, 0 },
> +};
> +
>  /* map numeric codes from mdhd atom to ISO 639 */
>  /* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
>  /* http://developer.apple.com/documentation/mac/Text/Text-368.html */
> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index 51abea52de..f3a7a8633d 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -41,6 +41,7 @@ extern const AVCodecTag ff_mp4_obj_type[];
>  extern const AVCodecTag ff_codec_movvideo_tags[];
>  extern const AVCodecTag ff_codec_movaudio_tags[];
>  extern const AVCodecTag ff_codec_movsubtitle_tags[];
> +extern const AVCodecTag ff_codec_movdata_tags[];
>  
>  int ff_mov_iso639_to_lang(const char lang[4], int mp4);
>  int ff_mov_lang_to_iso639(unsigned code, char to[4]);
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index d66f4e338c..8915e3b9e0 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2034,6 +2034,8 @@ static int mov_codec_id(AVStream *st, uint32_t format)
>              id = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
>              if (id > 0)
>                  st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
> +            else
> +                id = ff_codec_get_id(ff_codec_movdata_tags, format);

I think this should also set codec_type like the other cases


>          }
>      }
>  
> @@ -2507,6 +2509,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
>              mov_parse_stsd_subtitle(c, pb, st, sc,
>                                      size - (avio_tell(pb) - start_pos));
>          } else {
> +            st->codecpar->codec_id = id;

if this is done for all cases it should be factored out 
(maybe in a seperate patch)

thx

[...]
John Stebbins Aug. 31, 2018, 3:25 p.m. UTC | #2
On 08/30/2018 03:59 PM, Michael Niedermayer wrote:
> On Mon, Aug 27, 2018 at 12:57:07PM -0700, John Stebbins wrote:
>> This allows for validation of the track type
>> ---
>>  libavformat/isom.c | 5 +++++
>>  libavformat/isom.h | 1 +
>>  libavformat/mov.c  | 3 +++
>>  3 files changed, 9 insertions(+)
>>
>> diff --git a/libavformat/isom.c b/libavformat/isom.c
>> index ce66d1bcd4..ca9d22e4f7 100644
>> --- a/libavformat/isom.c
>> +++ b/libavformat/isom.c
>> @@ -374,6 +374,11 @@ const AVCodecTag ff_codec_movsubtitle_tags[] = {
>>      { AV_CODEC_ID_NONE, 0 },
>>  };
>>  
>> +const AVCodecTag ff_codec_movdata_tags[] = {
>> +    { AV_CODEC_ID_BIN_DATA, MKTAG('g', 'p', 'm', 'd') },
>> +    { AV_CODEC_ID_NONE, 0 },
>> +};
>> +
>>  /* map numeric codes from mdhd atom to ISO 639 */
>>  /* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
>>  /* http://developer.apple.com/documentation/mac/Text/Text-368.html */
>> diff --git a/libavformat/isom.h b/libavformat/isom.h
>> index 51abea52de..f3a7a8633d 100644
>> --- a/libavformat/isom.h
>> +++ b/libavformat/isom.h
>> @@ -41,6 +41,7 @@ extern const AVCodecTag ff_mp4_obj_type[];
>>  extern const AVCodecTag ff_codec_movvideo_tags[];
>>  extern const AVCodecTag ff_codec_movaudio_tags[];
>>  extern const AVCodecTag ff_codec_movsubtitle_tags[];
>> +extern const AVCodecTag ff_codec_movdata_tags[];
>>  
>>  int ff_mov_iso639_to_lang(const char lang[4], int mp4);
>>  int ff_mov_lang_to_iso639(unsigned code, char to[4]);
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index d66f4e338c..8915e3b9e0 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -2034,6 +2034,8 @@ static int mov_codec_id(AVStream *st, uint32_t format)
>>              id = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
>>              if (id > 0)
>>                  st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
>> +            else
>> +                id = ff_codec_get_id(ff_codec_movdata_tags, format);
> I think this should also set codec_type like the other cases
>
>
>>          }
>>      }
>>  
>> @@ -2507,6 +2509,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
>>              mov_parse_stsd_subtitle(c, pb, st, sc,
>>                                      size - (avio_tell(pb) - start_pos));
>>          } else {
>> +            st->codecpar->codec_id = id;
> if this is done for all cases it should be factored out 
> (maybe in a seperate patch)
>
> thx
>

Sure
diff mbox

Patch

diff --git a/libavformat/isom.c b/libavformat/isom.c
index ce66d1bcd4..ca9d22e4f7 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -374,6 +374,11 @@  const AVCodecTag ff_codec_movsubtitle_tags[] = {
     { AV_CODEC_ID_NONE, 0 },
 };
 
+const AVCodecTag ff_codec_movdata_tags[] = {
+    { AV_CODEC_ID_BIN_DATA, MKTAG('g', 'p', 'm', 'd') },
+    { AV_CODEC_ID_NONE, 0 },
+};
+
 /* map numeric codes from mdhd atom to ISO 639 */
 /* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
 /* http://developer.apple.com/documentation/mac/Text/Text-368.html */
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 51abea52de..f3a7a8633d 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -41,6 +41,7 @@  extern const AVCodecTag ff_mp4_obj_type[];
 extern const AVCodecTag ff_codec_movvideo_tags[];
 extern const AVCodecTag ff_codec_movaudio_tags[];
 extern const AVCodecTag ff_codec_movsubtitle_tags[];
+extern const AVCodecTag ff_codec_movdata_tags[];
 
 int ff_mov_iso639_to_lang(const char lang[4], int mp4);
 int ff_mov_lang_to_iso639(unsigned code, char to[4]);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d66f4e338c..8915e3b9e0 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2034,6 +2034,8 @@  static int mov_codec_id(AVStream *st, uint32_t format)
             id = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
             if (id > 0)
                 st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+            else
+                id = ff_codec_get_id(ff_codec_movdata_tags, format);
         }
     }
 
@@ -2507,6 +2509,7 @@  int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
             mov_parse_stsd_subtitle(c, pb, st, sc,
                                     size - (avio_tell(pb) - start_pos));
         } else {
+            st->codecpar->codec_id = id;
             ret = mov_parse_stsd_data(c, pb, st, sc,
                                       size - (avio_tell(pb) - start_pos));
             if (ret < 0)