]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/error_resilience.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / error_resilience.c
index 1c1420f93ce8f6bb6bcf35f940cb75bace323afe..63f996ccde11f699a743eddd8c964e8b30deb1e9 100644 (file)
@@ -48,24 +48,31 @@ static void decode_mb(MpegEncContext *s, int ref)
 
     ff_init_block_index(s);
     ff_update_block_index(s);
+    s->dest[1] += (16 >> s->chroma_x_shift) - 8;
+    s->dest[2] += (16 >> s->chroma_x_shift) - 8;
 
     if (CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264) {
         H264Context *h = (void*)s;
         h->mb_xy = s->mb_x + s->mb_y * s->mb_stride;
         memset(h->non_zero_count_cache, 0, sizeof(h->non_zero_count_cache));
-        assert(ref >= 0);
+        av_assert1(ref >= 0);
         /* FIXME: It is possible albeit uncommon that slice references
          * differ between slices. We take the easy approach and ignore
          * it for now. If this turns out to have any relevance in
          * practice then correct remapping should be added. */
         if (ref >= h->ref_count[0])
             ref = 0;
+        if (!h->ref_list[0][ref].f.data[0]) {
+            av_log(s->avctx, AV_LOG_DEBUG, "Reference not available for error concealing\n");
+            ref = 0;
+        }
         fill_rectangle(&s->current_picture.f.ref_index[0][4 * h->mb_xy],
                        2, 2, 2, ref, 1);
         fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
         fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8,
                        pack16to32(s->mv[0][0][0], s->mv[0][0][1]), 4);
-        assert(!FRAME_MBAFF);
+        h->mb_mbaff =
+        h->mb_field_decoding_flag = 0;
         ff_h264_hl_decode_mb(h);
     } else {
         assert(ref == 0);
@@ -81,7 +88,7 @@ static void set_mv_strides(MpegEncContext *s, int *mv_step, int *stride)
 {
     if (s->codec_id == CODEC_ID_H264) {
         H264Context *h = (void*)s;
-        assert(s->quarter_sample);
+        av_assert0(s->quarter_sample);
         *mv_step = 4;
         *stride  = h->b_stride;
     } else {
@@ -174,7 +181,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
 {
     int b_x, b_y;
     int16_t  (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4);
-    uint16_t (*dist)[4] = av_malloc(stride*h*sizeof(uint16_t)*4);
+    uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4);
 
     for(b_y=0; b_y<h; b_y++){
         int color= 1024;
@@ -248,7 +255,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
             weight_sum = 0;
             guess      = 0;
             for (j = 0; j < 4; j++) {
-                int64_t weight  = 256 * 256 * 256 * 16 / dist[b_x + b_y*stride][j];
+                int64_t weight  = 256 * 256 * 256 * 16 / FFMAX(dist[b_x + b_y*stride][j], 1);
                 guess          += weight*(int64_t)col[b_x + b_y*stride][j];
                 weight_sum     += weight;
             }
@@ -493,8 +500,8 @@ static void guess_mv(MpegEncContext *s)
 
                     if (fixed[mb_xy] == MV_FROZEN)
                         continue;
-                    assert(!IS_INTRA(s->current_picture.f.mb_type[mb_xy]));
-                    assert(s->last_picture_ptr && s->last_picture_ptr->f.data[0]);
+                    av_assert1(!IS_INTRA(s->current_picture.f.mb_type[mb_xy]));
+                    av_assert1(s->last_picture_ptr && s->last_picture_ptr->f.data[0]);
 
                     j = 0;
                     if (mb_x > 0             && fixed[mb_xy - 1]         == MV_FROZEN)