comparison h264.c @ 3004:a22cf6e46b0e libavcodec

CQM: fix fallback to JVT scaling lists
author lorenm
date Sat, 31 Dec 2005 13:20:24 +0000
parents 5411789c5f19
children 6f6f307cffac
comparison
equal deleted inserted replaced
3003:5411789c5f19 3004:a22cf6e46b0e
7110 } 7110 }
7111 7111
7112 return 0; 7112 return 0;
7113 } 7113 }
7114 7114
7115 static void decode_scaling_list(H264Context *h, uint8_t *factors, int size, const uint8_t *default_list){ 7115 static void decode_scaling_list(H264Context *h, uint8_t *factors, int size,
7116 const uint8_t *jvt_list, const uint8_t *fallback_list){
7116 MpegEncContext * const s = &h->s; 7117 MpegEncContext * const s = &h->s;
7117 int i, last = 8, next = 8; 7118 int i, last = 8, next = 8;
7118 const uint8_t *scan = size == 16 ? zigzag_scan : zigzag_scan8x8; 7119 const uint8_t *scan = size == 16 ? zigzag_scan : zigzag_scan8x8;
7119 if(!get_bits1(&s->gb)) /* matrix not written, we use the default one */ 7120 if(!get_bits1(&s->gb)) /* matrix not written, we use the predicted one */
7120 memcpy(factors, default_list, size*sizeof(uint8_t)); 7121 memcpy(factors, fallback_list, size*sizeof(uint8_t));
7121 else 7122 else
7122 for(i=0;i<size;i++){ 7123 for(i=0;i<size;i++){
7123 if(next) 7124 if(next)
7124 next = (last + get_se_golomb(&s->gb)) & 0xff; 7125 next = (last + get_se_golomb(&s->gb)) & 0xff;
7125 if(!i && !next){ /* matrix not written, we use the default one */ 7126 if(!i && !next){ /* matrix not written, we use the preset one */
7126 memcpy(factors, default_list, size*sizeof(uint8_t)); 7127 memcpy(factors, jvt_list, size*sizeof(uint8_t));
7127 break; 7128 break;
7128 } 7129 }
7129 last = factors[scan[i]] = next ? next : last; 7130 last = factors[scan[i]] = next ? next : last;
7130 } 7131 }
7131 } 7132 }
7140 fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0], 7141 fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0],
7141 fallback_sps ? sps->scaling_matrix8[1] : default_scaling8[1] 7142 fallback_sps ? sps->scaling_matrix8[1] : default_scaling8[1]
7142 }; 7143 };
7143 if(get_bits1(&s->gb)){ 7144 if(get_bits1(&s->gb)){
7144 sps->scaling_matrix_present |= is_sps; 7145 sps->scaling_matrix_present |= is_sps;
7145 decode_scaling_list(h,scaling_matrix4[0],16,fallback[0]); // Intra, Y 7146 decode_scaling_list(h,scaling_matrix4[0],16,default_scaling4[0],fallback[0]); // Intra, Y
7146 decode_scaling_list(h,scaling_matrix4[1],16,scaling_matrix4[0]); // Intra, Cr 7147 decode_scaling_list(h,scaling_matrix4[1],16,default_scaling4[0],scaling_matrix4[0]); // Intra, Cr
7147 decode_scaling_list(h,scaling_matrix4[2],16,scaling_matrix4[1]); // Intra, Cb 7148 decode_scaling_list(h,scaling_matrix4[2],16,default_scaling4[0],scaling_matrix4[1]); // Intra, Cb
7148 decode_scaling_list(h,scaling_matrix4[3],16,fallback[1]); // Inter, Y 7149 decode_scaling_list(h,scaling_matrix4[3],16,default_scaling4[1],fallback[1]); // Inter, Y
7149 decode_scaling_list(h,scaling_matrix4[4],16,scaling_matrix4[3]); // Inter, Cr 7150 decode_scaling_list(h,scaling_matrix4[4],16,default_scaling4[1],scaling_matrix4[3]); // Inter, Cr
7150 decode_scaling_list(h,scaling_matrix4[5],16,scaling_matrix4[4]); // Inter, Cb 7151 decode_scaling_list(h,scaling_matrix4[5],16,default_scaling4[1],scaling_matrix4[4]); // Inter, Cb
7151 if(is_sps || pps->transform_8x8_mode){ 7152 if(is_sps || pps->transform_8x8_mode){
7152 decode_scaling_list(h,scaling_matrix8[0],64,fallback[2]); // Intra, Y 7153 decode_scaling_list(h,scaling_matrix8[0],64,default_scaling8[0],fallback[2]); // Intra, Y
7153 decode_scaling_list(h,scaling_matrix8[1],64,fallback[3]); // Inter, Y 7154 decode_scaling_list(h,scaling_matrix8[1],64,default_scaling8[1],fallback[3]); // Inter, Y
7154 } 7155 }
7155 } else if(fallback_sps) { 7156 } else if(fallback_sps) {
7156 memcpy(scaling_matrix4, sps->scaling_matrix4, 6*16*sizeof(uint8_t)); 7157 memcpy(scaling_matrix4, sps->scaling_matrix4, 6*16*sizeof(uint8_t));
7157 memcpy(scaling_matrix8, sps->scaling_matrix8, 2*64*sizeof(uint8_t)); 7158 memcpy(scaling_matrix8, sps->scaling_matrix8, 2*64*sizeof(uint8_t));
7158 } 7159 }