intel / media-driver

Intel Graphics Media Driver to support hardware decode, encode and video processing.
https://github.com/intel/media-driver/wiki
Other
939 stars 337 forks source link

JPEG decoding doesn't work #1819

Open RankoR opened 2 months ago

RankoR commented 2 months ago

I'm running Arch on i9-14900K. libva and libva-utils are installed.

loadjpeg ~/Downloads/jpeg/random_noise_1.jpg                                                                                                                                                                                                                                   
WARNING:Height need to be a multiple of 16 (current height is 1080)
Decoding JPEG image 1920x1080...
Trying display: wayland
loadjpeg: ../libva-utils-2.21.0/decode/tinyjpeg.c:612: tinyjpeg_decode: Assertion `0' failed.
[1]    269509 IOT instruction (core dumped)  loadjpeg ~/Downloads/jpeg/random_noise_1.jpg

When I'm running this C++ code:

const int fd = open("/dev/dri/renderD128", O_RDWR);
    vaDisplay = vaGetDisplayDRM(fd);
    int major, minor;
    VAStatus status = vaInitialize(vaDisplay, &major, &minor);
    if (status != VA_STATUS_SUCCESS) {
        throw std::runtime_error("Failed to initialize VA display");
    }

    VAEntrypoint entrypoints[5];
    int num_entrypoints, vld_entrypoint;
    status = vaQueryConfigEntrypoints(vaDisplay, VAProfileJPEGBaseline, entrypoints,
                                      &num_entrypoints);

    if (status != VA_STATUS_SUCCESS) {
        throw std::runtime_error("Failed to query config entrypoints");
    }

    for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) {
        if (entrypoints[vld_entrypoint] == VAEntrypointVLD)
            break;
    }

    if (vld_entrypoint == num_entrypoints) {
        throw std::runtime_error("Failed to find VLD entry point");
    }

    VASurfaceAttrib forcc;
    forcc.type = VASurfaceAttribPixelFormat;
    forcc.flags = VA_SURFACE_ATTRIB_SETTABLE;
    forcc.value.type = VAGenericValueTypeInteger;

    // Create VA configuration and context
    VAConfigAttrib configAttrib;
    configAttrib.type = VAConfigAttribRTFormat;
    VAProfile profile;
    VAEntrypoint entrypoint;

    status = vaGetConfigAttributes(vaDisplay, VAProfileJPEGBaseline, VAEntrypointVLD,
                          &configAttrib, 1);

    if (status != VA_STATUS_SUCCESS) {
        throw std::runtime_error("Failed to get config attributes");
    }

It returns VA_STATUS_ERROR_UNSUPPORTED_PROFILE from vaGetConfigAttributes.

Or if I call

status = vaCreateConfig(vaDisplay, VAProfileJPEGBaseline, VAEntrypointVLD, &configAttrib, 1, &vaConfig);

I'm getting the same result.

But, however, there is not error when I change VAProfileJPEGBaseline to VAProfileH264Main or VAProfileVP9Profile0 for example.

So, what's the problem and how to decode JPEG?

XinfengZhang commented 1 week ago

it should be a media driver issue, I will move it to https://github.com/intel/media-driver/ , and assign it.

Jexu commented 6 days ago

How about vainfo? It will list all supported profiles.

Jexu commented 6 days ago

Do you open intel driver? it looks NVDEC driver opened? And multi gpu exists on your machine?

RankoR commented 6 days ago

@Jexu yep, posted wrong output originally. I have Nvidia GPU, and can't find out yet how to launch vainfo for the iGPU, it uses nvidia by default.

Jexu commented 6 days ago

Try to open another gpu node under /dev/dri/renderD*

intel-mediadev commented 6 days ago

Auto Created VSMGWL-74546 for further analysis.