Skip to content

Commit

Permalink
WIP: change value codecs output_bit_depth
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamaika1 authored Nov 25, 2024
1 parent 9baf768 commit 87a50aa
Showing 1 changed file with 38 additions and 37 deletions.
75 changes: 38 additions & 37 deletions examples/heif_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -862,43 +862,6 @@ int main(int argc, char** argv)
bool option_show_parameters = false;
int thumbnail_bbox_size = 0;
int output_bit_depth = bit_depth;
struct heif_encoder* encoder = nullptr;
//#if (UVG_BIT_DEPTH == 10) || (KVZ_BIT_DEPTH == 10) || HAVE_VVENC
if ((output_bit_depth == 10) && ((encoderId[0] == 'k' && encoderId[1] == 'v') ||
(encoderId[0] == 'u' && encoderId[1] == 'v') ||
(encoderId[0] == 'v' && encoderId[1] == 'v'))) {
int output_bit_depth = 10;
heif_encoder_set_parameter(encoder, "chroma", "420");
printf("Warming: For kvazaar, uvg266, vvenc is always output yuv420p10le");
}
/*#else
if ((output_bit_depth == 8) && ((encoderId[0] == 'k' && encoderId[1] == 'v') ||
(encoderId[0] == 'u' && encoderId[1] == 'v'))) {
int output_bit_depth = 10;
heif_encoder_set_parameter(encoder, "chroma", "420");
printf("Warming: For kvazaar, uvg266 is always output yuv420p");
}
#endif*/
//#if HAVE_OPENJPEG_ENCODER || HAVE_OPENJPH_ENCODER
if ((output_bit_depth == 16) && ((encoderId[4] == 'j' && encoderId[5] == 'p' && encoderId[6] == 'e') ||
(encoderId[4] == 'j' && encoderId[5] == 'p' && encoderId[6] == 'h'))) {
int output_bit_depth = 16;
heif_encoder_set_parameter(encoder, "chroma", "444");
printf("Warming: Don't use jpeg image 8bit. openjpeg is always output rgb48(a)\n"
"libheif has no added functions openjpeg2000 in yuv420/422/444 10/12bit\n");
}
//#else
if ((output_bit_depth == 8) && ((encoderId[4] == 'j' && encoderId[5] == 'p' && encoderId[6] == 'e') ||
(encoderId[4] == 'j' && encoderId[5] == 'p' && encoderId[6] == 'h'))) {
int output_bit_depth = 10;
heif_encoder_set_parameter(encoder, "chroma", "444");
printf("Warming: openjpeg is always output rgb24(a)\n"
"libheif has no added functions openjpeg2000 in yuv420/422/444 10/12bit\n");
}
#if !HAVE_LIBDE265 && !HAVE_OpenH264_DECODER && !HAVE_AOM_DECODER && !HAVE_DAV1D && \
!HAVE_JPEG_DECODER && !HAVE_OPENJPEG_DECODER && !HAVE_VVDEC
printf("Warming: Don't use heif{avif}. libheif has no decoders installed.\n"
#endif
bool force_enc_av1f = false;
bool force_enc_vvc = false;
bool force_enc_uncompressed = false;
Expand Down Expand Up @@ -1086,6 +1049,7 @@ int main(int argc, char** argv)

// ==============================================================================

struct heif_encoder* encoder = nullptr;

if (list_encoders) {
show_list_of_all_encoders();
Expand Down Expand Up @@ -1225,6 +1189,43 @@ int main(int argc, char** argv)

// ==============================================================================

#if (UVG_BIT_DEPTH == 10) || (KVZ_BIT_DEPTH == 10) || HAVE_VVENC
if ((output_bit_depth == 10) && ((encoderId[0] == 'k' && encoderId[1] == 'v') ||
(encoderId[0] == 'u' && encoderId[1] == 'v') ||
(encoderId[0] == 'v' && encoderId[1] == 'v'))) {
int output_bit_depth = 10;
heif_encoder_set_parameter(encoder, "chroma", "420");
printf("Warming: For kvazaar, uvg266, vvenc is always output yuv420p10le");
}
#else
if ((output_bit_depth == 8) && ((encoderId[0] == 'k' && encoderId[1] == 'v') ||
(encoderId[0] == 'u' && encoderId[1] == 'v'))) {
int output_bit_depth = 10;
heif_encoder_set_parameter(encoder, "chroma", "420");
printf("Warming: For kvazaar, uvg266 is always output yuv420p");
}
#endif
//#if HAVE_OPENJPEG_ENCODER || HAVE_OPENJPH_ENCODER
if ((output_bit_depth == 16) && ((encoderId[4] == 'j' && encoderId[5] == 'p' && encoderId[6] == 'e') ||
(encoderId[4] == 'j' && encoderId[5] == 'p' && encoderId[6] == 'h'))) {
int output_bit_depth = 16;
heif_encoder_set_parameter(encoder, "chroma", "444");
printf("Warming: Don't use jpeg image 8bit. openjpeg is always output rgb48(a)\n"
"libheif has no added functions openjpeg2000 in yuv420/422/444 10/12bit\n");
}
//#else
if ((output_bit_depth == 8) && ((encoderId[4] == 'j' && encoderId[5] == 'p' && encoderId[6] == 'e') ||
(encoderId[4] == 'j' && encoderId[5] == 'p' && encoderId[6] == 'h'))) {
int output_bit_depth = 10;
heif_encoder_set_parameter(encoder, "chroma", "444");
printf("Warming: openjpeg is always output rgb24(a)\n"
"libheif has no added functions openjpeg2000 in yuv420/422/444 10/12bit\n");
}
//#endif
#if !HAVE_LIBDE265 && !HAVE_OpenH264_DECODER && !HAVE_AOM_DECODER && !HAVE_DAV1D && \
!HAVE_JPEG_DECODER && !HAVE_OPENJPEG_DECODER && !HAVE_VVDEC
printf("Warming: Don't use heif{avif}. libheif has no decoders installed.\n");
#endif
InputImage input_image = load_image(input_filename, output_bit_depth);

std::shared_ptr<heif_image> image = input_image.image;
Expand Down

0 comments on commit 87a50aa

Please sign in to comment.