From patchwork Wed Oct 6 10:14:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 30954 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp219389iob; Wed, 6 Oct 2021 03:15:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjzVVIfTFj6d0B9HtjCZvYTlNGwkV0ztOrLZCDhrWfsz3Q1brxT61IuVA637nfe8B/vlgO X-Received: by 2002:a17:906:3805:: with SMTP id v5mr30554229ejc.440.1633515314410; Wed, 06 Oct 2021 03:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633515314; cv=none; d=google.com; s=arc-20160816; b=FFD6TuGqSfwg3hOYXxiQGW7nE2V7pI1FXbFiPSWgYWE2pRpNRcTgZDoPEyy5fQJQT1 0qj+Pc/Wp4ISVBurdhXHkCfxpf1KqPMqIB6iTRlJ6uHC340wju/rEyo1beSY0XZcpoSl qM1rLE7/YMFWnOS1gFQczUJ6DlflE78Y9nQk+O5rp3Ip1T0UANUCkz0CJEclB9MNjYA1 Jd8RSyGSTsf4hA/aCxOBjYQL78hPVTHA9e2qf0x6cKze2DyddT5UNNsVji7OENfJxSOv gd3il1bg5AzjdVOwIgaaNdx/SPDMXnA/R2SKN6p5ZAroF7fMlQ4bVy5/Fkj/LSirnKfk BrMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=TuXSpxJzvnsK7JmpnLdTKzGw1f5oXhEVyqT5tjBCsSI=; b=DCqXL7oqxD3Z/OErNwC0dimpdJqVc0y/M8dsfBVIHCVfl7RZlISb7h3U/c5Khj2NfR SRMNhxWgH040RO8un6oqTUlksGbrFv1+janfqMlTPWjnSSywsIm94eue4Jbew3a4blZe sPtnnPhGGjmOE4SXDkiQ4zQSqpIdEVg9Uztrj3TH1GiHgMn3GlyrzmPWu8Tm/qUVnyNj eebZYbJiqf+yamLfxGEXbE5/n+MVhRmb/XEdWeBW8/fx7rO5lCvzCuqbImcw3Ws/hsiY ek+PCoXNb+OpZMzxwEXGixw42MrjC2L0fUOHoBn2Bwlbh7Ztb6DUETBfnGSNCaV6CRzs xT2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=eWEsylJB; 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 dd3si24787976edb.123.2021.10.06.03.15.13; Wed, 06 Oct 2021 03:15:14 -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=eWEsylJB; 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 0121168AD08; Wed, 6 Oct 2021 13:14:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 87EF268AB51 for ; Wed, 6 Oct 2021 13:14:21 +0300 (EEST) Received: by mail-pj1-f50.google.com with SMTP id q7-20020a17090a2e0700b001a01027dd88so2078883pjd.1 for ; Wed, 06 Oct 2021 03:14:21 -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; bh=stvOrMhh8/2wUPJxqlNzcOVrmmkGoecaCOdwMB9moB0=; b=eWEsylJBn5eAKgd2HF7lVRFMCwJr73cpx3nSpBBBVBXLEZZzqtI+7XvyDgc/ynU1oy GrZ33vxx6QzlWt2gpA7A+WHRTGTRmkXpZgYtna7UsXzA8r32nlEE8wu0u3izi41nCcxe TSNrMhrsbIdZv2S7oNSOMFQrgmpEgqDRDMjJJWG3VKVGLXoC9CEbK1+jeLUuYUEo3guk LthOccrMBAGAUlqRvDCj5K7FoBprdLlFc19892R4m+LRCVJD5V85CGI3foAt0dVJtV85 US22cbEL05mAvXbZhoq+uwnLj+4PvdMA3+/IrGOEFV/p6hAfycvh62fvOv3m9jWhF3vt 5WZw== 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; bh=stvOrMhh8/2wUPJxqlNzcOVrmmkGoecaCOdwMB9moB0=; b=vyY+2LRvETTLEUKc72lgnUYogIxfkJQo67htGdZc9O8voJAdiekvgyyqpTccCl7CiO UE7a1QGIvXkhfYk57008XC63egks7D3UtRjb/5V//9LagjNX5QQgRX1o8VggCH0WQTSr jmFo8pPw7NtdIBmVO3kiFsEM3R9ns/r1BMCpU+ndBl7eeyqYmiDN1v5NbggxdWjOpyPG hTFfA7NVdf/6+F5CEACF4NmASC7NCcTElpMEZujsaBaMEbmLtKbMgs5jpp12yXUvJiFa 0q133vFudzcGbZwtghhtaryNztekcG5jcx0WbotyOn01O+IEZaWesk3yfeVZ8GCfcci3 ZZyA== X-Gm-Message-State: AOAM531cSgGWYaRHtwzrhiY07/t5pdSnvxM7WQbR+FQL8NCHSYEb9sZN wIVKNggjMPE5U0ZQKMr6bkF2FDEFyo4= X-Received: by 2002:a17:90b:28d:: with SMTP id az13mr9853416pjb.30.1633515259765; Wed, 06 Oct 2021 03:14:19 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id i125sm20338309pfc.36.2021.10.06.03.14.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Oct 2021 03:14:19 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Oct 2021 18:14:08 +0800 Message-Id: <1633515251-5156-5-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1633515251-5156-1-git-send-email-lance.lmwang@gmail.com> References: <1633515251-5156-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/8] avformat/rtpdec_rfc4175: add support for exactframerate 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FZbb/b1nc/aK From: Limin Wang Signed-off-by: Limin Wang --- libavformat/rtpdec_rfc4175.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c index 46d30ed..367567d 100644 --- a/libavformat/rtpdec_rfc4175.c +++ b/libavformat/rtpdec_rfc4175.c @@ -25,9 +25,11 @@ #include "rtpdec_formats.h" #include "libavutil/avstring.h" #include "libavutil/pixdesc.h" +#include "libavutil/parseutils.h" struct PayloadContext { char *sampling; + char *framerate; int depth; int width; int height; @@ -45,6 +47,7 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data) enum AVPixelFormat pixfmt; int tag; const AVPixFmtDescriptor *desc; + AVRational framerate; if (!strncmp(data->sampling, "YCbCr-4:2:2", 11)) { tag = MKTAG('U', 'Y', 'V', 'Y'); @@ -69,6 +72,14 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data) stream->codecpar->bits_per_coded_sample = av_get_bits_per_pixel(desc); data->frame_size = data->width * data->height * data->pgroup / data->xinc; + if (data->framerate) { + if (av_parse_video_rate(&framerate, data->framerate) < 0) + return AVERROR(EINVAL); + stream->avg_frame_rate = framerate; + if (framerate.den) + stream->codecpar->bit_rate = data->frame_size * av_q2d(framerate) * 8; + } + return 0; } @@ -84,6 +95,8 @@ static int rfc4175_parse_fmtp(AVFormatContext *s, AVStream *stream, data->sampling = av_strdup(value); else if (!strncmp(attr, "depth", 5)) data->depth = atoi(value); + else if (!strncmp(attr, "exactframerate", 14)) + data->framerate = av_strdup(value); return 0; } @@ -112,6 +125,7 @@ static int rfc4175_parse_sdp_line(AVFormatContext *s, int st_index, ret = rfc4175_parse_format(stream, data); av_freep(&data->sampling); + av_freep(&data->framerate); return ret; }