Commit 2e2de104 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: split TestFfmpegChroma() in two functions

parent fd6cead7
...@@ -122,16 +122,6 @@ static const struct ...@@ -122,16 +122,6 @@ static const struct
{ 0, 0, 0, 0, 0 } { 0, 0, 0, 0, 0 }
}; };
int TestFfmpegChroma( int i_ffmpeg_id, vlc_fourcc_t i_vlc_fourcc )
{
for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
{
if( chroma_table[i].i_chroma == i_vlc_fourcc || chroma_table[i].i_chroma_id == i_ffmpeg_id )
return VLC_SUCCESS;
}
return VLC_EGENERIC;
}
/* FIXME special case the RGB formats */ /* FIXME special case the RGB formats */
int GetFfmpegChroma( int *restrict i_ffmpeg_chroma, const video_format_t *fmt ) int GetFfmpegChroma( int *restrict i_ffmpeg_chroma, const video_format_t *fmt )
{ {
...@@ -154,6 +144,14 @@ int GetFfmpegChroma( int *restrict i_ffmpeg_chroma, const video_format_t *fmt ) ...@@ -154,6 +144,14 @@ int GetFfmpegChroma( int *restrict i_ffmpeg_chroma, const video_format_t *fmt )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
vlc_fourcc_t FindVlcChroma( int i_ffmpeg_id )
{
for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
if( chroma_table[i].i_chroma_id == i_ffmpeg_id )
return chroma_table[i].i_chroma;
return 0;
}
int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma ) int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma )
{ {
/* TODO FIXME for rgb format we HAVE to set rgb mask/shift */ /* TODO FIXME for rgb format we HAVE to set rgb mask/shift */
...@@ -170,3 +168,11 @@ int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma ) ...@@ -170,3 +168,11 @@ int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma )
} }
return VLC_EGENERIC; return VLC_EGENERIC;
} }
int FindFfmpegChroma( vlc_fourcc_t fourcc )
{
for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
if( chroma_table[i].i_chroma == fourcc )
return chroma_table[i].i_chroma_id;
return PIX_FMT_NONE;
}
...@@ -26,8 +26,10 @@ ...@@ -26,8 +26,10 @@
#ifndef _VLC_AVUTIL_CHROMA_H #ifndef _VLC_AVUTIL_CHROMA_H
#define _VLC_AVUTIL_CHROMA_H 1 #define _VLC_AVUTIL_CHROMA_H 1
int TestFfmpegChroma( int i_ffmpeg_id, vlc_fourcc_t i_vlc_fourcc ); int FindFfmpegChroma( vlc_fourcc_t );
int GetFfmpegChroma( int *i_ffmpeg_chroma, const video_format_t *fmt ); int GetFfmpegChroma( int *i_ffmpeg_chroma, const video_format_t *fmt );
vlc_fourcc_t FindVlcChroma( int );
int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma ); int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma );
#endif #endif
...@@ -220,11 +220,9 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -220,11 +220,9 @@ int OpenEncoder( vlc_object_t *p_this )
else if( !GetFfmpegCodec( p_enc->fmt_out.i_codec, &i_cat, &i_codec_id, else if( !GetFfmpegCodec( p_enc->fmt_out.i_codec, &i_cat, &i_codec_id,
&psz_namecodec ) ) &psz_namecodec ) )
{ {
if( TestFfmpegChroma( -1, p_enc->fmt_out.i_codec ) != VLC_SUCCESS ) if( FindFfmpegChroma( p_enc->fmt_out.i_codec ) == PIX_FMT_NONE )
{ return VLC_EGENERIC; /* handed chroma output */
/* handed chroma output */
return VLC_EGENERIC;
}
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec_id = CODEC_ID_RAWVIDEO; i_codec_id = CODEC_ID_RAWVIDEO;
psz_namecodec = "Raw video"; psz_namecodec = "Raw video";
......
...@@ -902,7 +902,7 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec, ...@@ -902,7 +902,7 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
{ {
vlc_va_Extract( p_sys->p_va, p_pic, p_ff_pic ); vlc_va_Extract( p_sys->p_va, p_pic, p_ff_pic );
} }
else if( TestFfmpegChroma( p_sys->p_context->pix_fmt, -1 ) == VLC_SUCCESS ) else if( FindVlcChroma( p_sys->p_context->pix_fmt ) )
{ {
int i_plane, i_size, i_line; int i_plane, i_size, i_line;
uint8_t *p_dst, *p_src; uint8_t *p_dst, *p_src;
......
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