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/rtpdec_jpeg.c: Allow sender to include the qtable in fragment offset calculation
@ 2025-12-09 17:57 Hayden Myers via ffmpeg-devel
  2025-12-10  1:07 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Hayden Myers via ffmpeg-devel @ 2025-12-09 17:57 UTC (permalink / raw)
  To: haydenm315, ffmpeg-devel; +Cc: Hayden Myers

Signed-off-by: Hayden Myers <haydenm315@gmail.com>
---
 libavformat/rtpdec_jpeg.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c
index 4d9ee0d754..871f3a732e 100644
--- a/libavformat/rtpdec_jpeg.c
+++ b/libavformat/rtpdec_jpeg.c
@@ -353,9 +353,25 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
     }
 
     if (off != avio_tell(jpeg->frame) - jpeg->hdr_size) {
-        av_log(ctx, AV_LOG_ERROR,
-               "Missing packets; dropping frame.\n");
-        return AVERROR(EAGAIN);
+        /* The fragment offset may include the quant table data. Allow the
+         * offset to differ by the size of the quant header and table.
+         */
+
+        // Default to 2 * 64 byte tables for 8 bit precision.
+        uint8_t qtable_len =  128;
+
+        // Use the q table len value stored in the ctx
+        if (q >= 127 && q < 255)
+            qtable_len = jpeg->qtables_len[q-128];
+
+        // account for MBZ, Precision, and Length bytes.
+        qtable_len += 4;
+
+        if (off != (avio_tell(jpeg->frame) - (jpeg->hdr_size - qtable_len))) {
+            av_log(ctx, AV_LOG_ERROR,
+                "Missing packets; dropping frame.\n");
+            return AVERROR(EAGAIN);
+        }
     }
 
     /* Copy data to frame buffer. */
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] Re: [PATCH] libavformat/rtpdec_jpeg.c: Allow sender to include the qtable in fragment offset calculation
  2025-12-09 17:57 [FFmpeg-devel] [PATCH] libavformat/rtpdec_jpeg.c: Allow sender to include the qtable in fragment offset calculation Hayden Myers via ffmpeg-devel
@ 2025-12-10  1:07 ` Michael Niedermayer via ffmpeg-devel
  2025-12-10 18:25   ` Hayden Myers via ffmpeg-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Niedermayer via ffmpeg-devel @ 2025-12-10  1:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Michael Niedermayer


[-- Attachment #1.1: Type: text/plain, Size: 1512 bytes --]

Hi Hayden

On Tue, Dec 09, 2025 at 12:57:40PM -0500, Hayden Myers via ffmpeg-devel wrote:
> Signed-off-by: Hayden Myers <haydenm315@gmail.com>
> ---
>  libavformat/rtpdec_jpeg.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c
> index 4d9ee0d754..871f3a732e 100644
> --- a/libavformat/rtpdec_jpeg.c
> +++ b/libavformat/rtpdec_jpeg.c
> @@ -353,9 +353,25 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
>      }
>  
>      if (off != avio_tell(jpeg->frame) - jpeg->hdr_size) {
> -        av_log(ctx, AV_LOG_ERROR,
> -               "Missing packets; dropping frame.\n");
> -        return AVERROR(EAGAIN);
> +        /* The fragment offset may include the quant table data. Allow the
> +         * offset to differ by the size of the quant header and table.
> +         */
> +

> +        // Default to 2 * 64 byte tables for 8 bit precision.
> +        uint8_t qtable_len =  128;

exact length is not needed here, int tends to lead to fewer surprises


> +
> +        // Use the q table len value stored in the ctx
> +        if (q >= 127 && q < 255)
> +            qtable_len = jpeg->qtables_len[q-128];

127-128 is -1 thus results in out of array. jpeg->qtables_len[-1];

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 163 bytes --]

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] Re: [PATCH] libavformat/rtpdec_jpeg.c: Allow sender to include the qtable in fragment offset calculation
  2025-12-10  1:07 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
@ 2025-12-10 18:25   ` Hayden Myers via ffmpeg-devel
  0 siblings, 0 replies; 3+ messages in thread
From: Hayden Myers via ffmpeg-devel @ 2025-12-10 18:25 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Hayden Myers

Michael,

Addressed these comments in PATCH V2.  Thank you.

On Tue, Dec 9, 2025 at 8:08 PM Michael Niedermayer via ffmpeg-devel <
ffmpeg-devel@ffmpeg.org> wrote:

> Hi Hayden
>
> On Tue, Dec 09, 2025 at 12:57:40PM -0500, Hayden Myers via ffmpeg-devel
> wrote:
> > Signed-off-by: Hayden Myers <haydenm315@gmail.com>
> > ---
> >  libavformat/rtpdec_jpeg.c | 22 +++++++++++++++++++---
> >  1 file changed, 19 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c
> > index 4d9ee0d754..871f3a732e 100644
> > --- a/libavformat/rtpdec_jpeg.c
> > +++ b/libavformat/rtpdec_jpeg.c
> > @@ -353,9 +353,25 @@ static int jpeg_parse_packet(AVFormatContext *ctx,
> PayloadContext *jpeg,
> >      }
> >
> >      if (off != avio_tell(jpeg->frame) - jpeg->hdr_size) {
> > -        av_log(ctx, AV_LOG_ERROR,
> > -               "Missing packets; dropping frame.\n");
> > -        return AVERROR(EAGAIN);
> > +        /* The fragment offset may include the quant table data. Allow
> the
> > +         * offset to differ by the size of the quant header and table.
> > +         */
> > +
>
> > +        // Default to 2 * 64 byte tables for 8 bit precision.
> > +        uint8_t qtable_len =  128;
>
> exact length is not needed here, int tends to lead to fewer surprises
>
>
> > +
> > +        // Use the q table len value stored in the ctx
> > +        if (q >= 127 && q < 255)
> > +            qtable_len = jpeg->qtables_len[q-128];
>
> 127-128 is -1 thus results in out of array. jpeg->qtables_len[-1];
>
> thx
>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Democracy is the form of government in which you can choose your dictator
> _______________________________________________
> ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
> To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
>
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-10 18:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-09 17:57 [FFmpeg-devel] [PATCH] libavformat/rtpdec_jpeg.c: Allow sender to include the qtable in fragment offset calculation Hayden Myers via ffmpeg-devel
2025-12-10  1:07 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
2025-12-10 18:25   ` Hayden Myers 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