summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhao Yakui <yakui.zhao@intel.com>2014-01-13 09:42:32 +0800
committerYakui Zhao <yakui.zhao@intel.com>2014-01-13 09:42:32 +0800
commit0a843549292550e1917baa9e62e04ce2d9e86277 (patch)
treeaa80c40c458a86c348a090274db59195ca003113
parent6d44354b78bfe3852999ec9914fb21d1fb9f2f45 (diff)
downloadlibva-intel-driver-0a843549292550e1917baa9e62e04ce2d9e86277.tar.gz
libva-intel-driver-0a843549292550e1917baa9e62e04ce2d9e86277.tar.bz2
libva-intel-driver-0a843549292550e1917baa9e62e04ce2d9e86277.zip
Remove the unnecessary sorting to simplify the DPB buffer management
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
-rw-r--r--src/i965_decoder_utils.c52
1 files changed, 11 insertions, 41 deletions
diff --git a/src/i965_decoder_utils.c b/src/i965_decoder_utils.c
index 0e93e76..8f12c4d 100644
--- a/src/i965_decoder_utils.c
+++ b/src/i965_decoder_utils.c
@@ -420,6 +420,7 @@ intel_update_avc_frame_store_index(VADriverContextP ctx,
/* add the new reference frame into the internal DPB */
if (!found) {
int frame_idx;
+ int slot_found;
struct object_surface *obj_surface = decode_state->reference_objects[i];
/*
@@ -428,60 +429,29 @@ intel_update_avc_frame_store_index(VADriverContextP ctx,
*/
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
+ slot_found = 0;
+ frame_idx = -1;
/* Find a free frame store index */
- for (frame_idx = 0; frame_idx < MAX_GEN_REFERENCE_FRAMES; frame_idx++) {
- for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
- if (frame_store[j].surface_id == VA_INVALID_ID ||
- frame_store[j].obj_surface == NULL)
- continue;
-
- if (frame_store[j].frame_store_id == frame_idx) /* the store index is in use */
- break;
- }
-
- if (j == MAX_GEN_REFERENCE_FRAMES)
- break;
- }
-
- assert(frame_idx < MAX_GEN_REFERENCE_FRAMES);
-
for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
if (frame_store[j].surface_id == VA_INVALID_ID ||
frame_store[j].obj_surface == NULL) {
- frame_store[j].surface_id = ref_pic->picture_id;
- frame_store[j].frame_store_id = frame_idx;
- frame_store[j].obj_surface = obj_surface;
+ frame_idx = j;
+ slot_found = 1;
break;
}
}
- }
- }
- /* sort */
- for (i = 0; i < MAX_GEN_REFERENCE_FRAMES - 1; i++) {
- if (frame_store[i].surface_id != VA_INVALID_ID &&
- frame_store[i].obj_surface != NULL &&
- frame_store[i].frame_store_id == i)
- continue;
- for (j = i + 1; j < MAX_GEN_REFERENCE_FRAMES; j++) {
- if (frame_store[j].surface_id != VA_INVALID_ID &&
- frame_store[j].obj_surface != NULL &&
- frame_store[j].frame_store_id == i) {
- VASurfaceID id = frame_store[i].surface_id;
- int frame_idx = frame_store[i].frame_store_id;
- struct object_surface *obj_surface = frame_store[i].obj_surface;
-
- frame_store[i].surface_id = frame_store[j].surface_id;
- frame_store[i].frame_store_id = frame_store[j].frame_store_id;
- frame_store[i].obj_surface = frame_store[j].obj_surface;
- frame_store[j].surface_id = id;
+ if (slot_found) {
+ frame_store[j].surface_id = ref_pic->picture_id;
frame_store[j].frame_store_id = frame_idx;
frame_store[j].obj_surface = obj_surface;
- break;
- }
+ } else {
+ WARN_ONCE("Not free slot for DPB reference list!!!\n");
+ }
}
}
+
}
void