Skip to content

Commit

Permalink
use vector::emplace_back in color-conversion state_after_conversion()
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 22, 2024
1 parent 2e88157 commit fe25a21
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 65 deletions.
2 changes: 1 addition & 1 deletion libheif/color-conversion/alpha.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Op_drop_alpha_plane::state_after_conversion(const ColorState& input_state,
output_state = input_state;
output_state.has_alpha = false;

states.push_back({output_state, SpeedCosts_Trivial});
states.emplace_back(output_state, SpeedCosts_Trivial);

return states;
}
Expand Down
8 changes: 4 additions & 4 deletions libheif/color-conversion/chroma_sampling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Op_YCbCr444_to_YCbCr420_average<Pixel>::state_after_conversion(const ColorState&
output_state.bits_per_pixel = input_state.bits_per_pixel;
output_state.nclx_profile = input_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -286,7 +286,7 @@ Op_YCbCr444_to_YCbCr422_average<Pixel>::state_after_conversion(const ColorState&
output_state.bits_per_pixel = input_state.bits_per_pixel;
output_state.nclx_profile = input_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ Op_YCbCr420_bilinear_to_YCbCr444<Pixel>::state_after_conversion(const ColorState
output_state.bits_per_pixel = input_state.bits_per_pixel;
output_state.nclx_profile = input_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -757,7 +757,7 @@ Op_YCbCr422_bilinear_to_YCbCr444<Pixel>::state_after_conversion(const ColorState
output_state.bits_per_pixel = input_state.bits_per_pixel;
output_state.nclx_profile = input_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down
60 changes: 30 additions & 30 deletions libheif/color-conversion/colorconversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,36 +219,36 @@ void ColorConversionPipeline::init_ops()
}

std::vector<std::shared_ptr<ColorConversionOperation>>& ops = m_operation_pool;
ops.push_back(std::make_shared<Op_RGB_to_RGB24_32>());
ops.push_back(std::make_shared<Op_RGB24_32_to_RGB>());
ops.push_back(std::make_shared<Op_YCbCr_to_RGB<uint16_t>>());
ops.push_back(std::make_shared<Op_YCbCr_to_RGB<uint8_t>>());
ops.push_back(std::make_shared<Op_YCbCr420_to_RGB24>());
ops.push_back(std::make_shared<Op_YCbCr420_to_RGB32>());
ops.push_back(std::make_shared<Op_YCbCr420_to_RRGGBBaa>());
ops.push_back(std::make_shared<Op_RGB_HDR_to_RRGGBBaa_BE>());
ops.push_back(std::make_shared<Op_RGB_to_RRGGBBaa_BE>());
ops.push_back(std::make_shared<Op_mono_to_YCbCr420>());
ops.push_back(std::make_shared<Op_mono_to_RGB24_32>());
ops.push_back(std::make_shared<Op_RRGGBBaa_swap_endianness>());
ops.push_back(std::make_shared<Op_RRGGBBaa_BE_to_RGB_HDR>());
ops.push_back(std::make_shared<Op_RGB24_32_to_YCbCr>());
ops.push_back(std::make_shared<Op_RGB_to_YCbCr<uint8_t>>());
ops.push_back(std::make_shared<Op_RGB_to_YCbCr<uint16_t>>());
ops.push_back(std::make_shared<Op_RRGGBBxx_HDR_to_YCbCr420>());
ops.push_back(std::make_shared<Op_RGB24_32_to_YCbCr444_GBR>());
ops.push_back(std::make_shared<Op_drop_alpha_plane>());
ops.push_back(std::make_shared<Op_to_hdr_planes>());
ops.push_back(std::make_shared<Op_to_sdr_planes>());
ops.push_back(std::make_shared<Op_YCbCr420_bilinear_to_YCbCr444<uint8_t>>());
ops.push_back(std::make_shared<Op_YCbCr420_bilinear_to_YCbCr444<uint16_t>>());
ops.push_back(std::make_shared<Op_YCbCr422_bilinear_to_YCbCr444<uint8_t>>());
ops.push_back(std::make_shared<Op_YCbCr422_bilinear_to_YCbCr444<uint16_t>>());
ops.push_back(std::make_shared<Op_YCbCr444_to_YCbCr420_average<uint8_t>>());
ops.push_back(std::make_shared<Op_YCbCr444_to_YCbCr420_average<uint16_t>>());
ops.push_back(std::make_shared<Op_YCbCr444_to_YCbCr422_average<uint8_t>>());
ops.push_back(std::make_shared<Op_YCbCr444_to_YCbCr422_average<uint16_t>>());
ops.push_back(std::make_shared<Op_Any_RGB_to_YCbCr_420_Sharp>());
ops.emplace_back(std::make_shared<Op_RGB_to_RGB24_32>());
ops.emplace_back(std::make_shared<Op_RGB24_32_to_RGB>());
ops.emplace_back(std::make_shared<Op_YCbCr_to_RGB<uint16_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr_to_RGB<uint8_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr420_to_RGB24>());
ops.emplace_back(std::make_shared<Op_YCbCr420_to_RGB32>());
ops.emplace_back(std::make_shared<Op_YCbCr420_to_RRGGBBaa>());
ops.emplace_back(std::make_shared<Op_RGB_HDR_to_RRGGBBaa_BE>());
ops.emplace_back(std::make_shared<Op_RGB_to_RRGGBBaa_BE>());
ops.emplace_back(std::make_shared<Op_mono_to_YCbCr420>());
ops.emplace_back(std::make_shared<Op_mono_to_RGB24_32>());
ops.emplace_back(std::make_shared<Op_RRGGBBaa_swap_endianness>());
ops.emplace_back(std::make_shared<Op_RRGGBBaa_BE_to_RGB_HDR>());
ops.emplace_back(std::make_shared<Op_RGB24_32_to_YCbCr>());
ops.emplace_back(std::make_shared<Op_RGB_to_YCbCr<uint8_t>>());
ops.emplace_back(std::make_shared<Op_RGB_to_YCbCr<uint16_t>>());
ops.emplace_back(std::make_shared<Op_RRGGBBxx_HDR_to_YCbCr420>());
ops.emplace_back(std::make_shared<Op_RGB24_32_to_YCbCr444_GBR>());
ops.emplace_back(std::make_shared<Op_drop_alpha_plane>());
ops.emplace_back(std::make_shared<Op_to_hdr_planes>());
ops.emplace_back(std::make_shared<Op_to_sdr_planes>());
ops.emplace_back(std::make_shared<Op_YCbCr420_bilinear_to_YCbCr444<uint8_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr420_bilinear_to_YCbCr444<uint16_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr422_bilinear_to_YCbCr444<uint8_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr422_bilinear_to_YCbCr444<uint16_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr444_to_YCbCr420_average<uint8_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr444_to_YCbCr420_average<uint16_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr444_to_YCbCr422_average<uint8_t>>());
ops.emplace_back(std::make_shared<Op_YCbCr444_to_YCbCr422_average<uint16_t>>());
ops.emplace_back(std::make_shared<Op_Any_RGB_to_YCbCr_420_Sharp>());
}


Expand Down
4 changes: 2 additions & 2 deletions libheif/color-conversion/hdr_sdr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Op_to_hdr_planes::state_after_conversion(const ColorState& input_state,
output_state = input_state;
output_state.bits_per_pixel = target_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -131,7 +131,7 @@ Op_to_sdr_planes::state_after_conversion(const ColorState& input_state,
output_state = input_state;
output_state.bits_per_pixel = 8;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down
6 changes: 3 additions & 3 deletions libheif/color-conversion/monochrome.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Op_mono_to_YCbCr420::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = input_state.has_alpha;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_OptimizedSoftware});
states.emplace_back(std::move(output_state), SpeedCosts_OptimizedSoftware);

return states;
}
Expand Down Expand Up @@ -183,7 +183,7 @@ Op_mono_to_RGB24_32::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = false;
output_state.bits_per_pixel = 8;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);
}


