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 v1] avcodec/cbs_vp8: Use little endian in fixed()
@ 2024-01-25  0:54 Dai, Jianhui J
  2024-02-23  0:43 ` Dai, Jianhui J
  2024-03-26 13:14 ` Ronald S. Bultje
  0 siblings, 2 replies; 4+ messages in thread
From: Dai, Jianhui J @ 2024-01-25  0:54 UTC (permalink / raw)
  To: ffmpeg-devel

This commit adds value range checks to cbs_vp8_read_unsigned_le,
migrates fixed() to use it, and enforces little-endian consistency for
all read methods.

Signed-off-by: Jianhui Dai <jianhui.j.dai@intel.com>
---
 libavcodec/cbs_vp8.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/libavcodec/cbs_vp8.c b/libavcodec/cbs_vp8.c
index 065156c248..7a0752019b 100644
--- a/libavcodec/cbs_vp8.c
+++ b/libavcodec/cbs_vp8.c
@@ -181,9 +181,11 @@ static int cbs_vp8_bool_decoder_read_signed(
     return 0;
 }
 
-static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *gbc,
-                                 int width, const char *name,
-                                 const int *subscripts, uint32_t *write_to)
+static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx,
+                                    GetBitContext *gbc, int width,
+                                    const char *name, const int *subscripts,
+                                    uint32_t *write_to, uint32_t range_min,
+                                    uint32_t range_max)
 {
     int32_t value;
 
@@ -200,6 +202,14 @@ static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g
 
     CBS_TRACE_READ_END();
 
+    if (value < range_min || value > range_max) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR,
+               "%s out of range: "
+               "%" PRIu32 ", but must be in [%" PRIu32 ",%" PRIu32 "].\n",
+               name, value, range_min, range_max);
+        return AVERROR_INVALIDDATA;
+    }
+
     *write_to = value;
     return 0;
 }
@@ -246,15 +256,16 @@ static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g
     do { \
         uint32_t value; \
         CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, \
-                                    SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
+                                       SUBSCRIPTS(subs, __VA_ARGS__), &value, \
+                                       0, MAX_UINT_BITS(width))); \
         current->name = value; \
     } while (0)
 
 #define fixed(width, name, value) \
     do { \
         uint32_t fixed_value; \
-        CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, 0, &fixed_value, \
-                                   value, value)); \
+        CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, 0, &fixed_value, \
+                                       value, value)); \
     } while (0)
 
 #define bc_unsigned_subs(width, prob, enable_trace, name, subs, ...) \
-- 
2.25.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] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH v1] avcodec/cbs_vp8: Use little endian in fixed()
  2024-01-25  0:54 [FFmpeg-devel] [PATCH v1] avcodec/cbs_vp8: Use little endian in fixed() Dai, Jianhui J
@ 2024-02-23  0:43 ` Dai, Jianhui J
  2024-03-26 13:14 ` Ronald S. Bultje
  1 sibling, 0 replies; 4+ messages in thread
From: Dai, Jianhui J @ 2024-02-23  0:43 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Dai,
> Jianhui J
> Sent: Thursday, January 25, 2024 8:54 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v1] avcodec/cbs_vp8: Use little endian in fixed()
> 
> This commit adds value range checks to cbs_vp8_read_unsigned_le, migrates
> fixed() to use it, and enforces little-endian consistency for all read methods.
> 
> Signed-off-by: Jianhui Dai <jianhui.j.dai@intel.com>
> ---
>  libavcodec/cbs_vp8.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/cbs_vp8.c b/libavcodec/cbs_vp8.c index
> 065156c248..7a0752019b 100644
> --- a/libavcodec/cbs_vp8.c
> +++ b/libavcodec/cbs_vp8.c
> @@ -181,9 +181,11 @@ static int cbs_vp8_bool_decoder_read_signed(
>      return 0;
>  }
> 
> -static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx,
> GetBitContext *gbc,
> -                                 int width, const char *name,
> -                                 const int *subscripts, uint32_t *write_to)
> +static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx,
> +                                    GetBitContext *gbc, int width,
> +                                    const char *name, const int *subscripts,
> +                                    uint32_t *write_to, uint32_t range_min,
> +                                    uint32_t range_max)
>  {
>      int32_t value;
> 
> @@ -200,6 +202,14 @@ static int
> cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g
> 
>      CBS_TRACE_READ_END();
> 
> +    if (value < range_min || value > range_max) {
> +        av_log(ctx->log_ctx, AV_LOG_ERROR,
> +               "%s out of range: "
> +               "%" PRIu32 ", but must be in [%" PRIu32 ",%" PRIu32 "].\n",
> +               name, value, range_min, range_max);
> +        return AVERROR_INVALIDDATA;
> +    }
> +
>      *write_to = value;
>      return 0;
>  }
> @@ -246,15 +256,16 @@ static int
> cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g
>      do { \
>          uint32_t value; \
>          CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, \
> -                                    SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
> +                                       SUBSCRIPTS(subs, __VA_ARGS__), &value, \
> +                                       0, MAX_UINT_BITS(width))); \
>          current->name = value; \
>      } while (0)
> 
>  #define fixed(width, name, value) \
>      do { \
>          uint32_t fixed_value; \
> -        CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, 0, &fixed_value, \
> -                                   value, value)); \
> +        CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, 0, &fixed_value, \
> +                                       value, value)); \
>      } while (0)
> 
>  #define bc_unsigned_subs(width, prob, enable_trace, name, subs, ...) \

