[FFmpeg-devel] [PATCH v3 7/7] avformat/rtp: support for RGB/BGR for rfc4175

lance.lmwang at gmail.com lance.lmwang at gmail.com
Wed Nov 24 17:27:45 EET 2021


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 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;
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list