[Libva] [PATCH] avcenc: Remove dynamic shrink of coded buf to avoid multiple encoding

yakui.zhao at intel.com yakui.zhao at intel.com
Mon Nov 11 17:58:44 PST 2013


From: Zhao Yakui <yakui.zhao2intel.com>

Currently the h264 encoding will shrink the size of coded buf dynamically after
encoding one frame. But it will cause that the allocated coded buf can
hold the required encoded bit-stream and then rerun the encoding again. This
will waste the precious GPU resource and affect the encoding performance.

Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
 test/encode/avcenc.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/test/encode/avcenc.c b/test/encode/avcenc.c
index b734300..5aee8bb 100644
--- a/test/encode/avcenc.c
+++ b/test/encode/avcenc.c
@@ -1286,20 +1286,6 @@ store_coded_buffer(FILE *avc_fp, int slice_type)
         w_items = fwrite(coded_mem, slice_data_length, 1, avc_fp);
     } while (w_items != 1);
 
-    if (slice_type == SLICE_TYPE_I) {
-        if (avcenc_context.codedbuf_i_size > slice_data_length * 3 / 2) {
-            avcenc_context.codedbuf_i_size = slice_data_length * 3 / 2;
-        }
-        
-        if (avcenc_context.codedbuf_pb_size < slice_data_length) {
-            avcenc_context.codedbuf_pb_size = slice_data_length;
-        }
-    } else {
-        if (avcenc_context.codedbuf_pb_size > slice_data_length * 3 / 2) {
-            avcenc_context.codedbuf_pb_size = slice_data_length * 3 / 2;
-        }
-    }
-
     vaUnmapBuffer(va_dpy, avcenc_context.codedbuf_buf_id);
 
     return 0;
@@ -1522,7 +1508,7 @@ static void avcenc_context_init(int width, int height)
     avcenc_context.codedbuf_buf_id = VA_INVALID_ID;
     avcenc_context.misc_parameter_hrd_buf_id = VA_INVALID_ID;
     avcenc_context.codedbuf_i_size = width * height;
-    avcenc_context.codedbuf_pb_size = 0;
+    avcenc_context.codedbuf_pb_size = width * height;
     avcenc_context.current_input_surface = SID_INPUT_PICTURE_0;
     avcenc_context.upload_thread_value = -1;
     avcenc_context.packed_sei_header_param_buf_id = VA_INVALID_ID;
-- 
1.7.12-rc1



More information about the Libva mailing list