[FFmpeg-devel] [PATCH] libavformat/mov.c: export vendor id as metadata
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Wed Nov 18 20:50:56 EET 2020
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
More information about the ffmpeg-devel
mailing list