Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added VVC codec functions #1108

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/heif_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ void list_all_decoders()
std::cout << "HEIC decoders:\n";
list_decoders(heif_compression_HEVC);

std::cout << "VVIC decoders:\n";
list_decoders(heif_compression_VVC);

std::cout << "AVIF decoders:\n";
list_decoders(heif_compression_AV1);

Expand Down
32 changes: 27 additions & 5 deletions examples/heif_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ const int OPTION_NCLX_TRANSFER_CHARACTERISTIC = 1002;
const int OPTION_NCLX_FULL_RANGE_FLAG = 1003;
const int OPTION_PLUGIN_DIRECTORY = 1004;
const int OPTION_PITM_DESCRIPTION = 1005;
const int OPTION_USE_JPEG_COMPRESSION = 1006;
const int OPTION_USE_JPEG2000_COMPRESSION = 1007;
const int OPTION_VERBOSE = 1008;
const int OPTION_USE_VVC_COMPRESSION = 1006;
const int OPTION_USE_JPEG_COMPRESSION = 1007;
const int OPTION_USE_JPEG2000_COMPRESSION = 1008;
const int OPTION_VERBOSE = 1009;


static struct option long_options[] = {
Expand All @@ -112,6 +113,7 @@ static struct option long_options[] = {
{(char* const) "bit-depth", required_argument, 0, 'b'},
{(char* const) "even-size", no_argument, 0, 'E'},
{(char* const) "avif", no_argument, 0, 'A'},
{(char* const) "vvc", no_argument, 0, OPTION_USE_VVC_COMPRESSION},
{(char* const) "jpeg", no_argument, 0, OPTION_USE_JPEG_COMPRESSION},
{(char* const) "jpeg2000", no_argument, 0, OPTION_USE_JPEG2000_COMPRESSION},
#if WITH_UNCOMPRESSED_CODEC
Expand Down Expand Up @@ -159,6 +161,7 @@ void show_help(const char* argv0)
<< " -b, --bit-depth # bit-depth of generated HEIF/AVIF file when using 16-bit PNG input (default: 10 bit)\n"
<< " -p set encoder parameter (NAME=VALUE)\n"
<< " -A, --avif encode as AVIF (not needed if output filename with .avif suffix is provided)\n"
<< " --vvc encode as VVC (even more experimental)\n"
<< " --jpeg encode as JPEG\n"
<< " --jpeg2000 encode as JPEG 2000 (experimental)\n"
#if WITH_UNCOMPRESSED_CODEC
Expand Down Expand Up @@ -355,6 +358,9 @@ static const char* get_compression_format_name(heif_compression_format format)
case heif_compression_AV1:
return "AV1";
break;
case heif_compression_VVC:
return "VVC";
break;
case heif_compression_HEVC:
return "HEVC";
break;
Expand All @@ -375,7 +381,8 @@ static const char* get_compression_format_name(heif_compression_format format)

static void show_list_of_all_encoders()
{
for (auto compression_format : {heif_compression_HEVC, heif_compression_AV1, heif_compression_JPEG, heif_compression_JPEG2000
for (auto compression_format : {heif_compression_VVC, heif_compression_HEVC, heif_compression_AV1, heif_compression_JPEG,
heif_compression_JPEG2000
#if WITH_UNCOMPRESSED_CODEC
, heif_compression_uncompressed
#endif
Expand All @@ -385,6 +392,9 @@ static void show_list_of_all_encoders()
case heif_compression_AV1:
std::cout << "AVIF";
break;
case heif_compression_VVC:
std::cout << "VVIC";
break;
case heif_compression_HEVC:
std::cout << "HEIC";
break;
Expand Down Expand Up @@ -434,6 +444,9 @@ heif_compression_format guess_compression_format_from_filename(const std::string
if (ends_with(filename_lowercase, ".avif")) {
return heif_compression_AV1;
}
else if (ends_with(filename_lowercase, ".vvic")) {
return heif_compression_VVC;
}
else if (ends_with(filename_lowercase, ".heic")) {
return heif_compression_HEVC;
}
Expand All @@ -450,6 +463,7 @@ std::string suffix_for_compression_format(heif_compression_format format)
{
switch (format) {
case heif_compression_AV1: return "avif";
case heif_compression_VVC: return "vvic";
case heif_compression_HEVC: return "heic";
case heif_compression_JPEG2000: return "hej2";
default: return "data";
Expand Down Expand Up @@ -479,6 +493,7 @@ int main(int argc, char** argv)
int thumbnail_bbox_size = 0;
int output_bit_depth = 10;
bool force_enc_av1f = false;
bool force_enc_vvc = false;
bool force_enc_uncompressed = false;
bool force_enc_jpeg = false;
bool force_enc_jpeg2000 = false;
Expand Down Expand Up @@ -557,6 +572,9 @@ int main(int argc, char** argv)
case OPTION_PITM_DESCRIPTION:
property_pitm_description = optarg;
break;
case OPTION_USE_VVC_COMPRESSION:
force_enc_vvc = true;
break;
case OPTION_USE_JPEG_COMPRESSION:
force_enc_jpeg = true;
break;
Expand Down Expand Up @@ -604,7 +622,8 @@ int main(int argc, char** argv)
return 5;
}

if ((force_enc_av1f ? 1 : 0) + (force_enc_uncompressed ? 1 : 0) + (force_enc_jpeg ? 1 : 0) + (force_enc_jpeg2000 ? 1 : 0) > 1) {
if ((force_enc_av1f ? 1 : 0) + (force_enc_vvc ? 1 : 0) + (force_enc_uncompressed ? 1 : 0) + (force_enc_jpeg ? 1 : 0) +
(force_enc_jpeg2000 ? 1 : 0) > 1) {
std::cerr << "Choose at most one output compression format.\n";
}

Expand Down Expand Up @@ -649,6 +668,9 @@ int main(int argc, char** argv)
if (force_enc_av1f) {
compressionFormat = heif_compression_AV1;
}
else if (force_enc_vvc) {
compressionFormat = heif_compression_VVC;
}
else if (force_enc_uncompressed) {
compressionFormat = heif_compression_uncompressed;
}
Expand Down
Loading
Loading