Move fields from encoder_state_t to frame

Moves fields prepared and frame_done from encoder_state_t to
encoder_state_config_frame_t.
This commit is contained in:
Arttu Ylä-Outinen 2016-08-21 12:27:58 +09:00
parent 97863cdaa2
commit 6c4f2d196a
4 changed files with 25 additions and 24 deletions

View file

@ -48,8 +48,11 @@ static int encoder_state_config_frame_init(encoder_state_t * const state) {
state->frame->poc = 0; state->frame->poc = 0;
state->frame->total_bits_coded = 0; state->frame->total_bits_coded = 0;
state->frame->cur_gop_bits_coded = 0; state->frame->cur_gop_bits_coded = 0;
state->frame->prepared = 0;
state->frame->done = 1;
state->frame->rc_alpha = 3.2003; state->frame->rc_alpha = 3.2003;
state->frame->rc_beta = -1.367; state->frame->rc_beta = -1.367;
return 1; return 1;
} }
@ -303,8 +306,6 @@ int kvz_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
child_state->children[0].encoder_control = NULL; child_state->children[0].encoder_control = NULL;
child_state->tqj_bitstream_written = NULL; child_state->tqj_bitstream_written = NULL;
child_state->tqj_recon_done = NULL; child_state->tqj_recon_done = NULL;
child_state->prepared = 0;
child_state->frame_done = 1;
if (!parent_state) { if (!parent_state) {
const encoder_control_t * const encoder = child_state->encoder_control; const encoder_control_t * const encoder = child_state->encoder_control;

View file

@ -967,7 +967,7 @@ void kvz_encode_one_frame(encoder_state_t * const state, kvz_picture* frame)
assert(!state->tqj_bitstream_written); assert(!state->tqj_bitstream_written);
state->tqj_bitstream_written = job; state->tqj_bitstream_written = job;
} }
state->frame_done = 0; state->frame->done = 0;
//kvz_threadqueue_flush(main_state->encoder_control->threadqueue); //kvz_threadqueue_flush(main_state->encoder_control->threadqueue);
} }
@ -985,7 +985,7 @@ void kvz_encoder_prepare(encoder_state_t *state)
const encoder_control_t * const encoder = state->encoder_control; const encoder_control_t * const encoder = state->encoder_control;
// The previous frame must be done before the next one is started. // The previous frame must be done before the next one is started.
assert(state->frame_done); assert(state->frame->done);
if (state->frame->num == -1) { if (state->frame->num == -1) {
// We're at the first frame, so don't care about all this stuff. // We're at the first frame, so don't care about all this stuff.
@ -993,7 +993,7 @@ void kvz_encoder_prepare(encoder_state_t *state)
state->frame->poc = 0; state->frame->poc = 0;
assert(!state->tile->frame->source); assert(!state->tile->frame->source);
assert(!state->tile->frame->rec); assert(!state->tile->frame->rec);
state->prepared = 1; state->frame->prepared = 1;
return; return;
} }
@ -1034,7 +1034,7 @@ void kvz_encoder_prepare(encoder_state_t *state)
state->frame->num = prev_state->frame->num + 1; state->frame->num = prev_state->frame->num + 1;
state->frame->poc = prev_state->frame->poc + 1; state->frame->poc = prev_state->frame->poc + 1;
state->prepared = 1; state->frame->prepared = 1;
} }
coeff_scan_order_t kvz_get_scan_order(int8_t cu_type, int intra_mode, int depth) coeff_scan_order_t kvz_get_scan_order(int8_t cu_type, int intra_mode, int depth)

View file

@ -88,6 +88,19 @@ typedef struct encoder_state_config_frame_t {
double rc_alpha; double rc_alpha;
double rc_beta; double rc_beta;
/**
* \brief Indicates that this encoder state is ready for encoding the
* next frame i.e. kvz_encoder_prepare has been called.
*/
bool prepared;
/**
* \brief Indicates that the previous frame has been encoded and the
* encoded data written and the encoding the next frame has not been
* started yet.
*/
bool done;
} encoder_state_config_frame_t; } encoder_state_config_frame_t;
typedef struct encoder_state_config_tile_t { typedef struct encoder_state_config_tile_t {
@ -185,19 +198,6 @@ typedef struct encoder_state_t {
bitstream_t stream; bitstream_t stream;
cabac_data_t cabac; cabac_data_t cabac;
/**
* \brief Indicates that this encoder state is ready for encoding the
* next frame i.e. kvz_encoder_prepare has been called.
*/
int prepared;
/**
* \brief Indicates that the previous frame has been encoded and the
* encoded data written and the encoding the next frame has not been
* started yet.
*/
int frame_done;
uint32_t stats_bitstream_length; //Bitstream length written in bytes uint32_t stats_bitstream_length; //Bitstream length written in bytes
//Jobs to wait for //Jobs to wait for

View file

@ -213,7 +213,7 @@ static int kvazaar_encode(kvz_encoder *enc,
encoder_state_t *state = &enc->states[enc->cur_state_num]; encoder_state_t *state = &enc->states[enc->cur_state_num];
if (!state->prepared) { if (!state->frame->prepared) {
kvz_encoder_prepare(state); kvz_encoder_prepare(state);
} }
@ -235,13 +235,13 @@ static int kvazaar_encode(kvz_encoder *enc,
return 1; return 1;
} }
if (!state->frame_done) { if (!state->frame->done) {
// We started encoding a frame; move to the next encoder state. // We started encoding a frame; move to the next encoder state.
enc->cur_state_num = (enc->cur_state_num + 1) % (enc->num_encoder_states); enc->cur_state_num = (enc->cur_state_num + 1) % (enc->num_encoder_states);
} }
encoder_state_t *output_state = &enc->states[enc->out_state_num]; encoder_state_t *output_state = &enc->states[enc->out_state_num];
if (!output_state->frame_done && if (!output_state->frame->done &&
(pic_in == NULL || enc->cur_state_num == enc->out_state_num)) { (pic_in == NULL || enc->cur_state_num == enc->out_state_num)) {
kvz_threadqueue_waitfor(enc->control->threadqueue, output_state->tqj_bitstream_written); kvz_threadqueue_waitfor(enc->control->threadqueue, output_state->tqj_bitstream_written);
@ -256,8 +256,8 @@ static int kvazaar_encode(kvz_encoder *enc,
if (src_out) *src_out = kvz_image_copy_ref(output_state->tile->frame->source); if (src_out) *src_out = kvz_image_copy_ref(output_state->tile->frame->source);
if (info_out) set_frame_info(info_out, output_state); if (info_out) set_frame_info(info_out, output_state);
output_state->frame_done = 1; output_state->frame->done = 1;
output_state->prepared = 0; output_state->frame->prepared = 0;
enc->frames_done += 1; enc->frames_done += 1;
enc->out_state_num = (enc->out_state_num + 1) % (enc->num_encoder_states); enc->out_state_num = (enc->out_state_num + 1) % (enc->num_encoder_states);