From patchwork Sun Dec 5 17:35:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: quietvoid X-Patchwork-Id: 32009 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp3509825iog; Sun, 5 Dec 2021 09:36:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCubivP2L+a4XqnrOO2+DFui1ZpYtoCl/zGrZzLzi9hPsk2Bxz0R8HsaRnTydXnwcCFBZP X-Received: by 2002:a17:907:2d10:: with SMTP id gs16mr38066090ejc.353.1638725809571; Sun, 05 Dec 2021 09:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638725809; cv=none; d=google.com; s=arc-20160816; b=MaM0piiim+71NBMbEayM5nf03cFSaihOgRLSXG+zbVMWEZ547WuUEnX5MCvDEXCo/k ngDRmDaVCO5HlyEbewadem7ZDvjrLYl6a38mtL0zYI2QWHBs76x8TD23hNl7+WrMa722 UQaySW1bbt3oNPGl9bxe4gvS1+8OCYDgvWfpJQ7lQhQcXYFJYZ4xpsGaykPT83MJ+Og2 e5Nn4Wxs6CisfLU4Qd3DLz2vsK/01lEgzXqhof190/0UF/rbEIMdT/cMQuWfSHMfmixr Y4d5kxmYAUgNWyejM1PQjjJoAr5UVb7w5b/mIgO6jtrdHC5AGv+stkt6hFRnKkAbYD/p QcIw== 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=UA/PezBEoV51rrZzvV1i9MHjzCbGph0rifvijqMEHuE=; b=UTblGbH1wk0sx27qMRRwrylNj5EFYOgOBrkmJgx8iNLfI1ABb61Vlj11iEq8Xe8BJ2 YH0+DPf/yrBOA+W3W+E6mCGVKZE0jkTlHybsSbrz9njU+ulw5shlPqpHL8LvFRD50YB2 WMi4k46MUjBhkex6e6kL2mhcEwCAjvX5/mO1O7lKS4YYDcOwIN6jQjV6wcZSq8Ff0AOT fBORBi0XiyGAKG4HK1fqmZZoaRkix4sh/+fcP1Y2I0CNHAACTuNKXwk7I6Ofkg8ZvK1p NNRvUr/ghNQJPLfViSmIadss8CF6RGRFH09H073bO0RDnuOSsk4b0pYP9wh3OR/PDSgX MR5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=U4o0T0se; 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 d10si14857900ejm.131.2021.12.05.09.36.49; Sun, 05 Dec 2021 09:36:49 -0800 (PST) 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=U4o0T0se; 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 464E568AF3B; Sun, 5 Dec 2021 19:36:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 23A6568AC6D for ; Sun, 5 Dec 2021 19:35:57 +0200 (EET) Received: by mail-ed1-f48.google.com with SMTP id t5so33547184edd.0 for ; Sun, 05 Dec 2021 09:35:57 -0800 (PST) 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=uP5+oHZBRuNM3+G5B3qfzoCH2FhTnSL7rn4ZlhC+5jI=; b=U4o0T0seBAliVmHnjiAzN9l6h+OHSuxg0zdyJUkfblv4kiVLvr/vVITJaUgbFglXUH uLeemTB+RGty+t8w6ye4KiHXPQC2pZihPei6aL1BPbGGF2e1oSqZrLTt10h20ykIghiS jS5Yl0VE2RLx18JvLrYTY/PPmU1TS3JSgEGdv/npjEU2pNTUthKwnUlCLnqhn/p7D/LK vqc7Bl4+9ZLV+mhQX4SDPbO4dmQulp0Jhnfc32jMrJP7tHM9CimIr7fCThm8ceT+w0pb ChAGi0YWlU4+wu9q6OuCtlG6BwZgwMUZ/IfLzVnji5X9daOH/5JOwTKV1WXXs1olLyZ0 koeQ== 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=uP5+oHZBRuNM3+G5B3qfzoCH2FhTnSL7rn4ZlhC+5jI=; b=8J4gYe4NXkiXIRqiuqM1uKWik8XjctNfTlxQY8tW+Cg3l8QyW1JIwC4i1hfwDVBXTj my2qTND7FT0PQ1t5XjGpyHH+dQWO/mBQ0hz/BlPjBuHiQXN1gaTSzA68q94HSYyuz8wm w376nLaG34cYMSOnfYsifxua3Miwgkprj/6laTbpyQ3B2E5OEu6s+zRfJNK8jbtzE3Qy JN8c+yGGXYBMtYhiAOSKMdSSdLRxChbAxEl1E7v9sHHi6SCqV3Wj2eW0I/WbUt0wy7Ui S/UQqBVxI9s2zO6F9b5o9SRvBPYznV/ZNk8MXPBb1YFg9uMmLALEEL8DsfQ4KQnSmM3X QU9A== X-Gm-Message-State: AOAM533J7HFsTzu6UtiPoGwxxKIynARwATmRlR7IDc2muEzxXN9J5zYA Gg+Uo50+t4OE+fmZQSjB8qX3/UvXPcD9Tw== X-Received: by 2002:a17:907:9487:: with SMTP id dm7mr40676885ejc.95.1638725756378; Sun, 05 Dec 2021 09:35:56 -0800 (PST) Received: from localhost.localdomain ([2a01:4f8:162:73cc::2]) by smtp.gmail.com with ESMTPSA id h7sm6312352edb.89.2021.12.05.09.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 09:35:56 -0800 (PST) From: quietvoid X-Google-Original-From: quietvoid To: ffmpeg-devel@ffmpeg.org Date: Sun, 5 Dec 2021 18:35:34 +0100 Message-Id: <20211205173535.2306292-5-tcChlisop0@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211205173535.2306292-1-tcChlisop0@gmail.com> References: <20211205173535.2306292-1-tcChlisop0@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 4/5] 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: bYYXJtbiFFXI 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 | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 38ff90833a..208378fc11 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,8 @@ 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]; + avio_wb32(pb, 32); /* size = 8 + 24 */ if (dovi->dv_profile > 10) ffio_wfourcc(pb, "dvwC"); @@ -1918,23 +1921,10 @@ 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); + + ff_isom_put_dvcc_dvvc(s, buf, dovi); + avio_write(pb, buf, sizeof(buf)); + return 32; /* 8 + 24 */ }