Ping reviewers to help to apply. 

The review history can be found here:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/CH3PR11MB793797554CDB411074364733B1742@CH3PR11MB7937.namprd11.prod.outlook.com/

> --
> 2.25.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".
_______________________________________________
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] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH v1] avcodec/cbs_vp8: Use little endian in fixed()
  2024-01-25  0:54 [FFmpeg-devel] [PATCH v1] avcodec/cbs_vp8: Use little endian in fixed() Dai, Jianhui J
  2024-02-23  0:43 ` Dai, Jianhui J
@ 2024-03-26 13:14 ` Ronald S. Bultje
  2024-03-27  0:55   ` Dai, Jianhui J
  1 sibling, 1 reply; 4+ messages in thread
From: Ronald S. Bultje @ 2024-03-26 13:14 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi,

On Wed, Jan 24, 2024 at 7:54 PM Dai, Jianhui J <
jianhui.j.dai-at-intel.com@ffmpeg.org> wrote:

> This commit adds value range checks to cbs_vp8_read_unsigned_le,
> migrates fixed() to use it, and enforces little-endian consistency for
> all read methods.
>
> Signed-off-by: Jianhui Dai <jianhui.j.dai@intel.com>
> ---
>  libavcodec/cbs_vp8.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/cbs_vp8.c b/libavcodec/cbs_vp8.c
> index 065156c248..7a0752019b 100644
> --- a/libavcodec/cbs_vp8.c
> +++ b/libavcodec/cbs_vp8.c
> @@ -181,9 +181,11 @@ static int cbs_vp8_bool_decoder_read_signed(
>      return 0;
>  }
>
> -static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx,
> GetBitContext *gbc,
> -                                 int width, const char *name,
> -                                 const int *subscripts, uint32_t
> *write_to)
> +static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx,
> +                                    GetBitContext *gbc, int width,
> +                                    const char *name, const int
> *subscripts,
> +                                    uint32_t *write_to, uint32_t
> range_min,
> +                                    uint32_t range_max)
>  {
>      int32_t value;
>
> @@ -200,6 +202,14 @@ static int
> cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g
>
>      CBS_TRACE_READ_END();
>
> +    if (value < range_min || value > range_max) {
> +        av_log(ctx->log_ctx, AV_LOG_ERROR,
> +               "%s out of range: "
> +               "%" PRIu32 ", but must be in [%" PRIu32 ",%" PRIu32 "].\n",
> +               name, value, range_min, range_max);
> +        return AVERROR_INVALIDDATA;
> +    }
> +
>      *write_to = value;
>      return 0;
>  }
> @@ -246,15 +256,16 @@ static int
> cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g
>      do { \
>          uint32_t value; \
>          CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, \
> -                                    SUBSCRIPTS(subs, __VA_ARGS__),
> &value)); \
> +                                       SUBSCRIPTS(subs, __VA_ARGS__),
> &value, \
> +                                       0, MAX_UINT_BITS(width))); \
>          current->name = value; \
>      } while (0)
>
>  #define fixed(width, name, value) \
>      do { \
>          uint32_t fixed_value; \
> -        CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, 0,
> &fixed_value, \
> -                                   value, value)); \
> +        CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, 0,
> &fixed_value, \
> +                                       value, value)); \
>      } while (0)
>
>  #define bc_unsigned_subs(width, prob, enable_trace, name, subs, ...) \
> --
> 2.25.1
>

Merged.

Ronald
_______________________________________________
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] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH v1] avcodec/cbs_vp8: Use little endian in fixed()
  2024-03-26 13:14 ` Ronald S. Bultje
