Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] libavformat/rtpenc_jpeg.c: Added support for DRI frames in MJPEG RTP packetization
@ 2024-02-19  8:31 rayjay via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: rayjay via ffmpeg-devel @ 2024-02-19  8:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: rayjay

Signed-off-by: rayjay <526528945@qq.com>
---
 libavformat/rtpenc_jpeg.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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);
-- 
2.40.0.windows.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-19  8:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19  8:31 [FFmpeg-devel] [PATCH] libavformat/rtpenc_jpeg.c: Added support for DRI frames in MJPEG RTP packetization rayjay via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git