/** Parses the rest of header. */ void PpsEndOfHeader(unsigned char *data, int *Position, PPS *pt_pps) { pt_pps -> num_RefIdxL0_active_minus1 = (unsigned char) read_ue(data, Position); pt_pps -> num_RefIdxL1_active_minus1 = (unsigned char) read_ue(data, Position); pt_pps -> WeightedPredFlag = (unsigned char) getNbits(data, Position, 1); pt_pps -> WeightedBipredIdc = (unsigned char) getNbits(data, Position, 2); //pt_pps -> weighted_bipred_idc = pt_pps -> pic_init_qp = (unsigned char) (read_se(data, Position) + 26); read_se(data, Position); //pic_init_qs_minus26 = pt_pps -> second_chroma_qp_index_offset = pt_pps -> chroma_qp_index_offset = (char) read_se(data, Position); pt_pps -> deblocking_filter_control_present_flag = (unsigned char) getNbits(data, Position, 1); pt_pps -> constrained_intra_pred_flag = (unsigned char) getNbits(data, Position, 1); pt_pps -> redundant_pic_cnt_present_flag = (unsigned char) getNbits(data, Position, 1); }
/** Parses the additional information. */ void PpsHighProfile(unsigned char *data, int *Position, PPS *pt_pps, SPS *pt_sps) { pt_pps -> transform_8x8_mode_flag = (unsigned char) getNbits(data, Position, 1); decode_scaling_matrices(data, Position, pt_sps, 0, pt_pps -> scaling_matrix4, pt_pps -> scaling_matrix8); pt_pps -> second_chroma_qp_index_offset = (char) read_se(data, Position); if ( abs(pt_pps -> second_chroma_qp_index_offset) > 12){ pt_pps -> second_chroma_qp_index_offset = pt_pps -> chroma_qp_index_offset; } }
int main(int ac,char **av) { int mempoolsize=1024*1024; SE *code; int c; if(ac>1) { while((c=getopt(ac,av,"vh?p:"))!=-1) { switch(c) { case 'v': versioninfo(stdout,av[0]); return 0; case '?': case 'h': versioninfo(stdout,av[0]); helpinfo(stdout,av[0]); return 0; case 'p': mempoolsize=atoi(optarg); break; default: helpinfo(stdout,av[0]); return 1; } } } init_mempool(mempoolsize); init_symbols_list(); gather_symbols((code=read_se(stdin))); assemble(code,stdout,1); printf("\n"); return 0; }
/*! * \param *dc The current DecodingContext. * \param mbAddr The current macroblock address. * \return 0 if macroblock decoding fail, 1 otherwise. * * This function extract one macroblock from the bitstream, handle intra/inter * prediction for its blocks. */ int macroblock_layer(DecodingContext_t *dc, const int mbAddr) { TRACE_INFO(MB, "<> " BLD_GREEN "macroblock_layer(" CLR_RESET "%i" BLD_GREEN ")\n" CLR_RESET, mbAddr); int retcode = FAILURE; // Macroblock allocation //////////////////////////////////////////////////////////////////////////// dc->mb_array[mbAddr] = (Macroblock_t*)calloc(1, sizeof(Macroblock_t)); if (dc->mb_array[mbAddr] == NULL) { TRACE_ERROR(MB, "Unable to alloc new macroblock!\n"); } else { // Set macroblock address dc->mb_array[mbAddr]->mbAddr = mbAddr; // Shortcuts pps_t *pps = dc->pps_array[dc->active_slice->pic_parameter_set_id]; sps_t *sps = dc->sps_array[pps->seq_parameter_set_id]; slice_t *slice = dc->active_slice; Macroblock_t *mb = dc->mb_array[mbAddr]; // Macroblock decoding //////////////////////////////////////////////////////////////////////// #if ENABLE_DEBUG mb->mbFileAddrStart = bitstream_get_absolute_bit_offset(dc->bitstr); #endif // ENABLE_DEBUG deriv_macroblockneighbours_availability(dc, mbAddr); MbPosition(mb, sps); if (pps->entropy_coding_mode_flag) mb->mb_type = read_ae(dc, SE_mb_type); else mb->mb_type = read_ue(dc->bitstr); mb->MbPartPredMode[0] = MbPartPredMode(mb, slice->slice_type, 0); mb->NumMbPart = NumMbPart(slice->slice_type, mb->mb_type); if (mb->mb_type == I_PCM) { #if ENABLE_IPCM TRACE_3(MB, "---- macroblock_layer - I PCM macroblock\n"); while (bitstream_check_alignment(dc->bitstr) == false) { if (read_bit(dc->bitstr) != 0) // pcm_alignment_zero_bit { TRACE_ERROR(MB, " Error while reading pcm_alignment_zero_bit: must be 0!\n"); return FAILURE; } } // CABAC initialization process //FIXME needed? See 'ITU-T H.264' recommendation 9.3.1.2 initCabacDecodingEngine(dc); int i = 0; for (i = 0; i < 256; i++) { mb->pcm_sample_luma[i] = (uint8_t)read_bits(dc->bitstr, sps->BitDepthY); } // CABAC initialization process //FIXME needed? See 'ITU-T H.264' recommendation 9.3.1.2 initCabacDecodingEngine(dc); for (i = 0; i < 2 * sps->MbWidthC * sps->MbHeightC; i++) { mb->pcm_sample_chroma[i] = (uint8_t)read_bits(dc->bitstr, sps->BitDepthC); } // CABAC initialization process //FIXME needed? See 'ITU-T H.264' recommendation 9.3.1.2 initCabacDecodingEngine(dc); #else // ENABLE_IPCM TRACE_ERROR(MB, "I_PCM decoding is currently disabled!\n"); return UNSUPPORTED; #endif // ENABLE_IPCM } else { #if ENABLE_INTER_PRED bool noSubMbPartSizeLessThan8x8Flag = true; if (mb->mb_type != I_NxN && mb->MbPartPredMode[0] != Intra_16x16 && mb->NumMbPart == 4) { TRACE_3(MB, "---- macroblock_layer - mb partition & related\n"); int mbPartIdx = 0; for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if (mb->sub_mb_type[mbPartIdx] != B_Direct_8x8) { if (NumSubMbPart(slice->slice_type, mb->sub_mb_type[mbPartIdx]) > 1) { noSubMbPartSizeLessThan8x8Flag = false; } } else if (sps->direct_8x8_inference_flag == false) { noSubMbPartSizeLessThan8x8Flag = false; } } // Read sub macroblock prediction mode sub_mb_pred(dc, mb->mb_type, mb->sub_mb_type); } else #endif // ENABLE_INTER_PRED { TRACE_3(MB, "---- macroblock_layer - transform_size_8x8_flag & prediction modes\n"); if (pps->transform_8x8_mode_flag == true && mb->mb_type == I_NxN) { if (pps->entropy_coding_mode_flag) mb->transform_size_8x8_flag = read_ae(dc, SE_transform_size_8x8_flag); else mb->transform_size_8x8_flag = read_bit(dc->bitstr); // Need to update MbPartPredMode in order to detect I_8x8 prediction mode mb->MbPartPredMode[0] = MbPartPredMode(mb, slice->slice_type, 0); } // Read macroblock prediction mode mb_pred(dc, mb); } if (mb->MbPartPredMode[0] != Intra_16x16) { TRACE_3(MB, "---- macroblock_layer - coded block pattern & transform_size_8x8_flag\n"); if (pps->entropy_coding_mode_flag) mb->coded_block_pattern = read_ae(dc, SE_coded_block_pattern); else mb->coded_block_pattern = read_me(dc->bitstr, sps->ChromaArrayType, dc->IdrPicFlag); mb->CodedBlockPatternLuma = mb->coded_block_pattern % 16; mb->CodedBlockPatternChroma = mb->coded_block_pattern / 16; #if ENABLE_INTER_PRED if (mb->CodedBlockPatternLuma > 0 && pps->transform_8x8_mode_flag == true && mb->mb_type != I_NxN && noSubMbPartSizeLessThan8x8Flag == true && (mb->mb_type != B_Direct_16x16 || sps->direct_8x8_inference_flag == true)) { if (pps->entropy_coding_mode_flag) mb->transform_size_8x8_flag = read_ae(dc, SE_transform_size_8x8_flag); else mb->transform_size_8x8_flag = read_bit(dc->bitstr); // Need to update MbPartPredMode in order to account for I_8x8 prediction mode if (transform_size_8x8_flag) mb->MbPartPredMode[0] = MbPartPredMode(mb, slice->slice_type, 0); } #endif // ENABLE_INTER_PRED } if (mb->CodedBlockPatternLuma > 0 || mb->CodedBlockPatternChroma > 0 || mb->MbPartPredMode[0] == Intra_16x16) { TRACE_3(MB, "---- macroblock_layer - quantization parameter & residual datas\n"); // Read QP delta if (pps->entropy_coding_mode_flag) mb->mb_qp_delta = read_ae(dc, SE_mb_qp_delta); else mb->mb_qp_delta = read_se(dc->bitstr); // Parse the residual coefficients //////////////////////////////////////////////////////////////// // Luma levels residual_luma(dc, 0, 15); // Chroma levels residual_chroma(dc, 0, 15); } else { TRACE_3(MB, "---- macroblock_layer - No residual datas to decode in this macroblock\n"); } // Compute luma Quantization Parameters if (mb->mb_qp_delta) mb->QPY = ((slice->QPYprev + mb->mb_qp_delta + 52 + sps->QpBdOffsetY*2) % (52 + sps->QpBdOffsetY)) - sps->QpBdOffsetY; else mb->QPY = slice->QPYprev; mb->QPprimeY = mb->QPY + sps->QpBdOffsetY; slice->QPYprev = mb->QPY; // Set Transform Bypass Mode if (sps->qpprime_y_zero_transform_bypass_flag == true && mb->QPprimeY == 0) mb->TransformBypassModeFlag = true; // Prediction process (include quantization and transformation stages) //////////////////////////////////////////////////////////////// if (dc->IdrPicFlag) { retcode = intra_prediction_process(dc, mb); } else { retcode = inter_prediction_process(dc, mb); } // Print macroblock(s) header and block data ? //////////////////////////////////////////////////////////////// #if ENABLE_DEBUG mb->mbFileAddrStop = bitstream_get_absolute_bit_offset(dc->bitstr) - 1; int frame_debug_range[2] = {-1, -1}; // Range of (idr) frame(s) to debug/analyse int mb_debug_range[2] = {-1, -1}; // Range of macroblock(s) to debug/analyse if (dc->idrCounter >= frame_debug_range[0] && dc->idrCounter <= frame_debug_range[1]) { if (mb->mbAddr >= mb_debug_range[0] && mb->mbAddr <= mb_debug_range[1]) { print_macroblock_layer(dc, mb); print_macroblock_pixel_residual(mb); print_macroblock_pixel_predicted(mb); print_macroblock_pixel_final(mb); } } #endif // ENABLE_DEBUG } TRACE_3(MB, "---- macroblock_layer - the end\n\n"); } return retcode; }
/*! * \param *dc The current DecodingContext. * \param mb_type The macroblock prediction type. * \param *sub_mb_type The sub macroblock prediction type. * * Find the sub macroblock prediction type (intra prediction mode or motion vectors exctraction). */ static void sub_mb_pred(DecodingContext_t *dc, const unsigned int mb_type, unsigned int *sub_mb_type) { TRACE_INFO(MB, " > " BLD_GREEN "sub_mb_pred()\n" CLR_RESET); // Shortcut Macroblock_t *mb = dc->mb_array[dc->CurrMbAddr]; slice_t *slice = dc->active_slice; // Read sub_mb_type int mbPartIdx = 0; for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if (dc->entropy_coding_mode_flag) sub_mb_type[mbPartIdx] = read_ae(dc, SE_sub_mb_type); else sub_mb_type[mbPartIdx] = read_ue(dc->bitstr); } // ref_idx_l0 for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if ((slice->num_ref_idx_l0_active_minus1 > 0 || slice->mb_field_decoding_flag != slice->field_pic_flag) && mb_type != P_8x8ref0 && sub_mb_type[mbPartIdx] != B_Direct_8x8 && SubMbPredMode(slice->slice_type, sub_mb_type[mbPartIdx]) != Pred_L1) { if (dc->entropy_coding_mode_flag) mb->ref_idx_l0[mbPartIdx] = read_ae(dc, SE_ref_idx_lx); else mb->ref_idx_l0[mbPartIdx] = read_te(dc->bitstr, 0); } } // ref_idx_l1 for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if ((slice->num_ref_idx_l1_active_minus1 > 0 || slice->mb_field_decoding_flag != slice->field_pic_flag) && sub_mb_type[mbPartIdx] != B_Direct_8x8 && SubMbPredMode(slice->slice_type, sub_mb_type[mbPartIdx]) != Pred_L0) { if (dc->entropy_coding_mode_flag) mb->ref_idx_l1[mbPartIdx] = read_ae(dc, SE_ref_idx_lx); else mb->ref_idx_l1[mbPartIdx] = read_te(dc->bitstr, 0); } } // mvd_l0 for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if (sub_mb_type[mbPartIdx] != B_Direct_8x8 && SubMbPredMode(slice->slice_type, sub_mb_type[mbPartIdx]) != Pred_L1) { int subMbPartIdx = 0; for (subMbPartIdx = 0; subMbPartIdx < NumSubMbPart(slice->slice_type, sub_mb_type[mbPartIdx]); subMbPartIdx++) { if (dc->entropy_coding_mode_flag) { mb->mvd_l0[mbPartIdx][subMbPartIdx][0] = read_ae(dc, SE_mvd_lx0); mb->mvd_l0[mbPartIdx][subMbPartIdx][1] = read_ae(dc, SE_mvd_lx1); } else { mb->mvd_l0[mbPartIdx][subMbPartIdx][0] = read_se(dc->bitstr); mb->mvd_l0[mbPartIdx][subMbPartIdx][1] = read_se(dc->bitstr); } } } } // mvd_l1 for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if (sub_mb_type[mbPartIdx] != B_Direct_8x8 && SubMbPredMode(slice->slice_type, sub_mb_type[mbPartIdx]) != Pred_L0) { int subMbPartIdx = 0; for (subMbPartIdx = 0; subMbPartIdx < NumSubMbPart(slice->slice_type, sub_mb_type[mbPartIdx]); subMbPartIdx++) { if (dc->entropy_coding_mode_flag) { mb->mvd_l1[mbPartIdx][subMbPartIdx][0] = read_ae(dc, SE_mvd_lx0); mb->mvd_l1[mbPartIdx][subMbPartIdx][1] = read_ae(dc, SE_mvd_lx1); } else { mb->mvd_l1[mbPartIdx][subMbPartIdx][0] = read_se(dc->bitstr); mb->mvd_l1[mbPartIdx][subMbPartIdx][1] = read_se(dc->bitstr); } } } } }
int main(int ac, char **av) { FILE *codefile=stdin; int mempoolsize=1024*1024; int c; SE *prog,*result; silent=0; if(ac<2) { versioninfo(stderr,av[0]); helpinfo(stderr,av[0]); return 1; } while((c=getopt(ac,av,"svch?p:"))!=-1) { switch(c) { case 's': silent=1; break; case 'c': conscellinfo(stdout,av[0]); return 0; case 'v': versioninfo(stdout,av[0]); return 0; case '?': case 'h': versioninfo(stdout,av[0]); helpinfo(stdout,av[0]); return 0; case 'p': mempoolsize=atoi(optarg); break; default: // versioninfo(stderr,av[0]); // helpinfo(stdout,av[0]); return 1; } } if((codefile=fopen(av[optind],"r"))) { if(silent!=1) printf("Initializing mempool (%d cells)...\n",mempoolsize); init_mempool(mempoolsize); if(silent!=1) printf("Loading code from %s...\n",av[optind]); prog=read_se(codefile); if(silent!=1) printf("Allocating %d env-slot(s) for environments...\n",numval(car(prog))); Dreg=(SE **)malloc(sizeof(SE *)*numval(car(prog))); Rreg=NIL; Creg=NIL; C_push(cdr(prog)); if(silent!=1) printf("Running the machine.\n"); result=run(); if(silent!=1) printf("Result: "); write_se(result,stdout); printf("\n"); // ? if(silent!=1) printf("\nAuf wiedersehen!\n"); return 0; } else fprintf(stderr,"Could not open file %s.\n",av[optind]); return 1; }
//for init access unit int slice_header_svc_cut(unsigned char *data, SPS *sps, PPS *pps, int *position, SLICE *Slice, NAL *Nal) { PPS *pt_pps_id ; SPS *pt_sps_id ; int PicParameterId; int SeqParameterId; //Read header data Slice -> first_mb_in_slice = read_ue(data, position); Slice -> slice_type = read_ue(data, position); if ( Slice -> slice_type > 4 ) { Slice -> slice_type -= 5 ; } PicParameterId = read_ue(data, position); Nal -> pic_parameter_id[Nal -> LayerId] = PicParameterId = CLIP3(0, PPS_BUF_SIZE - 1, PicParameterId); pt_pps_id = &pps[PicParameterId]; //Should be in slice header //Sometimes Subset SPS are after PPS (rtsp) if(pt_pps_id -> seq_parameter_set_id > sps[0] . MaxSpsId){ pt_pps_id -> seq_parameter_set_id = sps[0] . MaxSpsId; } SeqParameterId = pt_pps_id -> seq_parameter_set_id + (Nal -> LayerId ? 16: 0); pt_sps_id = &sps[SeqParameterId]; Slice -> frame_num = getNbits(data, position, pt_sps_id -> log2_max_frame_num ); //Read Frame parameter if ( !pt_sps_id -> frame_mbs_only_flag ) { Slice -> field_pic_flag = getNbits(data, position, 1); if ( Slice -> field_pic_flag ) { Slice->bottom_field_flag = getNbits(data, position, 1); } } else { Slice->field_pic_flag = 0; } if ( 1 == Nal -> IdrFlag) { Slice->idr_pic_id = read_ue(data, position);//idr_pic_id = } if ( pt_sps_id -> pic_order_cnt_type == 0 ) { Slice -> pic_order_cnt_lsb = getNbits(data, position, pt_sps_id -> log2_max_pic_order_cnt_lsb ); if ( pt_pps_id -> pic_order_present_flag && !Slice -> field_pic_flag ) Slice -> delta_pic_order_cnt_bottom = read_se(data, position); } if ( pt_sps_id -> pic_order_cnt_type == 1 && !pt_sps_id -> delta_pic_order_always_zero_flag ) { Slice -> delta_pic_order_cnt [0] = read_se(data, position); if ( pt_pps_id -> pic_order_present_flag && !Slice -> field_pic_flag ) Slice -> delta_pic_order_cnt [1] = read_se(data, position); } if ( pt_pps_id -> redundant_pic_cnt_present_flag ) { read_ue(data, position);//redundant_pic_cnt = } return 0; }
/*! * \param *dc The current DecodingContext. * \param *slice The current Slice. */ static int decodeSliceHeader(DecodingContext_t *dc, slice_t *slice) { TRACE_INFO(SLICE, "> " BLD_GREEN "decodeSliceHeader()\n" CLR_RESET); // Slice header decoding //////////////////////////////////////////////////////////////////////////// slice->first_mb_in_slice = read_ue(dc->bitstr); slice->slice_type = read_ue(dc->bitstr); slice->pic_parameter_set_id = read_ue(dc->bitstr); // Shortcuts pps_t *pps = dc->pps_array[slice->pic_parameter_set_id]; sps_t *sps = dc->sps_array[pps->seq_parameter_set_id]; if (sps->separate_colour_plane_flag) { slice->colour_plane_id = read_bits(dc->bitstr, 2); } slice->frame_num = read_bits(dc->bitstr, sps->log2_max_frame_num_minus4 + 4); if (sps->frame_mbs_only_flag == false) { slice->field_pic_flag = read_bit(dc->bitstr); if (slice->field_pic_flag) { slice->bottom_field_flag = read_bit(dc->bitstr); slice->MaxPicNum = sps->MaxFrameNum*2; slice->CurrPicNum = slice->frame_num*2 + 1; } else { slice->MaxPicNum = sps->MaxFrameNum; slice->CurrPicNum = slice->frame_num; } } slice->MbaffFrameFlag = sps->mb_adaptive_frame_field_flag && !slice->field_pic_flag; slice->PicHeightInMbs = sps->FrameHeightInMbs / (1 + slice->field_pic_flag); slice->PicHeightInSamplesL = slice->PicHeightInMbs * 16; slice->PicHeightInSamplesC = slice->PicHeightInMbs * sps->MbHeightC; slice->PicSizeInMbs = sps->PicWidthInMbs * slice->PicHeightInMbs; if (dc->IdrPicFlag) { slice->PrevRefFrameNum = 0; slice->idr_pic_id = read_ue(dc->bitstr); } if (sps->pic_order_cnt_type == 0) { slice->pic_order_cnt_lsb = read_bits(dc->bitstr, sps->log2_max_pic_order_cnt_lsb_minus4 + 4); if (pps->bottom_field_pic_order_in_frame_present_flag && slice->field_pic_flag == false) { slice->delta_pic_order_cnt_bottom = read_se(dc->bitstr); } } else if (sps->pic_order_cnt_type == 1 && sps->delta_pic_order_always_zero_flag == false) { slice->delta_pic_order_cnt[0] = read_se(dc->bitstr); if (pps->bottom_field_pic_order_in_frame_present_flag && slice->field_pic_flag == false) { slice->delta_pic_order_cnt[1] = read_se(dc->bitstr); } } if (pps->redundant_pic_cnt_present_flag) { slice->redundant_pic_cnt = read_ue(dc->bitstr); } if (slice->slice_type == 1 || slice->slice_type == 6) // B frame { TRACE_ERROR(SLICE, ">>> UNSUPPORTED (B frame)\n"); return UNSUPPORTED; slice->direct_spatial_mv_pred_flag = read_bit(dc->bitstr); } if (slice->slice_type == 0 || slice->slice_type == 5 || slice->slice_type == 3 || slice->slice_type == 8 || slice->slice_type == 1 || slice->slice_type == 6) // P, SP, B frame { TRACE_ERROR(SLICE, ">>> UNSUPPORTED (P, SP, B frame)\n"); return UNSUPPORTED; /* slice->num_ref_idx_active_override_flag = read_bit(dc->bitstr); if (slice->num_ref_idx_active_override_flag) { slice->num_ref_idx_l0_active_minus1 = read_ue(dc->bitstr); if (slice->slice_type == 1 || slice->slice_type == 6) // B frame { slice->num_ref_idx_l1_active_minus1 = read_ue(dc->bitstr); } } */ } if (dc->active_nalu->nal_unit_type == 20) { TRACE_ERROR(SLICE, ">>> UNSUPPORTED (unit_type == 20: MVC extension)\n"); return UNSUPPORTED; } else { // RPLM slice->rplm = decodeRPLM(dc, slice); } if ((pps->weighted_pred_flag == true && (slice->slice_type == 0 || slice->slice_type == 5 || slice->slice_type == 3 || slice->slice_type == 8)) || (pps->weighted_bipred_idc == 1 && (slice->slice_type == 1 || slice->slice_type == 6))) // P, SP, B frame { // PWT slice->pwt = decodePWT(dc, slice); } if (dc->active_nalu->nal_ref_idc != 0) { // DRPM slice->drpm = decodeDRPM(dc, slice); } if (pps->entropy_coding_mode_flag == true && ((slice->slice_type != 2 && slice->slice_type != 7) && (slice->slice_type != 4 && slice->slice_type != 9))) // Not I or SI frame { slice->cabac_init_idc = read_ue(dc->bitstr); } slice->slice_qp_delta = read_se(dc->bitstr); slice->SliceQPY = 26 + pps->pic_init_qp_minus26 + slice->slice_qp_delta; slice->QPYprev = slice->SliceQPY; // Set QPYprev value to use it in the first macroblock if (slice->slice_type == 3 || slice->slice_type == 8 || slice->slice_type == 4 || slice->slice_type == 9) // SP, SI frame { #if ENABLE_SWITCHING_SLICE if (slice->slice_type == 4 || slice->slice_type == 9) { slice->sp_for_switch_flag = read_bit(dc->bitstr); } slice->slice_qs_delta = read_se(dc->bitstr); slice->SliceQSY = 26 + pps->pic_init_qs_minus26 + slice->slice_qs_delta; #else /* ENABLE_SWITCHING_SLICE */ TRACE_ERROR(SLICE, ">>> UNSUPPORTED (slice_type == SP || slice_type == SI)\n"); return UNSUPPORTED; #endif /* ENABLE_SWITCHING_SLICE */ } if (pps->deblocking_filter_control_present_flag) { slice->disable_deblocking_filter_idc = read_ue(dc->bitstr); if (slice->disable_deblocking_filter_idc != 1) { slice->slice_alpha_c0_offset_div2 = read_se(dc->bitstr); slice->slice_beta_offset_div2 = read_se(dc->bitstr); slice->FilterOffsetA = slice->slice_alpha_c0_offset_div2 << 1; slice->FilterOffsetB = slice->slice_beta_offset_div2 << 1; } } if (pps->num_slice_groups_minus1 > 0 && pps->slice_group_map_type >= 3 && pps->slice_group_map_type <= 5) { TRACE_ERROR(SLICE, ">>> UNSUPPORTED (FMO)\n"); return UNSUPPORTED; } // Check content return checkSliceHeader(dc); }
/** This function permits to decode the image reference of each sub-macroblock. @param data The NAL unit. @param position The current position in the NAL. @param block Contains all parameters of the current macroblock. @param slice The slice structure. */ int sub_mb_pred_svc ( const unsigned char *ai_pcData, int *position, const SLICE *ai_pstSlice, DATA *aio_pstMacroblock, RESIDU *Current_residu) { int mbPartIdx ; int subMbPartIdx ; //Recovery of the sub-macroblock type GetCavlcSubMbType(ai_pcData, position, Current_residu); #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckSubMbType( Current_residu -> SubMbType, ai_pstSlice -> slice_type? MaxBSubMbType:MaxPSubMbType)){ return 1; } #endif //Recovery of the image reference of each sub-macroblock if( ai_pstSlice -> AdaptiveMotionPredictionFlag && Current_residu -> InCropWindow ) { for ( mbPartIdx = 0 ; mbPartIdx < 4 ; mbPartIdx++ ) { if (sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != Pred_L1 && sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != B_direct) { aio_pstMacroblock -> MotionPredL0 [mbPartIdx] = getNbits(ai_pcData, position, 1); } } //Recovery of the image reference of each sub-macroblock for ( mbPartIdx = 0 ; mbPartIdx < 4 ; mbPartIdx++ ) { if ( sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != Pred_L0 && sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != B_direct) { aio_pstMacroblock -> MotionPredL1 [mbPartIdx] = getNbits(ai_pcData, position, 1); } } }else{ aio_pstMacroblock -> MotionPredL0[0] = aio_pstMacroblock -> MotionPredL0[1] = aio_pstMacroblock -> MotionPredL0[2] = aio_pstMacroblock -> MotionPredL0[3] = aio_pstMacroblock -> MotionPredL1[0] = aio_pstMacroblock -> MotionPredL1[1] = aio_pstMacroblock -> MotionPredL1[2] = aio_pstMacroblock -> MotionPredL1[3] = ai_pstSlice -> DefaultMotionPredictionFlag; } if (ai_pstSlice -> num_RefIdxL0_active_minus1 != 0){ for ( mbPartIdx = 0 ; mbPartIdx < 4 ; mbPartIdx++ ) { if ((Current_residu -> MbType != P_8x8ref0) && (!aio_pstMacroblock -> MotionPredL0[mbPartIdx]) && (sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != B_direct) && (sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != Pred_L1)) { aio_pstMacroblock -> RefIdxL0 [mbPartIdx] = read_te(ai_pcData, position, ai_pstSlice -> num_RefIdxL0_active_minus1); } } } #ifdef ERROR_DETECTION //Error Detection if(ErrorsCheckSubRefLx(aio_pstMacroblock -> RefIdxL0, ai_pstSlice -> num_RefIdxL0_active_minus1)){ return 1; } #endif //Recovery of the image reference of each sub-macroblock if (ai_pstSlice -> num_RefIdxL1_active_minus1 != 0){ for ( mbPartIdx = 0 ; mbPartIdx < 4 ; mbPartIdx++ ) { if ((sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != B_direct) && (sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != Pred_L0) && (!aio_pstMacroblock -> MotionPredL1[mbPartIdx])) { aio_pstMacroblock -> RefIdxL1 [mbPartIdx] = read_te(ai_pcData, position, ai_pstSlice -> num_RefIdxL1_active_minus1); } } } #ifdef ERROR_DETECTION //Error Detection if(ErrorsCheckSubRefLx(aio_pstMacroblock -> RefIdxL1, ai_pstSlice -> num_RefIdxL1_active_minus1)){ return 1; } #endif //Recovery of the motion vector of each sub-macroblock for ( mbPartIdx = 0 ; mbPartIdx < 4 ; mbPartIdx++ ) { if ( sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != B_direct && sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != Pred_L1 ) { for ( subMbPartIdx = 0 ; subMbPartIdx < sub_num_part[ ai_pstSlice -> slice_type][ Current_residu -> SubMbType [mbPartIdx]] ; subMbPartIdx++ ) { int index = ( mbPartIdx << 2) + subMbPartIdx; aio_pstMacroblock -> MvdL0 [index][0] = read_se(ai_pcData, position); aio_pstMacroblock -> MvdL0 [index][1] = read_se(ai_pcData, position); } } } //Recovery of the motion vector of each sub-macroblock for ( mbPartIdx = 0 ; mbPartIdx < 4 ; mbPartIdx++ ) { if ( sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != B_direct && sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType [mbPartIdx]] != Pred_L0 ) { for ( subMbPartIdx = 0 ; subMbPartIdx < sub_num_part[ ai_pstSlice -> slice_type][ Current_residu -> SubMbType [mbPartIdx]] ; subMbPartIdx++ ) { int index = ( mbPartIdx << 2) + subMbPartIdx; aio_pstMacroblock -> MvdL1 [index][0] = read_se(ai_pcData, position); aio_pstMacroblock -> MvdL1 [index][1] = read_se(ai_pcData, position); } } } return 0; }
int macroblock_layer_in_scalable_extension(const NAL *Nal, const PPS *Pps, RESIDU *Current_residu, RESIDU *BaseResidu, const unsigned char *ai_pcData, int *position, const SLICE *ai_pstSlice, DATA Tab_Block[], const VLC_TABLES *vlc, unsigned char aio_tiNon_zero_count_cache [ ], unsigned char aio_tiSlice_table [ ], const short iMb_x, const short iMb_y, int direct_8x8_inference_flag, int *last_QP) { int noSubMbPartSizeLessThan8x8; int BaseModeFlag = 0; const int iCurrMbAddr = iMb_x + iMb_y * (short)(ai_pstSlice -> mb_stride); short intra4x4_pred_mode_cache[40]; DATA * aio_pstBlock = &Tab_Block[iCurrMbAddr]; //TODO if( ai_pstSlice -> AdaptiveBaseModeFlag && Current_residu -> InCropWindow) { Current_residu -> BaseModeFlag = BaseModeFlag = getNbits(ai_pcData, position, 1); //u(1) }else if (ai_pstSlice -> DefaultBaseModeFlag){ Current_residu -> BaseModeFlag = BaseModeFlag = 1; } if(!BaseModeFlag){ int mb_type = read_ue(ai_pcData, position); //According to the slice type and the macroblock type //the parameters are adjusted switch ( ai_pstSlice -> slice_type ) { case EI : #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckMbType(mb_type, I_BL)){ return 1; } #endif aio_pstBlock -> MbPartPredMode [0] = i_mb_type_info[mb_type] . type; Current_residu -> MbType = i_mb_type_info[mb_type] . type; Current_residu -> Cbp = i_mb_type_info[mb_type] . Cbp; Current_residu -> Intra16x16PredMode = i_mb_type_info[mb_type] . pred_mode; break ; case EP : if (mb_type < 5){ #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckMbType(mb_type, P_BL)){ return 1; } #endif aio_pstBlock -> NumMbPart = p_mb_type_info[mb_type] . partcount; aio_pstBlock -> MbPartPredMode [0] = p_mb_type_info[mb_type] . type_0; aio_pstBlock -> MbPartPredMode [1] = p_mb_type_info[mb_type] . type_1; Current_residu -> MbType = p_mb_type_info[mb_type] . name; Current_residu -> Mode = p_mb_type_info[mb_type] . Mode; } else { mb_type -= 5; #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckMbType(mb_type, I_BL)){ return 1; } #endif aio_pstBlock -> MbPartPredMode [0] = i_mb_type_info[mb_type] . type; Current_residu -> MbType = i_mb_type_info[mb_type] . type; Current_residu -> Cbp = i_mb_type_info[mb_type] . Cbp; Current_residu -> Intra16x16PredMode = i_mb_type_info[mb_type] . pred_mode; } break ; case EB : if (mb_type < 23) { #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckMbType(mb_type, B_BL)){ return 1; } #endif aio_pstBlock -> NumMbPart = b_mb_type_info[mb_type] . partcount; aio_pstBlock -> MbPartPredMode [0] = b_mb_type_info[mb_type] . type_0; aio_pstBlock -> MbPartPredMode [1] = b_mb_type_info[mb_type] . type_1; Current_residu -> MbType = b_mb_type_info[mb_type] . name; Current_residu -> Mode = b_mb_type_info[mb_type] . Mode; } else { mb_type -= 23; #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckMbType(mb_type, I_BL)){ return 1; } #endif aio_pstBlock -> MbPartPredMode [0] = i_mb_type_info[mb_type] . type; Current_residu -> MbType = i_mb_type_info[mb_type] . type; Current_residu -> Cbp = i_mb_type_info[mb_type] . Cbp; Current_residu -> Intra16x16PredMode = i_mb_type_info[mb_type] . pred_mode; } break; } //Initialize base macroblock address GetBaseMbAddr(Nal, aio_pstBlock, iMb_x << 4, iMb_y << 4); } else{ aio_pstBlock -> MbPartPredMode [0] = Current_residu -> MbType = GetBaseType(Nal, BaseResidu, aio_pstBlock, iMb_x, iMb_y); } //Updating the slice table in order to save in which slice each macroblock belong to Current_residu -> SliceNum = aio_tiSlice_table [iCurrMbAddr] = ai_pstSlice -> slice_num ; if ( !BaseModeFlag && Current_residu -> MbType == INTRA_PCM ) { while ( !bytes_aligned(*position) ) { getNbits(ai_pcData, position, 1);//pcm_alignment_zero_bit = } ParseIPCM(ai_pcData, position, Current_residu, aio_tiNon_zero_count_cache); } else { //Updating the parameter in order to decode the VLC fill_caches_svc( ai_pstSlice, Current_residu, BaseResidu, 0, aio_tiNon_zero_count_cache, aio_tiSlice_table, aio_pstBlock, intra4x4_pred_mode_cache, iMb_x, iMb_y, Pps -> constrained_intra_pred_flag, Nal -> TCoeffPrediction); if (!BaseModeFlag){ //Recovery of the motion vectors for the sub_macroblock if ( !IS_I(Current_residu -> MbType) && (aio_pstBlock -> NumMbPart == 4)) { int mbPartIdx; if(sub_mb_pred_svc(ai_pcData, position, ai_pstSlice, aio_pstBlock, Current_residu)){ return 1; } noSubMbPartSizeLessThan8x8 = 0; if ( direct_8x8_inference_flag ){ noSubMbPartSizeLessThan8x8 = 1; } for ( mbPartIdx = 0; mbPartIdx < 4; mbPartIdx ++){ if ( sub_mb_type_name[ai_pstSlice -> slice_type][Current_residu -> SubMbType[mbPartIdx]] != B_direct){ if ( sub_num_part[ai_pstSlice -> slice_type][Current_residu -> SubMbType[mbPartIdx]] > 1 ) noSubMbPartSizeLessThan8x8 = 0; } } } else { noSubMbPartSizeLessThan8x8 = 1; if ( Pps -> transform_8x8_mode_flag && Current_residu -> MbType == INTRA_4x4 && getNbits(ai_pcData, position, 1)){ Current_residu -> MbType = Current_residu -> Transform8x8 = aio_pstBlock -> Transform8x8 = aio_pstBlock -> MbPartPredMode[0] = INTRA_8x8; } //Recovery of the prediction mode and the motion vectors for the macroblock if(mb_pred_svc(ai_pcData, position, ai_pstSlice, aio_pstBlock, Current_residu, intra4x4_pred_mode_cache)){ return 1; } } } //Decoding process of the VLC if( ai_pstSlice -> AdaptiveResidualPredictionFlag && ai_pstSlice -> slice_type != EI && (BaseModeFlag || ( !IS_I( Current_residu -> MbType) && Current_residu -> InCropWindow ))){ Current_residu -> ResidualPredictionFlag = getNbits(ai_pcData, position, 1); }else{ Current_residu -> ResidualPredictionFlag = ai_pstSlice -> DefaultResidualPredictionFlag; } if ( BaseModeFlag || aio_pstBlock -> MbPartPredMode[0] != INTRA_16x16 ){ Current_residu -> Cbp = read_me_svc(ai_pcData, position, aio_pstBlock -> MbPartPredMode[0],Current_residu, iCurrMbAddr, ai_pstSlice, iMb_x); if ( (Current_residu -> Cbp & 15) && Pps -> transform_8x8_mode_flag && (BaseModeFlag || (!IS_I(Current_residu -> MbType) && noSubMbPartSizeLessThan8x8 && ( Current_residu -> MbType == B_direct || direct_8x8_inference_flag))) && getNbits(ai_pcData, position, 1)){ Current_residu -> Transform8x8 = aio_pstBlock -> Transform8x8 = INTRA_8x8; } } if ( Current_residu -> Cbp > 0 || (Current_residu -> MbType == INTRA_16x16)) { int mb_qp_delta = read_se(ai_pcData, position); residual(ai_pcData, position, Current_residu, vlc, aio_tiNon_zero_count_cache); //In case of cbp is equal to zéro, we check if there is a DC level if (Current_residu -> Cbp == 0 && aio_tiNon_zero_count_cache[0] != 0){ Current_residu -> Cbp = 15; } if ( Current_residu -> MbType == INTRA_16x16 && !(Current_residu -> Cbp & 15) && (Current_residu -> Cbp & 0x30) && aio_tiNon_zero_count_cache[0]){ Current_residu -> Cbp += 15; } #ifdef TI_OPTIM *last_QP = Current_residu -> Qp = divide(*last_QP + mb_qp_delta + 52, 52) >> 8 ; #else *last_QP = Current_residu -> Qp = (*last_QP + mb_qp_delta + 52) % 52; #endif }else {
/** This function permits to decode the prediction mode or the image reference. @param ai_pcData The NAL unit. @param position The current position in the NAL. @param block Contains all parameters of the current macroblock. @param ai_pstSlice The slice structure. @param ao_pstIntra_pred_mode Contains the prediction mode for the current macroblock. */ int mb_pred_svc( const unsigned char *ai_pcData, int *position, const SLICE *ai_pstSlice, DATA *aio_pstMacroblock, RESIDU *Current_residu, short *intra4x4_pred_mode_cache) { int mbPartIdx ; //Recovery of the prediction mode if(IS_I(aio_pstMacroblock -> MbPartPredMode [0])){ if(mb_pred_I(ai_pcData, position, Current_residu, Current_residu -> Intra16x16DCLevel, intra4x4_pred_mode_cache)){ return 1; } } else if ( aio_pstMacroblock -> MbPartPredMode [0] != B_direct ) { if( ai_pstSlice -> AdaptiveMotionPredictionFlag && Current_residu -> InCropWindow ) { if(ReadMotionPredSVC(ai_pcData, position, aio_pstMacroblock -> MotionPredL0, aio_pstMacroblock, Pred_L1)) return 1; if(ReadMotionPredSVC(ai_pcData, position, aio_pstMacroblock -> MotionPredL1, aio_pstMacroblock, Pred_L0)) return 1; }else{ aio_pstMacroblock -> MotionPredL0[0] = aio_pstMacroblock -> MotionPredL0[1] = aio_pstMacroblock -> MotionPredL0[2] = aio_pstMacroblock -> MotionPredL0[3] = aio_pstMacroblock -> MotionPredL1[0] = aio_pstMacroblock -> MotionPredL1[1] = aio_pstMacroblock -> MotionPredL1[2] = aio_pstMacroblock -> MotionPredL1[3] = ai_pstSlice -> DefaultMotionPredictionFlag; } if ( ai_pstSlice -> num_RefIdxL0_active_minus1 != 0 ){ for ( mbPartIdx = 0 ; mbPartIdx < aio_pstMacroblock -> NumMbPart ; mbPartIdx++ ) { if ( (aio_pstMacroblock -> MbPartPredMode [mbPartIdx] != Pred_L1 ) && (!aio_pstMacroblock -> MotionPredL0[mbPartIdx])) { aio_pstMacroblock -> RefIdxL0 [mbPartIdx] = read_te(ai_pcData, position, ai_pstSlice -> num_RefIdxL0_active_minus1); } } } #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckRefLx(aio_pstMacroblock -> RefIdxL0, ai_pstSlice -> num_RefIdxL0_active_minus1)){ return 1; } #endif //Recovery of of the image reference for the frame if ( ai_pstSlice -> num_RefIdxL1_active_minus1 != 0 ){ for ( mbPartIdx = 0 ; mbPartIdx < aio_pstMacroblock -> NumMbPart ; mbPartIdx++ ) { if ((aio_pstMacroblock -> MbPartPredMode [mbPartIdx] != Pred_L0) && (!aio_pstMacroblock -> MotionPredL1[mbPartIdx])) { aio_pstMacroblock -> RefIdxL1 [mbPartIdx] = read_te(ai_pcData, position, ai_pstSlice -> num_RefIdxL1_active_minus1); } } } #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckRefLx(aio_pstMacroblock -> RefIdxL1, ai_pstSlice -> num_RefIdxL1_active_minus1)){ return 1; } #endif //Recovery of of the motion vector for the frame P for ( mbPartIdx = 0 ; mbPartIdx < aio_pstMacroblock -> NumMbPart ; mbPartIdx++ ) { /* Pour eviter de traiter les Images B*/ if ( aio_pstMacroblock -> MbPartPredMode [mbPartIdx] != Pred_L1 ) { aio_pstMacroblock -> MvdL0 [mbPartIdx << 2][0] = read_se(ai_pcData, position); aio_pstMacroblock -> MvdL0 [mbPartIdx << 2][1] = read_se(ai_pcData, position); } } //Recovery of of the motion vector for the frame B for ( mbPartIdx = 0 ; mbPartIdx < aio_pstMacroblock -> NumMbPart ; mbPartIdx++ ) { if ( aio_pstMacroblock -> MbPartPredMode [mbPartIdx] != Pred_L0 ) { aio_pstMacroblock -> MvdL1 [ mbPartIdx << 2][0] = read_se(ai_pcData, position); aio_pstMacroblock -> MvdL1 [ mbPartIdx << 2][1] = read_se(ai_pcData, position); } } }else{ Current_residu -> Mode = 4; for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++){ Current_residu -> SubMbType [mbPartIdx] = 3; } } return 0; }
/** This function permits to recover the macroblock's data from the vlc All the parameters decoded will be stored in differents structures or tables. @param Pps PPS structure of the current video. @param picture_residu Structure whixh contains information about the macroblock. @param data The NAL unit. @param aio_piPosition The current aio_piPosition in the NAL. @param Slice The Slice structure. @param block Contains all parameters of the current macroblock. @param vlc The VLC tables in order to decode the Nal Unit. @param non_zero_count_cache Specifies the coeff_token of each blocks 4x4 of a macroblock. @param non_zero_count Specifies the coeff_token of each block of the picture. @param SliceTable Specifies in which Slice belongs each macroblock of the picture. @param intra_pred_mod Contains the prediction mode for each macroblock. @param ai_iMb_x The x position of the macroblock in the picture. @param ai_iMb_y The y position of the macroblock in the picture. @param last_QP Give the QP of the last decoded macroblock. @param iCurrMbAddr Number of the current macroblock. */ char macroblock_I_partitionning(const PPS *Pps, RESIDU *picture_residu, const unsigned char *ai_pcData, int *aio_piPosition, SLICE *Slice, DATA *aio_pstBlock, const VLC_TABLES * Vlc, unsigned char *NonZeroCountCache, unsigned char *SliceTable, const short ai_iMb_x, const short ai_iMb_y, unsigned char *last_QP, int iCurrMbAddr) { short intra4x4_pred_mode_cache[40]; #ifdef ERROR_DETECTION //Error detection if(ErrorsCheckIMbType(picture_residu -> MbType)){ return 1; } #endif //Updating the Slice table in order to save in which slice each macroblock belong to picture_residu -> SliceNum = SliceTable [iCurrMbAddr] = Slice -> slice_num ; if ( picture_residu -> MbType == INTRA_PCM ) { while ( !bytes_aligned(*aio_piPosition) ) { getNbits(ai_pcData, aio_piPosition, 1);//pcm_alignment_zero_bit = } ParseIPCM(ai_pcData, aio_piPosition, picture_residu, NonZeroCountCache); } else { //Updating the parameter in order to decode the VLC fill_caches_I( Slice, picture_residu, 0, NonZeroCountCache, aio_pstBlock, SliceTable, intra4x4_pred_mode_cache, ai_iMb_x, ai_iMb_y, Pps -> constrained_intra_pred_flag); if ( Pps -> transform_8x8_mode_flag && picture_residu -> MbType == INTRA_4x4 && getNbits(ai_pcData, aio_piPosition, 1)){ picture_residu -> Transform8x8 = picture_residu -> MbType = aio_pstBlock -> Transform8x8 = INTRA_8x8; } //Recovery of the prediction mode and the motion vectors for the macroblock if(mb_pred_I(ai_pcData, aio_piPosition, picture_residu, picture_residu -> Intra16x16DCLevel, intra4x4_pred_mode_cache)){ return 1; } if ( aio_pstBlock -> MbPartPredMode[0] != INTRA_16x16 ) { picture_residu -> Cbp = read_me(ai_pcData, aio_piPosition, aio_pstBlock -> MbPartPredMode[0]); } if ( picture_residu -> Cbp > 0 || (picture_residu -> MbType == INTRA_16x16)){ int mb_qp_delta = read_se(ai_pcData, aio_piPosition); #ifdef TI_OPTIM *last_QP = picture_residu -> Qp = divide(*last_QP + mb_qp_delta + 52, 52) >> 8 ; #else *last_QP = picture_residu -> Qp = (*last_QP + mb_qp_delta + 52) % 52; #endif //Decoding process of the VLC residual(ai_pcData, aio_piPosition, picture_residu, Vlc, NonZeroCountCache); } else {
/** This function permits to decode from the bitstream the Sequence Parameter Set NAL unit. All the parameters decoded will be stored in the sps structure. @param data The NAL unit. @param position The current position in the NAL. @param NalBytesInNalunit The sizes of the NAL unit in bytes. @param sps The sps structure which contains all parameters decoded in this NAL. */ void seq_parameter_set_data ( unsigned char *data, int *position, SPS *pt_sps){ int i = 0 ; if( pt_sps -> profile_idc == 100 || pt_sps -> profile_idc == 110 || pt_sps -> profile_idc == 122 || pt_sps -> profile_idc == 244 || pt_sps -> profile_idc == 44 || pt_sps -> profile_idc == 83 || pt_sps -> profile_idc == 86 ) { pt_sps -> chroma_format_idc = read_ue(data, position); if( pt_sps -> chroma_format_idc == 3 ){ getNbits(data, position, 1);//separate_colour_plane_flag } pt_sps -> bit_depth_luma = read_ue(data, position) + 8; pt_sps -> bit_depth_chroma = read_ue(data, position) + 8; getNbits(data, position, 1);//qpprime_y_zero_transform_bypass_flag decode_scaling_matrices(data, position, pt_sps,1, pt_sps -> scaling_matrix4 , pt_sps -> scaling_matrix8); } pt_sps -> log2_max_frame_num = read_ue(data, position) + 4; pt_sps -> pic_order_cnt_type = read_ue(data, position); if ( pt_sps -> pic_order_cnt_type == 0 ) { pt_sps -> log2_max_pic_order_cnt_lsb = read_ue(data, position) + 4; } else if ( pt_sps -> pic_order_cnt_type == 1 ) { pt_sps -> delta_pic_order_always_zero_flag = getNbits(data, position, 1); pt_sps -> offset_for_non_ref_pic = read_se(data, position); pt_sps -> offset_for_top_to_bottom_field = read_se(data, position); pt_sps -> num_ref_frames_in_pic_order_cnt_cycle = read_ue(data, position); for (; i < pt_sps -> num_ref_frames_in_pic_order_cnt_cycle ; i++ ) { pt_sps -> offset_for_ref_frame [i] = read_se(data, position); } } pt_sps -> num_ref_frames = read_ue(data, position);// getNbits(data, position, 1);//gaps_in_frame_num_value_allowed_flag = pt_sps -> pic_width_in_mbs = read_ue(data, position) + 1; pt_sps -> pic_height_in_map_units = read_ue(data, position) + 1; pt_sps -> frame_mbs_only_flag = getNbits(data, position, 1); pt_sps -> PicSizeInMbs = pt_sps -> pic_width_in_mbs * pt_sps -> pic_height_in_map_units; if ( !pt_sps -> frame_mbs_only_flag ) { pt_sps -> MbAdaptiveFrameFieldFlag = getNbits(data, position, 1); } //To initialize the number of decoded frame before displaying. get_max_dpb(pt_sps); pt_sps -> direct_8x8_inference_flag = getNbits(data, position, 1); if ( getNbits(data, position, 1)) {//frame_cropping_flag pt_sps -> CropLeft = (read_ue(data, position)) << 1;//frame_crop_left_offset = pt_sps -> CropRight = (read_ue(data, position)) << 1;//frame_crop_right_offset = pt_sps -> CropTop = (read_ue(data, position)) << 1;//frame_crop_top_offset = pt_sps -> CropBottom = (read_ue(data, position)) << 1;//frame_crop_bottom_offset = } if ( getNbits(data, position, 1) ) { vui_parameters(data, position, pt_sps); } }