@ 2024-03-27  0:55   ` Dai, Jianhui J
  0 siblings, 0 replies; 4+ messages in thread
From: Dai, Jianhui J @ 2024-03-27  0:55 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Ronald
> S. Bultje
> Sent: Tuesday, March 26, 2024 9:14 PM
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v1] avcodec/cbs_vp8: Use little endian in
> fixed()
> 
> Hi,
> 
> On Wed, Jan 24, 2024 at 7:54 PM Dai, Jianhui J < jianhui.j.dai-at-
> intel.com@ffmpeg.org> wrote:
> 
> > This commit adds value range checks to cbs_vp8_read_unsigned_le,
> > migrates fixed() to use it, and enforces little-endian consistency for
> > all read methods.
> >
> > Signed-off-by: Jianhui Dai <jianhui.j.dai@intel.com>
> > ---
> >  libavcodec/cbs_vp8.c | 23 +++++++++++++++++------
> >  1 file changed, 17 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavcodec/cbs_vp8.c b/libavcodec/cbs_vp8.c index
> > 065156c248..7a0752019b 100644
> > --- a/libavcodec/cbs_vp8.c
> > +++ b/libavcodec/cbs_vp8.c
> > @@ -181,9 +181,11 @@ static int cbs_vp8_bool_decoder_read_signed(
> >      return 0;
> >  }
> >
> > -static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx,
> > GetBitContext *gbc,
> > -                                 int width, const char *name,
> > -                                 const int *subscripts, uint32_t
> > *write_to)
> > +static int cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx,
> > +                                    GetBitContext *gbc, int width,
> > +                                    const char *name, const int
> > *subscripts,
> > +                                    uint32_t *write_to, uint32_t
> > range_min,
> > +                                    uint32_t range_max)
> >  {
> >      int32_t value;
> >
> > @@ -200,6 +202,14 @@ static int
> > cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g
> >
> >      CBS_TRACE_READ_END();
> >
> > +    if (value < range_min || value > range_max) {
> > +        av_log(ctx->log_ctx, AV_LOG_ERROR,
> > +               "%s out of range: "
> > +               "%" PRIu32 ", but must be in [%" PRIu32 ",%" PRIu32 "].\n",
> > +               name, value, range_min, range_max);
> > +        return AVERROR_INVALIDDATA;
> > +    }
> > +
> >      *write_to = value;
> >      return 0;
> >  }
> > @@ -246,15 +256,16 @@ static int
> > cbs_vp8_read_unsigned_le(CodedBitstreamContext *ctx, GetBitContext *g
> >      do { \
> >          uint32_t value; \
> >          CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, \
> > -                                    SUBSCRIPTS(subs, __VA_ARGS__),
> > &value)); \
> > +                                       SUBSCRIPTS(subs, __VA_ARGS__),
> > &value, \
> > +                                       0, MAX_UINT_BITS(width))); \
> >          current->name = value; \
> >      } while (0)
> >
> >  #define fixed(width, name, value) \
> >      do { \
> >          uint32_t fixed_value; \
> > -        CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, 0,
> > &fixed_value, \
> > -                                   value, value)); \
> > +        CHECK(cbs_vp8_read_unsigned_le(ctx, rw, width, #name, 0,
> > &fixed_value, \
> > +                                       value, value)); \
> >      } while (0)
> >
> >  #define bc_unsigned_subs(width, prob, enable_trace, name, subs, ...)
> > \
> > --
> > 2.25.1
> >
> 
> Merged.

Ronald, Thank you!

> 
> Ronald
> _______________________________________________
> 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".
_______________________________________________
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] 4+ messages in thread

end of thread, other threads:[~2024-03-27  0:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25  0:54 [FFmpeg-devel] [PATCH v1] avcodec/cbs_vp8: Use little endian in fixed() Dai, Jianhui J
2024-02-23  0:43 ` Dai, Jianhui J
2024-03-26 13:14 ` Ronald S. Bultje
2024-03-27  0:55   ` Dai, Jianhui J

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