Message ID | 20201118182415.1160436-1-tfoucu@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel] libavformat/mov.c: export vendor id as metadata | expand |
Context | Check | Description |
---|---|---|
andriy/PPC64_make | success | Make finished |
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make_fate | success | Make fate finished |
Thierry Foucu: > --- > libavformat/mov.c | 24 +++++++++++++++++-- > ...hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 + > .../fate/hapqa-extract-nosnappy-to-hapq-mov | 1 + > tests/ref/fate/mov-zombie | 2 +- > tests/ref/fate/rgb24-mkv | 4 ++-- > 5 files changed, 27 insertions(+), 5 deletions(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 2b90e31170..1f9163d658 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -2095,6 +2095,8 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, > uint8_t codec_name[32] = { 0 }; > int64_t stsd_start; > unsigned int len; > + int32_t id = 0; > + char vendor_id[5]; > > /* The first 16 bytes of the video sample description are already > * read in ff_mov_read_stsd_entries() */ > @@ -2102,7 +2104,15 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, > > avio_rb16(pb); /* version */ > avio_rb16(pb); /* revision level */ > - avio_rb32(pb); /* vendor */ > + id = avio_rb32(pb); /* vendor */ > + if (id != 0) { > + vendor_id[0] = (id >> 24) & 0xff; > + vendor_id[1] = (id >> 16) & 0xff; > + vendor_id[2] = (id >> 8) & 0xff; > + vendor_id[3] = (id >> 0) & 0xff; > + vendor_id[4] = 0; > + av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); > + } > avio_rb32(pb); /* temporal quality */ > avio_rb32(pb); /* spatial quality */ > > @@ -2150,10 +2160,20 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, > { > int bits_per_sample, flags; > uint16_t version = avio_rb16(pb); > + int32_t id = 0; > + char vendor_id[5]; > AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE); > > avio_rb16(pb); /* revision level */ > - avio_rb32(pb); /* vendor */ > + id = avio_rb32(pb); /* vendor */ > + if (id != 0) { > + vendor_id[0] = (id >> 24) & 0xff; > + vendor_id[1] = (id >> 16) & 0xff; > + vendor_id[2] = (id >> 8) & 0xff; > + vendor_id[3] = (id >> 0) & 0xff; AV_WB32(). Alternatively, one could use av_fourcc2str() if you like its handling of characters outside the [A-Za-z0-9._ -] set (but for this you would need to read the number via avio_rl32()). - Andreas
On Wed, Nov 18, 2020 at 10:56 AM Andreas Rheinhardt < andreas.rheinhardt@gmail.com> wrote: > Thierry Foucu: > > --- > > libavformat/mov.c | 24 +++++++++++++++++-- > > ...hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 + > > .../fate/hapqa-extract-nosnappy-to-hapq-mov | 1 + > > tests/ref/fate/mov-zombie | 2 +- > > tests/ref/fate/rgb24-mkv | 4 ++-- > > 5 files changed, 27 insertions(+), 5 deletions(-) > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index 2b90e31170..1f9163d658 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -2095,6 +2095,8 @@ static void mov_parse_stsd_video(MOVContext *c, > AVIOContext *pb, > > uint8_t codec_name[32] = { 0 }; > > int64_t stsd_start; > > unsigned int len; > > + int32_t id = 0; > > + char vendor_id[5]; > > > > /* The first 16 bytes of the video sample description are already > > * read in ff_mov_read_stsd_entries() */ > > @@ -2102,7 +2104,15 @@ static void mov_parse_stsd_video(MOVContext *c, > AVIOContext *pb, > > > > avio_rb16(pb); /* version */ > > avio_rb16(pb); /* revision level */ > > - avio_rb32(pb); /* vendor */ > > + id = avio_rb32(pb); /* vendor */ > > + if (id != 0) { > > + vendor_id[0] = (id >> 24) & 0xff; > > + vendor_id[1] = (id >> 16) & 0xff; > > + vendor_id[2] = (id >> 8) & 0xff; > > + vendor_id[3] = (id >> 0) & 0xff; > > + vendor_id[4] = 0; > > + av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); > > + } > > avio_rb32(pb); /* temporal quality */ > > avio_rb32(pb); /* spatial quality */ > > > > @@ -2150,10 +2160,20 @@ static void mov_parse_stsd_audio(MOVContext *c, > AVIOContext *pb, > > { > > int bits_per_sample, flags; > > uint16_t version = avio_rb16(pb); > > + int32_t id = 0; > > + char vendor_id[5]; > > AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, > "compatible_brands", NULL, AV_DICT_MATCH_CASE); > > > > avio_rb16(pb); /* revision level */ > > - avio_rb32(pb); /* vendor */ > > + id = avio_rb32(pb); /* vendor */ > > + if (id != 0) { > > + vendor_id[0] = (id >> 24) & 0xff; > > + vendor_id[1] = (id >> 16) & 0xff; > > + vendor_id[2] = (id >> 8) & 0xff; > > + vendor_id[3] = (id >> 0) & 0xff; > > AV_WB32(). Alternatively, one could use av_fourcc2str() if you like its > handling of characters outside the [A-Za-z0-9._ -] set (but for this you > would need to read the number via avio_rl32()). > > Good to know about this API. Will send new patch > - Andreas > _______________________________________________ > 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".
diff --git a/libavformat/mov.c b/libavformat/mov.c index 2b90e31170..1f9163d658 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2095,6 +2095,8 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, uint8_t codec_name[32] = { 0 }; int64_t stsd_start; unsigned int len; + int32_t id = 0; + char vendor_id[5]; /* The first 16 bytes of the video sample description are already * read in ff_mov_read_stsd_entries() */ @@ -2102,7 +2104,15 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, avio_rb16(pb); /* version */ avio_rb16(pb); /* revision level */ - avio_rb32(pb); /* vendor */ + id = avio_rb32(pb); /* vendor */ + if (id != 0) { + vendor_id[0] = (id >> 24) & 0xff; + vendor_id[1] = (id >> 16) & 0xff; + vendor_id[2] = (id >> 8) & 0xff; + vendor_id[3] = (id >> 0) & 0xff; + vendor_id[4] = 0; + av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); + } avio_rb32(pb); /* temporal quality */ avio_rb32(pb); /* spatial quality */ @@ -2150,10 +2160,20 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, { int bits_per_sample, flags; uint16_t version = avio_rb16(pb); + int32_t id = 0; + char vendor_id[5]; AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE); avio_rb16(pb); /* revision level */ - avio_rb32(pb); /* vendor */ + id = avio_rb32(pb); /* vendor */ + if (id != 0) { + vendor_id[0] = (id >> 24) & 0xff; + vendor_id[1] = (id >> 16) & 0xff; + vendor_id[2] = (id >> 8) & 0xff; + vendor_id[3] = (id >> 0) & 0xff; + vendor_id[4] = 0; + av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); + } st->codecpar->channels = avio_rb16(pb); /* channel count */ st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* sample size */ diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov index 61af08aa23..04a965b12a 100644 --- a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov +++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov @@ -69,5 +69,6 @@ DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 TAG:language=eng TAG:handler_name=Module de gestion video +TAG:vendor_id=FFMP TAG:encoder=HAPAlpha Only [/STREAM] diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov index 1fb31ec7f0..d9e5c94ffb 100644 --- a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov +++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov @@ -69,5 +69,6 @@ DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 TAG:language=eng TAG:handler_name=Module de gestion video +TAG:vendor_id=FFMP TAG:encoder=HAPQ [/STREAM] diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie index 1a6625bc8f..c566b14d47 100644 --- a/tests/ref/fate/mov-zombie +++ b/tests/ref/fate/mov-zombie @@ -194,5 +194,5 @@ frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=188623|pkt_pts_time=2. packet|codec_type=video|stream_index=0|pts=197632|pts_time=2.195911|dts=191625|dts_time=2.129167|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=580|pos=101820|flags=__ frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=191626|pkt_pts_time=2.129178|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=191626|best_effort_timestamp_time=2.129178|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=99180|pkt_size=1666|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=63|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message -stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_time_base=212521/12744000|codec_tag_string=avc1|codec_tag=0x31637661|width=160|height=240|coded_width=160|coded_height=240|closed_captions=0|has_b_frames=1|sample_aspect_ratio=2:1|display_aspect_ratio=4:3|pix_fmt=yuv420p|level=12|color_range=tv|color_space=smpte170m|color_transfer=bt709|color_primaries=smpte170m|chroma_location=topleft|field_order=unknown|timecode=N/A|refs=2|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=30000/1001|avg_frame_rate=6372000/212521|time_base=1/90000|start_pts=0|start_time=0.000000|duration_ts=2125200|duration=23.613333|bit_rate=333874|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=708|nb_read_frames=65|nb_read_packets=66|disposition:default=1|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:rotate=0|tag:creation_time=2008-05-12T20:59:27.000000Z|tag:language=eng|tag:handler_name=Apple Video Media Handler|tag:encoder=H.264 +stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_time_base=212521/12744000|codec_tag_string=avc1|codec_tag=0x31637661|width=160|height=240|coded_width=160|coded_height=240|closed_captions=0|has_b_frames=1|sample_aspect_ratio=2:1|display_aspect_ratio=4:3|pix_fmt=yuv420p|level=12|color_range=tv|color_space=smpte170m|color_transfer=bt709|color_primaries=smpte170m|chroma_location=topleft|field_order=unknown|timecode=N/A|refs=2|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=30000/1001|avg_frame_rate=6372000/212521|time_base=1/90000|start_pts=0|start_time=0.000000|duration_ts=2125200|duration=23.613333|bit_rate=333874|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=708|nb_read_frames=65|nb_read_packets=66|disposition:default=1|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:rotate=0|tag:creation_time=2008-05-12T20:59:27.000000Z|tag:language=eng|tag:handler_name=Apple Video Media Handler|tag:vendor_id=appl|tag:encoder=H.264 side_data|side_data_type=Display Matrix|displaymatrix=\n00000000: 131072 0 0\n00000001: 0 65536 0\n00000002: 0 0 1073741824\n|rotation=0 diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv index 3b14cd0ef0..1ef70349b7 100644 --- a/tests/ref/fate/rgb24-mkv +++ b/tests/ref/fate/rgb24-mkv @@ -1,5 +1,5 @@ -fde8903c4df0ba8235dafcfd8a2f368c *tests/data/fate/rgb24-mkv.matroska -58216 tests/data/fate/rgb24-mkv.matroska +6244b8750d4155d3c9357bab26396ef9 *tests/data/fate/rgb24-mkv.matroska +58245 tests/data/fate/rgb24-mkv.matroska #tb 0: 1/10 #media_type 0: video #codec_id 0: rawvideo