From patchwork Wed Nov 24 15:27:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31627 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp10609302iob; Wed, 24 Nov 2021 07:30:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBiu/bo9ZDFCyExspG51PHANh7LrlRjtPYWVh7AMP/hKXQXpoVrbFlNJy8v5DqE4tlWypQ X-Received: by 2002:a05:6402:2692:: with SMTP id w18mr25970844edd.220.1637767815030; Wed, 24 Nov 2021 07:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637767815; cv=none; d=google.com; s=arc-20160816; b=DM3l9elD7YYjMMt4sUn80OWfScAimjFsVIK9+hJeZ/EhkOxWB/D5A8ZhEz8aIC3FtV +IHEe2J0eDVeExrLi1OttHCWHZ0PlSFJUIC439mJSUc7z9XwqsCdMSWDYoMjLiwgtP3y Es261/kdF9VTNtj8YpsbgkqgIvL6H111gg7tAcb5WVGtv1zo+vZ4o6MzNhEioLNN3yt+ CPtRBl+R16kQCBtlwOhlC/2xyfgQTGABP3E4XlH9yMt/Pp2vpCeguzDSoUpJDmpoNuS1 4ASQk9u7WASSt2mJXUPK4kg/8zfL0riJpimIv6lJjfl0CSYVr7dY36SXeuXxSAafcKu3 cADA== 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=en+dJ+nnmSENta4xkbbXHuKI9xTSt55UQd6CKSlpEow=; b=EtfnRf+9XSpRntBeH7CwEPBEKeRCSnXwvnc72BrDI0GO7AFPXkJyzhfNZz7tYKpgER 0P9FhEGy7GNo0AIecQ+mA2X5GGftQdEkuBrliUX1VDVmNvZBPRKuq0YnjNR7yALRKRPT Xcav2JZ4M29CPuOd7nxF8cuyCD1PDPf+QsBguYZhkwrjVHUBz/HF8mQbCddym4A15DKD HTB/4ph+C8mGLIEzlm4d0gDqJu7vaNjli/y8a3m6gA27Vo9MvmmkVGE7/FowS238RRnu jrE283vkiGBsJUT0PNb3btBji0EmTCPjrPxD7wI5IjBttRPGc0SSJTqhL9VDh+dKWXMg cOkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Qf41T5Pt; 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 hc19si247015ejc.688.2021.11.24.07.30.14; Wed, 24 Nov 2021 07:30:15 -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=Qf41T5Pt; 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 5681868ADB0; Wed, 24 Nov 2021 17:29:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6295C68AC48 for ; Wed, 24 Nov 2021 17:28:59 +0200 (EET) Received: by mail-pf1-f178.google.com with SMTP id b68so2971970pfg.11 for ; Wed, 24 Nov 2021 07:28:59 -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; bh=V7mxJL4jMCbMgUNhMMxBIL0Scz/a5Y/TuukWmK25cmg=; b=Qf41T5PtafI3RU/iK5qj7Bb4NG1LHCHeVBRSSc5iRLvL/9VboFQcb+KjlRpL309Vbr zjOQQ8R0QYtZRhXw/GJA6TJoO8bGzoPumF0S4SqMs6azk16pUpN7wZh+YFicoheOb0J4 gWcpWgxdgaJM5NWOjgPibqZib7FBz3IAceul59gImyp3ioGIRkeq0oUVWGAD+IJhta2l KGOaiqCilowUjhgJQTDGSehw8RkUIvUAxRzj4lVWkw62P4AdpjGMLRj3ctVT3c3ARrEQ GXLVvX9oCdz9dpHJi0UmY3OXUKexNsb/g2QbEnivNm0aw8qikrEH4IhWwg74i5MWYJIT n4Wg== 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=V7mxJL4jMCbMgUNhMMxBIL0Scz/a5Y/TuukWmK25cmg=; b=E5AuSuTuRjKxZZat4gcHr+KWSTr5BJzIAUUeHng0kjoMN3Gnuuf+RszPrTN4ANguFa r6Wc5qyA5q4sTTI2m4596x6Srqm+Ubcj7FWg77rrBfep5aTybebNDALRYW4RiwAr5LoH Ik4+FEQlZgfxZYFHhXGkpMmMZftS2vj9GULLD6MBCVU8i3elgS2X1b4QO3tRM/HmR8Ln q19wffH6TpYQz9ZAOkVo1Vo5Am0iBEV0EqW4Ek70gxGohmffkTvh0RjD5PgZBlDj/srQ jPo4DUECPy1XDKCqdMAC0P5LiDSRp7A73nFGlLf6YGGom3DkO0Ovaq6yU/dxANRGTr3N x/2g== X-Gm-Message-State: AOAM533DT3XKQ20uoZ0YwRp+EVTCXhvB+MyItozkRRQ3MDHJc6netusk MgYLlLVB+lZmxwWcmBc9uq7jWYZlcdo= X-Received: by 2002:a05:6a00:1741:b0:49f:99e6:1d1d with SMTP id j1-20020a056a00174100b0049f99e61d1dmr7142484pfc.34.1637767737584; Wed, 24 Nov 2021 07:28:57 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id b6sm83842pfm.170.2021.11.24.07.28.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 07:28:57 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Nov 2021 23:27:45 +0800 Message-Id: <1637767665-6777-7-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> References: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 7/7] avformat/rtp: support for RGB/BGR for rfc4175 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: HsZT7XKT91Ri From: Limin Wang Signed-off-by: Limin Wang --- libavformat/rtpdec_rfc4175.c | 20 ++++++++++++++++++++ libavformat/rtpenc_rfc4175.c | 8 ++++++++ libavformat/sdp.c | 6 ++++++ 3 files changed, 34 insertions(+) diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c index 5a7058b..7feefd2 100644 --- a/libavformat/rtpdec_rfc4175.c +++ b/libavformat/rtpdec_rfc4175.c @@ -74,6 +74,26 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data) } else { return AVERROR_INVALIDDATA; } + } else if (!strncmp(data->sampling, "RGB", 3)) { + tag = MKTAG('R', 'G', 'B', 24); + if (data->depth == 8) { + data->xinc = 1; + data->pgroup = 3; + pixfmt = AV_PIX_FMT_RGB24; + stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + } else { + return AVERROR_INVALIDDATA; + } + } else if (!strncmp(data->sampling, "BGR", 3)) { + tag = MKTAG('B', 'G', 'R', 24); + if (data->depth == 8) { + data->xinc = 1; + data->pgroup = 3; + pixfmt = AV_PIX_FMT_BGR24; + stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + } else { + return AVERROR_INVALIDDATA; + } } else { return AVERROR_INVALIDDATA; } diff --git a/libavformat/rtpenc_rfc4175.c b/libavformat/rtpenc_rfc4175.c index 4623b4a..ea4c370 100644 --- a/libavformat/rtpenc_rfc4175.c +++ b/libavformat/rtpenc_rfc4175.c @@ -45,6 +45,14 @@ void ff_rtp_send_raw_rfc4175(AVFormatContext *s1, const uint8_t *buf, int size) xinc = yinc = 4; pgroup = 6; break; + case AV_PIX_FMT_RGB24: + xinc = yinc = 1; + pgroup = 3; + break; + case AV_PIX_FMT_BGR24: + xinc = yinc = 1; + pgroup = 3; + break; default: return; } diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 5ad2a54..a41c2cf 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -676,6 +676,12 @@ static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int case AV_PIX_FMT_YUV420P: pix_fmt = "YCbCr-4:2:0"; break; + case AV_PIX_FMT_RGB24: + pix_fmt = "RGB"; + break; + case AV_PIX_FMT_BGR24: + pix_fmt = "BGR"; + break; default: av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n"); return NULL;