This source file includes following definitions.
- analyze
#include "libde265/encoder/algo/cb-intra-inter.h"
#include "libde265/encoder/algo/coding-options.h"
#include "libde265/encoder/encoder-context.h"
#include <assert.h>
#include <limits>
#include <math.h>
enc_cb* Algo_CB_IntraInter_BruteForce::analyze(encoder_context* ectx,
context_model_table& ctxModel,
enc_cb* cb)
{
assert(cb->pcm_flag==0);
bool try_intra = true;
bool try_inter = (ectx->shdr->slice_type != SLICE_TYPE_I);
bool debug_halt = try_inter;
try_inter = false;
if (ectx->imgdata->frame_number > 0) {
}
CodingOptions<enc_cb> options(ectx,cb,ctxModel);
CodingOption<enc_cb> option_intra = options.new_option(try_intra);
CodingOption<enc_cb> option_inter = options.new_option(try_inter);
options.start();
enc_cb* cb_inter = NULL;
enc_cb* cb_intra = NULL;
const int log2CbSize = cb->log2Size;
const int x = cb->x;
const int y = cb->y;
if (option_inter) {
option_inter.begin();
cb_inter = option_inter.get_node();
cb_inter->PredMode = MODE_INTER;
ectx->img->set_pred_mode(x,y, log2CbSize, MODE_INTER);
enc_cb* cb_result;
descend(cb,"inter");
cb_result=mInterAlgo->analyze(ectx, option_inter.get_context(), cb_inter);
ascend();
if (cb_result->PredMode != MODE_SKIP) {
CABAC_encoder_estim* cabac = option_inter.get_cabac();
cabac->reset();
cabac->write_CABAC_bit(CONTEXT_MODEL_PRED_MODE_FLAG, 0);
float rate_pred_mode_flag = cabac->getRDBits();
cb_result->rate += rate_pred_mode_flag;
}
option_inter.set_node(cb_result);
option_inter.end();
}
if (option_intra) {
option_intra.begin();
cb_intra = option_intra.get_node();
cb_intra->PredMode = MODE_INTRA;
ectx->img->set_pred_mode(x,y, log2CbSize, MODE_INTRA);
enc_cb* cb_result;
descend(cb,"intra");
cb_result=mIntraAlgo->analyze(ectx, option_intra.get_context(), cb_intra);
ascend();
if (ectx->shdr->slice_type != SLICE_TYPE_I) {
CABAC_encoder_estim* cabac = option_intra.get_cabac();
cabac->reset();
cabac->write_CABAC_bit(CONTEXT_MODEL_PRED_MODE_FLAG, 1);
float rate_pred_mode_flag = cabac->getRDBits();
cb_result->rate += rate_pred_mode_flag;
}
option_intra.set_node(cb_result);
option_intra.end();
}
options.compute_rdo_costs();
return options.return_best_rdo_node();
}