Mercurial > libavcodec.hg
comparison h264.c @ 10859:762e6bb0ba40 libavcodec
Split (picture|seq) parameter set decoding out of h264.c.
no speedloss meassured, also its really not touching anything that is speed relevant.
author | michael |
---|---|
date | Tue, 12 Jan 2010 19:33:45 +0000 |
parents | 31645cf81fcb |
children | d9c084a0c22b |
comparison
equal
deleted
inserted
replaced
10858:31645cf81fcb | 10859:762e6bb0ba40 |
---|---|
2035 } | 2035 } |
2036 }else{ | 2036 }else{ |
2037 for(i=16; i<16+8; i++){ | 2037 for(i=16; i<16+8; i++){ |
2038 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 2038 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
2039 uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i]; | 2039 uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i]; |
2040 svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, chroma_qp[s->qscale + 12] - 12, 2); | 2040 svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, ff_h264_chroma_qp[s->qscale + 12] - 12, 2); |
2041 } | 2041 } |
2042 } | 2042 } |
2043 } | 2043 } |
2044 } | 2044 } |
2045 } | 2045 } |
5592 } | 5592 } |
5593 #endif | 5593 #endif |
5594 return -1; //not reached | 5594 return -1; //not reached |
5595 } | 5595 } |
5596 | 5596 |
5597 static inline int decode_hrd_parameters(H264Context *h, SPS *sps){ | |
5598 MpegEncContext * const s = &h->s; | |
5599 int cpb_count, i; | |
5600 cpb_count = get_ue_golomb_31(&s->gb) + 1; | |
5601 | |
5602 if(cpb_count > 32U){ | |
5603 av_log(h->s.avctx, AV_LOG_ERROR, "cpb_count %d invalid\n", cpb_count); | |
5604 return -1; | |
5605 } | |
5606 | |
5607 get_bits(&s->gb, 4); /* bit_rate_scale */ | |
5608 get_bits(&s->gb, 4); /* cpb_size_scale */ | |
5609 for(i=0; i<cpb_count; i++){ | |
5610 get_ue_golomb(&s->gb); /* bit_rate_value_minus1 */ | |
5611 get_ue_golomb(&s->gb); /* cpb_size_value_minus1 */ | |
5612 get_bits1(&s->gb); /* cbr_flag */ | |
5613 } | |
5614 sps->initial_cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; | |
5615 sps->cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; | |
5616 sps->dpb_output_delay_length = get_bits(&s->gb, 5) + 1; | |
5617 sps->time_offset_length = get_bits(&s->gb, 5); | |
5618 sps->cpb_cnt = cpb_count; | |
5619 return 0; | |
5620 } | |
5621 | |
5622 static inline int decode_vui_parameters(H264Context *h, SPS *sps){ | |
5623 MpegEncContext * const s = &h->s; | |
5624 int aspect_ratio_info_present_flag; | |
5625 unsigned int aspect_ratio_idc; | |
5626 | |
5627 aspect_ratio_info_present_flag= get_bits1(&s->gb); | |
5628 | |
5629 if( aspect_ratio_info_present_flag ) { | |
5630 aspect_ratio_idc= get_bits(&s->gb, 8); | |
5631 if( aspect_ratio_idc == EXTENDED_SAR ) { | |
5632 sps->sar.num= get_bits(&s->gb, 16); | |
5633 sps->sar.den= get_bits(&s->gb, 16); | |
5634 }else if(aspect_ratio_idc < FF_ARRAY_ELEMS(pixel_aspect)){ | |
5635 sps->sar= pixel_aspect[aspect_ratio_idc]; | |
5636 }else{ | |
5637 av_log(h->s.avctx, AV_LOG_ERROR, "illegal aspect ratio\n"); | |
5638 return -1; | |
5639 } | |
5640 }else{ | |
5641 sps->sar.num= | |
5642 sps->sar.den= 0; | |
5643 } | |
5644 // s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height); | |
5645 | |
5646 if(get_bits1(&s->gb)){ /* overscan_info_present_flag */ | |
5647 get_bits1(&s->gb); /* overscan_appropriate_flag */ | |
5648 } | |
5649 | |
5650 sps->video_signal_type_present_flag = get_bits1(&s->gb); | |
5651 if(sps->video_signal_type_present_flag){ | |
5652 get_bits(&s->gb, 3); /* video_format */ | |
5653 sps->full_range = get_bits1(&s->gb); /* video_full_range_flag */ | |
5654 | |
5655 sps->colour_description_present_flag = get_bits1(&s->gb); | |
5656 if(sps->colour_description_present_flag){ | |
5657 sps->color_primaries = get_bits(&s->gb, 8); /* colour_primaries */ | |
5658 sps->color_trc = get_bits(&s->gb, 8); /* transfer_characteristics */ | |
5659 sps->colorspace = get_bits(&s->gb, 8); /* matrix_coefficients */ | |
5660 if (sps->color_primaries >= AVCOL_PRI_NB) | |
5661 sps->color_primaries = AVCOL_PRI_UNSPECIFIED; | |
5662 if (sps->color_trc >= AVCOL_TRC_NB) | |
5663 sps->color_trc = AVCOL_TRC_UNSPECIFIED; | |
5664 if (sps->colorspace >= AVCOL_SPC_NB) | |
5665 sps->colorspace = AVCOL_SPC_UNSPECIFIED; | |
5666 } | |
5667 } | |
5668 | |
5669 if(get_bits1(&s->gb)){ /* chroma_location_info_present_flag */ | |
5670 s->avctx->chroma_sample_location = get_ue_golomb(&s->gb)+1; /* chroma_sample_location_type_top_field */ | |
5671 get_ue_golomb(&s->gb); /* chroma_sample_location_type_bottom_field */ | |
5672 } | |
5673 | |
5674 sps->timing_info_present_flag = get_bits1(&s->gb); | |
5675 if(sps->timing_info_present_flag){ | |
5676 sps->num_units_in_tick = get_bits_long(&s->gb, 32); | |
5677 sps->time_scale = get_bits_long(&s->gb, 32); | |
5678 if(sps->num_units_in_tick-1 > 0x7FFFFFFEU || sps->time_scale-1 > 0x7FFFFFFEU){ | |
5679 av_log(h->s.avctx, AV_LOG_ERROR, "time_scale/num_units_in_tick invalid or unsupported (%d/%d)\n", sps->time_scale, sps->num_units_in_tick); | |
5680 return -1; | |
5681 } | |
5682 sps->fixed_frame_rate_flag = get_bits1(&s->gb); | |
5683 } | |
5684 | |
5685 sps->nal_hrd_parameters_present_flag = get_bits1(&s->gb); | |
5686 if(sps->nal_hrd_parameters_present_flag) | |
5687 if(decode_hrd_parameters(h, sps) < 0) | |
5688 return -1; | |
5689 sps->vcl_hrd_parameters_present_flag = get_bits1(&s->gb); | |
5690 if(sps->vcl_hrd_parameters_present_flag) | |
5691 if(decode_hrd_parameters(h, sps) < 0) | |
5692 return -1; | |
5693 if(sps->nal_hrd_parameters_present_flag || sps->vcl_hrd_parameters_present_flag) | |
5694 get_bits1(&s->gb); /* low_delay_hrd_flag */ | |
5695 sps->pic_struct_present_flag = get_bits1(&s->gb); | |
5696 | |
5697 sps->bitstream_restriction_flag = get_bits1(&s->gb); | |
5698 if(sps->bitstream_restriction_flag){ | |
5699 get_bits1(&s->gb); /* motion_vectors_over_pic_boundaries_flag */ | |
5700 get_ue_golomb(&s->gb); /* max_bytes_per_pic_denom */ | |
5701 get_ue_golomb(&s->gb); /* max_bits_per_mb_denom */ | |
5702 get_ue_golomb(&s->gb); /* log2_max_mv_length_horizontal */ | |
5703 get_ue_golomb(&s->gb); /* log2_max_mv_length_vertical */ | |
5704 sps->num_reorder_frames= get_ue_golomb(&s->gb); | |
5705 get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/ | |
5706 | |
5707 if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){ | |
5708 av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", sps->num_reorder_frames); | |
5709 return -1; | |
5710 } | |
5711 } | |
5712 | |
5713 return 0; | |
5714 } | |
5715 | |
5716 static void decode_scaling_list(H264Context *h, uint8_t *factors, int size, | |
5717 const uint8_t *jvt_list, const uint8_t *fallback_list){ | |
5718 MpegEncContext * const s = &h->s; | |
5719 int i, last = 8, next = 8; | |
5720 const uint8_t *scan = size == 16 ? zigzag_scan : ff_zigzag_direct; | |
5721 if(!get_bits1(&s->gb)) /* matrix not written, we use the predicted one */ | |
5722 memcpy(factors, fallback_list, size*sizeof(uint8_t)); | |
5723 else | |
5724 for(i=0;i<size;i++){ | |
5725 if(next) | |
5726 next = (last + get_se_golomb(&s->gb)) & 0xff; | |
5727 if(!i && !next){ /* matrix not written, we use the preset one */ | |
5728 memcpy(factors, jvt_list, size*sizeof(uint8_t)); | |
5729 break; | |
5730 } | |
5731 last = factors[scan[i]] = next ? next : last; | |
5732 } | |
5733 } | |
5734 | |
5735 static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_sps, | |
5736 uint8_t (*scaling_matrix4)[16], uint8_t (*scaling_matrix8)[64]){ | |
5737 MpegEncContext * const s = &h->s; | |
5738 int fallback_sps = !is_sps && sps->scaling_matrix_present; | |
5739 const uint8_t *fallback[4] = { | |
5740 fallback_sps ? sps->scaling_matrix4[0] : default_scaling4[0], | |
5741 fallback_sps ? sps->scaling_matrix4[3] : default_scaling4[1], | |
5742 fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0], | |
5743 fallback_sps ? sps->scaling_matrix8[1] : default_scaling8[1] | |
5744 }; | |
5745 if(get_bits1(&s->gb)){ | |
5746 sps->scaling_matrix_present |= is_sps; | |
5747 decode_scaling_list(h,scaling_matrix4[0],16,default_scaling4[0],fallback[0]); // Intra, Y | |
5748 decode_scaling_list(h,scaling_matrix4[1],16,default_scaling4[0],scaling_matrix4[0]); // Intra, Cr | |
5749 decode_scaling_list(h,scaling_matrix4[2],16,default_scaling4[0],scaling_matrix4[1]); // Intra, Cb | |
5750 decode_scaling_list(h,scaling_matrix4[3],16,default_scaling4[1],fallback[1]); // Inter, Y | |
5751 decode_scaling_list(h,scaling_matrix4[4],16,default_scaling4[1],scaling_matrix4[3]); // Inter, Cr | |
5752 decode_scaling_list(h,scaling_matrix4[5],16,default_scaling4[1],scaling_matrix4[4]); // Inter, Cb | |
5753 if(is_sps || pps->transform_8x8_mode){ | |
5754 decode_scaling_list(h,scaling_matrix8[0],64,default_scaling8[0],fallback[2]); // Intra, Y | |
5755 decode_scaling_list(h,scaling_matrix8[1],64,default_scaling8[1],fallback[3]); // Inter, Y | |
5756 } | |
5757 } | |
5758 } | |
5759 | |
5760 int ff_h264_decode_seq_parameter_set(H264Context *h){ | |
5761 MpegEncContext * const s = &h->s; | |
5762 int profile_idc, level_idc; | |
5763 unsigned int sps_id; | |
5764 int i; | |
5765 SPS *sps; | |
5766 | |
5767 profile_idc= get_bits(&s->gb, 8); | |
5768 get_bits1(&s->gb); //constraint_set0_flag | |
5769 get_bits1(&s->gb); //constraint_set1_flag | |
5770 get_bits1(&s->gb); //constraint_set2_flag | |
5771 get_bits1(&s->gb); //constraint_set3_flag | |
5772 get_bits(&s->gb, 4); // reserved | |
5773 level_idc= get_bits(&s->gb, 8); | |
5774 sps_id= get_ue_golomb_31(&s->gb); | |
5775 | |
5776 if(sps_id >= MAX_SPS_COUNT) { | |
5777 av_log(h->s.avctx, AV_LOG_ERROR, "sps_id (%d) out of range\n", sps_id); | |
5778 return -1; | |
5779 } | |
5780 sps= av_mallocz(sizeof(SPS)); | |
5781 if(sps == NULL) | |
5782 return -1; | |
5783 | |
5784 sps->profile_idc= profile_idc; | |
5785 sps->level_idc= level_idc; | |
5786 | |
5787 memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4)); | |
5788 memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8)); | |
5789 sps->scaling_matrix_present = 0; | |
5790 | |
5791 if(sps->profile_idc >= 100){ //high profile | |
5792 sps->chroma_format_idc= get_ue_golomb_31(&s->gb); | |
5793 if(sps->chroma_format_idc == 3) | |
5794 sps->residual_color_transform_flag = get_bits1(&s->gb); | |
5795 sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8; | |
5796 sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8; | |
5797 sps->transform_bypass = get_bits1(&s->gb); | |
5798 decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8); | |
5799 }else{ | |
5800 sps->chroma_format_idc= 1; | |
5801 sps->bit_depth_luma = 8; | |
5802 sps->bit_depth_chroma = 8; | |
5803 } | |
5804 | |
5805 sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4; | |
5806 sps->poc_type= get_ue_golomb_31(&s->gb); | |
5807 | |
5808 if(sps->poc_type == 0){ //FIXME #define | |
5809 sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4; | |
5810 } else if(sps->poc_type == 1){//FIXME #define | |
5811 sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb); | |
5812 sps->offset_for_non_ref_pic= get_se_golomb(&s->gb); | |
5813 sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb); | |
5814 sps->poc_cycle_length = get_ue_golomb(&s->gb); | |
5815 | |
5816 if((unsigned)sps->poc_cycle_length >= FF_ARRAY_ELEMS(sps->offset_for_ref_frame)){ | |
5817 av_log(h->s.avctx, AV_LOG_ERROR, "poc_cycle_length overflow %u\n", sps->poc_cycle_length); | |
5818 goto fail; | |
5819 } | |
5820 | |
5821 for(i=0; i<sps->poc_cycle_length; i++) | |
5822 sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb); | |
5823 }else if(sps->poc_type != 2){ | |
5824 av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type); | |
5825 goto fail; | |
5826 } | |
5827 | |
5828 sps->ref_frame_count= get_ue_golomb_31(&s->gb); | |
5829 if(sps->ref_frame_count > MAX_PICTURE_COUNT-2 || sps->ref_frame_count >= 32U){ | |
5830 av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n"); | |
5831 goto fail; | |
5832 } | |
5833 sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb); | |
5834 sps->mb_width = get_ue_golomb(&s->gb) + 1; | |
5835 sps->mb_height= get_ue_golomb(&s->gb) + 1; | |
5836 if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 || | |
5837 avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height)){ | |
5838 av_log(h->s.avctx, AV_LOG_ERROR, "mb_width/height overflow\n"); | |
5839 goto fail; | |
5840 } | |
5841 | |
5842 sps->frame_mbs_only_flag= get_bits1(&s->gb); | |
5843 if(!sps->frame_mbs_only_flag) | |
5844 sps->mb_aff= get_bits1(&s->gb); | |
5845 else | |
5846 sps->mb_aff= 0; | |
5847 | |
5848 sps->direct_8x8_inference_flag= get_bits1(&s->gb); | |
5849 | |
5850 #ifndef ALLOW_INTERLACE | |
5851 if(sps->mb_aff) | |
5852 av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF support not included; enable it at compile-time.\n"); | |
5853 #endif | |
5854 sps->crop= get_bits1(&s->gb); | |
5855 if(sps->crop){ | |
5856 sps->crop_left = get_ue_golomb(&s->gb); | |
5857 sps->crop_right = get_ue_golomb(&s->gb); | |
5858 sps->crop_top = get_ue_golomb(&s->gb); | |
5859 sps->crop_bottom= get_ue_golomb(&s->gb); | |
5860 if(sps->crop_left || sps->crop_top){ | |
5861 av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n"); | |
5862 } | |
5863 if(sps->crop_right >= 8 || sps->crop_bottom >= (8>> !sps->frame_mbs_only_flag)){ | |
5864 av_log(h->s.avctx, AV_LOG_ERROR, "brainfart cropping not supported, this could look slightly wrong ...\n"); | |
5865 } | |
5866 }else{ | |
5867 sps->crop_left = | |
5868 sps->crop_right = | |
5869 sps->crop_top = | |
5870 sps->crop_bottom= 0; | |
5871 } | |
5872 | |
5873 sps->vui_parameters_present_flag= get_bits1(&s->gb); | |
5874 if( sps->vui_parameters_present_flag ) | |
5875 if (decode_vui_parameters(h, sps) < 0) | |
5876 goto fail; | |
5877 | |
5878 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ | |
5879 av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d\n", | |
5880 sps_id, sps->profile_idc, sps->level_idc, | |
5881 sps->poc_type, | |
5882 sps->ref_frame_count, | |
5883 sps->mb_width, sps->mb_height, | |
5884 sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"), | |
5885 sps->direct_8x8_inference_flag ? "8B8" : "", | |
5886 sps->crop_left, sps->crop_right, | |
5887 sps->crop_top, sps->crop_bottom, | |
5888 sps->vui_parameters_present_flag ? "VUI" : "", | |
5889 ((const char*[]){"Gray","420","422","444"})[sps->chroma_format_idc], | |
5890 sps->timing_info_present_flag ? sps->num_units_in_tick : 0, | |
5891 sps->timing_info_present_flag ? sps->time_scale : 0 | |
5892 ); | |
5893 } | |
5894 | |
5895 av_free(h->sps_buffers[sps_id]); | |
5896 h->sps_buffers[sps_id]= sps; | |
5897 h->sps = *sps; | |
5898 return 0; | |
5899 fail: | |
5900 av_free(sps); | |
5901 return -1; | |
5902 } | |
5903 | |
5904 static void | |
5905 build_qp_table(PPS *pps, int t, int index) | |
5906 { | |
5907 int i; | |
5908 for(i = 0; i < 52; i++) | |
5909 pps->chroma_qp_table[t][i] = chroma_qp[av_clip(i + index, 0, 51)]; | |
5910 } | |
5911 | |
5912 int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){ | |
5913 MpegEncContext * const s = &h->s; | |
5914 unsigned int pps_id= get_ue_golomb(&s->gb); | |
5915 PPS *pps; | |
5916 | |
5917 if(pps_id >= MAX_PPS_COUNT) { | |
5918 av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id); | |
5919 return -1; | |
5920 } | |
5921 | |
5922 pps= av_mallocz(sizeof(PPS)); | |
5923 if(pps == NULL) | |
5924 return -1; | |
5925 pps->sps_id= get_ue_golomb_31(&s->gb); | |
5926 if((unsigned)pps->sps_id>=MAX_SPS_COUNT || h->sps_buffers[pps->sps_id] == NULL){ | |
5927 av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n"); | |
5928 goto fail; | |
5929 } | |
5930 | |
5931 pps->cabac= get_bits1(&s->gb); | |
5932 pps->pic_order_present= get_bits1(&s->gb); | |
5933 pps->slice_group_count= get_ue_golomb(&s->gb) + 1; | |
5934 if(pps->slice_group_count > 1 ){ | |
5935 pps->mb_slice_group_map_type= get_ue_golomb(&s->gb); | |
5936 av_log(h->s.avctx, AV_LOG_ERROR, "FMO not supported\n"); | |
5937 switch(pps->mb_slice_group_map_type){ | |
5938 case 0: | |
5939 #if 0 | |
5940 | for( i = 0; i <= num_slice_groups_minus1; i++ ) | | | | |
5941 | run_length[ i ] |1 |ue(v) | | |
5942 #endif | |
5943 break; | |
5944 case 2: | |
5945 #if 0 | |
5946 | for( i = 0; i < num_slice_groups_minus1; i++ ) | | | | |
5947 |{ | | | | |
5948 | top_left_mb[ i ] |1 |ue(v) | | |
5949 | bottom_right_mb[ i ] |1 |ue(v) | | |
5950 | } | | | | |
5951 #endif | |
5952 break; | |
5953 case 3: | |
5954 case 4: | |
5955 case 5: | |
5956 #if 0 | |
5957 | slice_group_change_direction_flag |1 |u(1) | | |
5958 | slice_group_change_rate_minus1 |1 |ue(v) | | |
5959 #endif | |
5960 break; | |
5961 case 6: | |
5962 #if 0 | |
5963 | slice_group_id_cnt_minus1 |1 |ue(v) | | |
5964 | for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | | | |
5965 |) | | | | |
5966 | slice_group_id[ i ] |1 |u(v) | | |
5967 #endif | |
5968 break; | |
5969 } | |
5970 } | |
5971 pps->ref_count[0]= get_ue_golomb(&s->gb) + 1; | |
5972 pps->ref_count[1]= get_ue_golomb(&s->gb) + 1; | |
5973 if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){ | |
5974 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n"); | |
5975 goto fail; | |
5976 } | |
5977 | |
5978 pps->weighted_pred= get_bits1(&s->gb); | |
5979 pps->weighted_bipred_idc= get_bits(&s->gb, 2); | |
5980 pps->init_qp= get_se_golomb(&s->gb) + 26; | |
5981 pps->init_qs= get_se_golomb(&s->gb) + 26; | |
5982 pps->chroma_qp_index_offset[0]= get_se_golomb(&s->gb); | |
5983 pps->deblocking_filter_parameters_present= get_bits1(&s->gb); | |
5984 pps->constrained_intra_pred= get_bits1(&s->gb); | |
5985 pps->redundant_pic_cnt_present = get_bits1(&s->gb); | |
5986 | |
5987 pps->transform_8x8_mode= 0; | |
5988 h->dequant_coeff_pps= -1; //contents of sps/pps can change even if id doesn't, so reinit | |
5989 memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4)); | |
5990 memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8)); | |
5991 | |
5992 if(get_bits_count(&s->gb) < bit_length){ | |
5993 pps->transform_8x8_mode= get_bits1(&s->gb); | |
5994 decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8); | |
5995 pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb); //second_chroma_qp_index_offset | |
5996 } else { | |
5997 pps->chroma_qp_index_offset[1]= pps->chroma_qp_index_offset[0]; | |
5998 } | |
5999 | |
6000 build_qp_table(pps, 0, pps->chroma_qp_index_offset[0]); | |
6001 build_qp_table(pps, 1, pps->chroma_qp_index_offset[1]); | |
6002 if(pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1]) | |
6003 h->pps.chroma_qp_diff= 1; | |
6004 | |
6005 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ | |
6006 av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n", | |
6007 pps_id, pps->sps_id, | |
6008 pps->cabac ? "CABAC" : "CAVLC", | |
6009 pps->slice_group_count, | |
6010 pps->ref_count[0], pps->ref_count[1], | |
6011 pps->weighted_pred ? "weighted" : "", | |
6012 pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1], | |
6013 pps->deblocking_filter_parameters_present ? "LPAR" : "", | |
6014 pps->constrained_intra_pred ? "CONSTR" : "", | |
6015 pps->redundant_pic_cnt_present ? "REDU" : "", | |
6016 pps->transform_8x8_mode ? "8x8DCT" : "" | |
6017 ); | |
6018 } | |
6019 | |
6020 av_free(h->pps_buffers[pps_id]); | |
6021 h->pps_buffers[pps_id]= pps; | |
6022 return 0; | |
6023 fail: | |
6024 av_free(pps); | |
6025 return -1; | |
6026 } | |
6027 | |
6028 /** | 5597 /** |
6029 * Call decode_slice() for each context. | 5598 * Call decode_slice() for each context. |
6030 * | 5599 * |
6031 * @param h h264 master context | 5600 * @param h h264 master context |
6032 * @param context_count number of contexts to execute | 5601 * @param context_count number of contexts to execute |