[FFmpeg-cvslog] Merge commit 'ecc31f6b086453ab9811dce2ae5ceb6a7c19e4ad'

Derek Buitenhuis git at videolan.org
Wed Apr 27 17:34:55 CEST 2016


ffmpeg | branch: master | Derek Buitenhuis <derek.buitenhuis at gmail.com> | Wed Apr 27 16:34:40 2016 +0100| [a2922b5d614ca6db025364f47bc4a1e4812859aa] | committer: Derek Buitenhuis

Merge commit 'ecc31f6b086453ab9811dce2ae5ceb6a7c19e4ad'

* commit 'ecc31f6b086453ab9811dce2ae5ceb6a7c19e4ad':
  h264: move ff_h264_check_intra[4x4]_pred_mode() to h264_parse

Merged-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2922b5d614ca6db025364f47bc4a1e4812859aa
---

 libavcodec/Makefile     |    2 +-
 libavcodec/h264.c       |   93 -----------------------------------------------
 libavcodec/h264.h       |   13 -------
 libavcodec/h264_cabac.c |   10 +++--
 libavcodec/h264_cavlc.c |    9 +++--
 libavcodec/h264_parse.c |   92 ++++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/h264_parse.h |   15 ++++++++
 libavcodec/svq3.c       |   10 +++--
 8 files changed, 128 insertions(+), 116 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4cda4dc..8f63261 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -509,7 +509,7 @@ OBJS-$(CONFIG_SUNRAST_ENCODER)         += sunrastenc.o
 OBJS-$(CONFIG_SVQ1_DECODER)            += svq1dec.o svq1.o svq13.o h263data.o
 OBJS-$(CONFIG_SVQ1_ENCODER)            += svq1enc.o svq1.o  h263data.o  \
                                           h263.o ituh263enc.o
-OBJS-$(CONFIG_SVQ3_DECODER)            += svq3.o svq13.o mpegutils.o
+OBJS-$(CONFIG_SVQ3_DECODER)            += svq3.o svq13.o mpegutils.o h264_parse.o
 OBJS-$(CONFIG_TEXT_DECODER)            += textdec.o ass.o
 OBJS-$(CONFIG_TEXT_ENCODER)            += srtenc.o ass_split.o
 OBJS-$(CONFIG_TAK_DECODER)             += takdec.o tak.o takdsp.o
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 5a0f0bb..6dbe5c7 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -132,99 +132,6 @@ void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl,
     }
 }
 
