From patchwork Thu Dec 10 12:27:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Mallon X-Patchwork-Id: 24513 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5657044BD60 for ; Thu, 10 Dec 2020 14:27:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 386E0689FB2; Thu, 10 Dec 2020 14:27:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18EF9688392 for ; Thu, 10 Dec 2020 14:27:25 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id l9so5257473wrt.13 for ; Thu, 10 Dec 2020 04:27:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codex.online; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8xuj+E2Q1IXOKhHjid9Ll1yWhYU15W16GWXRJRmdR5A=; b=XfQJwtks875Yi3MrRPGkl6ej8D7EtVqR3rMeYGhSDNIGxIEVTZI55KkpWQhltSAzdu hfBoKyFnlLCie/NMJpuyx1Q5cjuDtYxGX7w9XLQYwEaMa5uER5XcDTlHCjsf1OTb1Nac MI1DGu+JLdLR75X5GapwNumRG8op13Ucsha+s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8xuj+E2Q1IXOKhHjid9Ll1yWhYU15W16GWXRJRmdR5A=; b=Ru1MT/BUz//pJeIGPPJ62qJnftlTl1lDpLsRAcMWtKXbA4U3dU397ZytwjfuK9zMj4 AUoIfl9gcTUb7Nn52nU6Q2ryAtZvBB6RBLZF4ViHrmDDSoPSmkoNW7/2Gxu4B0qjiNkJ QZ4d6OT0WxZa1HaJYZ96KlBx4W58a0F/wObVpi3UmvBLPuZw27NhdmSc/n+BjdJf0G0o UOVZoN6wE+vfQGHAexCNDL6g805ZwjNaeNiREPGki/fFA+oRQCK+QnUJ1MwyurOl2ncd +aAd5yu492Cedx57es5LKw1eSoAGrw1AL9IMvmCkESJHeOEPADSZrtBZGPm0PMbgZuEa HD6Q== X-Gm-Message-State: AOAM530Bh4R9GGzCZVrFmvVXrNepXqruOXZXH2l3RQoM9LK1TTYsN2C4 Z+W99pC9g+7kowdd2ROuwlqhmlDb+0DflWpA X-Google-Smtp-Source: ABdhPJxDc3kFtVh/Fguh3esP8wB3Bm0+WABJm4XLNO3MaXnM5AdvtrRJ88Ki4zEV1dn5y/cGNYL+EA== X-Received: by 2002:adf:f08a:: with SMTP id n10mr7917213wro.142.1607603244281; Thu, 10 Dec 2020 04:27:24 -0800 (PST) Received: from localhost ([66.159.216.147]) by smtp.gmail.com with ESMTPSA id h184sm9870628wmh.23.2020.12.10.04.27.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Dec 2020 04:27:23 -0800 (PST) From: Harry Mallon To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Dec 2020 12:27:14 +0000 Message-Id: <20201210122718.74374-2-harry.mallon@codex.online> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201210122718.74374-1-harry.mallon@codex.online> References: <20201207103214.75790-1-harry.mallon@codex.online> <20201210122718.74374-1-harry.mallon@codex.online> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/6] avcodec/dpx: Read alternative frame rate from television header X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Harry Mallon --- libavcodec/dpx.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index b1833ed9ef..7e3ac0af2e 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -216,10 +216,23 @@ static int decode_frame(AVCodecContext *avctx, else avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; + /* preferred frame rate from Motion-picture film header */ if (offset >= 1724 + 4) { buf = avpkt->data + 1724; i = read32(&buf, endian); - if(i) { + if(i && i != 0xFFFFFFFF) { + AVRational q = av_d2q(av_int2float(i), 4096); + if (q.num > 0 && q.den > 0) + avctx->framerate = q; + } + } + + /* alternative frame rate from television header */ + if (offset >= 1940 + 4 && + !(avctx->framerate.num && avctx->framerate.den)) { + buf = avpkt->data + 1940; + i = read32(&buf, endian); + if(i && i != 0xFFFFFFFF) { AVRational q = av_d2q(av_int2float(i), 4096); if (q.num > 0 && q.den > 0) avctx->framerate = q;