Merge remote-tracking branch 'qatar/release/0.8' into release/0.10
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 14 Oct 2012 02:45:42 +0000 (04:45 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 16 Oct 2012 02:25:51 +0000 (04:25 +0200)
* qatar/release/0.8: (23 commits)
  snow: Check mallocs at init
  vorbis: Validate that the floor 1 X values contain no duplicates.
  vorbisenc: check all allocations for failure
  indeo3: validate new frame size before resetting decoder
  lavfi: avfilter_merge_formats: handle case where inputs are same
  rv34: error out on size changes with frame threading
  rv34: Handle only complete frames in frame-mt.
  rv34: use AVERROR return values in ff_rv34_decode_frame()
  vlc/rl: Add ff_ prefix to the nonstatic symbols
  h263: Add ff_ prefix to nonstatic symbols
  alsdec: check opt_order.
  golomb: check remaining bits during unary decoding in get_ur_golomb_jpegls()
  lavf: don't segfault when a NULL filename is passed to avformat_open_input()
  mpegvideo: Don't use ff_mspel_motion() for vc1
  imgconvert: avoid undefined left shift in avcodec_find_best_pix_fmt
  eval: fix swapping of lt() and lte()
  nuv: check RTjpeg header for validity
  Revert "nuv: check per-frame header for validity."
  bmpdec: only initialize palette for pal8.
  sipr: fall back to setting mode based on bit_rate.
  ...

Conflicts:
avconv.c
libavcodec/dnxhddec.c
libavcodec/golomb.h
libavcodec/h263.h
libavcodec/imgconvert.c
libavcodec/mpegvideo_common.h
libavcodec/mpegvideo_enc.c
libavcodec/nuv.c
libavcodec/rv34.c
libavcodec/sipr.c
libavcodec/vorbisdec.c
libavcodec/vorbisenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
66 files changed:
1  2 
libavcodec/4xm.c
libavcodec/alsdec.c
libavcodec/bitstream.c
libavcodec/bmp.c
libavcodec/cook.c
libavcodec/dnxhddec.c
libavcodec/dv.c
libavcodec/faxcompr.c
libavcodec/fraps.c
libavcodec/get_bits.h
libavcodec/h261dec.c
libavcodec/h261enc.c
libavcodec/h263.c
libavcodec/h263.h
libavcodec/h263data.h
libavcodec/h263dec.c
libavcodec/huffman.c
libavcodec/huffyuv.c
libavcodec/indeo3.c
libavcodec/indeo5.c
libavcodec/intelh263dec.c
libavcodec/ituh263dec.c
libavcodec/ituh263enc.c
libavcodec/ivi_common.c
libavcodec/mimic.c
libavcodec/mjpegdec.c
libavcodec/motionpixels.c
libavcodec/mpc8.c
libavcodec/mpeg12.c
libavcodec/mpeg12enc.c
libavcodec/mpeg4videodec.c
libavcodec/mpeg4videoenc.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo_common.h
libavcodec/mpegvideo_enc.c
libavcodec/msmpeg4.c
libavcodec/msmpeg4data.c
libavcodec/nuv.c
libavcodec/rl.h
libavcodec/rtjpeg.h
libavcodec/rv10.c
libavcodec/rv34.c
libavcodec/rv34data.h
libavcodec/rv40.c
libavcodec/sipr.c
libavcodec/smacker.c
libavcodec/snow.c
libavcodec/snowdec.c
libavcodec/snowenc.c
libavcodec/svq1dec.c
libavcodec/svq1enc.c
libavcodec/truemotion2.c
libavcodec/utvideo.c
libavcodec/vc1dec.c
libavcodec/vorbis.c
libavcodec/vorbis.h
libavcodec/vorbisdec.c
libavcodec/vorbisenc.c
libavcodec/vp3.c
libavcodec/vp6.c
libavcodec/wma.c
libavcodec/wmv2enc.c
libavfilter/formats.c
libavformat/utils.c
libavutil/eval.c
tests/ref/fate/eval

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -415,10 -390,10 +415,10 @@@ static av_cold int dnxhd_decode_close(A
      DNXHDContext *ctx = avctx->priv_data;
  
      if (ctx->picture.data[0])
 -        avctx->release_buffer(avctx, &ctx->picture);
 +        ff_thread_release_buffer(avctx, &ctx->picture);
-     free_vlc(&ctx->ac_vlc);
-     free_vlc(&ctx->dc_vlc);
-     free_vlc(&ctx->run_vlc);
+     ff_free_vlc(&ctx->ac_vlc);
+     ff_free_vlc(&ctx->dc_vlc);
+     ff_free_vlc(&ctx->run_vlc);
      return 0;
  }
  
diff --cc libavcodec/dv.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -55,12 -55,12 +55,12 @@@ extern VLC ff_h263_cbpy_vlc
  
  extern RLTable ff_h263_rl_inter;
  
- extern RLTable rl_intra_aic;
+ extern RLTable ff_rl_intra_aic;
  
- extern const uint16_t h263_format[8][2];
- extern const uint8_t modified_quant_tab[2][32];
+ extern const uint16_t ff_h263_format[8][2];
+ extern const uint8_t ff_modified_quant_tab[2][32];
 -extern uint16_t ff_mba_max[6];
 -extern uint8_t ff_mba_length[7];
 +extern const uint16_t ff_mba_max[6];
 +extern const uint8_t ff_mba_length[7];
  
  extern uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -711,13 -707,13 +711,13 @@@ av_cold int MPV_encode_init(AVCodecCont
          break;
      case CODEC_ID_H263:
          if (!CONFIG_H263_ENCODER)
 -        return -1;
 +            return -1;
-         if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format),
+         if (ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format),
                               s->width, s->height) == 8) {
 -            av_log(avctx, AV_LOG_INFO,
 +            av_log(avctx, AV_LOG_ERROR,
                     "The specified picture size of %dx%d is not valid for "
                     "the H.263 codec.\nValid sizes are 128x96, 176x144, "
 -                   "352x288, 704x576, and 1408x1152."
 +                   "352x288, 704x576, and 1408x1152. "
                     "Try H.263+.\n", s->width, s->height);
              return -1;
          }
@@@ -2086,10 -2078,9 +2086,10 @@@ static av_always_inline void encode_mb_
      case CODEC_ID_RV10:
      case CODEC_ID_RV20:
          if (CONFIG_H263_ENCODER)
-             h263_encode_mb(s, s->block, motion_x, motion_y);
+             ff_h263_encode_mb(s, s->block, motion_x, motion_y);
          break;
      case CODEC_ID_MJPEG:
 +    case CODEC_ID_AMV:
          if (CONFIG_MJPEG_ENCODER)
              ff_mjpeg_encode_mb(s, s->block);
          break;
Simple merge
Simple merge
@@@ -187,31 -180,25 +187,33 @@@ retry
          if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen))
              av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
          buf = c->decomp_buf;
 -        buf_size = c->decomp_size;
 +        buf_size = c->decomp_size - AV_LZO_OUTPUT_PADDING - outlen;
      }
      if (c->codec_frameheader) {
 -        int w, h, q;
 +        int w, h, q, res;
-         if (buf[0] != 'V' || buf_size < 12) {
-             av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame (wrong codec_tag?)\n");
+         if (buf_size < RTJPEG_HEADER_SIZE || buf[4] != RTJPEG_HEADER_SIZE ||
+             buf[5] != RTJPEG_FILE_VERSION) {
+             av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame\n");
              return AVERROR_INVALIDDATA;
          }
          w = AV_RL16(&buf[6]);
          h = AV_RL16(&buf[8]);
          q = buf[10];
 -        if (!codec_reinit(avctx, w, h, q))
 -            return -1;
++
 +        res = codec_reinit(avctx, w, h, q);
 +        if (res < 0)
 +            return res;
 +        if (res) {
 +            buf = avpkt->data;
 +            buf_size = avpkt->size;
 +            size_change = 1;
 +            goto retry;
 +        }
-         buf = &buf[12];
-         buf_size -= 12;
+         buf = &buf[RTJPEG_HEADER_SIZE];
+         buf_size -= RTJPEG_HEADER_SIZE;
      }
  
 -    if (keyframe && c->pic.data[0])
 +    if ((size_change || keyframe) && c->pic.data[0])
          avctx->release_buffer(avctx, &c->pic);
      c->pic.reference = 3;
      c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
diff --cc libavcodec/rl.h
Simple merge
Simple merge
Simple merge
@@@ -1421,65 -1421,11 +1421,15 @@@ static int rv34_decode_slice(RV34DecCon
          return -1;
      }
  
-     if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
-         if (s->width != r->si.width || s->height != r->si.height) {
-             int err;
-             av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n",
-                    r->si.width, r->si.height);
-             MPV_common_end(s);
-             s->width  = r->si.width;
-             s->height = r->si.height;
-             avcodec_set_dimensions(s->avctx, s->width, s->height);
-             if ((err = MPV_common_init(s)) < 0)
-                 return err;
-             if ((err = rv34_decoder_realloc(r)) < 0)
-                 return err;
-         }
-         s->pict_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
-         if(MPV_frame_start(s, s->avctx) < 0)
-             return -1;
-         ff_er_frame_start(s);
-         if (!r->tmp_b_block_base) {
-             int i;
-             r->tmp_b_block_base = av_malloc(s->linesize * 48);
-             for (i = 0; i < 2; i++)
-                 r->tmp_b_block_y[i] = r->tmp_b_block_base + i * 16 * s->linesize;
-             for (i = 0; i < 4; i++)
-                 r->tmp_b_block_uv[i] = r->tmp_b_block_base + 32 * s->linesize
-                                        + (i >> 1) * 8 * s->uvlinesize + (i & 1) * 16;
-         }
-         r->cur_pts = r->si.pts;
-         if(s->pict_type != AV_PICTURE_TYPE_B){
-             r->last_pts = r->next_pts;
-             r->next_pts = r->cur_pts;
-         }else{
-             int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts);
-             int dist0   = GET_PTS_DIFF(r->cur_pts,  r->last_pts);
-             int dist1   = GET_PTS_DIFF(r->next_pts, r->cur_pts);
-             if(!refdist){
-                 r->weight1 = r->weight2 = 8192;
-             }else{
-                 r->weight1 = (dist0 << 14) / refdist;
-                 r->weight2 = (dist1 << 14) / refdist;
-             }
-         }
-         s->mb_x = s->mb_y = 0;
-         ff_thread_finish_setup(s->avctx);
-     } else {
-         int slice_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
-         if (slice_type != s->pict_type) {
-             av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
-             return AVERROR_INVALIDDATA;
-         }
-         if (s->width != r->si.width || s->height != r->si.height) {
-             av_log(s->avctx, AV_LOG_ERROR, "Size mismatch\n");
-             return AVERROR_INVALIDDATA;
-         }
+     slice_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
+     if (slice_type != s->pict_type) {
+         av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
+         return AVERROR_INVALIDDATA;
+     }
++    if (s->width != r->si.width || s->height != r->si.height) {
++        av_log(s->avctx, AV_LOG_ERROR, "Size mismatch\n");
++        return AVERROR_INVALIDDATA;
 +    }
  
      r->si.end = end;
      s->qscale = r->si.quant;
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -578,15 -574,11 +578,19 @@@ static int vorbis_parse_setup_hdr_floor
              }
  
  // Precalculate order of x coordinates - needed for decode
-             ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim);
+             if (ff_vorbis_ready_floor1_list(vc->avccontext,
+                                             floor_setup->data.t1.list,
+                                             floor_setup->data.t1.x_list_dim)) {
+                 return AVERROR_INVALIDDATA;
+             }
 +
 +            for (j=1; j<floor_setup->data.t1.x_list_dim; j++) {
 +                if (   floor_setup->data.t1.list[ floor_setup->data.t1.list[j-1].sort ].x
 +                    == floor_setup->data.t1.list[ floor_setup->data.t1.list[j  ].sort ].x) {
 +                    av_log(vc->avccontext, AV_LOG_ERROR, "Non unique x values in floor type 1\n");
 +                    return AVERROR_INVALIDDATA;
 +                }
 +            }
          } else if (floor_setup->floor_type == 0) {
              unsigned max_codebook_dim = 0;
  
@@@ -952,33 -999,7 +999,6 @@@ static int apply_window_and_mdct(vorbis
      return 1;
  }
  
- static av_cold int vorbis_encode_init(AVCodecContext *avccontext)
- {
-     vorbis_enc_context *venc = avccontext->priv_data;
-     if (avccontext->channels != 2) {
-         av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
-         return -1;
-     }
-     create_vorbis_context(venc, avccontext);
-     if (avccontext->flags & CODEC_FLAG_QSCALE)
-         venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;
-     else
-         venc->quality = 0.03;
-     venc->quality *= venc->quality;
-     avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
-     avccontext->frame_size     = 1 << (venc->log2_blocksize[0] - 1);
-     avccontext->coded_frame            = avcodec_alloc_frame();
-     avccontext->coded_frame->key_frame = 1;
-     return 0;
- }
--
  static int vorbis_encode_frame(AVCodecContext *avccontext,
                                 unsigned char *packets,
                                 int buf_size, void *data)
@@@ -1102,6 -1123,43 +1122,43 @@@ static av_cold int vorbis_encode_close(
      return 0 ;
  }
  
 -        av_log(avccontext, AV_LOG_ERROR, "Current Libav Vorbis encoder only supports 2 channels.\n");
+ static av_cold int vorbis_encode_init(AVCodecContext *avccontext)
+ {
+     vorbis_enc_context *venc = avccontext->priv_data;
+     int ret;
+     if (avccontext->channels != 2) {
++        av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
+         return -1;
+     }
+     if ((ret = create_vorbis_context(venc, avccontext)) < 0)
+         goto error;
+     if (avccontext->flags & CODEC_FLAG_QSCALE)
+         venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;
+     else
+         venc->quality = 0.03;
+     venc->quality *= venc->quality;
+     if ((ret = put_main_header(venc, (uint8_t**)&avccontext->extradata)) < 0)
+         goto error;
+     avccontext->extradata_size = ret;
+     avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1);
+     avccontext->coded_frame = avcodec_alloc_frame();
+     if (!avccontext->coded_frame) {
+         ret = AVERROR(ENOMEM);
+         goto error;
+     }
+     return 0;
+ error:
+     vorbis_encode_close(avccontext);
+     return ret;
+ }
  AVCodec ff_vorbis_encoder = {
      .name           = "vorbis",
      .type           = AVMEDIA_TYPE_AUDIO,
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -45,10 -43,11 +45,13 @@@ static void merge_ref(AVFilterFormats *
  AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
  {
      AVFilterFormats *ret;
 -    unsigned i, j, k = 0, m_count;
 +    unsigned i, j, k = 0;
 +
 +    if (a == b) return a;
  
+     if (a == b)
+         return a;
      ret = av_mallocz(sizeof(AVFilterFormats));
  
      /* merge list of formats */
Simple merge
Simple merge
Simple merge