-/**
- * Check if the top & left blocks are available if needed and
- * change the dc mode so it only uses the available blocks.
- */
-int ff_h264_check_intra4x4_pred_mode(const H264Context *h, H264SliceContext *sl)
-{
-    static const int8_t top[12] = {
-        -1, 0, LEFT_DC_PRED, -1, -1, -1, -1, -1, 0
-    };
-    static const int8_t left[12] = {
-        0, -1, TOP_DC_PRED, 0, -1, -1, -1, 0, -1, DC_128_PRED
-    };
-    int i;
-
-    if (!(sl->top_samples_available & 0x8000)) {
-        for (i = 0; i < 4; i++) {
-            int status = top[sl->intra4x4_pred_mode_cache[scan8[0] + i]];
-            if (status < 0) {
-                av_log(h->avctx, AV_LOG_ERROR,
-                       "top block unavailable for requested intra4x4 mode %d at %d %d\n",
-                       status, sl->mb_x, sl->mb_y);
-                return AVERROR_INVALIDDATA;
-            } else if (status) {
-                sl->intra4x4_pred_mode_cache[scan8[0] + i] = status;
-            }
-        }
-    }
-
-    if ((sl->left_samples_available & 0x8888) != 0x8888) {
-        static const int mask[4] = { 0x8000, 0x2000, 0x80, 0x20 };
-        for (i = 0; i < 4; i++)
-            if (!(sl->left_samples_available & mask[i])) {
-                int status = left[sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i]];
-                if (status < 0) {
-                    av_log(h->avctx, AV_LOG_ERROR,
-                           "left block unavailable for requested intra4x4 mode %d at %d %d\n",
-                           status, sl->mb_x, sl->mb_y);
-                    return AVERROR_INVALIDDATA;
-                } else if (status) {
-                    sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i] = status;
-                }
-            }
-    }
-
-    return 0;
-} // FIXME cleanup like ff_h264_check_intra_pred_mode
-
-/**
- * Check if the top & left blocks are available if needed and
- * change the dc mode so it only uses the available blocks.
- */
-int ff_h264_check_intra_pred_mode(const H264Context *h, H264SliceContext *sl,
-                                  int mode, int is_chroma)
-{
-    static const int8_t top[4]  = { LEFT_DC_PRED8x8, 1, -1, -1 };
-    static const int8_t left[5] = { TOP_DC_PRED8x8, -1,  2, -1, DC_128_PRED8x8 };
-
-    if (mode > 3U) {
-        av_log(h->avctx, AV_LOG_ERROR,
-               "out of range intra chroma pred mode at %d %d\n",
-               sl->mb_x, sl->mb_y);
-        return AVERROR_INVALIDDATA;
-    }
-
-    if (!(sl->top_samples_available & 0x8000)) {
-        mode = top[mode];
-        if (mode < 0) {
-            av_log(h->avctx, AV_LOG_ERROR,
-                   "top block unavailable for requested intra mode at %d %d\n",
-                   sl->mb_x, sl->mb_y);
-            return AVERROR_INVALIDDATA;
-        }
-    }
-
-    if ((sl->left_samples_available & 0x8080) != 0x8080) {
-        mode = left[mode];
-        if (mode < 0) {
-            av_log(h->avctx, AV_LOG_ERROR,
-                   "left block unavailable for requested intra mode at %d %d\n",
-                   sl->mb_x, sl->mb_y);
-            return AVERROR_INVALIDDATA;
-        }
-        if (is_chroma && (sl->left_samples_available & 0x8080)) {
-            // mad cow disease mode, aka MBAFF + constrained_intra_pred
-            mode = ALZHEIMER_DC_L0T_PRED8x8 +
-                   (!(sl->left_samples_available & 0x8000)) +
-                   2 * (mode == DC_128_PRED8x8);
-        }
-    }
-
-    return mode;
-}
-
 const uint8_t *ff_h264_decode_nal(H264Context *h, H264SliceContext *sl,
                                   const uint8_t *src,
                                   int *dst_length, int *consumed, int length)
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index e655995..302f09a 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -900,19 +900,6 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
 
 int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice);
 
-/**
- * Check if the top & left blocks are available if needed & change the
- * dc mode so it only uses the available blocks.
- */
-int ff_h264_check_intra4x4_pred_mode(const H264Context *h, H264SliceContext *sl);
-
-/**
- * Check if the top & left blocks are available if needed & change the
- * dc mode so it only uses the available blocks.
- */
-int ff_h264_check_intra_pred_mode(const H264Context *h, H264SliceContext *sl,
-                                  int mode, int is_chroma);
-
 void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl);
 int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size);
 int ff_h264_decode_init(AVCodecContext *avctx);
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index cb98eb5..3df0f70 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -2085,16 +2085,20 @@ decode_intra_mb:
                 }
             }
             write_back_intra_pred_mode(h, sl);
