hardware/intel/common/libva
リビジョン | 4cb1712312be9d852b71bdf4da5eadbb1dc1adc6 (tree) |
---|---|
日時 | 2017-09-28 13:15:05 |
作者 | Xiang, Haihao <haihao.xiang@inte...> |
コミッター | Xiang, Haihao |
Fix segmentation fault in VA tracer
The first parameter of va_{error,info}Message is VADisplay
This fixes https://github.com/01org/libva/issues/123
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
@@ -262,7 +262,7 @@ VAStatus va_FoolBufferInfo( | ||
262 | 262 | return 1; /* fool is valid */ |
263 | 263 | } |
264 | 264 | |
265 | -static int va_FoolFillCodedBufEnc(struct fool_context *fool_ctx) | |
265 | +static int va_FoolFillCodedBufEnc(VADisplay dpy, struct fool_context *fool_ctx) | |
266 | 266 | { |
267 | 267 | char file_name[1024]; |
268 | 268 | struct stat file_stat = {0}; |
@@ -287,10 +287,10 @@ static int va_FoolFillCodedBufEnc(struct fool_context *fool_ctx) | ||
287 | 287 | fool_ctx->segbuf_enc = realloc(fool_ctx->segbuf_enc, file_stat.st_size); |
288 | 288 | ret = read(fd, fool_ctx->segbuf_enc, file_stat.st_size); |
289 | 289 | if (ret < file_stat.st_size) |
290 | - va_errorMessage("Reading file %s failed.\n", file_name); | |
290 | + va_errorMessage(dpy, "Reading file %s failed.\n", file_name); | |
291 | 291 | close(fd); |
292 | 292 | } else |
293 | - va_errorMessage("Open file %s failed:%s\n", file_name, strerror(errno)); | |
293 | + va_errorMessage(dpy, "Open file %s failed:%s\n", file_name, strerror(errno)); | |
294 | 294 | |
295 | 295 | codedbuf = (VACodedBufferSegment *)fool_ctx->fool_buf[VAEncCodedBufferType]; |
296 | 296 | codedbuf->size = file_stat.st_size; |
@@ -303,7 +303,7 @@ static int va_FoolFillCodedBufEnc(struct fool_context *fool_ctx) | ||
303 | 303 | return 0; |
304 | 304 | } |
305 | 305 | |
306 | -static int va_FoolFillCodedBufJPG(struct fool_context *fool_ctx) | |
306 | +static int va_FoolFillCodedBufJPG(VADisplay dpy, struct fool_context *fool_ctx) | |
307 | 307 | { |
308 | 308 | struct stat file_stat = {0}; |
309 | 309 | VACodedBufferSegment *codedbuf; |
@@ -315,10 +315,10 @@ static int va_FoolFillCodedBufJPG(struct fool_context *fool_ctx) | ||
315 | 315 | fool_ctx->segbuf_jpg = realloc(fool_ctx->segbuf_jpg, file_stat.st_size); |
316 | 316 | ret = read(fd, fool_ctx->segbuf_jpg, file_stat.st_size); |
317 | 317 | if (ret < file_stat.st_size) |
318 | - va_errorMessage("Reading file %s failed.\n", fool_ctx->fn_jpg); | |
318 | + va_errorMessage(dpy, "Reading file %s failed.\n", fool_ctx->fn_jpg); | |
319 | 319 | close(fd); |
320 | 320 | } else |
321 | - va_errorMessage("Open file %s failed:%s\n", fool_ctx->fn_jpg, strerror(errno)); | |
321 | + va_errorMessage(dpy, "Open file %s failed:%s\n", fool_ctx->fn_jpg, strerror(errno)); | |
322 | 322 | |
323 | 323 | codedbuf = (VACodedBufferSegment *)fool_ctx->fool_buf[VAEncCodedBufferType]; |
324 | 324 | codedbuf->size = file_stat.st_size; |
@@ -332,12 +332,12 @@ static int va_FoolFillCodedBufJPG(struct fool_context *fool_ctx) | ||
332 | 332 | } |
333 | 333 | |
334 | 334 | |
335 | -static int va_FoolFillCodedBuf(struct fool_context *fool_ctx) | |
335 | +static int va_FoolFillCodedBuf(VADisplay dpy, struct fool_context *fool_ctx) | |
336 | 336 | { |
337 | 337 | if (fool_ctx->entrypoint == VAEntrypointEncSlice) |
338 | - va_FoolFillCodedBufEnc(fool_ctx); | |
338 | + va_FoolFillCodedBufEnc(dpy, fool_ctx); | |
339 | 339 | else if (fool_ctx->entrypoint == VAEntrypointEncPicture) |
340 | - va_FoolFillCodedBufJPG(fool_ctx); | |
340 | + va_FoolFillCodedBufJPG(dpy, fool_ctx); | |
341 | 341 | |
342 | 342 | return 0; |
343 | 343 | } |
@@ -361,7 +361,7 @@ VAStatus va_FoolMapBuffer( | ||
361 | 361 | |
362 | 362 | /* it is coded buffer, fill coded segment from file */ |
363 | 363 | if (*pbuf && (buftype == VAEncCodedBufferType)) |
364 | - va_FoolFillCodedBuf(fool_ctx); | |
364 | + va_FoolFillCodedBuf(dpy, fool_ctx); | |
365 | 365 | |
366 | 366 | return 1; /* fool is valid */ |
367 | 367 | } |
@@ -561,13 +561,13 @@ static int open_tracing_specil_file( | ||
561 | 561 | if(type == 0) { |
562 | 562 | ptra_ctx->trace_codedbuf_fn = fn_env; |
563 | 563 | ptra_ctx->trace_fp_codedbuf = fp; |
564 | - va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save codedbuf into %s\n", | |
564 | + va_infoMessage(pva_trace->dpy, "LIBVA_TRACE_CODEDBUF is on, save codedbuf into %s\n", | |
565 | 565 | fn_env); |
566 | 566 | } |
567 | 567 | else { |
568 | 568 | ptra_ctx->trace_surface_fn = fn_env; |
569 | 569 | ptra_ctx->trace_fp_surface = fp; |
570 | - va_infoMessage("LIBVA_TRACE_SURFACE is on, save surface into %s\n", | |
570 | + va_infoMessage(pva_trace->dpy, "LIBVA_TRACE_SURFACE is on, save surface into %s\n", | |
571 | 571 | fn_env); |
572 | 572 | } |
573 | 573 |
@@ -615,7 +615,7 @@ static int open_tracing_log_file( | ||
615 | 615 | if(!pfp) |
616 | 616 | goto FAIL; |
617 | 617 | |
618 | - va_infoMessage("%s %s for the thread 0x%08x\n", | |
618 | + va_infoMessage(pva_trace->dpy, "%s %s for the thread 0x%08x\n", | |
619 | 619 | new_fn_flag ? "Open new log file" : "Append to log file", |
620 | 620 | plog_file->fn_log, thd_id); |
621 | 621 |
@@ -741,6 +741,8 @@ void va_TraceInit(VADisplay dpy) | ||
741 | 741 | return; |
742 | 742 | } |
743 | 743 | |
744 | + pva_trace->dpy = dpy; | |
745 | + | |
744 | 746 | if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) { |
745 | 747 | pva_trace->fn_log_env = strdup(env_value); |
746 | 748 | trace_ctx->plog_file = start_tracing2log_file(pva_trace); |
@@ -748,11 +750,11 @@ void va_TraceInit(VADisplay dpy) | ||
748 | 750 | trace_ctx->plog_file_list[0] = trace_ctx->plog_file; |
749 | 751 | va_trace_flag = VA_TRACE_FLAG_LOG; |
750 | 752 | |
751 | - va_infoMessage("LIBVA_TRACE is on, save log into %s\n", | |
753 | + va_infoMessage(dpy, "LIBVA_TRACE is on, save log into %s\n", | |
752 | 754 | trace_ctx->plog_file->fn_log); |
753 | 755 | } |
754 | 756 | else |
755 | - va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno)); | |
757 | + va_errorMessage(dpy, "Open file %s failed (%s)\n", env_value, strerror(errno)); | |
756 | 758 | } |
757 | 759 | |
758 | 760 | /* may re-get the global settings for multiple context */ |
@@ -810,7 +812,6 @@ void va_TraceInit(VADisplay dpy) | ||
810 | 812 | pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM] = trace_ctx; |
811 | 813 | |
812 | 814 | ((VADisplayContextP)dpy)->vatrace = (void *)pva_trace; |
813 | - pva_trace->dpy = dpy; | |
814 | 815 | |
815 | 816 | if(!va_trace_flag) |
816 | 817 | va_TraceEnd(dpy); |
@@ -882,6 +883,7 @@ void va_TraceEnd(VADisplay dpy) | ||
882 | 883 | } |
883 | 884 | free(pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM]); |
884 | 885 | |
886 | + pva_trace->dpy = NULL; | |
885 | 887 | free(pva_trace); |
886 | 888 | ((VADisplayContextP)dpy)->vatrace = NULL; |
887 | 889 | } |