[FFmpeg-cvslog] avformat/rtp: support RGB/BGR for rfc4175

Limin Wang git at videolan.org
Thu Nov 25 12:20:00 EET 2021


ffmpeg | branch: master | Limin Wang <lance.lmwang at gmail.com> | Wed Nov 24 19:14:17 2021 +0800| [522f577d7eca66c65aece841610cb008a10c1a2e] | committer: Limin Wang

avformat/rtp: support RGB/BGR for rfc4175

Reviewed-by: Lynne <dev at lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=522f577d7eca66c65aece841610cb008a10c1a2e
---

 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 5a7058bc14..7feefd2fff 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 4623b4ac23..ea4c3705f3 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 5ad2a54474..a41c2cf655 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;



More information about the ffmpeg-cvslog mailing list