-            if (ff_h264_check_intra4x4_pred_mode(h, sl) < 0 ) return -1;
+            if (ff_h264_check_intra4x4_pred_mode(sl->intra4x4_pred_mode_cache, h->avctx,
+                                                 sl->top_samples_available, sl->left_samples_available) < 0 )
+                return -1;
         } else {
-            sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, sl, sl->intra16x16_pred_mode, 0);
+            sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available,
+                                                                     sl->left_samples_available, sl->intra16x16_pred_mode, 0);
             if (sl->intra16x16_pred_mode < 0) return -1;
         }
         if(decode_chroma){
             h->chroma_pred_mode_table[mb_xy] =
             pred_mode                        = decode_cabac_mb_chroma_pre_mode(h, sl);
 
-            pred_mode= ff_h264_check_intra_pred_mode(h, sl, pred_mode, 1 );
+            pred_mode= ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available,
+                                                     sl->left_samples_available, pred_mode, 1 );
             if( pred_mode < 0 ) return -1;
             sl->chroma_pred_mode = pred_mode;
         } else {
diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index 2996cfd..be53914 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -825,15 +825,18 @@ decode_intra_mb:
                     sl->intra4x4_pred_mode_cache[scan8[i]] = mode;
             }
             write_back_intra_pred_mode(h, sl);
-            if (ff_h264_check_intra4x4_pred_mode(h, sl) < 0)
+            if (ff_h264_check_intra4x4_pred_mode(sl->intra4x4_pred_mode_cache, h->avctx,
+                                                 sl->top_samples_available, sl->left_samples_available) < 0)
                 return -1;
         }else{
-            sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, sl, sl->intra16x16_pred_mode, 0);
+            sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available,
+                                                                     sl->left_samples_available, sl->intra16x16_pred_mode, 0);
             if (sl->intra16x16_pred_mode < 0)
                 return -1;
         }
         if(decode_chroma){
-            pred_mode= ff_h264_check_intra_pred_mode(h, sl, get_ue_golomb_31(&sl->gb), 1);
+            pred_mode= ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available,
+                                                     sl->left_samples_available, get_ue_golomb_31(&sl->gb), 1);
             if(pred_mode < 0)
                 return -1;
             sl->chroma_pred_mode = pred_mode;
diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index ebd87b0..e6cc28e 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -94,3 +94,95 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
     pwt->use_weight = pwt->use_weight || pwt->use_weight_chroma;
     return 0;
 }
+
+/**
+ * Check if the top & left blocks are available if needed and
+ * change the dc mode so it only uses the available blocks.
+ */
+int ff_h264_check_intra4x4_pred_mode(int8_t *pred_mode_cache, void *logctx,
+                                     int top_samples_available, int left_samples_available)
+{
+    static const int8_t top[12] = {
+        -1, 0, LEFT_DC_PRED, -1, -1, -1, -1, -1, 0
+    };
+    static const int8_t left[12] = {
+        0, -1, TOP_DC_PRED, 0, -1, -1, -1, 0, -1, DC_128_PRED
+    };
+    int i;
+
+    if (!(top_samples_available & 0x8000)) {
+        for (i = 0; i < 4; i++) {
+            int status = top[pred_mode_cache[scan8[0] + i]];
+            if (status < 0) {
+                av_log(logctx, AV_LOG_ERROR,
+					   "top block unavailable for requested intra mode %d\n",
+                       status);
+                return AVERROR_INVALIDDATA;
+            } else if (status) {
+                pred_mode_cache[scan8[0] + i] = status;
+            }
+        }
+    }
+
+    if ((left_samples_available & 0x8888) != 0x8888) {
+        static const int mask[4] = { 0x8000, 0x2000, 0x80, 0x20 };
+        for (i = 0; i < 4; i++)
+            if (!(left_samples_available & mask[i])) {
+                int status = left[pred_mode_cache[scan8[0] + 8 * i]];
+                if (status < 0) {
+                    av_log(logctx, AV_LOG_ERROR,
+                           "left block unavailable for requested intra4x4 mode %d\n",
+                           status);
+                    return AVERROR_INVALIDDATA;
+                } else if (status) {
+                    pred_mode_cache[scan8[0] + 8 * i] = status;
+                }
+            }
+    }
+
+    return 0;
+}
+
+/**
+ * Check if the top & left blocks are available if needed and
+ * change the dc mode so it only uses the available blocks.
+ */
+int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available,
+                                  int left_samples_available,
+                                  int mode, int is_chroma)
+{
+    static const int8_t top[4]  = { LEFT_DC_PRED8x8, 1, -1, -1 };
+    static const int8_t left[5] = { TOP_DC_PRED8x8, -1,  2, -1, DC_128_PRED8x8 };
+
+    if (mode > 3U) {
+        av_log(logctx, AV_LOG_ERROR,
+               "out of range intra chroma pred mode\n");
+        return AVERROR_INVALIDDATA;
+    }
+
+    if (!(top_samples_available & 0x8000)) {
+        mode = top[mode];
+        if (mode < 0) {
+            av_log(logctx, AV_LOG_ERROR,
+                   "top block unavailable for requested intra mode\n");
+            return AVERROR_INVALIDDATA;
+        }
+    }
+
+    if ((left_samples_available & 0x8080) != 0x8080) {
+        mode = left[mode];
+        if (mode < 0) {
+            av_log(logctx, AV_LOG_ERROR,
+                   "left block unavailable for requested intra mode\n");
+            return AVERROR_INVALIDDATA;
+        }
+        if (is_chroma && (left_samples_available & 0x8080)) {
+            // mad cow disease mode, aka MBAFF + constrained_intra_pred
+            mode = ALZHEIMER_DC_L0T_PRED8x8 +
+                   (!(left_samples_available & 0x8000)) +
+                   2 * (mode == DC_128_PRED8x8);
+        }
+    }
+
+    return mode;
+}
diff --git a/libavcodec/h264_parse.h b/libavcodec/h264_parse.h
index d1a7af0..8329351 100644
--- a/libavcodec/h264_parse.h
+++ b/libavcodec/h264_parse.h
@@ -45,4 +45,19 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const struct SPS *sps,
                               const int *ref_count, int slice_type_nos,
                               H264PredWeightTable *pwt);
 
