Måns Rullgård <[email protected]> writes:

> Måns Rullgård <[email protected]> writes:
>
>> "Ronald S. Bultje" <[email protected]> writes:
>>
>>> Prevent values in floor1[] from wrapping over uint16_t boundaries (in
>>> crafted bitstreams, they can go < 0), which causes them to wrap to
>>> MAXUINT16, causing huge jumps in the dB LUT indexes. Likewise, clip
>>> (rather than wrap) dB LUT indexes, to prevent jumping of indexes at
>>> uint8_t wrapping boundaries.
>>> ---
>>>  libavcodec/vorbis.c    |   16 ++++++++--------
>>>  libavcodec/vorbisdec.c |   10 +++++-----
>>>  2 files changed, 13 insertions(+), 13 deletions(-)
>>>
>
> [...]
>
>> This is pointless.  The value passed into these functions is a uint8_t.
>> To get the effect you're looking for, you need to clip the value
>> computed in ff_vorbis_floor1_render_list().
>
> To be clear, this patch should be enough:
>
> diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
> index 0b26870..7d6a4f0 100644
> --- a/libavcodec/vorbis.c
> +++ b/libavcodec/vorbis.c
> @@ -207,9 +207,9 @@ void ff_vorbis_floor1_render_list(vorbis_floor1_entry * 
> list, int values,
>                                    int multiplier, float *out, int samples)
>  {
>      int lx, i;
> -    uint8_t ly;
> +    int ly;
>      lx = 0;
> -    ly = y_list[0] * multiplier;
> +    ly = av_clip_uint8(y_list[0] * multiplier);
>      for (i = 1; i < values; i++) {
>          int pos = list[i].sort;
>          if (flag[pos]) {

I missed the second place ly is assigned in the loop.  This should do it:

diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
index 0b26870..a0f1090 100644
--- a/libavcodec/vorbis.c
+++ b/libavcodec/vorbis.c
@@ -206,10 +206,9 @@ void ff_vorbis_floor1_render_list(vorbis_floor1_entry * 
list, int values,
                                   uint16_t *y_list, int *flag,
                                   int multiplier, float *out, int samples)
 {
-    int lx, i;
-    uint8_t ly;
+    int lx, ly, i;
     lx = 0;
-    ly = y_list[0] * multiplier;
+    ly = av_clip_uint8(y_list[0] * multiplier);
     for (i = 1; i < values; i++) {
         int pos = list[i].sort;
         if (flag[pos]) {
@@ -218,7 +217,7 @@ void ff_vorbis_floor1_render_list(vorbis_floor1_entry * 
list, int values,
             if (lx < samples)
                 render_line(lx, ly, FFMIN(x1,samples), y1, out);
             lx = x1;
-            ly = y1;
+            ly = av_clip_uint8(y1);
         }
         if (lx >= samples)
             break;

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to