-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLD_PRELOAD_va.c
38 lines (32 loc) · 1.3 KB
/
LD_PRELOAD_va.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#include <va/va.h>
#define PRELOAD(sym_t, sym) \
static sym_t (*_##sym)(); \
__attribute__((constructor)) static void _##sym##_init() { \
_##sym = dlsym(RTLD_NEXT, #sym); \
} \
sym_t(sym)
static VABufferID buf_id2;
PRELOAD(VAStatus, vaCreateBuffer)
(VADisplay dpy, VAContextID context, VABufferType type, unsigned int size,
unsigned int num_elements, void *data, VABufferID *buf_id) {
VAStatus ret =
_vaCreateBuffer(dpy, context, type, size, num_elements, data, buf_id);
if (type == VAProcPipelineParameterBufferType)
buf_id2 = *buf_id;
return ret;
}
PRELOAD(VAStatus, vaUnmapBuffer)(VADisplay dpy, VABufferID buf_id) {
VAStatus ret = _vaUnmapBuffer(dpy, buf_id);
if (buf_id == buf_id2) {
VAProcPipelineParameterBuffer *pipeline_param;
vaMapBuffer(dpy, buf_id, (void **)&pipeline_param);
pipeline_param->filter_flags |= VA_FILTER_INTERPOLATION_NEAREST_NEIGHBOR;
__builtin_dump_struct(pipeline_param, &printf);
_vaUnmapBuffer(dpy, buf_id);
}
buf_id2 = 0;
return ret;
}