]> git.sesse.net Git - nageru/commitdiff
Give in the right VAAPI context when decoding MJPEG.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 20 May 2020 22:04:54 +0000 (00:04 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 20 May 2020 22:04:54 +0000 (00:04 +0200)
This mirrors the fixes of e550c3b, but for the MJPEG decoding in
Futatabi instead of the MJPEG encoding in Nageru.

futatabi/vaapi_jpeg_decoder.cpp

index 758d974bfeb1fc4e0e6e9b595bef779f5f12bfa3..0441514a8b815efe62509e45490b595cc0a4562b 100644 (file)
@@ -383,8 +383,11 @@ shared_ptr<Frame> decode_jpeg_vaapi(const string &jpeg)
        pic_param.color_space = 0;  // YUV.
        pic_param.rotation = VA_ROTATION_NONE;
 
+       VAResources resources = get_va_resources(dinfo.image_width, dinfo.image_height);
+       ReleaseVAResources release(resources);
+
        VABufferID pic_param_buffer;
-       VAStatus va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VAPictureParameterBufferType, sizeof(pic_param), 1, &pic_param, &pic_param_buffer);
+       VAStatus va_status = vaCreateBuffer(va_dpy->va_dpy, resources.context, VAPictureParameterBufferType, sizeof(pic_param), 1, &pic_param, &pic_param_buffer);
        CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
        VABufferDestroyer destroy_pic_param(va_dpy->va_dpy, pic_param_buffer);
 
@@ -409,7 +412,7 @@ shared_ptr<Frame> decode_jpeg_vaapi(const string &jpeg)
        }
 
        VABufferID iq_buffer;
-       va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VAIQMatrixBufferType, sizeof(iq), 1, &iq, &iq_buffer);
+       va_status = vaCreateBuffer(va_dpy->va_dpy, resources.context, VAIQMatrixBufferType, sizeof(iq), 1, &iq, &iq_buffer);
        CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
        VABufferDestroyer destroy_iq(va_dpy->va_dpy, iq_buffer);
 
@@ -443,7 +446,7 @@ shared_ptr<Frame> decode_jpeg_vaapi(const string &jpeg)
        }
 
        VABufferID huff_buffer;
-       va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VAHuffmanTableBufferType, sizeof(huff), 1, &huff, &huff_buffer);
+       va_status = vaCreateBuffer(va_dpy->va_dpy, resources.context, VAHuffmanTableBufferType, sizeof(huff), 1, &huff, &huff_buffer);
        CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
        VABufferDestroyer destroy_huff(va_dpy->va_dpy, huff_buffer);
 
@@ -473,19 +476,16 @@ shared_ptr<Frame> decode_jpeg_vaapi(const string &jpeg)
        parms.num_mcus = horiz_mcus * vert_mcus;
 
        VABufferID slice_param_buffer;
-       va_status = vaCreateBuffer(va_dpy->va_dpy, config_id, VASliceParameterBufferType, sizeof(parms), 1, &parms, &slice_param_buffer);
+       va_status = vaCreateBuffer(va_dpy->va_dpy, resources.context, VASliceParameterBufferType, sizeof(parms), 1, &parms, &slice_param_buffer);
        CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
        VABufferDestroyer destroy_slice_param(va_dpy->va_dpy, slice_param_buffer);
 
        // The actual data. VA-API will destuff and all for us.
        VABufferID data_buffer;
-       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);
+       va_status = vaCreateBuffer(va_dpy->va_dpy, resources.context, VASliceDataBufferType, dinfo.src->bytes_in_buffer, 1, const_cast<unsigned char *>(dinfo.src->next_input_byte), &data_buffer);
        CHECK_VASTATUS_RET(va_status, "vaCreateBuffer");
        VABufferDestroyer destroy_data(va_dpy->va_dpy, data_buffer);
 
-       VAResources resources = get_va_resources(dinfo.image_width, dinfo.image_height);
-       ReleaseVAResources release(resources);
-
        va_status = vaBeginPicture(va_dpy->va_dpy, resources.context, resources.surface);
        CHECK_VASTATUS_RET(va_status, "vaBeginPicture");
        va_status = vaRenderPicture(va_dpy->va_dpy, resources.context, &pic_param_buffer, 1);