+/**
+ * Check if the top & left blocks are available if needed & change the
+ * dc mode so it only uses the available blocks.
+ */
+int ff_h264_check_intra4x4_pred_mode(int8_t *pred_mode_cache, void *logctx,
+                                     int top_samples_available, int left_samples_available);
+
+/**
+ * Check if the top & left blocks are available if needed & change the
+ * dc mode so it only uses the available blocks.
+ */
+int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available,
+                                  int left_samples_available,
+                                  int mode, int is_chroma);
+
 #endif /* AVCODEC_H264_PARSE_H */
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 0cf9159..01bac4a 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -778,7 +778,9 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
         i4x4[6] = i4x4_cache[7 + 8 * 1];
 
         if (mb_type == 8) {
-            ff_h264_check_intra4x4_pred_mode(h, sl);
+            ff_h264_check_intra4x4_pred_mode(sl->intra4x4_pred_mode_cache,
+                                             h->avctx, sl->top_samples_available,
+                                             sl->left_samples_available);
 
             sl->top_samples_available  = (s->mb_y == 0) ? 0x33FF : 0xFFFF;
             sl->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;
@@ -795,7 +797,8 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
         dir = ff_h264_i_mb_type_info[mb_type - 8].pred_mode;
         dir = (dir >> 1) ^ 3 * (dir & 1) ^ 1;
 
-        if ((sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, sl, dir, 0)) < 0) {
+        if ((sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available,
+                                                                      sl->left_samples_available, dir, 0)) < 0) {
             av_log(h->avctx, AV_LOG_ERROR, "ff_h264_check_intra_pred_mode < 0\n");
             return sl->intra16x16_pred_mode;
         }
@@ -899,7 +902,8 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
     h->cur_pic.mb_type[mb_xy] = mb_type;
 
     if (IS_INTRA(mb_type))
-        sl->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, sl, DC_PRED8x8, 1);
+        sl->chroma_pred_mode = ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available,
+                                                             sl->left_samples_available, DC_PRED8x8, 1);
 
     return 0;
 }


======================================================================

