return len;
}
+static void init_output(struct aec_stream *strm)
+{
+ /**
+ Direct output to next_out if next_out can hold a Coded Data
+ Set, use internal buffer otherwise.
+ */
+
+ struct internal_state *state = strm->state;
+
+ if (strm->avail_out > state->cds_len) {
+ if (!state->direct_out) {
+ state->direct_out = 1;
+ *strm->next_out = *state->cds;
+ state->cds = strm->next_out;
+ }
+ } else {
+ if (state->zero_blocks == 0 || state->direct_out) {
+ /* copy leftover from last block */
+ *state->cds_buf = *state->cds;
+ state->cds = state->cds_buf;
+ }
+ state->direct_out = 0;
+ }
+}
+
/*
*
* FSM functions
if (state->zero_blocks) {
/* The current block isn't zero but we have to emit a
* previous zero block first. The current block will be
- * handled later.
+ * flagged and handled later.
*/
- state->block -= strm->block_size;
- state->blocks_avail++;
+ state->block_nonzero = 1;
state->mode = m_encode_zero;
return M_CONTINUE;
}
struct internal_state *state = strm->state;
- if (strm->avail_out > state->cds_len) {
- if (!state->direct_out) {
- state->direct_out = 1;
- *strm->next_out = *state->cds;
- state->cds = strm->next_out;
- }
- } else {
- if (state->zero_blocks == 0 || state->direct_out) {
- /* copy leftover from last block */
- *state->cds_buf = *state->cds;
- state->cds = state->cds_buf;
- }
- state->direct_out = 0;
+ init_output(strm);
+
+ if (state->block_nonzero) {
+ state->block_nonzero = 0;
+ state->mode = m_select_code_option;
+ return M_CONTINUE;
}
if (state->blocks_avail == 0) {
int zero_ref; /* current zero block has a reference sample */
int64_t zero_ref_sample;/* reference sample of zero block */
int zero_blocks; /* number of contiguous zero blocks */
+ int block_nonzero; /* 1 if this is the first non-zero block
+ * after one or more zero blocks */
int k; /* splitting position */
int kmax; /* maximum number for k depending on id_len */
int flush; /* flush option copied from argument */