Merge commit '0af5a774ebc96ae9018926dc8b276c7f39767e3e' into release/1.1
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 2 Jun 2013 22:16:52 +0000 (00:16 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 2 Jun 2013 22:16:52 +0000 (00:16 +0200)
* commit '0af5a774ebc96ae9018926dc8b276c7f39767e3e':
  jpegls: check the scan offset
  jpegls: factorize return paths
  jpegls: return meaningful errors
  mpegvideo: allocate sufficiently large scratch buffer for interlaced vid

Conflicts:
libavcodec/jpeglsdec.c
libavcodec/mpegvideo.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/jpeglsdec.c

@@@ -262,11 -259,11 +262,11 @@@ int ff_jpegls_decode_picture(MJpegDecod
      int i, t = 0;
      uint8_t *zero, *last, *cur;
      JLSState *state;
-     int off = 0, stride = 1, width, shift;
+     int off = 0, stride = 1, width, shift, ret = 0;
  
 -    zero = av_mallocz(s->picture_ptr->linesize[0]);
 +    zero = av_mallocz(s->picture.linesize[0]);
      last = zero;
 -    cur = s->picture_ptr->data[0];
 +    cur = s->picture.data[0];
  
      state = av_mallocz(sizeof(JLSState));
      /* initialize JPEG-LS state from JPEG parameters */
      else
          shift = point_transform + (16 - s->bits);
  
 -    av_dlog(s->avctx, "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
 -            s->width, s->height, state->near, state->maxval,
 -            state->T1, state->T2, state->T3,
 -            state->reset, state->limit, state->qbpp, state->range);
 -    av_dlog(s->avctx, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
 -            ilv, point_transform, s->bits, s->cur_scan);
 +    if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
 +        av_log(s->avctx, AV_LOG_DEBUG, "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
 +                s->width, s->height, state->near, state->maxval,
 +                state->T1, state->T2, state->T3,
 +                state->reset, state->limit, state->qbpp, state->range);
 +        av_log(s->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
 +                ilv, point_transform, s->bits, s->cur_scan);
 +    }
      if(ilv == 0) { /* separate planes */
 -        off = s->cur_scan - 1;
+         if (s->cur_scan > s->nb_components) {
+             ret = AVERROR_INVALIDDATA;
+             goto end;
+         }
          stride = (s->nb_components > 1) ? 3 : 1;
 +        off = av_clip(s->cur_scan - 1, 0, stride - 1);
          width = s->width * stride;
          cur += off;
          for(i = 0; i < s->height; i++) {
                  }
              }
              last = cur;
 -            cur += s->picture_ptr->linesize[0];
 +            cur += s->picture.linesize[0];
          }
-     } else if(ilv == 2) { /* sample interleaving */
+     } else if (ilv == 2) { /* sample interleaving */
          av_log(s->avctx, AV_LOG_ERROR, "Sample interleaved images are not supported.\n");
-         av_free(state);
-         av_free(zero);
-         return -1;
+         ret = AVERROR_PATCHWELCOME;
+         goto end;
      }
  
      if(shift){ /* we need to do point transform or normalize samples */