Skip to content

Commit

Permalink
Use int16_t to make images smaller.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledyba-z committed Apr 15, 2022
1 parent 5913d12 commit e271be5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/AVIFBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ avif::FileBox AVIFBuilder::buildFileBox() {
}
}
this->fillFrameInfo(1, frame);
size_t nextID = 2;
uint16_t nextID = 2;
if(this->alpha_.has_value()) {
this->fillFrameInfo(nextID, alpha_.value(), avif::kAlphaAuxType());
this->linkAuxImages(nextID, 1);
Expand All @@ -179,16 +179,16 @@ avif::FileBox AVIFBuilder::buildFileBox() {
return this->fileBox_;
}

void AVIFBuilder::linkAuxImages(uint32_t const from, uint32_t const to) {
void AVIFBuilder::linkAuxImages(uint16_t const from, uint16_t const to) {
using namespace avif;
if(!this->fileBox_.metaBox.itemReferenceBox.has_value()) {
ItemReferenceBox box{
.references = std::vector<SingleItemTypeReferenceBoxLarge>{},
.references = std::vector<SingleItemTypeReferenceBox>{},
};
box.setFullBoxHeader(1, 0);
this->fileBox_.metaBox.itemReferenceBox = box;
}
auto& refs = std::get<std::vector<SingleItemTypeReferenceBoxLarge>>(this->fileBox_.metaBox.itemReferenceBox.value().references);
auto& refs = std::get<std::vector<SingleItemTypeReferenceBox>>(this->fileBox_.metaBox.itemReferenceBox.value().references);
for(auto& ref : refs) {
if(ref.fromItemID == from) {
for(auto const& oldTo : ref.toItemIDs) {
Expand All @@ -200,7 +200,7 @@ void AVIFBuilder::linkAuxImages(uint32_t const from, uint32_t const to) {
return;
}
}
auto box = SingleItemTypeReferenceBoxLarge{
auto box = SingleItemTypeReferenceBox {
.fromItemID = from,
.toItemIDs = {to},
};
Expand Down
2 changes: 1 addition & 1 deletion src/AVIFBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ class AVIFBuilder final {

private:
[[ nodiscard ]] avif::FileBox buildFileBox();
void linkAuxImages(uint32_t from, uint32_t to);
void linkAuxImages(uint16_t from, uint16_t to);
void fillFrameInfo(uint16_t itemID, AVIFBuilder::Frame const& frame, std::optional<std::string> const& auxType = {});
};

0 comments on commit e271be5

Please sign in to comment.