From: quietvoid <tcchlisop0@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: quietvoid <tcChlisop0@gmail.com> Subject: [FFmpeg-devel] [PATCH v12 3/5] avformat/mov: Refactor mov_read_dvcc_dvvc to use ff_isom_parse_dvcc_dvvc Date: Sat, 1 Jan 2022 17:51:51 +0100 Message-ID: <20220101165153.440729-4-tcChlisop0@gmail.com> (raw) In-Reply-To: <20220101165153.440729-1-tcChlisop0@gmail.com> To avoid duplicating code. The implementation in dovi_isom is identical. Signed-off-by: quietvoid <tcChlisop0@gmail.com> --- libavformat/Makefile | 2 +- libavformat/mov.c | 50 +++++++------------------------------------- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 4464c2b049..cd9810ba01 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -339,7 +339,7 @@ OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o OBJS-$(CONFIG_MODS_DEMUXER) += mods.o OBJS-$(CONFIG_MOFLEX_DEMUXER) += moflex.o OBJS-$(CONFIG_MOV_DEMUXER) += mov.o mov_chan.o mov_esds.o \ - qtpalette.o replaygain.o + qtpalette.o replaygain.o dovi_isom.o OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o \ movenchint.o mov_chan.o rtp.o \ movenccenc.o movenc_ttml.o rawutils.o diff --git a/libavformat/mov.c b/libavformat/mov.c index 351ecde770..ad5ab6b491 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -55,6 +55,7 @@ #include "avformat.h" #include "internal.h" #include "avio_internal.h" +#include "dovi_isom.h" #include "riff.h" #include "isom.h" #include "libavcodec/get_bits.h" @@ -7062,58 +7063,21 @@ static int mov_read_dmlp(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; - uint32_t buf; - AVDOVIDecoderConfigurationRecord *dovi; - size_t dovi_size; + uint8_t buf[ISOM_DVCC_DVVC_SIZE]; int ret; + int64_t read_size = atom.size; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; - if ((uint64_t)atom.size > (1<<30) || atom.size < 4) - return AVERROR_INVALIDDATA; - - dovi = av_dovi_alloc(&dovi_size); - if (!dovi) - return AVERROR(ENOMEM); - - dovi->dv_version_major = avio_r8(pb); - dovi->dv_version_minor = avio_r8(pb); - - buf = avio_rb16(pb); - dovi->dv_profile = (buf >> 9) & 0x7f; // 7 bits - dovi->dv_level = (buf >> 3) & 0x3f; // 6 bits - dovi->rpu_present_flag = (buf >> 2) & 0x01; // 1 bit - dovi->el_present_flag = (buf >> 1) & 0x01; // 1 bit - dovi->bl_present_flag = buf & 0x01; // 1 bit - if (atom.size >= 24) { // 4 + 4 + 4 * 4 - buf = avio_r8(pb); - dovi->dv_bl_signal_compatibility_id = (buf >> 4) & 0x0f; // 4 bits - } else { - // 0 stands for None - // Dolby Vision V1.2.93 profiles and levels - dovi->dv_bl_signal_compatibility_id = 0; - } + // At most 24 bytes + read_size = FFMIN(read_size, ISOM_DVCC_DVVC_SIZE); - ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, - (uint8_t *)dovi, dovi_size); - if (ret < 0) { - av_free(dovi); + if ((ret = ffio_read_size(pb, buf, read_size)) < 0) return ret; - } - av_log(c, AV_LOG_TRACE, "DOVI in dvcC/dvvC/dvwC box, version: %d.%d, profile: %d, level: %d, " - "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", - dovi->dv_version_major, dovi->dv_version_minor, - dovi->dv_profile, dovi->dv_level, - dovi->rpu_present_flag, - dovi->el_present_flag, - dovi->bl_present_flag, - dovi->dv_bl_signal_compatibility_id - ); - - return 0; + return ff_isom_parse_dvcc_dvvc(c->fc, st, buf, read_size); } static int mov_read_kind(MOVContext *c, AVIOContext *pb, MOVAtom atom) -- 2.34.1 _______________________________________________ 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".
next prev parent reply other threads:[~2022-01-01 16:52 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-01 16:51 [FFmpeg-devel] [PATCH v12 0/5] Add support for Matroska BlockAdditionMapping elements quietvoid 2022-01-01 16:51 ` [FFmpeg-devel] [PATCH v12 1/5] avformat/dovi_isom: Implement Dolby Vision configuration parsing/writing quietvoid 2022-01-01 16:51 ` [FFmpeg-devel] [PATCH v12 2/5] avformat/matroska{dec, enc}: Parse BlockAdditionMapping elements quietvoid 2022-01-01 16:51 ` quietvoid [this message] 2022-01-01 16:51 ` [FFmpeg-devel] [PATCH v12 4/5] avformat/movenc: Refactor mov_write_dvcc_dvvc_tag to use ff_isom_put_dvcc_dvvc quietvoid 2022-01-01 16:51 ` [FFmpeg-devel] [PATCH v12 5/5] fate/matroska: Add tests for reading/writing BlockAdditionMapping elements quietvoid
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220101165153.440729-4-tcChlisop0@gmail.com \ --to=tcchlisop0@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git