📄 hplx_vert_analysis_by_lifting.c
字号:
canvas_dims branch_dims, branch_frame_dims;
int top, bottom;
branch_dims = *dims;
if (base->vert_limit > 1) {
top = branch_dims.top_row;
bottom = top + branch_dims.rows - 1;
top = (top+1-b)>>1;
bottom = (bottom-b)>>1;
branch_dims.top_row = top;
branch_dims.rows = bottom+1-top;
}
branch_frame_dims = *frame_dims;
if (base->vert_limit > 1) {
branch_frame_dims.rows >>= 1;
branch_frame_dims.top_row = (branch_frame_dims.top_row+1-b)>>1;
}
base->branches[b]->initialize(base->branches[b],info,
&branch_dims,&branch_frame_dims);
}
start_vertical_frame(self);
}
/*****************************************************************************/
/* __push_line_fixed */
/*****************************************************************************/
static void
__push_line_fixed(hplx_analysis_stage_ref base, ifc_int *line_buf,
int width)
{
hplx_vert_analysis_by_lifting_ref self =
(hplx_vert_analysis_by_lifting_ref) base;
hplx_buffering_stage_ptr stage, in_stage;
hplx_row_buffer_state_ptr buf;
int n, b, done, next_row_odd;
if (base->vert_limit > 1) {
next_row_odd = (self->first_row_idx_in_frame +
self->current_frame_rows - self->rows_left_in_frame) & 1;
in_stage = self->buffering_stages; /* 1st buffer stage (odd indexed rows) */
in_stage += (1-next_row_odd);
assert(width == in_stage->cols);
if (width == 0)
return;
assert(self->rows_left_in_frame > 0);
if (self->buffering_stages[next_row_odd].rows == 0)
{ /* Signals of length < 2 must be treated specially. */
self->rows_left_in_frame--;
assert((self->rows_left_in_frame == 0) &&
(self->current_frame_rows == 1));
/* Fix for single sample discrepancy between VM8.5 and FDIS */
if (!in_stage->skip_last)
{
if ((self->current_frame_rows == 1) &&
(self->first_row_idx_in_frame & 1))
{
ifc_int *sp;
for (sp=line_buf, n=width; n > 0; n--)
{
*(sp++) <<= 1;
}
}
base->branches[next_row_odd]->push_line_fixed(
base->branches[next_row_odd],line_buf,width);
}
self->frame_idx++;
if (self->frame_idx < self->num_frames)
{
start_vertical_frame(self);
if (in_stage->special_first)
__push_line_fixed(base,line_buf,width);
}
return;
}
/* Add the new line to the relevant buffer. */
buf = hplx_lift_stage__add_row(in_stage);
if (buf->float_buf != NULL)
{
ifc_int *sp;
float *dp;
for (sp=line_buf, dp=buf->float_buf, n=width; n > 0; n--)
*(dp++) = (float)(*(sp++));
}
else
{
ifc_int *sp, *dp;
for (sp=line_buf, dp=buf->int_buf, n=width; n > 0; n--)
*(dp++) = *(sp++);
}
/* Generate and consume as many output lines as possible. */
do {
done = 1;
for (b=0; b < base->vert_limit; b++)
{
int next_row_idx;
stage = self->branch_output_stages[b];
next_row_idx = self->branch_next_row_idx[b];
if ((next_row_idx < (stage->rows-stage->skip_last)) &&
(hplx_lift_stage__get_rows(stage,next_row_idx,1,&buf)))
{
done = 0;
hplx_lift_stage__release_row(stage,next_row_idx);
if (buf->float_buf != NULL)
{
if (self->branch_needs_scaling[b])
{
float scale, *sp, *dp;
scale = self->branch_scale[b];
sp = buf->float_buf;
buf = hplx_lift_heap__get_tmp_buffer(&(self->heap));
for (dp=buf->float_buf, n=width; n > 0; n--)
*(dp++) = *(sp++) * scale;
}
base->branches[b]->push_line_float(base->branches[b],
buf->float_buf,width);
}
else
base->branches[b]->push_line_fixed(base->branches[b],
buf->int_buf,width);
self->branch_next_row_idx[b]++;
}
}
} while (!done);
/* Advance frame counters and move onto next frame if necessary. */
self->rows_left_in_frame--;
if (self->rows_left_in_frame == 0)
{
self->frame_idx++;
if (self->frame_idx < self->num_frames)
{
start_vertical_frame(self);
if (in_stage->special_first)
__push_line_fixed(base,line_buf,width);
/* Last line of last frame is first line of next frame. */
}
}
}
else {
if (base->use_floats) {
ifc_int *sp;
float *dp;
buf = hplx_lift_heap__get_tmp_buffer(&(self->heap));
for (sp=line_buf, dp = buf->float_buf, n=width; n > 0; n--)
*(dp++) = (float) *(sp++);
base->branches[0]->push_line_float(base->branches[0], buf->float_buf,width);
}
else {
base->branches[0]->push_line_fixed(base->branches[0], line_buf,width);
}
self->branch_next_row_idx[0]++;
}
}
/*****************************************************************************/
/* __push_line_float */
/*****************************************************************************/
static void
__push_line_float(hplx_analysis_stage_ref base, float *line_buf,
int width)
{
hplx_vert_analysis_by_lifting_ref self =
(hplx_vert_analysis_by_lifting_ref) base;
hplx_buffering_stage_ptr stage, in_stage;
hplx_row_buffer_state_ptr buf;
float *sp, *dp;
int b, n, done, next_row_odd;
if (base->vert_limit > 1) {
assert(self->kernel_type == INFO__FLOAT_LIFTING);
next_row_odd = (self->first_row_idx_in_frame +
self->current_frame_rows - self->rows_left_in_frame) & 1;
in_stage = self->buffering_stages; /* 1st buffer stage (odd indexed rows) */
in_stage += (1-next_row_odd);
assert(width == in_stage->cols);
if (width == 0)
return;
assert(self->rows_left_in_frame > 0);
if (self->buffering_stages[next_row_odd].rows == 0)
{ /* Signals of length < 2 must be treated specially. */
self->rows_left_in_frame--;
assert((self->rows_left_in_frame == 0) &&
(self->current_frame_rows == 1));
if (!in_stage->skip_last)
base->branches[next_row_odd]->push_line_float(
base->branches[next_row_odd],line_buf,width);
self->frame_idx++;
if (self->frame_idx < self->num_frames)
{
start_vertical_frame(self);
if (in_stage->special_first)
__push_line_float(base,line_buf,width);
}
return;
}
/* Add the new line to the relevant buffer. */
buf = hplx_lift_stage__add_row(in_stage);
for (sp=line_buf, dp=buf->float_buf, n=width; n > 0; n--)
*(dp++) = *(sp++);
/* Generate and consume as many output lines as possible. */
do {
done = 1;
for (b=0; b < base->vert_limit; b++)
{
int next_row_idx;
stage = self->branch_output_stages[b];
next_row_idx = self->branch_next_row_idx[b];
if ((next_row_idx < (stage->rows-stage->skip_last)) &&
(hplx_lift_stage__get_rows(stage,next_row_idx,1,&buf)))
{
done = 0;
hplx_lift_stage__release_row(stage,next_row_idx);
if (self->branch_needs_scaling[b])
{
float scale;
scale = self->branch_scale[b];
sp = buf->float_buf;
buf = hplx_lift_heap__get_tmp_buffer(&(self->heap));
for (dp=buf->float_buf, n=width; n > 0; n--)
*(dp++) = *(sp++) * scale;
}
base->branches[b]->push_line_float(base->branches[b],
buf->float_buf,width);
self->branch_next_row_idx[b]++;
}
}
} while (!done);
/* Advance frame counters and move onto next frame if necessary. */
self->rows_left_in_frame--;
if (self->rows_left_in_frame == 0)
{
self->frame_idx++;
if (self->frame_idx < self->num_frames)
{
start_vertical_frame(self);
if (in_stage->special_first)
__push_line_float(base,line_buf,width);
/* Last line of last frame is first line of next frame. */
}
}
}
else {
base->branches[0]->push_line_float(base->branches[0], line_buf,width);
}
}
/*****************************************************************************/
/* STATIC __terminate */
/*****************************************************************************/
static void
__terminate(hplx_analysis_stage_ref base)
{
hplx_vert_analysis_by_lifting_ref self =
(hplx_vert_analysis_by_lifting_ref) base;
hplx_row_buffer_state_ptr buf;
hplx_buffering_stage_ptr stage;
int b, n, num_buffers;
if (self->steps != NULL)
local_free(self->steps);
if (self->buffering_stages != NULL)
{
for (n=0; n < self->num_buffering_stages; n++)
{
stage = self->buffering_stages + n;
if (stage->row_buffers != NULL)
{
num_buffers = stage->next_row_idx - stage->min_row_idx;
for (b=0; b < num_buffers; b++)
hplx_lift_heap__return_buffer(stage->heap,
stage->row_buffers[b]);
local_free(stage->row_buffers);
}
}
local_free(self->buffering_stages);
}
while ((buf=self->heap.head) != NULL)
{
self->heap.head = buf->next;
if (buf->float_buf != NULL)
local_free(buf->float_buf);
if (buf->int_buf != NULL)
local_free(buf->int_buf);
local_free(buf);
}
for (b=0; b < base->vert_limit; b++)
base->branches[b]->terminate(base->branches[b]);
local_free(self);
}
/*****************************************************************************/
/* EXTERN create_hplx_vert_analysis_by_lifting */
/*****************************************************************************/
hplx_analysis_stage_ref
create_hplx_vert_analysis_by_lifting(void)
{
hplx_vert_analysis_by_lifting_ref result;
result = (hplx_vert_analysis_by_lifting_ref)
local_malloc(XFORM_MEM_KEY,sizeof(hplx_vert_analysis_by_lifting_obj));
result->base.initialize = __initialize;
result->base.push_line_fixed = __push_line_fixed;
result->base.push_line_float = __push_line_float;
result->base.terminate = __terminate;
return((hplx_analysis_stage_ref) result);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -