Skip to content

Implement NV12 to RGB24 color conversion with SYCL#2

Merged
dvrogozh merged 1 commit intointel:mainfrom
dvrogozh:fixes
Feb 27, 2026
Merged

Implement NV12 to RGB24 color conversion with SYCL#2
dvrogozh merged 1 commit intointel:mainfrom
dvrogozh:fixes

Conversation

@dvrogozh
Copy link
Contributor

@dvrogozh dvrogozh commented Feb 27, 2026

See ffmpeg color yuv2rgb color conversion reference:

Color conversion matrix copied from the ffmpeg internal output of:

ff_fill_rgb2yuv_table(av_csp_luma_coeffs_from_avcsp(color_space), rgb2yuv);
ff_matrix_invert_3x3(rgb2yuv, yuv2rgb);

with color space AVCOL_PRI_BT470BG and AVCOL_PRI_BT709.

Reference results for the nasa clip from torchcodec:

ffmpeg -i nasa_13013.mp4 -vf "scale=480:270:sws_flags=bilinear,format=rgb24" -y nasa_13013_ffmpeg_cpu.rgb
ffmpeg -f rawvideo -pix_fmt rgb24 -s:v 480x270 -i nasa_13013_xpu.rgb -f rawvideo -pix_fmt rgb24 -s:v 480x270 -i nasa_13013_ffmpeg_cpu.rgb -filter_complex "psnr"

PSNR r:52.915639 g:48.554012 b:52.363531 average:50.815521 min:49.467900 max:51.852806

CC: @eromomon

See ffmpeg color yuv2rgb color conversion reference:
* https://github.com/FFmpeg/FFmpeg/blob/a5d4c398b411a00ac09d8fe3b66117222323844c/libavfilter/opencl/colorspace_common.cl#L111

Color conversion matrix copied from the ffmpeg internal output of:

```
ff_fill_rgb2yuv_table(av_csp_luma_coeffs_from_avcsp(color_space), rgb2yuv);
ff_matrix_invert_3x3(rgb2yuv, yuv2rgb);
```

with color space `AVCOL_PRI_BT470BG` and `AVCOL_PRI_BT709`.

Reference results for the nasa clip from torchcodec:

```
ffmpeg -i nasa_13013.mp4 -vf "scale=480:270:sws_flags=bilinear,format=rgb24" -y nasa_13013_ffmpeg_cpu.rgb
ffmpeg -f rawvideo -pix_fmt rgb24 -s:v 480x270 -i nasa_13013_xpu.rgb -f rawvideo -pix_fmt rgb24 -s:v 480x270 -i nasa_13013_ffmpeg_cpu.rgb -filter_complex "psnr"

PSNR r:52.915639 g:48.554012 b:52.363531 average:50.815521 min:49.467900 max:51.852806
```

Signed-off-by: Edgar Romo Montiel <edgar.romo.montiel@intel.com>
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Co-authored-by: Edgar Romo Montiel <edgar.romo.montiel@intel.com>
Co-authored-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
@dvrogozh dvrogozh merged commit e6a2d7d into intel:main Feb 27, 2026
1 check passed
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