Browse code

h264: fix intra 16x16 mode check when using mbaff and constrained_intra_pred.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Laurent Aimar authored on 2011/10/03 04:07:41
Showing 5 changed files
... ...
@@ -97,12 +97,9 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h){
97 97
     }
98 98
 
99 99
     return 0;
100
-} //FIXME cleanup like ff_h264_check_intra_pred_mode
100
+} //FIXME cleanup like check_intra_pred_mode
101 101
 
102
-/**
103
- * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
104
- */
105
-int ff_h264_check_intra_pred_mode(H264Context *h, int mode){
102
+static int check_intra_pred_mode(H264Context *h, int mode, int is_chroma){
106 103
     MpegEncContext * const s = &h->s;
107 104
     static const int8_t top [7]= {LEFT_DC_PRED8x8, 1,-1,-1};
108 105
     static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8};
... ...
@@ -122,7 +119,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, int mode){
122 122
 
123 123
     if((h->left_samples_available&0x8080) != 0x8080){
124 124
         mode= left[ mode ];
125
-        if(h->left_samples_available&0x8080){ //mad cow disease mode, aka MBAFF + constrained_intra_pred
125
+        if(is_chroma && (h->left_samples_available&0x8080)){ //mad cow disease mode, aka MBAFF + constrained_intra_pred
126 126
             mode= ALZHEIMER_DC_L0T_PRED8x8 + (!(h->left_samples_available&0x8000)) + 2*(mode == DC_128_PRED8x8);
127 127
         }
128 128
         if(mode<0){
... ...
@@ -134,6 +131,23 @@ int ff_h264_check_intra_pred_mode(H264Context *h, int mode){
134 134
     return mode;
135 135
 }
136 136
 
137
+/**
138
+ * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
139
+ */
140
+int ff_h264_check_intra16x16_pred_mode(H264Context *h, int mode)
141
+{
142
+    return check_intra_pred_mode(h, mode, 0);
143
+}
144
+
145
+/**
146
+ * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
147
+ */
148
+int ff_h264_check_intra_chroma_pred_mode(H264Context *h, int mode)
149
+{
150
+    return check_intra_pred_mode(h, mode, 1);
151
+}
152
+
153
+
137 154
 const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){
138 155
     int i, si, di;
139 156
     uint8_t *dst;
... ...
@@ -668,7 +668,12 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h);
668 668
 /**
669 669
  * Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks.
670 670
  */
671
-int ff_h264_check_intra_pred_mode(H264Context *h, int mode);
671
+int ff_h264_check_intra16x16_pred_mode(H264Context *h, int mode);
672
+
673
+/**
674
+ * Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks.
675
+ */
676
+int ff_h264_check_intra_chroma_pred_mode(H264Context *h, int mode);
672 677
 
673 678
 void ff_h264_hl_decode_mb(H264Context *h);
674 679
 int ff_h264_frame_start(H264Context *h);
... ...
@@ -2013,14 +2013,14 @@ decode_intra_mb:
2013 2013
             write_back_intra_pred_mode(h);
2014 2014
             if( ff_h264_check_intra4x4_pred_mode(h) < 0 ) return -1;
2015 2015
         } else {
2016
-            h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode );
2016
+            h->intra16x16_pred_mode= ff_h264_check_intra16x16_pred_mode( h, h->intra16x16_pred_mode );
2017 2017
             if( h->intra16x16_pred_mode < 0 ) return -1;
2018 2018
         }
2019 2019
         if(decode_chroma){
2020 2020
             h->chroma_pred_mode_table[mb_xy] =
2021 2021
             pred_mode                        = decode_cabac_mb_chroma_pre_mode( h );
2022 2022
 
2023
-            pred_mode= ff_h264_check_intra_pred_mode( h, pred_mode );
2023
+            pred_mode= ff_h264_check_intra_chroma_pred_mode( h, pred_mode );
2024 2024
             if( pred_mode < 0 ) return -1;
2025 2025
             h->chroma_pred_mode= pred_mode;
2026 2026
         } else {
... ...
@@ -821,12 +821,12 @@ decode_intra_mb:
821 821
             if( ff_h264_check_intra4x4_pred_mode(h) < 0)
822 822
                 return -1;
823 823
         }else{
824
-            h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode(h, h->intra16x16_pred_mode);
824
+            h->intra16x16_pred_mode= ff_h264_check_intra16x16_pred_mode(h, h->intra16x16_pred_mode);
825 825
             if(h->intra16x16_pred_mode < 0)
826 826
                 return -1;
827 827
         }
828 828
         if(decode_chroma){
829
-            pred_mode= ff_h264_check_intra_pred_mode(h, get_ue_golomb_31(&s->gb));
829
+            pred_mode= ff_h264_check_intra_chroma_pred_mode(h, get_ue_golomb_31(&s->gb));
830 830
             if(pred_mode < 0)
831 831
                 return -1;
832 832
             h->chroma_pred_mode= pred_mode;
... ...
@@ -614,7 +614,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
614 614
         dir = i_mb_type_info[mb_type - 8].pred_mode;
615 615
         dir = (dir >> 1) ^ 3*(dir & 1) ^ 1;
616 616
 
617
-        if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir)) == -1){
617
+        if ((h->intra16x16_pred_mode = ff_h264_check_intra16x16_pred_mode(h, dir)) == -1){
618 618
             av_log(h->s.avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\n");
619 619
             return -1;
620 620
         }
... ...
@@ -713,7 +713,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
713 713
     s->current_picture.f.mb_type[mb_xy] = mb_type;
714 714
 
715 715
     if (IS_INTRA(mb_type)) {
716
-        h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8);
716
+        h->chroma_pred_mode = ff_h264_check_intra_chroma_pred_mode(h, DC_PRED8x8);
717 717
     }
718 718
 
719 719
     return 0;