* [FFmpeg-devel] [PATCH 1/1] libavformat/rtpenc_jpeg.c: add support for the DRI marker
@ 2024-01-26 18:12 Sebastien Cote
2024-01-27 0:47 ` Michael Niedermayer
0 siblings, 1 reply; 2+ messages in thread
From: Sebastien Cote @ 2024-01-26 18:12 UTC (permalink / raw)
To: ffmpeg-devel
This patch adds support for the DRI marker in the JPEG RTP payloader.
---
libavformat/rtpenc_jpeg.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c
index e4e95931f4..60f56680e2 100644
--- a/libavformat/rtpenc_jpeg.c
+++ b/libavformat/rtpenc_jpeg.c
@@ -33,6 +33,7 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const
uint8_t *buf, int size)
uint8_t type = 2; /* initialized non-0/1 value for RTP/JPEG type check*/
uint8_t w, h;
uint8_t *p;
+ uint16_t rst_marker_interval = 0;
int off = 0; /* fragment offset of the current JPEG frame */
int len;
int i;
@@ -155,6 +156,22 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const
uint8_t *buf, int size)
dht_size = 0;
continue;
}
+ } else if (buf[i + 1] == DRI) {
+ uint16_t dri_size = 0;
+ if (i + 5 > size) {
+ av_log(s1, AV_LOG_ERROR, "Too short JPEG header. Aborted!\n");
+ return;
+ }
+
+ dri_size = AV_RB16(&buf[i + 2]);
+ rst_marker_interval = AV_RB16(&buf[i + 4]);
+
+ if (i + 1 + dri_size > size) {
+ av_log(s1, AV_LOG_ERROR, "Too short JPEG header. Aborted!\n");
+ return;
+ }
+
+ i += 1 + dri_size;
} else if (buf[i + 1] == SOS) {
/* SOS is last marker in the header */
i += AV_RB16(&buf[i + 2]) + 2;
@@ -196,10 +213,16 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const
uint8_t *buf, int size)
}
}
+ if (rst_marker_interval > 0)
+ type += 64;
+
p = s->buf_ptr;
while (size > 0) {
int hdr_size = 8;
+ if (rst_marker_interval > 0)
+ hdr_size += 4;
+
if (off == 0 && nb_qtables)
hdr_size += 4 + 64 * nb_qtables;
@@ -214,6 +237,11 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const
uint8_t *buf, int size)
bytestream_put_byte(&p, w);
bytestream_put_byte(&p, h);
+ if (rst_marker_interval > 0) {
+ bytestream_put_be16(&p, rst_marker_interval);
+ bytestream_put_be16(&p, 0xFFFF);
+ }
+
if (off == 0 && nb_qtables) {
/* set quantization tables header */
bytestream_put_byte(&p, 0);
--
2.34.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] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/1] libavformat/rtpenc_jpeg.c: add support for the DRI marker
2024-01-26 18:12 [FFmpeg-devel] [PATCH 1/1] libavformat/rtpenc_jpeg.c: add support for the DRI marker Sebastien Cote
@ 2024-01-27 0:47 ` Michael Niedermayer
0 siblings, 0 replies; 2+ messages in thread
From: Michael Niedermayer @ 2024-01-27 0:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 853 bytes --]
On Fri, Jan 26, 2024 at 11:12:53AM -0700, Sebastien Cote wrote:
> This patch adds support for the DRI marker in the JPEG RTP payloader.
>
> ---
> libavformat/rtpenc_jpeg.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c
> index e4e95931f4..60f56680e2 100644
> --- a/libavformat/rtpenc_jpeg.c
> +++ b/libavformat/rtpenc_jpeg.c
> @@ -33,6 +33,7 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const
> uint8_t *buf, int size)
patch corrupted by line breaks
Applying: libavformat/rtpenc_jpeg.c: add support for the DRI marker
error: corrupt patch at line 10
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 2+ messages in thread
end of thread, other threads:[~2024-01-27 0:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 18:12 [FFmpeg-devel] [PATCH 1/1] libavformat/rtpenc_jpeg.c: add support for the DRI marker Sebastien Cote
2024-01-27 0:47 ` Michael Niedermayer
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