avformat/mov: Add support for reading and exporting horizontal field of view

These boxes are created by the Apple Vision Pro and the iPhone 15+ when
capture for the Vision Pro is enabled.

Based off of the swift API:
  * https://developer.apple.com/documentation/coremedia/kcmformatdescriptionextension_horizontalfieldofview

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis 2024-05-30 20:34:24 +01:00
parent 5c17376321
commit 8e7ca22b36
1 changed files with 29 additions and 0 deletions

View File

@ -6759,6 +6759,34 @@ static int mov_read_vexu(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
static int mov_read_hfov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams - 1];
sc = st->priv_data;
if (atom.size != 4) {
av_log(c->fc, AV_LOG_ERROR, "Invalid size of hfov box: %"PRIu64"\n", atom.size);
return AVERROR_INVALIDDATA;
}
if (!sc->stereo3d) {
sc->stereo3d = av_stereo3d_alloc();
if (!sc->stereo3d)
return AVERROR(ENOMEM);
}
sc->stereo3d->horizontal_field_of_view = avio_rb32(pb);
return 0;
}
static int mov_parse_uuid_spherical(MOVStreamContext *sc, AVIOContext *pb, size_t len)
{
int ret = 0;
@ -8878,6 +8906,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('s','t','3','d'), mov_read_st3d }, /* stereoscopic 3D video box */
{ MKTAG('s','v','3','d'), mov_read_sv3d }, /* spherical video box */
{ MKTAG('v','e','x','u'), mov_read_vexu }, /* video extension usage */
{ MKTAG('h','f','o','v'), mov_read_hfov },
{ MKTAG('d','O','p','s'), mov_read_dops },
{ MKTAG('d','m','l','p'), mov_read_dmlp },
{ MKTAG('S','m','D','m'), mov_read_smdm },