diff mbox series

[FFmpeg-devel] libavformat/rtpenc_jpeg.c: Added support for DRI frames in MJPEG RTP packetization

Message ID tencent_341E4718EA0658EADC9E2855D699B342C209@qq.com
State New
Headers show
Series [FFmpeg-devel] libavformat/rtpenc_jpeg.c: Added support for DRI frames in MJPEG RTP packetization | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

rayjay Feb. 19, 2024, 8:31 a.m. UTC
Signed-off-by: rayjay <526528945@qq.com>
---
 libavformat/rtpenc_jpeg.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c
index e4e95931f4..721c02ff76 100644
--- a/libavformat/rtpenc_jpeg.c
+++ b/libavformat/rtpenc_jpeg.c
@@ -37,6 +37,7 @@  void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
     int len;
     int i;
     int default_huffman_tables = 0;
+    uint16_t restart_interval = 0;
 
     s->buf_ptr   = s->buf;
     s->timestamp = s->cur_timestamp;
@@ -164,6 +165,9 @@  void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
                 return;
             }
             break;
+        } else if (buf[i + 1] == DRI) {
+            type |= 0x40;
+            restart_interval = AV_RB16(&buf[i + 4]);
         }
     }
 
@@ -203,6 +207,9 @@  void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
         if (off == 0 && nb_qtables)
             hdr_size += 4 + 64 * nb_qtables;
 
+        if (type & 0x40)
+            hdr_size += 4;
+
         /* payload max in one packet */
         len = FFMIN(size, s->max_payload_size - hdr_size);
 
@@ -214,6 +221,13 @@  void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
         bytestream_put_byte(&p, w);
         bytestream_put_byte(&p, h);
 
+        /* set dri */
+        if (type & 0x40) {
+            bytestream_put_be16(&p, restart_interval);
+            bytestream_put_byte(&p, 0xff);
+            bytestream_put_byte(&p, 0xff);
+        }
+
         if (off == 0 && nb_qtables) {
             /* set quantization tables header */
             bytestream_put_byte(&p, 0);