diff --cc libavcodec/Makefile
index 4cda4dc,e66ec51..8f63261
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@@ -509,22 -418,17 +509,22 @@@ OBJS-$(CONFIG_SUNRAST_ENCODER)         
  OBJS-$(CONFIG_SVQ1_DECODER)            += svq1dec.o svq1.o svq13.o h263data.o
  OBJS-$(CONFIG_SVQ1_ENCODER)            += svq1enc.o svq1.o  h263data.o  \
                                            h263.o ituh263enc.o
- OBJS-$(CONFIG_SVQ3_DECODER)            += svq3.o svq13.o mpegutils.o
+ OBJS-$(CONFIG_SVQ3_DECODER)            += svq3.o svq13.o mpegutils.o h264_parse.o
 -OBJS-$(CONFIG_TAK_DECODER)             += takdec.o tak.o
 +OBJS-$(CONFIG_TEXT_DECODER)            += textdec.o ass.o
 +OBJS-$(CONFIG_TEXT_ENCODER)            += srtenc.o ass_split.o
 +OBJS-$(CONFIG_TAK_DECODER)             += takdec.o tak.o takdsp.o
  OBJS-$(CONFIG_TARGA_DECODER)           += targa.o
  OBJS-$(CONFIG_TARGA_ENCODER)           += targaenc.o rle.o
 +OBJS-$(CONFIG_TARGA_Y216_DECODER)      += targa_y216dec.o
  OBJS-$(CONFIG_TDSC_DECODER)            += tdsc.o
  OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
 -OBJS-$(CONFIG_TIFF_DECODER)            += tiff.o lzw.o faxcompr.o
 -OBJS-$(CONFIG_TIFF_ENCODER)            += tiffenc.o rle.o lzwenc.o
 +OBJS-$(CONFIG_TIFF_DECODER)            += tiff.o lzw.o faxcompr.o tiff_data.o tiff_common.o
 +OBJS-$(CONFIG_TIFF_ENCODER)            += tiffenc.o rle.o lzwenc.o tiff_data.o
  OBJS-$(CONFIG_TMV_DECODER)             += tmv.o cga_data.o
 +OBJS-$(CONFIG_TRUEHD_DECODER)          += mlpdec.o mlpdsp.o
  OBJS-$(CONFIG_TRUEMOTION1_DECODER)     += truemotion1.o
  OBJS-$(CONFIG_TRUEMOTION2_DECODER)     += truemotion2.o
 +OBJS-$(CONFIG_TRUEMOTION2RT_DECODER)   += truemotion2rt.o
  OBJS-$(CONFIG_TRUESPEECH_DECODER)      += truespeech.o
  OBJS-$(CONFIG_TSCC_DECODER)            += tscc.o msrledec.o
  OBJS-$(CONFIG_TSCC2_DECODER)           += tscc2.o
diff --cc libavcodec/h264.h
index e655995,e00ce88..302f09a
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@@ -900,21 -808,8 +900,8 @@@ int ff_h264_decode_ref_pic_marking(H264
  
  int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice);
  
- /**
-  * Check if the top & left blocks are available if needed & change the
-  * dc mode so it only uses the available blocks.
-  */
- int ff_h264_check_intra4x4_pred_mode(const H264Context *h, H264SliceContext *sl);
- 
- /**
-  * Check if the top & left blocks are available if needed & change the
-  * dc mode so it only uses the available blocks.
-  */
- int ff_h264_check_intra_pred_mode(const H264Context *h, H264SliceContext *sl,
-                                   int mode, int is_chroma);
- 
  void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl);
 -int ff_h264_decode_extradata(H264Context *h);
 +int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size);
  int ff_h264_decode_init(AVCodecContext *avctx);
  void ff_h264_decode_init_vlc(void);
  
diff --cc libavcodec/h264_parse.c
index ebd87b0,50b1118..e6cc28e
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@@ -94,3 -84,95 +94,95 @@@ int ff_h264_pred_weight_table(GetBitCon
      pwt->use_weight = pwt->use_weight || pwt->use_weight_chroma;
      return 0;
  }
