Skip to content

Commit

Permalink
Merge pull request #1408 from lovell/aom-encoder-intrabc-off
Browse files Browse the repository at this point in the history
AOM encoder: Expose control over Intra Block Copy (intrabc)
  • Loading branch information
farindk authored Nov 22, 2024
2 parents 331bd06 + 88f0426 commit e04390d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion libheif/plugins/encoder_aom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct encoder_struct_aom
bool lossless;
bool lossless_alpha;
bool auto_tiles;
bool intra_block_copy;

#if defined(HAVE_AOM_CODEC_SET_OPTION)
std::vector<custom_option> custom_options;
Expand Down Expand Up @@ -162,6 +163,7 @@ static const char* kParam_alpha_min_q = "alpha-min-q";
static const char* kParam_alpha_max_q = "alpha-max-q";
static const char* kParam_lossless_alpha = "lossless-alpha";
static const char* kParam_auto_tiles = "auto-tiles";
static const char* kParam_intra_block_copy = "intra-block-copy";
static const char* kParam_threads = "threads";
static const char* kParam_realtime = "realtime";
static const char* kParam_speed = "speed";
Expand Down Expand Up @@ -200,7 +202,7 @@ static const char* aom_plugin_name()
}


#define MAX_NPARAMETERS 15
#define MAX_NPARAMETERS 16

static struct heif_encoder_parameter aom_encoder_params[MAX_NPARAMETERS];
static const struct heif_encoder_parameter* aom_encoder_parameter_ptrs[MAX_NPARAMETERS + 1];
Expand Down Expand Up @@ -373,6 +375,16 @@ static void aom_init_parameters()
p->has_default = true;
d[i++] = p++;

#if defined(AOM_CTRL_AV1E_SET_ENABLE_INTRABC)
assert(i < MAX_NPARAMETERS);
p->version = 2;
p->name = kParam_intra_block_copy;
p->type = heif_encoder_parameter_type_boolean;
p->boolean.default_value = true;
p->has_default = true;
d[i++] = p++;
#endif

assert(i < MAX_NPARAMETERS + 1);
d[i++] = nullptr;
}
Expand Down Expand Up @@ -585,6 +597,11 @@ struct heif_error aom_set_parameter_boolean(void* encoder_raw, const char* name,
} else if (strcmp(name, kParam_auto_tiles) == 0) {
encoder->auto_tiles = value;
return heif_error_ok;
#if defined(AOM_CTRL_AV1E_SET_ENABLE_INTRABC)
} else if (strcmp(name, kParam_intra_block_copy) == 0) {
encoder->intra_block_copy = value;
return heif_error_ok;
#endif
}

set_value(kParam_realtime, realtime_mode);
Expand Down Expand Up @@ -1037,6 +1054,10 @@ struct heif_error aom_encode_image(void* encoder_raw, const struct heif_image* i
}
#endif

#if defined(AOM_CTRL_AV1E_SET_ENABLE_INTRABC)
aom_codec_control(&codec, AV1E_SET_ENABLE_INTRABC, encoder->intra_block_copy);
#endif

#if defined(HAVE_AOM_CODEC_SET_OPTION)
// Apply the custom AOM encoder options.
// These should always be applied last as they can override the values that were set above.
Expand Down

0 comments on commit e04390d

Please sign in to comment.