Advertisement
oanastratulat

Untitled

Jan 11th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.31 KB | None | 0 0
  1. index 28176f3..e299812 100644
  2. --- a/libavcodec/vorbis.c
  3. +++ b/libavcodec/vorbis.c
  4. @@ -179,12 +179,14 @@ static inline void render_line_unrolled(intptr_t x, uint8_t y, int x1,
  5.      }
  6.  }
  7.  
  8. -static void render_line(int x0, uint8_t y0, int x1, int y1, float *buf)
  9. +static int render_line(int x0, uint8_t y0, int x1, int y1, float *buf)
  10.  {
  11.      int dy  = y1 - y0;
  12.      int adx = x1 - x0;
  13.      int ady = FFABS(dy);
  14.      int sy  = dy < 0 ? -1 : 1;
  15. +    if (adx == 0)
  16. +        return -1;
  17.      buf[x0] = ff_vorbis_floor1_inverse_db_table[y0];
  18.      if (ady*2 <= adx) { // optimized common case
  19.          render_line_unrolled(x0, y0, x1, sy, ady, adx, buf);
  20. @@ -204,9 +206,10 @@ static void render_line(int x0, uint8_t y0, int x1, int y1, float *buf)
  21.              buf[x] = ff_vorbis_floor1_inverse_db_table[y];
  22.          }
  23.      }
  24. +    return 0;
  25.  }
  26.  
  27. -void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
  28. +int ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
  29.                                    uint16_t *y_list, int *flag,
  30.                                    int multiplier, float *out, int samples)
  31.  {
  32. @@ -219,8 +222,8 @@ void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
  33.          if (flag[pos]) {
  34.              int x1 = list[pos].x;
  35.              int y1 = y_list[pos] * multiplier;
  36. -            if (lx < samples)
  37. -                render_line(lx, ly, FFMIN(x1,samples), y1, out);
  38. +            if (lx < samples && render_line(lx, ly, FFMIN(x1,samples), y1, out) < 0)
  39. +                return -1;
  40.              lx = x1;
  41.              ly = y1;
  42.          }
  43. @@ -228,5 +231,7 @@ void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
  44.              break;
  45.      }
  46.      if (lx < samples)
  47. -        render_line(lx, ly, samples, ly, out);
  48. +        if (render_line(lx, ly, samples, ly, out) == -1)
  49. +            return -1;
  50. +    return 0;
  51.  }
  52. diff --git a/libavcodec/vorbis.h b/libavcodec/vorbis.h
  53. index cad080e..03b1f1b 100644
  54. --- a/libavcodec/vorbis.h
  55. +++ b/libavcodec/vorbis.h
  56. @@ -39,7 +39,7 @@ typedef struct {
  57.  void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values);
  58.  unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n); // x^(1/n)
  59.  int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num);
  60. -void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
  61. +int ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
  62.                                    uint16_t *y_list, int *flag,
  63.                                    int multiplier, float * out, int samples);
  64.  void vorbis_inverse_coupling(float *mag, float *ang, int blocksize);
  65. diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
  66. index 6bf785e..bd2dfd9 100644
  67. --- a/libavcodec/vorbisdec.c
  68. +++ b/libavcodec/vorbisdec.c
  69. @@ -1270,7 +1270,9 @@ static int vorbis_floor1_decode(vorbis_context *vc,
  70.  
  71.  // Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ?
  72.  
  73. -    ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x);
  74. +    if (ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x) == -1)
  75. +        return AVERROR_INVALIDDATA;
  76. +        
  77.  
  78.      av_dlog(NULL, " Floor decoded\n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement