Commit 31960f45 authored by François Cartegnie's avatar François Cartegnie 🤞

ImageWrite: create filters when RGB masks differ

refs #13349

(cherry picked from commit b7b69fcf)
parent a9b274ce
......@@ -317,6 +317,29 @@ error:
return NULL;
}
/* FIXME: refactor by splitting video_format_IsSimilar() API */
static bool BitMapFormatIsSimilar( const video_format_t *f1,
const video_format_t *f2 )
{
if( f1->i_chroma == VLC_CODEC_RGB15 ||
f1->i_chroma == VLC_CODEC_RGB16 ||
f1->i_chroma == VLC_CODEC_RGB24 ||
f1->i_chroma == VLC_CODEC_RGB32 )
{
video_format_t v1 = *f1;
video_format_t v2 = *f2;
video_format_FixRgb( &v1 );
video_format_FixRgb( &v2 );
if( v1.i_rmask != v2.i_rmask ||
v1.i_gmask != v2.i_gmask ||
v1.i_bmask != v2.i_bmask )
return false;
}
return true;
}
/**
* Write an image
*
......@@ -349,14 +372,16 @@ static block_t *ImageWrite( image_handler_t *p_image, picture_t *p_pic,
/* Check if we need chroma conversion or resizing */
if( p_image->p_enc->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
p_image->p_enc->fmt_in.video.i_width != p_fmt_in->i_width ||
p_image->p_enc->fmt_in.video.i_height != p_fmt_in->i_height )
p_image->p_enc->fmt_in.video.i_height != p_fmt_in->i_height ||
!BitMapFormatIsSimilar( &p_image->p_enc->fmt_in.video, p_fmt_in ) )
{
picture_t *p_tmp_pic;
if( p_image->p_filter )
if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
p_image->p_filter->fmt_out.video.i_chroma !=
p_image->p_enc->fmt_in.video.i_chroma )
p_image->p_enc->fmt_in.video.i_chroma ||
!BitMapFormatIsSimilar( &p_image->p_filter->fmt_in.video, p_fmt_in ) )
{
/* We need to restart a new filter */
DeleteFilter( p_image->p_filter );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment