Merge commit '73e8fab31dc19c4371499e612856accbc00b2820'
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 14 Feb 2014 12:35:45 +0000 (13:35 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 14 Feb 2014 12:35:45 +0000 (13:35 +0100)
* commit '73e8fab31dc19c4371499e612856accbc00b2820':
  h264: print values in case of error

Conflicts:
libavcodec/h264.c
libavcodec/h264_ps.c

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

@@@ -1506,8 -1466,9 +1506,9 @@@ int ff_h264_decode_extradata(H264Contex
  
          h->is_avc = 1;
  
 -        if (avctx->extradata_size < 7) {
 +        if (size < 7) {
-             av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
+             av_log(avctx, AV_LOG_ERROR,
 -                   "avcC %d too short\n", avctx->extradata_size);
++                   "avcC %d too short\n", size);
              return AVERROR_INVALIDDATA;
          }
          /* sps and pps in the avcC always have length coded with 2 bytes,
@@@ -3474,8 -3367,8 +3474,8 @@@ static int decode_slice_header(H264Cont
      slice_type = get_ue_golomb_31(&h->gb);
      if (slice_type > 9) {
          av_log(h->avctx, AV_LOG_ERROR,
-                "slice type too large (%d) at %d %d\n",
+                "slice type %d too large at %d %d\n",
 -               h->slice_type, h->mb_x, h->mb_y);
 +               slice_type, h->mb_x, h->mb_y);
          return AVERROR_INVALIDDATA;
      }
      if (slice_type > 4) {
@@@ -4569,11 -4384,9 +4569,11 @@@ static int decode_slice(struct AVCodecC
                      loop_filter(h, lf_x_start, h->mb_x + 1);
                  return 0;
              }
 -            if (ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) {
 +            if (h->cabac.bytestream > h->cabac.bytestream_end + 2 )
 +                av_log(h->avctx, AV_LOG_DEBUG, "bytestream overread %td\n", h->cabac.bytestream_end - h->cabac.bytestream);
 +            if (ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 4) {
                  av_log(h->avctx, AV_LOG_ERROR,
-                        "error while decoding MB %d %d, bytestream (%td)\n",
+                        "error while decoding MB %d %d, bytestream %td\n",
                         h->mb_x, h->mb_y,
                         h->cabac.bytestream_end - h->cabac.bytestream);
                  er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x,
Simple merge
@@@ -437,11 -392,10 +437,12 @@@ int ff_h264_decode_seq_parameter_set(H2
      }
  
      sps->ref_frame_count = get_ue_golomb_31(&h->gb);
 +    if (h->avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
 +        sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
      if (sps->ref_frame_count > MAX_PICTURE_COUNT - 2 ||
 -        sps->ref_frame_count >= 32U) {
 +        sps->ref_frame_count > 16U) {
-         av_log(h->avctx, AV_LOG_ERROR, "too many reference frames\n");
+         av_log(h->avctx, AV_LOG_ERROR,
+                "too many reference frames %d\n", sps->ref_frame_count);
          goto fail;
      }
      sps->gaps_in_frame_num_allowed_flag = get_bits1(&h->gb);
@@@ -601,8 -530,13 +602,8 @@@ int ff_h264_decode_picture_parameter_se
      int bits_left;
  
      if (pps_id >= MAX_PPS_COUNT) {
-         av_log(h->avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id);
+         av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
          return AVERROR_INVALIDDATA;
 -    } else if (h->sps.bit_depth_luma > 10) {
 -        av_log(h->avctx, AV_LOG_ERROR,
 -               "Unimplemented luma bit depth=%d (max=10)\n",
 -               h->sps.bit_depth_luma);
 -        return AVERROR_PATCHWELCOME;
      }
  
      pps = av_mallocz(sizeof(PPS));
      pps->sps_id = get_ue_golomb_31(&h->gb);
      if ((unsigned)pps->sps_id >= MAX_SPS_COUNT ||
          h->sps_buffers[pps->sps_id] == NULL) {
-         av_log(h->avctx, AV_LOG_ERROR, "sps_id out of range\n");
+         av_log(h->avctx, AV_LOG_ERROR, "sps_id %u out of range\n", pps->sps_id);
          goto fail;
      }
 +    sps = h->sps_buffers[pps->sps_id];
 +    qp_bd_offset = 6 * (sps->bit_depth_luma - 8);
 +    if (sps->bit_depth_luma > 14) {
 +        av_log(h->avctx, AV_LOG_ERROR,
 +               "Invalid luma bit depth=%d\n",
 +               sps->bit_depth_luma);
 +        goto fail;
 +    } else if (sps->bit_depth_luma == 11 || sps->bit_depth_luma == 13) {
 +        av_log(h->avctx, AV_LOG_ERROR,
 +               "Unimplemented luma bit depth=%d\n",
 +               sps->bit_depth_luma);
 +        goto fail;
 +    }
  
      pps->cabac             = get_bits1(&h->gb);
      pps->pic_order_present = get_bits1(&h->gb);