+ 
+ /**
+  * Check if the top & left blocks are available if needed and
+  * change the dc mode so it only uses the available blocks.
+  */
+ int ff_h264_check_intra4x4_pred_mode(int8_t *pred_mode_cache, void *logctx,
+                                      int top_samples_available, int left_samples_available)
+ {
+     static const int8_t top[12] = {
+         -1, 0, LEFT_DC_PRED, -1, -1, -1, -1, -1, 0
+     };
+     static const int8_t left[12] = {
+         0, -1, TOP_DC_PRED, 0, -1, -1, -1, 0, -1, DC_128_PRED
+     };
+     int i;
+ 
+     if (!(top_samples_available & 0x8000)) {
+         for (i = 0; i < 4; i++) {
+             int status = top[pred_mode_cache[scan8[0] + i]];
+             if (status < 0) {
+                 av_log(logctx, AV_LOG_ERROR,
 -                       "top block unavailable for requested intra4x4 mode %d\n",
++					   "top block unavailable for requested intra mode %d\n",
+                        status);
+                 return AVERROR_INVALIDDATA;
+             } else if (status) {
+                 pred_mode_cache[scan8[0] + i] = status;
+             }
+         }
+     }
+ 
+     if ((left_samples_available & 0x8888) != 0x8888) {
+         static const int mask[4] = { 0x8000, 0x2000, 0x80, 0x20 };
+         for (i = 0; i < 4; i++)
+             if (!(left_samples_available & mask[i])) {
+                 int status = left[pred_mode_cache[scan8[0] + 8 * i]];
+                 if (status < 0) {
+                     av_log(logctx, AV_LOG_ERROR,
+                            "left block unavailable for requested intra4x4 mode %d\n",
+                            status);
+                     return AVERROR_INVALIDDATA;
+                 } else if (status) {
+                     pred_mode_cache[scan8[0] + 8 * i] = status;
+                 }
+             }
+     }
+ 
+     return 0;
+ }
+ 
+ /**
+  * Check if the top & left blocks are available if needed and
+  * change the dc mode so it only uses the available blocks.
+  */
+ int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available,
+                                   int left_samples_available,
+                                   int mode, int is_chroma)
+ {
+     static const int8_t top[4]  = { LEFT_DC_PRED8x8, 1, -1, -1 };
+     static const int8_t left[5] = { TOP_DC_PRED8x8, -1,  2, -1, DC_128_PRED8x8 };
+ 
+     if (mode > 3U) {
+         av_log(logctx, AV_LOG_ERROR,
+                "out of range intra chroma pred mode\n");
+         return AVERROR_INVALIDDATA;
+     }
+ 
+     if (!(top_samples_available & 0x8000)) {
+         mode = top[mode];
+         if (mode < 0) {
+             av_log(logctx, AV_LOG_ERROR,
+                    "top block unavailable for requested intra mode\n");
+             return AVERROR_INVALIDDATA;
+         }
+     }
+ 
+     if ((left_samples_available & 0x8080) != 0x8080) {
+         mode = left[mode];
++        if (mode < 0) {
++            av_log(logctx, AV_LOG_ERROR,
++                   "left block unavailable for requested intra mode\n");
++            return AVERROR_INVALIDDATA;
++        }
+         if (is_chroma && (left_samples_available & 0x8080)) {
+             // mad cow disease mode, aka MBAFF + constrained_intra_pred
+             mode = ALZHEIMER_DC_L0T_PRED8x8 +
+                    (!(left_samples_available & 0x8000)) +
+                    2 * (mode == DC_128_PRED8x8);
+         }
 -        if (mode < 0) {
 -            av_log(logctx, AV_LOG_ERROR,
 -                   "left block unavailable for requested intra mode\n");
 -            return AVERROR_INVALIDDATA;
 -        }
+     }
+ 
+     return mode;
+ }



More information about the ffmpeg-cvslog mailing list