mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
cog: Fix the virtual frame line cache
This commit is contained in:
parent
e34ea433d5
commit
213cc0b06d
2 changed files with 20 additions and 20 deletions
|
@ -86,6 +86,7 @@ struct _CogFrame {
|
||||||
CogFrameData components[3];
|
CogFrameData components[3];
|
||||||
|
|
||||||
int is_virtual;
|
int is_virtual;
|
||||||
|
int cache_offset[3];
|
||||||
int cached_lines[3][COG_FRAME_CACHE_SIZE];
|
int cached_lines[3][COG_FRAME_CACHE_SIZE];
|
||||||
CogFrame *virt_frame1;
|
CogFrame *virt_frame1;
|
||||||
CogFrame *virt_frame2;
|
CogFrame *virt_frame2;
|
||||||
|
|
|
@ -53,8 +53,9 @@ cog_frame_new_virtual (CogMemoryDomain * domain, CogFrameFormat format,
|
||||||
frame->regions[0] =
|
frame->regions[0] =
|
||||||
malloc (frame->components[0].stride * COG_FRAME_CACHE_SIZE);
|
malloc (frame->components[0].stride * COG_FRAME_CACHE_SIZE);
|
||||||
for (i = 0; i < COG_FRAME_CACHE_SIZE; i++) {
|
for (i = 0; i < COG_FRAME_CACHE_SIZE; i++) {
|
||||||
frame->cached_lines[0][i] = -1;
|
frame->cached_lines[0][i] = 0;
|
||||||
}
|
}
|
||||||
|
frame->cache_offset[0] = 0;
|
||||||
frame->is_virtual = TRUE;
|
frame->is_virtual = TRUE;
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
|
@ -114,8 +115,9 @@ cog_frame_new_virtual (CogMemoryDomain * domain, CogFrameFormat format,
|
||||||
|
|
||||||
frame->regions[i] = malloc (comp->stride * COG_FRAME_CACHE_SIZE);
|
frame->regions[i] = malloc (comp->stride * COG_FRAME_CACHE_SIZE);
|
||||||
for (j = 0; j < COG_FRAME_CACHE_SIZE; j++) {
|
for (j = 0; j < COG_FRAME_CACHE_SIZE; j++) {
|
||||||
frame->cached_lines[i][j] = -1;
|
frame->cached_lines[i][j] = 0;
|
||||||
}
|
}
|
||||||
|
frame->cache_offset[i] = 0;
|
||||||
}
|
}
|
||||||
frame->is_virtual = TRUE;
|
frame->is_virtual = TRUE;
|
||||||
|
|
||||||
|
@ -127,8 +129,6 @@ cog_virt_frame_get_line (CogFrame * frame, int component, int i)
|
||||||
{
|
{
|
||||||
CogFrameData *comp = &frame->components[component];
|
CogFrameData *comp = &frame->components[component];
|
||||||
int j;
|
int j;
|
||||||
int min;
|
|
||||||
int min_j;
|
|
||||||
|
|
||||||
g_return_val_if_fail (i >= 0, NULL);
|
g_return_val_if_fail (i >= 0, NULL);
|
||||||
g_return_val_if_fail (i < comp->height, NULL);
|
g_return_val_if_fail (i < comp->height, NULL);
|
||||||
|
@ -137,27 +137,26 @@ cog_virt_frame_get_line (CogFrame * frame, int component, int i)
|
||||||
return COG_FRAME_DATA_GET_LINE (&frame->components[component], i);
|
return COG_FRAME_DATA_GET_LINE (&frame->components[component], i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < COG_FRAME_CACHE_SIZE; j++) {
|
if (i < frame->cache_offset[component]) {
|
||||||
if (frame->cached_lines[component][j] == i) {
|
g_warning ("cache failure");
|
||||||
return COG_OFFSET (frame->regions[component], comp->stride * j);
|
return NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
min_j = 0;
|
while (i >= frame->cache_offset[component] + COG_FRAME_CACHE_SIZE) {
|
||||||
min = frame->cached_lines[component][0];
|
j = frame->cache_offset[component] & (COG_FRAME_CACHE_SIZE - 1);
|
||||||
for (j = 1; j < COG_FRAME_CACHE_SIZE; j++) {
|
frame->cached_lines[component][j] = 0;
|
||||||
if (frame->cached_lines[component][j] < min) {
|
|
||||||
min = frame->cached_lines[component][j];
|
frame->cache_offset[component]++;
|
||||||
min_j = j;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
frame->cached_lines[component][min_j] = i;
|
|
||||||
|
|
||||||
cog_virt_frame_render_line (frame,
|
j = i & (COG_FRAME_CACHE_SIZE - 1);
|
||||||
COG_OFFSET (frame->regions[component], comp->stride * min_j),
|
if (!frame->cached_lines[component][j]) {
|
||||||
component, i);
|
cog_virt_frame_render_line (frame,
|
||||||
|
COG_OFFSET (frame->regions[component], comp->stride * j), component, i);
|
||||||
|
frame->cached_lines[component][j] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return COG_OFFSET (frame->regions[component], comp->stride * min_j);
|
return COG_OFFSET (frame->regions[component], comp->stride * j);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue