Skip to content

Commit

Permalink
Fix encoding images <16 pixels wide with rav1e (see #365)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Sep 5, 2022
1 parent 5fb52b6 commit d506bcc
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions libheif/heif_encoder_rav1e.cc
Expand Up @@ -58,7 +58,7 @@ struct encoder_struct_rav1e
bool data_read = false;
};

static const char* kError_out_of_memory = "Out of memory";
//static const char* kError_out_of_memory = "Out of memory";

static const char* kParam_min_q = "min-q";
static const char* kParam_threads = "threads";
Expand Down Expand Up @@ -481,8 +481,8 @@ void rav1e_query_input_colorspace2(void* encoder_raw, heif_colorspace* colorspac
void rav1e_query_encoded_size(void* encoder, uint32_t input_width, uint32_t input_height,
uint32_t* encoded_width, uint32_t* encoded_height)
{
*encoded_width = std::max(input_width, 16U);
*encoded_height = std::max(input_height, 16U);
*encoded_width = input_width;
*encoded_height = input_height;
}


Expand All @@ -491,26 +491,6 @@ struct heif_error rav1e_encode_image(void* encoder_raw, const struct heif_image*
{
auto* encoder = (struct encoder_struct_rav1e*) encoder_raw;

// --- round image size to minimum size

uint32_t rounded_width, rounded_height;
rav1e_query_encoded_size(encoder,
image->image->get_width(),
image->image->get_height(),
&rounded_width,
&rounded_height);

bool success = image->image->extend_padding_to_size(rounded_width, rounded_height);
if (!success) {
struct heif_error err = {
heif_error_Memory_allocation_error,
heif_suberror_Unspecified,
kError_out_of_memory
};
return err;
}


const heif_chroma chroma = heif_image_get_chroma_format(image);

uint8_t yShift = 0;
Expand Down

0 comments on commit d506bcc

Please sign in to comment.