Mercurial > libavcodec.hg
comparison h264.c @ 2763:01ed2c3b8f08 libavcodec
H.264 lossless mode
author | lorenm |
---|---|
date | Fri, 17 Jun 2005 08:24:35 +0000 |
parents | 64333ef1ca21 |
children | 0609f405e000 |
comparison
equal
deleted
inserted
replaced
2762:64333ef1ca21 | 2763:01ed2c3b8f08 |
---|---|
59 */ | 59 */ |
60 typedef struct SPS{ | 60 typedef struct SPS{ |
61 | 61 |
62 int profile_idc; | 62 int profile_idc; |
63 int level_idc; | 63 int level_idc; |
64 int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag | |
64 int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4 | 65 int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4 |
65 int poc_type; ///< pic_order_cnt_type | 66 int poc_type; ///< pic_order_cnt_type |
66 int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4 | 67 int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4 |
67 int delta_pic_order_always_zero_flag; | 68 int delta_pic_order_always_zero_flag; |
68 int offset_for_non_ref_pic; | 69 int offset_for_non_ref_pic; |
234 /** | 235 /** |
235 * current pps | 236 * current pps |
236 */ | 237 */ |
237 PPS pps; //FIXME move to Picture perhaps? (->no) do we need that? | 238 PPS pps; //FIXME move to Picture perhaps? (->no) do we need that? |
238 | 239 |
240 uint16_t (*dequant4_coeff)[16]; // FIXME quant matrices should be per SPS or PPS | |
239 uint16_t (*dequant8_coeff)[64]; | 241 uint16_t (*dequant8_coeff)[64]; |
240 | 242 |
241 int slice_num; | 243 int slice_num; |
242 uint8_t *slice_table_base; | 244 uint8_t *slice_table_base; |
243 uint8_t *slice_table; ///< slice_table_base + mb_stride + 1 | 245 uint8_t *slice_table; ///< slice_table_base + mb_stride + 1 |
342 uint8_t *direct_table; | 344 uint8_t *direct_table; |
343 uint8_t direct_cache[5*8]; | 345 uint8_t direct_cache[5*8]; |
344 | 346 |
345 uint8_t zigzag_scan[16]; | 347 uint8_t zigzag_scan[16]; |
346 uint8_t field_scan[16]; | 348 uint8_t field_scan[16]; |
349 const uint8_t *zigzag_scan_q0; | |
350 const uint8_t *field_scan_q0; | |
347 }H264Context; | 351 }H264Context; |
348 | 352 |
349 static VLC coeff_token_vlc[4]; | 353 static VLC coeff_token_vlc[4]; |
350 static VLC chroma_dc_coeff_token_vlc; | 354 static VLC chroma_dc_coeff_token_vlc; |
351 | 355 |
2902 h->slice_table= NULL; | 2906 h->slice_table= NULL; |
2903 | 2907 |
2904 av_freep(&h->mb2b_xy); | 2908 av_freep(&h->mb2b_xy); |
2905 av_freep(&h->mb2b8_xy); | 2909 av_freep(&h->mb2b8_xy); |
2906 | 2910 |
2911 av_freep(&h->dequant4_coeff); | |
2907 av_freep(&h->dequant8_coeff); | 2912 av_freep(&h->dequant8_coeff); |
2908 | 2913 |
2909 av_freep(&h->s.obmc_scratchpad); | 2914 av_freep(&h->s.obmc_scratchpad); |
2910 } | 2915 } |
2911 | 2916 |
2947 h->mb2b_xy [mb_xy]= b_xy; | 2952 h->mb2b_xy [mb_xy]= b_xy; |
2948 h->mb2b8_xy[mb_xy]= b8_xy; | 2953 h->mb2b8_xy[mb_xy]= b8_xy; |
2949 } | 2954 } |
2950 } | 2955 } |
2951 | 2956 |
2957 CHECKED_ALLOCZ(h->dequant4_coeff, 52*16 * sizeof(uint16_t)); | |
2952 CHECKED_ALLOCZ(h->dequant8_coeff, 52*64 * sizeof(uint16_t)); | 2958 CHECKED_ALLOCZ(h->dequant8_coeff, 52*64 * sizeof(uint16_t)); |
2959 memcpy(h->dequant4_coeff, dequant_coeff, 52*16 * sizeof(uint16_t)); | |
2953 for(q=0; q<52; q++){ | 2960 for(q=0; q<52; q++){ |
2954 int shift = div6[q]; | 2961 int shift = div6[q]; |
2955 int idx = rem6[q]; | 2962 int idx = rem6[q]; |
2956 if(shift >= 2) // qp<12 are shifted during dequant | 2963 if(shift >= 2) // qp<12 are shifted during dequant |
2957 shift -= 2; | 2964 shift -= 2; |
2958 for(x=0; x<64; x++) | 2965 for(x=0; x<64; x++) |
2959 h->dequant8_coeff[q][x] = dequant8_coeff_init[idx][ | 2966 h->dequant8_coeff[q][x] = dequant8_coeff_init[idx][ |
2960 dequant8_coeff_init_scan[(x>>1)&12 | x&3] ] << shift; | 2967 dequant8_coeff_init_scan[(x>>1)&12 | x&3] ] << shift; |
2968 } | |
2969 if(h->sps.transform_bypass){ | |
2970 for(x=0; x<16; x++) | |
2971 h->dequant4_coeff[0][x] = 1; | |
2972 for(x=0; x<64; x++) | |
2973 h->dequant8_coeff[0][x] = 1<<2; | |
2961 } | 2974 } |
2962 | 2975 |
2963 s->obmc_scratchpad = NULL; | 2976 s->obmc_scratchpad = NULL; |
2964 | 2977 |
2965 return 0; | 2978 return 0; |
3208 uint8_t *dest_y, *dest_cb, *dest_cr; | 3221 uint8_t *dest_y, *dest_cb, *dest_cr; |
3209 int linesize, uvlinesize /*dct_offset*/; | 3222 int linesize, uvlinesize /*dct_offset*/; |
3210 int i; | 3223 int i; |
3211 int *block_offset = &h->block_offset[0]; | 3224 int *block_offset = &h->block_offset[0]; |
3212 const unsigned int bottom = mb_y & 1; | 3225 const unsigned int bottom = mb_y & 1; |
3226 const int transform_bypass = (s->qscale == 0 && h->sps.transform_bypass); | |
3227 void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride); | |
3213 | 3228 |
3214 if(!s->decode) | 3229 if(!s->decode) |
3215 return; | 3230 return; |
3216 | 3231 |
3217 dest_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16; | 3232 dest_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16; |
3230 } else { | 3245 } else { |
3231 linesize = s->linesize; | 3246 linesize = s->linesize; |
3232 uvlinesize = s->uvlinesize; | 3247 uvlinesize = s->uvlinesize; |
3233 // dct_offset = s->linesize * 16; | 3248 // dct_offset = s->linesize * 16; |
3234 } | 3249 } |
3250 | |
3251 idct_add = transform_bypass | |
3252 ? IS_8x8DCT(mb_type) ? s->dsp.add_pixels8 : s->dsp.add_pixels4 | |
3253 : IS_8x8DCT(mb_type) ? s->dsp.h264_idct8_add : s->dsp.h264_idct_add; | |
3235 | 3254 |
3236 if (IS_INTRA_PCM(mb_type)) { | 3255 if (IS_INTRA_PCM(mb_type)) { |
3237 unsigned int x, y; | 3256 unsigned int x, y; |
3238 | 3257 |
3239 // The pixels are stored in h->mb array in the same order as levels, | 3258 // The pixels are stored in h->mb array in the same order as levels, |
3282 uint8_t * const ptr= dest_y + block_offset[i]; | 3301 uint8_t * const ptr= dest_y + block_offset[i]; |
3283 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ]; | 3302 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ]; |
3284 h->pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000, | 3303 h->pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000, |
3285 (h->topright_samples_available<<(i+1))&0x8000, linesize); | 3304 (h->topright_samples_available<<(i+1))&0x8000, linesize); |
3286 if(h->non_zero_count_cache[ scan8[i] ]) | 3305 if(h->non_zero_count_cache[ scan8[i] ]) |
3287 s->dsp.h264_idct8_add(ptr, h->mb + i*16, linesize); | 3306 idct_add(ptr, h->mb + i*16, linesize); |
3288 } | 3307 } |
3289 }else | 3308 }else |
3290 for(i=0; i<16; i++){ | 3309 for(i=0; i<16; i++){ |
3291 uint8_t * const ptr= dest_y + block_offset[i]; | 3310 uint8_t * const ptr= dest_y + block_offset[i]; |
3292 uint8_t *topright; | 3311 uint8_t *topright; |
3305 topright= NULL; | 3324 topright= NULL; |
3306 | 3325 |
3307 h->pred4x4[ dir ](ptr, topright, linesize); | 3326 h->pred4x4[ dir ](ptr, topright, linesize); |
3308 if(h->non_zero_count_cache[ scan8[i] ]){ | 3327 if(h->non_zero_count_cache[ scan8[i] ]){ |
3309 if(s->codec_id == CODEC_ID_H264) | 3328 if(s->codec_id == CODEC_ID_H264) |
3310 s->dsp.h264_idct_add(ptr, h->mb + i*16, linesize); | 3329 idct_add(ptr, h->mb + i*16, linesize); |
3311 else | 3330 else |
3312 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); | 3331 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); |
3313 } | 3332 } |
3314 } | 3333 } |
3315 } | 3334 } |
3316 }else{ | 3335 }else{ |
3317 h->pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize); | 3336 h->pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize); |
3318 if(s->codec_id == CODEC_ID_H264) | 3337 if(s->codec_id == CODEC_ID_H264){ |
3319 h264_luma_dc_dequant_idct_c(h->mb, s->qscale); | 3338 if(!transform_bypass) |
3320 else | 3339 h264_luma_dc_dequant_idct_c(h->mb, s->qscale); |
3340 }else | |
3321 svq3_luma_dc_dequant_idct_c(h->mb, s->qscale); | 3341 svq3_luma_dc_dequant_idct_c(h->mb, s->qscale); |
3322 } | 3342 } |
3323 if(h->deblocking_filter) { | 3343 if(h->deblocking_filter) { |
3324 if (h->mb_aff_frame) { | 3344 if (h->mb_aff_frame) { |
3325 if (bottom) { | 3345 if (bottom) { |
3343 | 3363 |
3344 | 3364 |
3345 if(!IS_INTRA4x4(mb_type)){ | 3365 if(!IS_INTRA4x4(mb_type)){ |
3346 if(s->codec_id == CODEC_ID_H264){ | 3366 if(s->codec_id == CODEC_ID_H264){ |
3347 const int di = IS_8x8DCT(mb_type) ? 4 : 1; | 3367 const int di = IS_8x8DCT(mb_type) ? 4 : 1; |
3348 void (*idct)(uint8_t *dst, DCTELEM *block, int stride) = | |
3349 IS_8x8DCT(mb_type) ? s->dsp.h264_idct8_add : s->dsp.h264_idct_add; | |
3350 for(i=0; i<16; i+=di){ | 3368 for(i=0; i<16; i+=di){ |
3351 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below | 3369 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below |
3352 uint8_t * const ptr= dest_y + block_offset[i]; | 3370 uint8_t * const ptr= dest_y + block_offset[i]; |
3353 idct(ptr, h->mb + i*16, linesize); | 3371 idct_add(ptr, h->mb + i*16, linesize); |
3354 } | 3372 } |
3355 } | 3373 } |
3356 }else{ | 3374 }else{ |
3357 for(i=0; i<16; i++){ | 3375 for(i=0; i<16; i++){ |
3358 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below | 3376 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below |
3362 } | 3380 } |
3363 } | 3381 } |
3364 } | 3382 } |
3365 | 3383 |
3366 if(!(s->flags&CODEC_FLAG_GRAY)){ | 3384 if(!(s->flags&CODEC_FLAG_GRAY)){ |
3367 chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp); | 3385 idct_add = transform_bypass ? s->dsp.add_pixels4 : s->dsp.h264_idct_add; |
3368 chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp); | 3386 if(!transform_bypass){ |
3387 chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp); | |
3388 chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp); | |
3389 } | |
3369 if(s->codec_id == CODEC_ID_H264){ | 3390 if(s->codec_id == CODEC_ID_H264){ |
3370 for(i=16; i<16+4; i++){ | 3391 for(i=16; i<16+4; i++){ |
3371 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 3392 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
3372 uint8_t * const ptr= dest_cb + block_offset[i]; | 3393 uint8_t * const ptr= dest_cb + block_offset[i]; |
3373 s->dsp.h264_idct_add(ptr, h->mb + i*16, uvlinesize); | 3394 idct_add(ptr, h->mb + i*16, uvlinesize); |
3374 } | 3395 } |
3375 } | 3396 } |
3376 for(i=20; i<20+4; i++){ | 3397 for(i=20; i<20+4; i++){ |
3377 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 3398 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
3378 uint8_t * const ptr= dest_cr + block_offset[i]; | 3399 uint8_t * const ptr= dest_cr + block_offset[i]; |
3379 s->dsp.h264_idct_add(ptr, h->mb + i*16, uvlinesize); | 3400 idct_add(ptr, h->mb + i*16, uvlinesize); |
3380 } | 3401 } |
3381 } | 3402 } |
3382 }else{ | 3403 }else{ |
3383 for(i=16; i<16+4; i++){ | 3404 for(i=16; i<16+4; i++){ |
3384 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 3405 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
4171 #define T(x) (x>>2) | ((x<<2) & 0xF) | 4192 #define T(x) (x>>2) | ((x<<2) & 0xF) |
4172 h->zigzag_scan[i] = T(zigzag_scan[i]); | 4193 h->zigzag_scan[i] = T(zigzag_scan[i]); |
4173 h-> field_scan[i] = T( field_scan[i]); | 4194 h-> field_scan[i] = T( field_scan[i]); |
4174 } | 4195 } |
4175 } | 4196 } |
4197 if(h->sps.transform_bypass){ //FIXME same ugly | |
4198 h->zigzag_scan_q0 = zigzag_scan; | |
4199 h->field_scan_q0 = field_scan; | |
4200 }else{ | |
4201 h->zigzag_scan_q0 = h->zigzag_scan; | |
4202 h->field_scan_q0 = h->field_scan; | |
4203 } | |
4176 | 4204 |
4177 alloc_tables(h); | 4205 alloc_tables(h); |
4178 | 4206 |
4179 s->avctx->width = s->width; | 4207 s->avctx->width = s->width; |
4180 s->avctx->height = s->height; | 4208 s->avctx->height = s->height; |
4919 const uint8_t *scan, *dc_scan; | 4947 const uint8_t *scan, *dc_scan; |
4920 | 4948 |
4921 // fill_non_zero_count_cache(h); | 4949 // fill_non_zero_count_cache(h); |
4922 | 4950 |
4923 if(IS_INTERLACED(mb_type)){ | 4951 if(IS_INTERLACED(mb_type)){ |
4924 scan= h->field_scan; | 4952 scan= s->qscale ? h->field_scan : h->field_scan_q0; |
4925 dc_scan= luma_dc_field_scan; | 4953 dc_scan= luma_dc_field_scan; |
4926 }else{ | 4954 }else{ |
4927 scan= h->zigzag_scan; | 4955 scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0; |
4928 dc_scan= luma_dc_zigzag_scan; | 4956 dc_scan= luma_dc_zigzag_scan; |
4929 } | 4957 } |
4930 | 4958 |
4931 dquant= get_se_golomb(&s->gb); | 4959 dquant= get_se_golomb(&s->gb); |
4932 | 4960 |
4941 else s->qscale-= 52; | 4969 else s->qscale-= 52; |
4942 } | 4970 } |
4943 | 4971 |
4944 h->chroma_qp= chroma_qp= get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale); | 4972 h->chroma_qp= chroma_qp= get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale); |
4945 if(IS_INTRA16x16(mb_type)){ | 4973 if(IS_INTRA16x16(mb_type)){ |
4946 if( decode_residual(h, h->intra_gb_ptr, h->mb, LUMA_DC_BLOCK_INDEX, dc_scan, dequant_coeff[s->qscale], 16) < 0){ | 4974 if( decode_residual(h, h->intra_gb_ptr, h->mb, LUMA_DC_BLOCK_INDEX, dc_scan, h->dequant4_coeff[s->qscale], 16) < 0){ |
4947 return -1; //FIXME continue if partitioned and other return -1 too | 4975 return -1; //FIXME continue if partitioned and other return -1 too |
4948 } | 4976 } |
4949 | 4977 |
4950 assert((cbp&15) == 0 || (cbp&15) == 15); | 4978 assert((cbp&15) == 0 || (cbp&15) == 15); |
4951 | 4979 |
4952 if(cbp&15){ | 4980 if(cbp&15){ |
4953 for(i8x8=0; i8x8<4; i8x8++){ | 4981 for(i8x8=0; i8x8<4; i8x8++){ |
4954 for(i4x4=0; i4x4<4; i4x4++){ | 4982 for(i4x4=0; i4x4<4; i4x4++){ |
4955 const int index= i4x4 + 4*i8x8; | 4983 const int index= i4x4 + 4*i8x8; |
4956 if( decode_residual(h, h->intra_gb_ptr, h->mb + 16*index, index, scan + 1, dequant_coeff[s->qscale], 15) < 0 ){ | 4984 if( decode_residual(h, h->intra_gb_ptr, h->mb + 16*index, index, scan + 1, h->dequant4_coeff[s->qscale], 15) < 0 ){ |
4957 return -1; | 4985 return -1; |
4958 } | 4986 } |
4959 } | 4987 } |
4960 } | 4988 } |
4961 }else{ | 4989 }else{ |
4981 nnz[0] |= nnz[1] | nnz[8] | nnz[9]; | 5009 nnz[0] |= nnz[1] | nnz[8] | nnz[9]; |
4982 }else{ | 5010 }else{ |
4983 for(i4x4=0; i4x4<4; i4x4++){ | 5011 for(i4x4=0; i4x4<4; i4x4++){ |
4984 const int index= i4x4 + 4*i8x8; | 5012 const int index= i4x4 + 4*i8x8; |
4985 | 5013 |
4986 if( decode_residual(h, gb, h->mb + 16*index, index, scan, dequant_coeff[s->qscale], 16) <0 ){ | 5014 if( decode_residual(h, gb, h->mb + 16*index, index, scan, h->dequant4_coeff[s->qscale], 16) <0 ){ |
4987 return -1; | 5015 return -1; |
4988 } | 5016 } |
4989 } | 5017 } |
4990 } | 5018 } |
4991 }else{ | 5019 }else{ |
4995 } | 5023 } |
4996 } | 5024 } |
4997 | 5025 |
4998 if(cbp&0x30){ | 5026 if(cbp&0x30){ |
4999 for(chroma_idx=0; chroma_idx<2; chroma_idx++) | 5027 for(chroma_idx=0; chroma_idx<2; chroma_idx++) |
5000 if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX, chroma_dc_scan, dequant_coeff[chroma_qp], 4) < 0){ | 5028 if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX, chroma_dc_scan, h->dequant4_coeff[chroma_qp], 4) < 0){ |
5001 return -1; | 5029 return -1; |
5002 } | 5030 } |
5003 } | 5031 } |
5004 | 5032 |
5005 if(cbp&0x20){ | 5033 if(cbp&0x20){ |
5006 for(chroma_idx=0; chroma_idx<2; chroma_idx++){ | 5034 for(chroma_idx=0; chroma_idx<2; chroma_idx++){ |
5007 for(i4x4=0; i4x4<4; i4x4++){ | 5035 for(i4x4=0; i4x4<4; i4x4++){ |
5008 const int index= 16 + 4*chroma_idx + i4x4; | 5036 const int index= 16 + 4*chroma_idx + i4x4; |
5009 if( decode_residual(h, gb, h->mb + 16*index, index, scan + 1, dequant_coeff[chroma_qp], 15) < 0){ | 5037 if( decode_residual(h, gb, h->mb + 16*index, index, scan + 1, h->dequant4_coeff[chroma_qp], 15) < 0){ |
5010 return -1; | 5038 return -1; |
5011 } | 5039 } |
5012 } | 5040 } |
5013 } | 5041 } |
5014 }else{ | 5042 }else{ |
5978 if( cbp || IS_INTRA16x16( mb_type ) ) { | 6006 if( cbp || IS_INTRA16x16( mb_type ) ) { |
5979 const uint8_t *scan, *dc_scan; | 6007 const uint8_t *scan, *dc_scan; |
5980 int dqp; | 6008 int dqp; |
5981 | 6009 |
5982 if(IS_INTERLACED(mb_type)){ | 6010 if(IS_INTERLACED(mb_type)){ |
5983 scan= h->field_scan; | 6011 scan= s->qscale ? h->field_scan : h->field_scan_q0; |
5984 dc_scan= luma_dc_field_scan; | 6012 dc_scan= luma_dc_field_scan; |
5985 }else{ | 6013 }else{ |
5986 scan= h->zigzag_scan; | 6014 scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0; |
5987 dc_scan= luma_dc_zigzag_scan; | 6015 dc_scan= luma_dc_zigzag_scan; |
5988 } | 6016 } |
5989 | 6017 |
5990 h->last_qscale_diff = dqp = decode_cabac_mb_dqp( h ); | 6018 h->last_qscale_diff = dqp = decode_cabac_mb_dqp( h ); |
5991 s->qscale += dqp; | 6019 s->qscale += dqp; |
5996 h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale); | 6024 h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale); |
5997 | 6025 |
5998 if( IS_INTRA16x16( mb_type ) ) { | 6026 if( IS_INTRA16x16( mb_type ) ) { |
5999 int i; | 6027 int i; |
6000 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" ); | 6028 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" ); |
6001 if( decode_cabac_residual( h, h->mb, 0, 0, dc_scan, dequant_coeff[s->qscale], 16) < 0) | 6029 if( decode_cabac_residual( h, h->mb, 0, 0, dc_scan, h->dequant4_coeff[s->qscale], 16) < 0) |
6002 return -1; | 6030 return -1; |
6003 if( cbp&15 ) { | 6031 if( cbp&15 ) { |
6004 for( i = 0; i < 16; i++ ) { | 6032 for( i = 0; i < 16; i++ ) { |
6005 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i ); | 6033 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i ); |
6006 if( decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, dequant_coeff[s->qscale], 15) < 0 ) | 6034 if( decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, h->dequant4_coeff[s->qscale], 15) < 0 ) |
6007 return -1; | 6035 return -1; |
6008 } | 6036 } |
6009 } else { | 6037 } else { |
6010 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1); | 6038 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1); |
6011 } | 6039 } |
6024 } | 6052 } |
6025 } else | 6053 } else |
6026 for( i4x4 = 0; i4x4 < 4; i4x4++ ) { | 6054 for( i4x4 = 0; i4x4 < 4; i4x4++ ) { |
6027 const int index = 4*i8x8 + i4x4; | 6055 const int index = 4*i8x8 + i4x4; |
6028 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index ); | 6056 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index ); |
6029 if( decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, dequant_coeff[s->qscale], 16) < 0 ) | 6057 if( decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, h->dequant4_coeff[s->qscale], 16) < 0 ) |
6030 return -1; | 6058 return -1; |
6031 } | 6059 } |
6032 } else { | 6060 } else { |
6033 uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; | 6061 uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; |
6034 nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; | 6062 nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; |
6038 | 6066 |
6039 if( cbp&0x30 ){ | 6067 if( cbp&0x30 ){ |
6040 int c; | 6068 int c; |
6041 for( c = 0; c < 2; c++ ) { | 6069 for( c = 0; c < 2; c++ ) { |
6042 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c ); | 6070 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c ); |
6043 if( decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, dequant_coeff[h->chroma_qp], 4) < 0) | 6071 if( decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, h->dequant4_coeff[h->chroma_qp], 4) < 0) |
6044 return -1; | 6072 return -1; |
6045 } | 6073 } |
6046 } | 6074 } |
6047 | 6075 |
6048 if( cbp&0x20 ) { | 6076 if( cbp&0x20 ) { |
6049 int c, i; | 6077 int c, i; |
6050 for( c = 0; c < 2; c++ ) { | 6078 for( c = 0; c < 2; c++ ) { |
6051 for( i = 0; i < 4; i++ ) { | 6079 for( i = 0; i < 4; i++ ) { |
6052 const int index = 16 + 4 * c + i; | 6080 const int index = 16 + 4 * c + i; |
6053 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 ); | 6081 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 ); |
6054 if( decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, dequant_coeff[h->chroma_qp], 15) < 0) | 6082 if( decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, h->dequant4_coeff[h->chroma_qp], 15) < 0) |
6055 return -1; | 6083 return -1; |
6056 } | 6084 } |
6057 } | 6085 } |
6058 } else { | 6086 } else { |
6059 uint8_t * const nnz= &h->non_zero_count_cache[0]; | 6087 uint8_t * const nnz= &h->non_zero_count_cache[0]; |
6895 if(sps->profile_idc >= 100){ //high profile | 6923 if(sps->profile_idc >= 100){ //high profile |
6896 if(get_ue_golomb(&s->gb) == 3) //chroma_format_idc | 6924 if(get_ue_golomb(&s->gb) == 3) //chroma_format_idc |
6897 get_bits1(&s->gb); //residual_color_transform_flag | 6925 get_bits1(&s->gb); //residual_color_transform_flag |
6898 get_ue_golomb(&s->gb); //bit_depth_luma_minus8 | 6926 get_ue_golomb(&s->gb); //bit_depth_luma_minus8 |
6899 get_ue_golomb(&s->gb); //bit_depth_chroma_minus8 | 6927 get_ue_golomb(&s->gb); //bit_depth_chroma_minus8 |
6900 get_bits1(&s->gb); //qpprime_y_zero_transform_bypass_flag | 6928 sps->transform_bypass = get_bits1(&s->gb); |
6901 if(get_bits1(&s->gb)){ //seq_scaling_matrix_present_flag | 6929 if(get_bits1(&s->gb)){ //seq_scaling_matrix_present_flag |
6902 av_log(h->s.avctx, AV_LOG_ERROR, "custom scaling matrix not implemented\n"); | 6930 av_log(h->s.avctx, AV_LOG_ERROR, "custom scaling matrix not implemented\n"); |
6903 return -1; | 6931 return -1; |
6904 } | 6932 } |
6905 } | 6933 } |