[vlc-commits] avcodec: split TestFfmpegChroma() in two functions

Rémi Denis-Courmont git at videolan.org
Fri Jan 4 18:25:57 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jan  4 19:11:39 2013 +0200| [2e2de1041e558156bfaacf9ca3ffbce74c5b6b0d] | committer: Rémi Denis-Courmont

avcodec: split TestFfmpegChroma() in two functions

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2e2de1041e558156bfaacf9ca3ffbce74c5b6b0d
---

 modules/codec/avcodec/chroma.c  |   26 ++++++++++++++++----------
 modules/codec/avcodec/chroma.h  |    4 +++-
 modules/codec/avcodec/encoder.c |    8 +++-----
 modules/codec/avcodec/video.c   |    2 +-
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/modules/codec/avcodec/chroma.c b/modules/codec/avcodec/chroma.c
index 0c86867..f482cf5 100644
--- a/modules/codec/avcodec/chroma.c
+++ b/modules/codec/avcodec/chroma.c
@@ -122,16 +122,6 @@ static const struct
     { 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 */
 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;
 }
 
+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 )
 {
     /* 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 )
     }
     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;
+}
diff --git a/modules/codec/avcodec/chroma.h b/modules/codec/avcodec/chroma.h
index 37b1588..d7ef4ef 100644
--- a/modules/codec/avcodec/chroma.h
+++ b/modules/codec/avcodec/chroma.h
@@ -26,8 +26,10 @@
 #ifndef _VLC_AVUTIL_CHROMA_H
 #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 );
+
+vlc_fourcc_t FindVlcChroma( int );
 int GetVlcChroma( video_format_t *fmt, int i_ffmpeg_chroma );
 
 #endif
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index bb45a61..1d6117a 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -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,
                              &psz_namecodec ) )
     {
-        if( TestFfmpegChroma( -1, p_enc->fmt_out.i_codec ) != VLC_SUCCESS )
-        {
-            /* handed chroma output */
-            return VLC_EGENERIC;
-        }
+        if( FindFfmpegChroma( p_enc->fmt_out.i_codec ) == PIX_FMT_NONE )
+            return VLC_EGENERIC; /* handed chroma output */
+
         i_cat      = VIDEO_ES;
         i_codec_id = CODEC_ID_RAWVIDEO;
         psz_namecodec = "Raw video";
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 2169848..8782e42 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -902,7 +902,7 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
     {
         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;
         uint8_t *p_dst, *p_src;



More information about the vlc-commits mailing list