| 42 | using namespace reader; |
| 43 | |
| 44 | void segmentation_params::parse(reader::SubByteReaderLogging &reader, unsigned primary_ref_frame) |
| 45 | { |
| 46 | SubByteReaderLoggingSubLevel subLevel(reader, "segmentation_params()"); |
| 47 | |
| 48 | int Segmentation_Feature_Bits[SEG_LVL_MAX] = {8, 6, 6, 6, 6, 3, 0, 0}; |
| 49 | int Segmentation_Feature_Signed[SEG_LVL_MAX] = {1, 1, 1, 1, 1, 0, 0, 0}; |
| 50 | int Segmentation_Feature_Max[SEG_LVL_MAX] = { |
| 51 | 255, MAX_LOOP_FILTER, MAX_LOOP_FILTER, MAX_LOOP_FILTER, MAX_LOOP_FILTER, 7, 0, 0}; |
| 52 | |
| 53 | this->segmentation_enabled = reader.readFlag("segmentation_enabled"); |
| 54 | if (this->segmentation_enabled) |
| 55 | { |
| 56 | if (primary_ref_frame == PRIMARY_REF_NONE) |
| 57 | { |
| 58 | this->segmentation_update_map = 1; |
| 59 | this->segmentation_temporal_update = 0; |
| 60 | this->segmentation_update_data = 1; |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | this->segmentation_update_map = reader.readFlag("segmentation_update_map"); |
| 65 | if (this->segmentation_update_map) |
| 66 | this->segmentation_temporal_update = reader.readFlag("segmentation_temporal_update"); |
| 67 | this->segmentation_update_data = reader.readFlag("segmentation_update_data"); |
| 68 | } |
| 69 | if (this->segmentation_update_data) |
| 70 | { |
| 71 | for (unsigned i = 0; i < MAX_SEGMENTS; i++) |
| 72 | { |
| 73 | for (unsigned j = 0; j < SEG_LVL_MAX; j++) |
| 74 | { |
| 75 | this->FeatureEnabled[i][j] = reader.readFlag("feature_enabled"); |
| 76 | int clippedValue = 0; |
| 77 | if (this->FeatureEnabled[i][j]) |
| 78 | { |
| 79 | auto bitsToRead = Segmentation_Feature_Bits[j]; |
| 80 | auto limit = Segmentation_Feature_Max[j]; |
| 81 | if (Segmentation_Feature_Signed[j]) |
| 82 | { |
| 83 | clippedValue = functions::clip( |
| 84 | int(reader.readSU("feature_value", bitsToRead + 1)), -limit, limit); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | clippedValue = |
| 89 | functions::clip(int(reader.readBits("feature_value", bitsToRead)), 0, limit); |
| 90 | } |
| 91 | } |
| 92 | this->FeatureData[i][j] = clippedValue; |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | for (unsigned i = 0; i < MAX_SEGMENTS; i++) |
| 100 | { |
| 101 | for (unsigned j = 0; j < SEG_LVL_MAX; j++) |