Expand All @@ -194,7 +194,7 @@ Op_mono_to_RGB24_32::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = true;
output_state.bits_per_pixel = 8;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down
23 changes: 10 additions & 13 deletions libheif/color-conversion/rgb2rgb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Op_RGB_to_RGB24_32::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = true;
output_state.bits_per_pixel = 8;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

// --- convert to RGB (without alpha)

Expand All @@ -57,7 +57,7 @@ Op_RGB_to_RGB24_32::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = false;
output_state.bits_per_pixel = 8;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -168,7 +168,7 @@ Op_RGB_HDR_to_RRGGBBaa_BE::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = false;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);
}


Expand All @@ -179,7 +179,7 @@ Op_RGB_HDR_to_RRGGBBaa_BE::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = true;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);


return states;
Expand Down Expand Up @@ -303,7 +303,7 @@ Op_RGB_to_RRGGBBaa_BE::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = false;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);
}


Expand All @@ -314,8 +314,7 @@ Op_RGB_to_RRGGBBaa_BE::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = true;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});

states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -432,8 +431,7 @@ Op_RRGGBBaa_BE_to_RGB_HDR::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = target_state.has_alpha;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});

states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -546,7 +544,7 @@ Op_RGB24_32_to_RGB::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = target_state.has_alpha;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -651,7 +649,7 @@ Op_RRGGBBaa_swap_endianness::state_after_conversion(const ColorState& input_stat
output_state.has_alpha = false;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);
}


