1 #include "vaapi_jpeg_decoder.h"
3 #include "jpeg_destroyer.h"
4 #include "jpeg_frame.h"
5 #include "jpeglib_error_wrapper.h"
7 #include "shared/memcpy_interleaved.h"
23 #include <va/va_drm.h>
24 #include <va/va_x11.h>
26 #define BUFFER_OFFSET(i) ((char *)nullptr + (i))
30 static unique_ptr<VADisplayWithCleanup> va_dpy;
31 static VAConfigID config_id;
32 static VAImageFormat uyvy_format;
33 bool vaapi_jpeg_decoding_usable = false;
36 unsigned width, height;
41 static list<VAResources> va_resources_freelist;
42 static mutex va_resources_mutex;
44 #define CHECK_VASTATUS(va_status, func) \
45 if (va_status != VA_STATUS_SUCCESS) { \
46 fprintf(stderr, "%s:%d (%s) failed with %d\n", __func__, __LINE__, func, va_status); \
50 #define CHECK_VASTATUS_RET(va_status, func) \
51 if (va_status != VA_STATUS_SUCCESS) { \
52 fprintf(stderr, "%s:%d (%s) failed with %d\n", __func__, __LINE__, func, va_status); \
56 // From libjpeg (although it's of course identical between implementations).
57 static const int jpeg_natural_order[DCTSIZE2] = {
58 0, 1, 8, 16, 9, 2, 3, 10,
59 17, 24, 32, 25, 18, 11, 4, 5,
60 12, 19, 26, 33, 40, 48, 41, 34,
61 27, 20, 13, 6, 7, 14, 21, 28,
62 35, 42, 49, 56, 57, 50, 43, 36,
63 29, 22, 15, 23, 30, 37, 44, 51,
64 58, 59, 52, 45, 38, 31, 39, 46,
65 53, 60, 61, 54, 47, 55, 62, 63,
68 VAResources get_va_resources(unsigned width, unsigned height)
71 lock_guard<mutex> lock(va_resources_mutex);
72 for (auto it = va_resources_freelist.begin(); it != va_resources_freelist.end(); ++it) {
73 if (it->width == width && it->height == height) {
74 VAResources ret = *it;
75 va_resources_freelist.erase(it);
86 VAStatus va_status = vaCreateSurfaces(va_dpy->va_dpy, VA_RT_FORMAT_YUV422,
88 &ret.surface, 1, nullptr, 0);
89 CHECK_VASTATUS(va_status, "vaCreateSurfaces");
91 va_status = vaCreateContext(va_dpy->va_dpy, config_id, width, height, 0, &ret.surface, 1, &ret.context);
92 CHECK_VASTATUS(va_status, "vaCreateContext");
94 va_status = vaCreateImage(va_dpy->va_dpy, &uyvy_format, width, height, &ret.image);
95 CHECK_VASTATUS(va_status, "vaCreateImage");
100 void release_va_resources(VAResources resources)
102 lock_guard<mutex> lock(va_resources_mutex);
103 if (va_resources_freelist.size() > 10) {
104 auto it = va_resources_freelist.end();
107 VAStatus va_status = vaDestroyImage(va_dpy->va_dpy, it->image.image_id);
108 CHECK_VASTATUS(va_status, "vaDestroyImage");
110 va_status = vaDestroyContext(va_dpy->va_dpy, it->context);
111 CHECK_VASTATUS(va_status, "vaDestroyContext");
113 va_status = vaDestroySurfaces(va_dpy->va_dpy, &it->surface, 1);
114 CHECK_VASTATUS(va_status, "vaDestroySurfaces");
116 va_resources_freelist.erase(it);
119 va_resources_freelist.push_front(resources);
122 // RAII wrapper to release VAResources on return (even on error).
123 class ReleaseVAResources {
125 ReleaseVAResources(const VAResources &resources)
126 : resources(resources) {}
127 ~ReleaseVAResources()
130 release_va_resources(resources);
134 void commit() { committed = true; }
137 const VAResources &resources;
138 bool committed = false;
141 VADisplayWithCleanup::~VADisplayWithCleanup()
143 if (va_dpy != nullptr) {
146 if (x11_display != nullptr) {
147 XCloseDisplay(x11_display);
154 unique_ptr<VADisplayWithCleanup> va_open_display(const string &va_display)
156 if (va_display.empty() || va_display[0] != '/') { // An X display.
157 Display *x11_display = XOpenDisplay(va_display.empty() ? nullptr : va_display.c_str());
158 if (x11_display == nullptr) {
159 fprintf(stderr, "error: can't connect to X server!\n");
163 unique_ptr<VADisplayWithCleanup> ret(new VADisplayWithCleanup);
164 ret->x11_display = x11_display;
165 ret->va_dpy = vaGetDisplay(x11_display);
166 if (ret->va_dpy == nullptr) {
170 } else { // A DRM node on the filesystem (e.g. /dev/dri/renderD128).
171 int drm_fd = open(va_display.c_str(), O_RDWR);
173 perror(va_display.c_str());
176 unique_ptr<VADisplayWithCleanup> ret(new VADisplayWithCleanup);
177 ret->drm_fd = drm_fd;
178 ret->va_dpy = vaGetDisplayDRM(drm_fd);
179 if (ret->va_dpy == nullptr) {
186 unique_ptr<VADisplayWithCleanup> try_open_va(const string &va_display, string *error)
188 unique_ptr<VADisplayWithCleanup> va_dpy = va_open_display(va_display);
189 if (va_dpy == nullptr) {
191 *error = "Opening VA display failed";
194 int major_ver, minor_ver;
195 VAStatus va_status = vaInitialize(va_dpy->va_dpy, &major_ver, &minor_ver);
196 if (va_status != VA_STATUS_SUCCESS) {
198 snprintf(buf, sizeof(buf), "vaInitialize() failed with status %d\n", va_status);
199 if (error != nullptr)
204 int num_entrypoints = vaMaxNumEntrypoints(va_dpy->va_dpy);
205 unique_ptr<VAEntrypoint[]> entrypoints(new VAEntrypoint[num_entrypoints]);
206 if (entrypoints == nullptr) {
207 if (error != nullptr)
208 *error = "Failed to allocate memory for VA entry points";
212 vaQueryConfigEntrypoints(va_dpy->va_dpy, VAProfileJPEGBaseline, entrypoints.get(), &num_entrypoints);
213 for (int slice_entrypoint = 0; slice_entrypoint < num_entrypoints; slice_entrypoint++) {
214 if (entrypoints[slice_entrypoint] != VAEntrypointVLD) {
218 // We found a usable decode, so return it.
222 if (error != nullptr)
223 *error = "Can't find VAEntrypointVLD for the JPEG profile";
227 string get_usable_va_display()
229 // Reduce the amount of chatter while probing,
230 // unless the user has specified otherwise.
231 bool need_env_reset = false;
232 if (getenv("LIBVA_MESSAGING_LEVEL") == nullptr) {
233 setenv("LIBVA_MESSAGING_LEVEL", "0", true);
234 need_env_reset = true;
237 // First try the default (ie., whatever $DISPLAY is set to).
238 unique_ptr<VADisplayWithCleanup> va_dpy = try_open_va("", nullptr);
239 if (va_dpy != nullptr) {
240 if (need_env_reset) {
241 unsetenv("LIBVA_MESSAGING_LEVEL");
246 fprintf(stderr, "The X11 display did not expose a VA-API JPEG decoder.\n");
248 // Try all /dev/dri/render* in turn. TODO: Accept /dev/dri/card*, too?
250 int err = glob("/dev/dri/renderD*", 0, nullptr, &g);
252 fprintf(stderr, "Couldn't list render nodes (%s) when trying to autodetect a replacement.\n", strerror(errno));
254 for (size_t i = 0; i < g.gl_pathc; ++i) {
255 string path = g.gl_pathv[i];
256 va_dpy = try_open_va(path, nullptr);
257 if (va_dpy != nullptr) {
258 fprintf(stderr, "Autodetected %s as a suitable replacement; using it.\n",
261 if (need_env_reset) {
262 unsetenv("LIBVA_MESSAGING_LEVEL");
269 fprintf(stderr, "No suitable VA-API JPEG decoders were found in /dev/dri; giving up.\n");
270 fprintf(stderr, "Note that if you are using an Intel CPU with an external GPU,\n");
271 fprintf(stderr, "you may need to enable the integrated Intel GPU in your BIOS\n");
272 fprintf(stderr, "to expose Quick Sync.\n");
276 void init_jpeg_vaapi()
278 string dpy = get_usable_va_display();
283 va_dpy = try_open_va(dpy, nullptr);
284 if (va_dpy == nullptr) {
288 VAConfigAttrib attr = { VAConfigAttribRTFormat, VA_RT_FORMAT_YUV422 };
290 VAStatus va_status = vaCreateConfig(va_dpy->va_dpy, VAProfileJPEGBaseline, VAEntrypointVLD,
291 &attr, 1, &config_id);
292 CHECK_VASTATUS(va_status, "vaCreateConfig");
294 int num_formats = vaMaxNumImageFormats(va_dpy->va_dpy);
295 assert(num_formats > 0);
297 unique_ptr<VAImageFormat[]> formats(new VAImageFormat[num_formats]);
298 va_status = vaQueryImageFormats(va_dpy->va_dpy, formats.get(), &num_formats);
299 CHECK_VASTATUS(va_status, "vaQueryImageFormats");
302 for (int i = 0; i < num_formats; ++i) {
303 // Seemingly VA_FOURCC_422H is no good for vaGetImage(). :-/
304 if (formats[i].fourcc == VA_FOURCC_UYVY) {
305 memcpy(&uyvy_format, &formats[i], sizeof(VAImageFormat));
314 fprintf(stderr, "VA-API JPEG decoding initialized.\n");
315 vaapi_jpeg_decoding_usable = true;
318 class VABufferDestroyer {
320 VABufferDestroyer(VADisplay dpy, VABufferID buf)
321 : dpy(dpy), buf(buf) {}
325 VAStatus va_status = vaDestroyBuffer(dpy, buf);
326 CHECK_VASTATUS(va_status, "vaDestroyBuffer");
334 shared_ptr<Frame> decode_jpeg_vaapi(const string &jpeg)
336 jpeg_decompress_struct dinfo;
337 JPEGWrapErrorManager error_mgr(&dinfo);
338 if (!error_mgr.run([&dinfo] { jpeg_create_decompress(&dinfo); })) {
341 JPEGDestroyer destroy_dinfo(&dinfo);
343 jpeg_save_markers(&dinfo, JPEG_APP0 + 1, 0xFFFF);
345 jpeg_mem_src(&dinfo, reinterpret_cast<const unsigned char *>(jpeg.data()), jpeg.size());
346 if (!error_mgr.run([&dinfo] { jpeg_read_header(&dinfo, true); })) {
350 if (dinfo.num_components != 3) {
351 fprintf(stderr, "Not a color JPEG. (%d components, Y=%dx%d, Cb=%dx%d, Cr=%dx%d)\n",
352 dinfo.num_components,
353 dinfo.comp_info[0].h_samp_factor, dinfo.comp_info[0].v_samp_factor,
354 dinfo.comp_info[1].h_samp_factor, dinfo.comp_info[1].v_samp_factor,
355 dinfo.comp_info[2].h_samp_factor, dinfo.comp_info[2].v_samp_factor);
358 if (dinfo.comp_info[0].h_samp_factor != 2 ||
359 dinfo.comp_info[1].h_samp_factor != 1 ||
360 dinfo.comp_info[1].v_samp_factor != dinfo.comp_info[0].v_samp_factor ||
361 dinfo.comp_info[2].h_samp_factor != 1 ||
362 dinfo.comp_info[2].v_samp_factor != dinfo.comp_info[0].v_samp_factor) {
363 fprintf(stderr, "Not 4:2:2. (Y=%dx%d, Cb=%dx%d, Cr=%dx%d)\n",
364 dinfo.comp_info[0].h_samp_factor, dinfo.comp_info[0].v_samp_factor,
365 dinfo.comp_info[1].h_samp_factor, dinfo.comp_info[1].v_samp_factor,
366 dinfo.comp_info[2].h_samp_factor, dinfo.comp_info[2].v_samp_factor);
370 // Picture parameters.
371 VAPictureParameterBufferJPEGBaseline pic_param;
372 memset(&pic_param, 0, sizeof(pic_param));
373 pic_param.picture_width = dinfo.image_width;
374 pic_param.picture_height = dinfo.image_height;
375 for (int component_idx = 0; component_idx < dinfo.num_components; ++component_idx) {
376 const jpeg_component_info *comp = &dinfo.comp_info[component_idx];
377 pic_param.components[component_idx].component_id = comp->component_id;
378 pic_param.components[component_idx].h_sampling_factor = comp->h_samp_factor;
379 pic_param.components[component_idx].v_sampling_factor = comp->v_samp_factor;
380 pic_param.components[component_idx].quantiser_table_selector = comp->quant_tbl_no;
382 pic_param.num_components = dinfo.num_components;
383 pic_param.color_space = 0; // YUV.
384 pic_param.rotation = VA_ROTATION_NONE;
386 VABufferID pic_param_buffer;
387 VAStatus va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VAPictureParameterBufferType, sizeof(pic_param), 1, &pic_param, &pic_param_buffer);
388 CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
389 VABufferDestroyer destroy_pic_param(va_dpy->va_dpy, pic_param_buffer);
391 // Quantization matrices.
392 VAIQMatrixBufferJPEGBaseline iq;
393 memset(&iq, 0, sizeof(iq));
395 for (int quant_tbl_idx = 0; quant_tbl_idx < min(4, NUM_QUANT_TBLS); ++quant_tbl_idx) {
396 const JQUANT_TBL *qtbl = dinfo.quant_tbl_ptrs[quant_tbl_idx];
397 if (qtbl == nullptr) {
398 iq.load_quantiser_table[quant_tbl_idx] = 0;
400 iq.load_quantiser_table[quant_tbl_idx] = 1;
401 for (int i = 0; i < 64; ++i) {
402 if (qtbl->quantval[i] > 255) {
403 fprintf(stderr, "Baseline JPEG only!\n");
406 iq.quantiser_table[quant_tbl_idx][i] = qtbl->quantval[jpeg_natural_order[i]];
411 VABufferID iq_buffer;
412 va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VAIQMatrixBufferType, sizeof(iq), 1, &iq, &iq_buffer);
413 CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
414 VABufferDestroyer destroy_iq(va_dpy->va_dpy, iq_buffer);
416 // Huffman tables (arithmetic is not supported).
417 VAHuffmanTableBufferJPEGBaseline huff;
418 memset(&huff, 0, sizeof(huff));
420 for (int huff_tbl_idx = 0; huff_tbl_idx < min(2, NUM_HUFF_TBLS); ++huff_tbl_idx) {
421 const JHUFF_TBL *ac_hufftbl = dinfo.ac_huff_tbl_ptrs[huff_tbl_idx];
422 const JHUFF_TBL *dc_hufftbl = dinfo.dc_huff_tbl_ptrs[huff_tbl_idx];
423 if (ac_hufftbl == nullptr) {
424 assert(dc_hufftbl == nullptr);
425 huff.load_huffman_table[huff_tbl_idx] = 0;
427 assert(dc_hufftbl != nullptr);
428 huff.load_huffman_table[huff_tbl_idx] = 1;
430 for (int i = 0; i < 16; ++i) {
431 huff.huffman_table[huff_tbl_idx].num_dc_codes[i] = dc_hufftbl->bits[i + 1];
433 for (int i = 0; i < 12; ++i) {
434 huff.huffman_table[huff_tbl_idx].dc_values[i] = dc_hufftbl->huffval[i];
436 for (int i = 0; i < 16; ++i) {
437 huff.huffman_table[huff_tbl_idx].num_ac_codes[i] = ac_hufftbl->bits[i + 1];
439 for (int i = 0; i < 162; ++i) {
440 huff.huffman_table[huff_tbl_idx].ac_values[i] = ac_hufftbl->huffval[i];
445 VABufferID huff_buffer;
446 va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VAHuffmanTableBufferType, sizeof(huff), 1, &huff, &huff_buffer);
447 CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
448 VABufferDestroyer destroy_huff(va_dpy->va_dpy, huff_buffer);
450 // Slice parameters (metadata about the slice).
451 VASliceParameterBufferJPEGBaseline parms;
452 memset(&parms, 0, sizeof(parms));
453 parms.slice_data_size = dinfo.src->bytes_in_buffer;
454 parms.slice_data_offset = 0;
455 parms.slice_data_flag = VA_SLICE_DATA_FLAG_ALL;
456 parms.slice_horizontal_position = 0;
457 parms.slice_vertical_position = 0;
458 for (int component_idx = 0; component_idx < dinfo.num_components; ++component_idx) {
459 const jpeg_component_info *comp = &dinfo.comp_info[component_idx];
460 parms.components[component_idx].component_selector = comp->component_id;
461 parms.components[component_idx].dc_table_selector = comp->dc_tbl_no;
462 parms.components[component_idx].ac_table_selector = comp->ac_tbl_no;
463 if (parms.components[component_idx].dc_table_selector > 1 ||
464 parms.components[component_idx].ac_table_selector > 1) {
465 fprintf(stderr, "Uses too many Huffman tables\n");
469 parms.num_components = dinfo.num_components;
470 parms.restart_interval = dinfo.restart_interval;
471 int horiz_mcus = (dinfo.image_width + (DCTSIZE * 2) - 1) / (DCTSIZE * 2);
472 int vert_mcus = (dinfo.image_height + DCTSIZE - 1) / DCTSIZE;
473 parms.num_mcus = horiz_mcus * vert_mcus;
475 VABufferID slice_param_buffer;
476 va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VASliceParameterBufferType, sizeof(parms), 1, &parms, &slice_param_buffer);
477 CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
478 VABufferDestroyer destroy_slice_param(va_dpy->va_dpy, slice_param_buffer);
480 // The actual data. VA-API will destuff and all for us.
481 VABufferID data_buffer;
482 va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VASliceDataBufferType, dinfo.src->bytes_in_buffer, 1, const_cast<unsigned char *>(dinfo.src->next_input_byte), &data_buffer);
483 CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
484 VABufferDestroyer destroy_data(va_dpy->va_dpy, data_buffer);
486 VAResources resources = get_va_resources(dinfo.image_width, dinfo.image_height);
487 ReleaseVAResources release(resources);
489 va_status = vaBeginPicture(va_dpy->va_dpy, resources.context, resources.surface);
490 CHECK_VASTATUS_RET(va_status, "vaBeginPicture");
491 va_status = vaRenderPicture(va_dpy->va_dpy, resources.context, &pic_param_buffer, 1);
492 CHECK_VASTATUS_RET(va_status, "vaRenderPicture(pic_param)");
493 va_status = vaRenderPicture(va_dpy->va_dpy, resources.context, &iq_buffer, 1);
494 CHECK_VASTATUS_RET(va_status, "vaRenderPicture(iq)");
495 va_status = vaRenderPicture(va_dpy->va_dpy, resources.context, &huff_buffer, 1);
496 CHECK_VASTATUS_RET(va_status, "vaRenderPicture(huff)");
497 va_status = vaRenderPicture(va_dpy->va_dpy, resources.context, &slice_param_buffer, 1);
498 CHECK_VASTATUS_RET(va_status, "vaRenderPicture(slice_param)");
499 va_status = vaRenderPicture(va_dpy->va_dpy, resources.context, &data_buffer, 1);
500 CHECK_VASTATUS_RET(va_status, "vaRenderPicture(data)");
501 va_status = vaEndPicture(va_dpy->va_dpy, resources.context);
502 CHECK_VASTATUS_RET(va_status, "vaEndPicture");
504 // vaDeriveImage() works, but the resulting image seems to live in
505 // uncached memory, which makes copying data out from it very, very slow.
506 // Thanks to FFmpeg for the observation that you can vaGetImage() the
507 // surface onto your own image (although then, it can't be planar, which
508 // is unfortunate for us).
511 va_status = vaDeriveImage(va_dpy->va_dpy, surf, &image);
512 CHECK_VASTATUS_RET(va_status, "vaDeriveImage");
514 va_status = vaSyncSurface(va_dpy->va_dpy, resources.surface);
515 CHECK_VASTATUS_RET(va_status, "vaSyncSurface");
517 va_status = vaGetImage(va_dpy->va_dpy, resources.surface, 0, 0, dinfo.image_width, dinfo.image_height, resources.image.image_id);
518 CHECK_VASTATUS_RET(va_status, "vaGetImage");
522 va_status = vaMapBuffer(va_dpy->va_dpy, resources.image.buf, &mapped);
523 CHECK_VASTATUS_RET(va_status, "vaMapBuffer");
525 shared_ptr<Frame> frame(new Frame);
527 // 4:2:2 planar (for vaDeriveImage).
528 frame->y.reset(new uint8_t[dinfo.image_width * dinfo.image_height]);
529 frame->cb.reset(new uint8_t[(dinfo.image_width / 2) * dinfo.image_height]);
530 frame->cr.reset(new uint8_t[(dinfo.image_width / 2) * dinfo.image_height]);
531 for (int component_idx = 0; component_idx < dinfo.num_components; ++component_idx) {
534 if (component_idx == 0) {
535 dptr = frame->y.get();
536 width = dinfo.image_width;
537 } else if (component_idx == 1) {
538 dptr = frame->cb.get();
539 width = dinfo.image_width / 2;
540 } else if (component_idx == 2) {
541 dptr = frame->cr.get();
542 width = dinfo.image_width / 2;
546 const uint8_t *sptr = (const uint8_t *)mapped + image.offsets[component_idx];
547 size_t spitch = image.pitches[component_idx];
548 for (size_t y = 0; y < dinfo.image_height; ++y) {
549 memcpy(dptr + y * width, sptr + y * spitch, width);
553 // Convert Y'CbCr to separate Y' and CbCr.
554 frame->is_semiplanar = true;
556 PBO pbo = global_pbo_pool->alloc_pbo();
557 size_t cbcr_offset = dinfo.image_width * dinfo.image_height;
558 uint8_t *y_pix = pbo.ptr;
559 uint8_t *cbcr_pix = pbo.ptr + cbcr_offset;
561 const uint8_t *src = (const uint8_t *)mapped + resources.image.offsets[0];
562 if (resources.image.pitches[0] == dinfo.image_width * 2) {
563 memcpy_interleaved(cbcr_pix, y_pix, src, dinfo.image_width * dinfo.image_height * 2);
565 for (unsigned y = 0; y < dinfo.image_height; ++y) {
566 memcpy_interleaved(cbcr_pix + y * dinfo.image_width, y_pix + y * dinfo.image_width,
567 src + y * resources.image.pitches[0], dinfo.image_width * 2);
571 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo.pbo);
572 frame->y = create_texture_2d(dinfo.image_width, dinfo.image_height, GL_R8, GL_RED, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
573 frame->cbcr = create_texture_2d(dinfo.image_width / 2, dinfo.image_height, GL_RG8, GL_RG, GL_UNSIGNED_BYTE, BUFFER_OFFSET(cbcr_offset));
574 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
576 glFlushMappedNamedBufferRange(pbo.pbo, 0, dinfo.image_width * dinfo.image_height * 2);
577 glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT);
578 pbo.upload_done = RefCountedGLsync(GL_SYNC_GPU_COMMANDS_COMPLETE, /*flags=*/0);
579 frame->uploaded_ui_thread = pbo.upload_done;
580 frame->uploaded_interpolation = pbo.upload_done;
581 global_pbo_pool->release_pbo(move(pbo));
583 frame->width = dinfo.image_width;
584 frame->height = dinfo.image_height;
585 frame->chroma_subsampling_x = 2;
586 frame->chroma_subsampling_y = 1;
588 if (dinfo.marker_list != nullptr &&
589 dinfo.marker_list->marker == JPEG_APP0 + 1 &&
590 dinfo.marker_list->data_length >= 4 &&
591 memcmp(dinfo.marker_list->data, "Exif", 4) == 0) {
592 frame->exif_data.assign(reinterpret_cast<char *>(dinfo.marker_list->data),
593 dinfo.marker_list->data_length);
596 va_status = vaUnmapBuffer(va_dpy->va_dpy, resources.image.buf);
597 CHECK_VASTATUS_RET(va_status, "vaUnmapBuffer");