1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "box/item_property_display_box.h" 17 18 #include <string> 19 20 #include "heif_constant.h" 21 #include "heif_error.h" 22 #include "heif_stream.h" 23 24 namespace OHOS { 25 namespace ImagePlugin { 26 ParseContent(HeifStreamReader & reader)27heif_error HeifMdcvBox::ParseContent(HeifStreamReader &reader) 28 { 29 colourVolume_.red.x = reader.Read16(); 30 colourVolume_.red.y = reader.Read16(); 31 colourVolume_.green.x = reader.Read16(); 32 colourVolume_.green.y = reader.Read16(); 33 colourVolume_.blue.x = reader.Read16(); 34 colourVolume_.blue.y = reader.Read16(); 35 colourVolume_.whitePoint.x = reader.Read16(); 36 colourVolume_.whitePoint.y = reader.Read16(); 37 colourVolume_.luminanceMax = reader.Read32(); 38 colourVolume_.luminanceMin = reader.Read32(); 39 return reader.GetError(); 40 } 41 Write(HeifStreamWriter & writer) const42heif_error HeifMdcvBox::Write(HeifStreamWriter &writer) const 43 { 44 size_t boxStart = ReserveHeader(writer); 45 46 writer.Write16(colourVolume_.red.x); 47 writer.Write16(colourVolume_.red.y); 48 writer.Write16(colourVolume_.green.x); 49 writer.Write16(colourVolume_.green.y); 50 writer.Write16(colourVolume_.blue.x); 51 writer.Write16(colourVolume_.blue.y); 52 writer.Write16(colourVolume_.whitePoint.x); 53 writer.Write16(colourVolume_.whitePoint.y); 54 writer.Write32(colourVolume_.luminanceMax); 55 writer.Write32(colourVolume_.luminanceMin); 56 57 WriteCalculatedHeader(writer, boxStart); 58 return heif_error_ok; 59 } 60 ParseContent(HeifStreamReader & reader)61heif_error HeifClliBox::ParseContent(HeifStreamReader &reader) 62 { 63 lightLevel_.maxContentLightLevel = reader.Read16(); 64 lightLevel_.maxPicAverageLightLevel = reader.Read16(); 65 return reader.GetError(); 66 } 67 Write(HeifStreamWriter & writer) const68heif_error HeifClliBox::Write(HeifStreamWriter &writer) const 69 { 70 size_t boxStart = ReserveHeader(writer); 71 72 writer.Write16(lightLevel_.maxContentLightLevel); 73 writer.Write16(lightLevel_.maxPicAverageLightLevel); 74 75 WriteCalculatedHeader(writer, boxStart); 76 return heif_error_ok; 77 } 78 } 79 }