Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits: a1671b79 by Steve Lhomme at 2026-05-02T13:03:12+00:00 Revert "codec: avcodec: fix mask mappings for 32 bits RGB" This reverts commit feada68ef67ff6d94e39e7b63ffdef3203aa5563. Fixes #29818 - - - - - faf9f526 by Steve Lhomme at 2026-05-02T13:03:12+00:00 avcodec/chroma: prioritize RGB mapping with the same mask If the mask corresponds exactly, we have an exact match. If the RGB source has a mask but none of the RGB mapping uses the same mask, we map to a close RGB format with a different mask. It's better than using the first VLC_CODEC_RGBxx in the list if there's one corresponding to the exact match. Another option would be to move the VLC_RGB_ES() calls at the end of the list. (cherry picked from commit a309fb4c10f238bb2319abe9ec489daa0c91521c) Signed-off-by: Steve Lhomme <[email protected]> - - - - - 7c1e5ca5 by Steve Lhomme at 2026-05-02T13:03:12+00:00 codec: avcodec: prioritize RGB with mask set to 0 GetVlcChroma() passes a libavutil chroma without a mask. AV_PIX_FMT_RGB32 is also AV_PIX_FMT_RGBA (or AV_PIX_FMT_BGRA depending on the endianess). So we returned VLC_CODEC_RGB32 with a mask rather than the proper VLC_CODEC_RGBA. FindVlcChroma() had the same problem but it doesn't return a mask. So returning VLC_CODEC_RGB32 is even more problematic. GetFfmpegChroma() is unaffected as we match the mask first. FindFfmpegChroma() is only used to check the format can be mapped. Fixes #29535 - - - - - 1 changed file: - modules/codec/avcodec/chroma.c Changes: ===================================== modules/codec/avcodec/chroma.c ===================================== @@ -144,13 +144,18 @@ static const struct VLC_RGB( VLC_CODEC_RGB15, AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555, 0x7c00, 0x03e0, 0x001f ) VLC_RGB( VLC_CODEC_RGB16, AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565, 0xf800, 0x07e0, 0x001f ) VLC_RGB( VLC_CODEC_RGB24, AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, 0xff0000, 0x00ff00, 0x0000ff ) - VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR, 0x00ff0000, 0x0000ff00, 0x000000ff) - VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0, 0xff000000, 0x00ff0000, 0x0000ff00) {VLC_CODEC_RGBA, AV_PIX_FMT_RGBA, 0, 0, 0 }, {VLC_CODEC_ARGB, AV_PIX_FMT_ARGB, 0, 0, 0 }, {VLC_CODEC_BGRA, AV_PIX_FMT_BGRA, 0, 0, 0 }, + VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_RGB32, AV_PIX_FMT_BGR32, 0x00ff0000, 0x0000ff00, 0x000000ff ) + VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_RGB32_1, AV_PIX_FMT_BGR32_1, 0xff000000, 0x00ff0000, 0x0000ff00 ) + +#ifdef AV_PIX_FMT_0BGR32 + VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_0BGR32, AV_PIX_FMT_0RGB32, 0x000000ff, 0x0000ff00, 0x00ff0000 ) +#endif + #if (LIBAVUTIL_VERSION_MICRO == 0 || LIBAVUTIL_VERSION_CHECK( 55, 0, 100 ) ) #ifdef WORDS_BIGENDIAN {VLC_CODEC_RGBA64, AV_PIX_FMT_RGBA64BE, 0, 0, 0 }, @@ -194,14 +199,23 @@ int GetFfmpegChroma( int *restrict i_ffmpeg_chroma, const video_format_t *fmt ) { for( int i = 0; chroma_table[i].i_chroma != 0; i++ ) { - if( chroma_table[i].i_chroma == fmt->i_chroma ) + if( chroma_table[i].i_chroma == fmt->i_chroma && + chroma_table[i].i_rmask == fmt->i_rmask && + chroma_table[i].i_gmask == fmt->i_gmask && + chroma_table[i].i_bmask == fmt->i_bmask ) + { + return chroma_table[i].i_chroma_id; + } + } + // try again without the mask as they may not correspond exactly + if (fmt->i_rmask || fmt->i_gmask || fmt->i_bmask) + { + for( int i = 0; chroma_table[i].i_chroma != 0; i++ ) { - if( ( chroma_table[i].i_rmask == 0 && - chroma_table[i].i_gmask == 0 && - chroma_table[i].i_bmask == 0 ) || - ( chroma_table[i].i_rmask == fmt->i_rmask && - chroma_table[i].i_gmask == fmt->i_gmask && - chroma_table[i].i_bmask == fmt->i_bmask ) ) + if( chroma_table[i].i_chroma == fmt->i_chroma && + chroma_table[i].i_rmask == 0 && + chroma_table[i].i_gmask == 0 && + chroma_table[i].i_bmask == 0 ) { *i_ffmpeg_chroma = chroma_table[i].i_chroma_id; return VLC_SUCCESS; View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/049988e7860b6fd4f70de054548ae9c209281660...7c1e5ca5df2267cdab8f9ca785c6de7d6cd21168 -- View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/049988e7860b6fd4f70de054548ae9c209281660...7c1e5ca5df2267cdab8f9ca785c6de7d6cd21168 You're receiving this email because of your account on code.videolan.org.
_______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
