From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 8245546DA7 for ; Tue, 11 Jul 2023 16:53:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 47B1768C5A4; Tue, 11 Jul 2023 19:53:42 +0300 (EEST) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD59168BE76 for ; Tue, 11 Jul 2023 19:53:35 +0300 (EEST) Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-6b87d505e28so4848520a34.2 for ; Tue, 11 Jul 2023 09:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689094414; x=1691686414; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=lwLC0I8eWnfZLhHtSMojduicwQEPirUp/AJ17SSGCoM=; b=Lica89fZISXeT2zzvuhAzSn8D1+LFi7hNFys+RlbmrW4CPPUIyUb5RMbwWW4YklnIK aGpswIJv4U44QIfFaBai3hERFNSs+7yUuohxxbME+8pNIj/6L+vjrZV2vGOfduBTQ/Bw kMP3+/ZHEX8R4AtVmZG3J1stOkfty3NDn4R2qP97G0UwaEYvH+hZTEjd/aBM6RRUbKzO WW5zzeMcO8WUv0bpnv/eCDhux3yI3/ElXdthlryUiWo9UT6Igj+P8N5q4d/r05iow+oa MlwPTczl2VUFgxUfPLV2lgtfo0goYifEg4tlLbKc+iL5AwyVKe/I5+vyn8Lbh2PrnNun yW7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689094414; x=1691686414; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lwLC0I8eWnfZLhHtSMojduicwQEPirUp/AJ17SSGCoM=; b=XA7rgGR2M4QFwXy4pz3q+A7KTdKNRKd103uBw3JISU+4qWMWyCAs/mWfGYxWN3tb4T Ad1Unw9QqInMgroFOweMDsY23OBaSGUf4Fxc7Uu0o5P04GzQWEyae0gLsLBatJjxNyMN ErnR5kTovpVFbVtRvd51+XIPW8GRIlmPgxgfnnjplO/woUZqIUO+rx8SweukM/Yiy2Tn ueiw1xyUw7OQhDVS/6Tr1h7Hg6N/KgtO3czwTuxZj6DEiRyI2H4kmCR7vD+TFzPvddg6 u+Duf1UopRY+9D6CjP0DVVzEanDUNHfdpQWJKf8SNqgkwmsP5pK2OX0gJnxEBTeXyyFx bCLQ== X-Gm-Message-State: ABy/qLYmDijhLNGo2fdPO2reG+g2y5/4LghYu0QHFRicApaa/r61zl/t zjkEuM7NmhJraaHxGA95O9na+7etQDM= X-Google-Smtp-Source: APBJJlE5h3+HNwhk37Zq9lcTAJ7sGFIrWUdEs7ZHja9mAy3Zjb80PEojgMKIKt26QIZWvRZD/sfL4w== X-Received: by 2002:a05:6870:f60f:b0:1b7:4521:2f2 with SMTP id ek15-20020a056870f60f00b001b7452102f2mr4975566oab.32.1689094413688; Tue, 11 Jul 2023 09:53:33 -0700 (PDT) Received: from [192.168.0.16] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id o4-20020a4aabc4000000b0056351d2841asm910187oon.20.2023.07.11.09.53.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Jul 2023 09:53:33 -0700 (PDT) Message-ID: <7c8489d4-38dd-9831-09dd-174f8b1dda5d@gmail.com> Date: Tue, 11 Jul 2023 13:53:31 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20230711074126.95328-1-damiog@gmail.com> <20230711074126.95328-2-damiog@gmail.com> From: James Almer In-Reply-To: <20230711074126.95328-2-damiog@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/mov: add support for 'amve' ambient viewing environment box. As defined in ISOBMFF (ISO/IEC 14496-12) document. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 7/11/2023 4:41 AM, Damiano Galassi wrote: > --- > libavformat/dump.c | 15 +++++++++++++++ > libavformat/isom.h | 2 ++ > libavformat/mov.c | 36 ++++++++++++++++++++++++++++++++++++ > libavformat/movenc.c | 22 ++++++++++++++++++++++ > 4 files changed, 75 insertions(+) > > diff --git a/libavformat/dump.c b/libavformat/dump.c > index d31e4c2ec6..eca6e733ae 100644 > --- a/libavformat/dump.c > +++ b/libavformat/dump.c > @@ -27,6 +27,7 @@ > #include "libavutil/intreadwrite.h" > #include "libavutil/log.h" > #include "libavutil/mastering_display_metadata.h" > +#include "libavutil/ambient_viewing_environment.h" > #include "libavutil/dovi_meta.h" > #include "libavutil/mathematics.h" > #include "libavutil/opt.h" > @@ -366,6 +367,17 @@ static void dump_content_light_metadata(void *ctx, const AVPacketSideData *sd) > metadata->MaxCLL, metadata->MaxFALL); > } > > +static void dump_ambient_viewing_environment_metadata(void *ctx, const AVPacketSideData *sd) > +{ > + const AVAmbientViewingEnvironment *ambient = > + (const AVAmbientViewingEnvironment *)sd->data; > + av_log(ctx, AV_LOG_INFO, "Ambvient Viewing Environment, " > + "ambient_illuminance=%f, ambient_light_x=%f, ambient_light_y=%f", > + av_q2d(ambient->ambient_illuminance), > + av_q2d(ambient->ambient_light_x), > + av_q2d(ambient->ambient_light_y)); > +} > + > static void dump_spherical(void *ctx, const AVCodecParameters *par, > const AVPacketSideData *sd) > { > @@ -497,6 +509,9 @@ static void dump_sidedata(void *ctx, const AVStream *st, const char *indent) > av_log(ctx, AV_LOG_INFO, "SMPTE ST 12-1:2014: "); > dump_s12m_timecode(ctx, st, sd); > break; > + case AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT: > + dump_ambient_viewing_environment_metadata(ctx, sd); > + break; > default: > av_log(ctx, AV_LOG_INFO, "unknown side data type %d " > "(%"SIZE_SPECIFIER" bytes)", sd->type, sd->size); > diff --git a/libavformat/isom.h b/libavformat/isom.h > index 4b1cd42f0f..486836fd62 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -29,6 +29,7 @@ > > #include "libavutil/encryption_info.h" > #include "libavutil/mastering_display_metadata.h" > +#include "libavutil/ambient_viewing_environment.h" > #include "libavutil/spherical.h" > #include "libavutil/stereo3d.h" > > @@ -249,6 +250,7 @@ typedef struct MOVStreamContext { > AVMasteringDisplayMetadata *mastering; > AVContentLightMetadata *coll; > size_t coll_size; > + AVAmbientViewingEnvironment *ambient; add a size_t ambient_size. > > uint32_t format; > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 444aca5235..693baa01a3 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -6010,6 +6010,31 @@ static int mov_read_clli(MOVContext *c, AVIOContext *pb, MOVAtom atom) > return 0; > } > > +static int mov_read_amve(MOVContext *c, AVIOContext *pb, MOVAtom atom) > +{ > + MOVStreamContext *sc; > + const int illuminance_den = 10000; > + const int ambient_den = 50000; > + if (c->fc->nb_streams < 1) > + return AVERROR_INVALIDDATA; > + sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data; > + if (atom.size < 6) { > + av_log(c->fc, AV_LOG_ERROR, "Empty Ambient Viewing Environment Info box\n"); > + return AVERROR_INVALIDDATA; > + } > + if (sc->ambient){ > + av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate AMVE\n"); > + return 0; > + } > + sc->ambient = av_ambient_viewing_environment_alloc(NULL); sc->ambient = av_ambient_viewing_environment_alloc(&sc->ambient_size); > + if (!sc->ambient) > + return AVERROR(ENOMEM); > + sc->ambient->ambient_illuminance = av_make_q(avio_rb32(pb), illuminance_den); > + sc->ambient->ambient_light_x = av_make_q(avio_rb16(pb), ambient_den); > + sc->ambient->ambient_light_y = av_make_q(avio_rb16(pb), ambient_den); > + return 0; > +} > + > static int mov_read_st3d(MOVContext *c, AVIOContext *pb, MOVAtom atom) > { > AVStream *st; > @@ -7921,6 +7946,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { > { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ > { MKTAG('p','i','t','m'), mov_read_pitm }, > { MKTAG('e','v','c','C'), mov_read_glbl }, > +{ MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box */ > { 0, NULL } > }; > > @@ -8391,6 +8417,7 @@ static int mov_read_close(AVFormatContext *s) > av_freep(&sc->spherical); > av_freep(&sc->mastering); > av_freep(&sc->coll); > + av_freep(&sc->ambient); > } > > av_freep(&mov->dv_demux); > @@ -8756,6 +8783,15 @@ static int mov_read_header(AVFormatContext *s) > > sc->coll = NULL; > } > + if (sc->ambient) { > + err = av_stream_add_side_data(st, AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT, > + (uint8_t *)sc->ambient, > + sizeof(*sc->ambient)); sc->ambient_size. sizeof(AVAmbientViewingEnvironment) is not part of the ABI, as the doxy states. > + if (err < 0) > + return err; > + > + sc->ambient = NULL; > + } > break; > } > } > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index f1cc80b1b3..9c6109f4bd 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -2220,6 +2220,27 @@ static int mov_write_mdcv_tag(AVIOContext *pb, MOVTrack *track) > return 32; > } > > +static int mov_write_amve_tag(AVIOContext *pb, MOVTrack *track) > +{ > + const int illuminance_den = 10000; > + const int ambient_den = 50000; > + const uint8_t *side_data; > + const AVAmbientViewingEnvironment *ambient; > + > + side_data = av_stream_get_side_data(track->st, AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT, NULL); > + ambient = (const AVAmbientViewingEnvironment*)side_data; > + if (!ambient || !ambient->ambient_illuminance.num) { > + return 0; > + } > + > + avio_wb32(pb, 16); // size > + ffio_wfourcc(pb, "amve"); > + avio_wb32(pb, rescale_mdcv(ambient->ambient_illuminance, illuminance_den)); > + avio_wb16(pb, rescale_mdcv(ambient->ambient_light_x, ambient_den)); > + avio_wb16(pb, rescale_mdcv(ambient->ambient_light_y, ambient_den)); > + return 16; > +} > + > static void find_compressor(char * compressor_name, int len, MOVTrack *track) > { > AVDictionaryEntry *encoder; > @@ -2430,6 +2451,7 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex > if (track->mode == MODE_MOV || track->mode == MODE_MP4) { Is it allowed in mov? > mov_write_clli_tag(pb, track); > mov_write_mdcv_tag(pb, track); > + mov_write_amve_tag(pb, track); > } > > if (track->mode == MODE_MP4 && mov->fc->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { _______________________________________________ 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".