Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JPEG decoding of an oddly encoded files on gen7/8 #530

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

digetx
Copy link

@digetx digetx commented Feb 9, 2021

Intel VA-API driver fails to decode couple JPEG files for me because of the offending implicit u8->int32 expansion in the code of the driver. This PR fixes the implicit integer expansion and decoding works properly now.

The VAAPI driver fails to decode JPEG if encoded data has component ID
set to 255 (-1) and selector to 0 because this produces a wrong result of
the final ID calculation since the component value is expanded to a 32bit
signed integer by compiler instead of keeping it unsigned 8bit, thus the
result is calculated as "0 - 255 + 1 = -254" instead of "0 - (-1) + 1 = 2".

Example output from FFmpeg:

...
[mjpeg @ 0x56156be1cc40] component 0 1:1 id: -1 quant:0
[mjpeg @ 0x56156be1cc40] component 1 1:1 id: 0 quant:1
[mjpeg @ 0x56156be1cc40] component 2 1:1 id: 1 quant:1
...
src/gen7_mfd.c:2549: gen7_mfd_jpeg_bsd_object: Assertion `0' failed.

This patch fixes the offending integer expansion, JPEG is successfully
decoded now.

Signed-off-by: Dmitry Osipenko <[email protected]>
@rathann
Copy link

rathann commented Jul 11, 2024

@digetx could you provide a sample JPEG file that fails to decode? I have a Haswell CPU and cannot find any JPEGs that would fail to decode locally.

@digetx
Copy link
Author

digetx commented Jul 14, 2024

Don't have those files anymore. IIRC, the fix was inspired by the FFMPEG swdec code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants