From patchwork Thu Oct 28 22:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: quietvoid X-Patchwork-Id: 31243 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:a610:0:0:0:0:0 with SMTP id q16csp1025626ioi; Thu, 28 Oct 2021 15:36:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa7iSjhvSLl1u39TfimhAc3L2O0bmrbXxl4T5CEWt0mhJGCQnYQn/JmWPeWXel+G0YOpoE X-Received: by 2002:a05:6402:4405:: with SMTP id y5mr9781837eda.339.1635460572727; Thu, 28 Oct 2021 15:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635460572; cv=none; d=google.com; s=arc-20160816; b=RLQ+ZK3rtA9/pHphcItw2WyOdiMq0qX2jCiTWww1UV4S5BeXNug8QifJCtOfgbvRle eWK9fcvinJOHDViBvV73NUdPoKdUVo18+rez8zasyxA0A5myloRIhTXO9xKnC30O9mXK WdJ/jWeG3RLe/BD+oz57DFspbk7cQbPOhznTpTDbh0UJFSNOuqDxD3ey8YxVJrALyTUa 1YJ9DT8nIe8GjAc2eZi40jiHoxn6KBjtv5Nq7uOnNwh1igt6iwVefG7DLztNdpENxZkq lI1Acryv386Yf/4E1+r/2tL82t70dkwA0BWuFox0daxUm+SW/W/rDWrQ4mHfr5LuDzrb Z27A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=CBItxf9qjFN8mfLiWMPu7j/74b9vdSqt70/DtEadJbA=; b=0ecq1FK3xtX7AoA/YpmtSo5cE8DRekgmfm5Zr5gL9Lwur4BjKBe8jeOKjDjNNGcDT7 jV5Bf9nJ+spDzyrSt4UL0DYidErLhteuDeo83i5vuwdaivAhZX8yToSJ3+HpJsmm2RTM ZEa1ohz3WESTLeo3f2aSWkyYRLBo9nxc+aK58u34chLs25o5uH3AvRq/Hk3WSSw5lJKt ZOJ5TjF+7VjzNAtJPeWGbo6U4AhvZAbJCup7sfbk3zNsZ3wqh5VyStIcl+3DWtj3NAnW XQvqaZXgywujSoeMKcLfyOfBCuorPpPV2gYKjRIBtg26fNtbQY0i7zAgd933dml0npNy 11FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=mvNKwlOI; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b18si5706917ejh.638.2021.10.28.15.36.12; Thu, 28 Oct 2021 15:36:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=mvNKwlOI; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F01D768AABE; Fri, 29 Oct 2021 01:35:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 89D2A68AA8E for ; Fri, 29 Oct 2021 01:35:24 +0300 (EEST) Received: by mail-wr1-f51.google.com with SMTP id m22so12886917wrb.0 for ; Thu, 28 Oct 2021 15:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fve8RuuOLzvEThHckGT2smw7fkMpjO+NM+jqLCAkqIo=; b=mvNKwlOIxAIKEEkc70u9R31Em0+BCst+rH0bAfAVziAjsH72/XK7eeiWysFFhmXFMA MsYb+iJD2CBJ8qHBDE7xeNEW5NJw7dlwf/8CNCuwuiLrWMbAfXk+AcFbwlX71TUCYdgW Yon5XAHBttaB7MZk5a8xxpUnyRebsLsqyGQ2giRQBGuBqEtOaMjDpWBuRPfUoBruFibF Ey6tzII7eYMPcVy5zTq9VVbR6+RQDfFYp+Pq5+Ve2fYsSS9UY7IYi/rntDW6qx9LbsJF XZDhULghkTM0ygQHKN6FvtsgADJMSxFJLIGI16BLsmA2842oVXkoV70zzND1EAcjO0SY svOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fve8RuuOLzvEThHckGT2smw7fkMpjO+NM+jqLCAkqIo=; b=iRhVa++ZwxVI6u2ZAgtEZzcpeTQR+3tXWZDgnZUh4iDHlVr9HmYyEz0CRQS7n3qYF7 s8IxUCMRHHqVjQYLH4zNUVSlm8mkpvBrq18P5K8s645Sn9OvqgCg08HzBVH5Q+VwDIfd euWbH5GxcHL96O1i0gLnGJEIwSd4Q8Drw1OFo+kW4LxJAvpvNF7Io0r+MA0TS3qwJtWJ ArrI1VtGEavHZuIyxdS9psi8PoIqhTW4NSrShl7Uv5MEg4LaEIB725xDMIkRLOR6NHLM HX5t9ryMTjyvVqfYyzWd++EsoWkaMBCt1lqVcC4fekI3k0fHoI35w/MvA9YDmK3wLHOW +mHw== X-Gm-Message-State: AOAM532VIpdYKoyQpYr1HgwkwOsyuSYX3N5e2UhXg9iAVnvR4qpvgRSz KGFlYxrHDqkFfBkssTHha+HVhwFzxZ5Fwg== X-Received: by 2002:a5d:5747:: with SMTP id q7mr9245861wrw.103.1635460523759; Thu, 28 Oct 2021 15:35:23 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:162:73cc::2]) by smtp.gmail.com with ESMTPSA id x7sm6798265wmi.43.2021.10.28.15.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 15:35:23 -0700 (PDT) From: quietvoid X-Google-Original-From: quietvoid To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Oct 2021 00:33:42 +0200 Message-Id: <20211028223342.1169258-5-tcChlisop0@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028223342.1169258-1-tcChlisop0@gmail.com> References: <20211028223342.1169258-1-tcChlisop0@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v7 4/4] avformat/movenc: Refactor mov_write_dvcc_dvvc_tag to use ff_isom_put_dvcc_dvvc 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 Cc: quietvoid Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: f+v+f/2upbqs Improves code legibility by not using bit shifts. Also avoids duplicating the dvcC/dvvC ISOM box writing code. Signed-off-by: quietvoid --- libavformat/movenc.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 37d4403f7a..cd9c4a0b5e 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -27,6 +27,7 @@ #include "movenc.h" #include "avformat.h" #include "avio_internal.h" +#include "dovi_isom.h" #include "riff.h" #include "avio.h" #include "isom.h" @@ -1911,6 +1912,9 @@ static int mov_write_sv3d_tag(AVFormatContext *s, AVIOContext *pb, AVSphericalMa static int mov_write_dvcc_dvvc_tag(AVFormatContext *s, AVIOContext *pb, AVDOVIDecoderConfigurationRecord *dovi) { + uint8_t buf[ISOM_DVCC_DVVC_SIZE]; + int size; + avio_wb32(pb, 32); /* size = 8 + 24 */ if (dovi->dv_profile > 10) ffio_wfourcc(pb, "dvwC"); @@ -1918,23 +1922,11 @@ static int mov_write_dvcc_dvvc_tag(AVFormatContext *s, AVIOContext *pb, AVDOVIDe ffio_wfourcc(pb, "dvvC"); else ffio_wfourcc(pb, "dvcC"); - avio_w8(pb, dovi->dv_version_major); - avio_w8(pb, dovi->dv_version_minor); - avio_wb16(pb, (dovi->dv_profile << 9) | (dovi->dv_level << 3) | - (dovi->rpu_present_flag << 2) | (dovi->el_present_flag << 1) | - dovi->bl_present_flag); - avio_wb32(pb, (dovi->dv_bl_signal_compatibility_id << 28) | 0); - - ffio_fill(pb, 0, 4 * 4); /* reserved */ - av_log(s, AV_LOG_DEBUG, "DOVI in %s box, version: %d.%d, profile: %d, level: %d, " - "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", - dovi->dv_profile > 10 ? "dvwC" : (dovi->dv_profile > 7 ? "dvvC" : "dvcC"), - 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); + + size = ff_isom_put_dvcc_dvvc(s, buf, sizeof(buf), dovi); + + avio_write(pb, buf, size); + return 32; /* 8 + 24 */ }