Expand All @@ -671,10 +669,9 @@ Op_RRGGBBaa_swap_endianness::state_after_conversion(const ColorState& input_stat
output_state.has_alpha = true;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);
}


return states;
}

Expand Down
10 changes: 5 additions & 5 deletions libheif/color-conversion/rgb2yuv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Op_RGB_to_YCbCr<Pixel>::state_after_conversion(const ColorState& input_state,
output_state.bits_per_pixel = input_state.bits_per_pixel;
output_state.nclx_profile = target_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);
}
else {
// --- convert to YCbCr 4:4:4
Expand All @@ -83,7 +83,7 @@ Op_RGB_to_YCbCr<Pixel>::state_after_conversion(const ColorState& input_state,
output_state.bits_per_pixel = input_state.bits_per_pixel;
output_state.nclx_profile = target_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);
}

return states;
Expand Down Expand Up @@ -330,7 +330,7 @@ Op_RRGGBBxx_HDR_to_YCbCr420::state_after_conversion(const ColorState& input_stat
output_state.bits_per_pixel = input_state.bits_per_pixel;
output_state.nclx_profile = target_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -517,7 +517,7 @@ Op_RGB24_32_to_YCbCr::state_after_conversion(const ColorState& input_state,
output_state.bits_per_pixel = 8;
output_state.nclx_profile = target_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -808,7 +808,7 @@ Op_RGB24_32_to_YCbCr444_GBR::state_after_conversion(const ColorState& input_stat
output_state.bits_per_pixel = 8;
output_state.nclx_profile = target_state.nclx_profile;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down
2 changes: 1 addition & 1 deletion libheif/color-conversion/rgb2yuv_sharp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Op_Any_RGB_to_YCbCr_420_Sharp::state_after_conversion(
output_state.has_alpha = target_state.has_alpha;
output_state.bits_per_pixel = target_state.bits_per_pixel;
output_state.nclx_profile = target_state.nclx_profile;
states.push_back({output_state, SpeedCosts_Slow});
states.emplace_back(output_state, SpeedCosts_Slow);

return states;
#else
Expand Down
10 changes: 5 additions & 5 deletions libheif/color-conversion/yuv2rgb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Op_YCbCr_to_RGB<Pixel>::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = input_state.has_alpha; // we simply keep the old alpha plane
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ Op_YCbCr420_to_RGB24::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = false;
output_state.bits_per_pixel = 8;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -412,7 +412,7 @@ Op_YCbCr420_to_RGB32::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = true;
output_state.bits_per_pixel = 8;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down Expand Up @@ -537,7 +537,7 @@ Op_YCbCr420_to_RRGGBBaa::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = input_state.has_alpha;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);


output_state.colorspace = heif_colorspace_RGB;
Expand All @@ -546,7 +546,7 @@ Op_YCbCr420_to_RRGGBBaa::state_after_conversion(const ColorState& input_state,
output_state.has_alpha = input_state.has_alpha;
output_state.bits_per_pixel = input_state.bits_per_pixel;

states.push_back({output_state, SpeedCosts_Unoptimized});
states.emplace_back(output_state, SpeedCosts_Unoptimized);

return states;
}
Expand Down
2 changes: 1 addition & 1 deletion libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ Error HeifContext::interpret_heif_file()
metadata->item_id = id;
metadata->item_type = fourcc_to_string(item_type);
metadata->content_type = content_type;
metadata->item_uri_type = item_uri_type;
metadata->item_uri_type = std::move(item_uri_type);

Error err = m_heif_file->get_uncompressed_item_data(id, &(metadata->m_data));
if (err) {
Expand Down

0 comments on commit fe25a21

Please sign in to comment.