[vlc-devel] commit: ffmpeg chroma: add rgb masks to the chroma mapping table. This fixes #1749 and likely #1762. (Derk-Jan Hartman )

git version control git at videolan.org
Tue Aug 19 22:55:36 CEST 2008


vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Tue Aug 19 22:53:45 2008 +0200| [0034fbab5587b1197b0458ab3af20ea2644e12bc] | committer: Derk-Jan Hartman 

ffmpeg chroma: add rgb masks to the chroma mapping table. This fixes #1749 and likely #1762.

- Not 100% sure about PIX_FMT_RGB4 and PIX_FMT_RGB8, because their comments in the avutil.h header are incorrect.
- We use FOURCC RGB8, but it seems we use FOURCC RGB2 for RGB8 troughout the rest of VLC. Should be checked.

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

 modules/codec/avcodec/chroma.h |   94 ++++++++++++++++++++++-----------------
 1 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/modules/codec/avcodec/chroma.h b/modules/codec/avcodec/chroma.h
index d804c0b..0c03637 100644
--- a/modules/codec/avcodec/chroma.h
+++ b/modules/codec/avcodec/chroma.h
@@ -19,72 +19,76 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 021100301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Chroma fourcc -> ffmpeg_id mapping
  *****************************************************************************/
 
-#define VLC_FF( fcc, fav ) \
-    { VLC_FOURCC fcc, fav }
-
-#if defined(WORDS_BIGENDIAN)
-#   define VLC_FF_RGB_DEFAULT( fcc, le, be ) VLC_FF( fcc, be )
-#else
-#   define VLC_FF_RGB_DEFAULT( fcc, le, be ) VLC_FF( fcc, le )
-#endif
-
 static const struct
 {
     vlc_fourcc_t  i_chroma;
-    int  i_chroma_id;
+    int           i_chroma_id;
+    uint32_t      i_rmask;
+    uint32_t      i_gmask;
+    uint32_t      i_bmask;
 
 } chroma_table[] =
 {
     /* Planar YUV formats */
-    VLC_FF( ('I','4','4','4'), PIX_FMT_YUV444P ),
-    VLC_FF( ('J','4','4','4'), PIX_FMT_YUVJ444P ),
+    {VLC_FOURCC('I','4','4','4'), PIX_FMT_YUV444P, 0, 0, 0 },
+    {VLC_FOURCC('J','4','4','4'), PIX_FMT_YUVJ444P, 0, 0, 0 },
 
 #if LIBAVUTIL_VERSION_INT >= ((49<<16)+(5<<8)+0)
-    VLC_FF( ('I','4','4','0'), PIX_FMT_YUV440P ),
-    VLC_FF( ('J','4','4','0'), PIX_FMT_YUVJ440P ),
+    {VLC_FOURCC('I','4','4','0'), PIX_FMT_YUV440P, 0, 0, 0 },
+    {VLC_FOURCC('J','4','4','0'), PIX_FMT_YUVJ440P, 0, 0, 0 },
 #endif
 
-    VLC_FF( ('I','4','2','2'), PIX_FMT_YUV422P ),
-    VLC_FF( ('J','4','2','2'), PIX_FMT_YUVJ422P ),
+    {VLC_FOURCC('I','4','2','2'), PIX_FMT_YUV422P, 0, 0, 0 },
+    {VLC_FOURCC('J','4','2','2'), PIX_FMT_YUVJ422P, 0, 0, 0 },
 
-    VLC_FF( ('I','4','2','0'), PIX_FMT_YUV420P ),
-    VLC_FF( ('Y','V','1','2'), PIX_FMT_YUV420P ),
-    VLC_FF( ('I','Y','U','V'), PIX_FMT_YUV420P ),
-    VLC_FF( ('J','4','2','0'), PIX_FMT_YUVJ420P ),
-    VLC_FF( ('I','4','1','1'), PIX_FMT_YUV411P ),
-    VLC_FF( ('I','4','1','0'), PIX_FMT_YUV410P ),
-    VLC_FF( ('Y','V','U','9'), PIX_FMT_YUV410P ),
+    {VLC_FOURCC('I','4','2','0'), PIX_FMT_YUV420P, 0, 0, 0 },
+    {VLC_FOURCC('Y','V','1','2'), PIX_FMT_YUV420P, 0, 0, 0 },
+    {VLC_FOURCC('I','Y','U','V'), PIX_FMT_YUV420P, 0, 0, 0 },
+    {VLC_FOURCC('J','4','2','0'), PIX_FMT_YUVJ420P, 0, 0, 0 },
+    {VLC_FOURCC('I','4','1','1'), PIX_FMT_YUV411P, 0, 0, 0 },
+    {VLC_FOURCC('I','4','1','0'), PIX_FMT_YUV410P, 0, 0, 0 },
+    {VLC_FOURCC('Y','V','U','9'), PIX_FMT_YUV410P, 0, 0, 0 },
 
-    VLC_FF( ('N','V','1','2'), PIX_FMT_NV12 ),
-    VLC_FF( ('N','V','2','1'), PIX_FMT_NV21 ),
+    {VLC_FOURCC('N','V','1','2'), PIX_FMT_NV12, 0, 0, 0 },
+    {VLC_FOURCC('N','V','2','1'), PIX_FMT_NV21, 0, 0, 0 },
 
     /* Packed YUV formats */
-    VLC_FF( ('Y','U','Y','2'), PIX_FMT_YUYV422 ),
-    VLC_FF( ('Y','U','Y','V'), PIX_FMT_YUYV422 ),
-    VLC_FF( ('U','Y','V','Y'), PIX_FMT_UYVY422 ),
-    VLC_FF( ('Y','4','1','1'), PIX_FMT_UYYVYY411 ),
+    {VLC_FOURCC('Y','U','Y','2'), PIX_FMT_YUYV422, 0, 0, 0 },
+    {VLC_FOURCC('Y','U','Y','V'), PIX_FMT_YUYV422, 0, 0, 0 },
+    {VLC_FOURCC('U','Y','V','Y'), PIX_FMT_UYVY422, 0, 0, 0 },
+    {VLC_FOURCC('Y','4','1','1'), PIX_FMT_UYYVYY411, 0, 0, 0 },
 
     /* Packed RGB formats */
-    VLC_FF_RGB_DEFAULT( ('R','G','B','8'), PIX_FMT_RGB8,    PIX_FMT_BGR8 ),
-    VLC_FF_RGB_DEFAULT( ('R','V','1','5'), PIX_FMT_RGB555,  PIX_FMT_BGR555 ),
-    VLC_FF_RGB_DEFAULT( ('R','V','1','6'), PIX_FMT_RGB565,  PIX_FMT_BGR565 ),
-    VLC_FF_RGB_DEFAULT( ('R','V','2','4'), PIX_FMT_RGB24,   PIX_FMT_BGR24 ),
-
-    VLC_FF( ('R','V','3','2'), PIX_FMT_RGBA32 ),    // FIXME is that wanted
+    {VLC_FOURCC('R','G','B','4'), PIX_FMT_RGB4, 0x10, 0x06, 0x01 }, /* FIXME verify */
+    {VLC_FOURCC('R','G','B','4'), PIX_FMT_BGR4, 0x01, 0x06, 0x10 },
+    {VLC_FOURCC('R','G','B','8'), PIX_FMT_RGB8, 0xC0, 0x38, 0x07 }, /* FIXME verify */
+    {VLC_FOURCC('R','G','B','8'), PIX_FMT_BGR8, 0x07, 0x38, 0xC0 },
+    {VLC_FOURCC('R','V','1','5'), PIX_FMT_RGB555, 0x7c00, 0x03e0, 0x001f },
+    {VLC_FOURCC('R','V','1','5'), PIX_FMT_RGB555, 0x7c00, 0x03e0, 0x001f },
+    {VLC_FOURCC('R','V','1','5'), PIX_FMT_BGR555, 0x001f, 0x03e0, 0x7c00 },
+    {VLC_FOURCC('R','V','1','6'), PIX_FMT_RGB565, 0xf800, 0x07e0, 0x001f },
+    {VLC_FOURCC('R','V','1','6'), PIX_FMT_BGR565, 0x001f, 0x07e0, 0x001f },
+    {VLC_FOURCC('R','V','2','4'), PIX_FMT_RGB24, 0xff0000, 0x00ff00, 0x0000ff },
+    {VLC_FOURCC('R','V','2','4'), PIX_FMT_BGR24, 0x0000ff, 0x00ff00, 0xff0000 },
+
+    {VLC_FOURCC('R','V','3','2'), PIX_FMT_RGB32, 0x00ff0000, 0x0000ff00, 0x000000ff },
+    {VLC_FOURCC('R','V','3','2'), PIX_FMT_BGR32, 0x000000ff, 0x0000ff00, 0x00ff0000 },
+    {VLC_FOURCC('R','V','3','2'), PIX_FMT_RGB32_1, 0xff000000, 0x00ff0000, 0x0000ff00 },
+    {VLC_FOURCC('R','V','3','2'), PIX_FMT_BGR32_1, 0x0000ff00, 0x00ff0000, 0xff000000 },
 
 #if defined(PIX_FMT_RGBA)
-    VLC_FF( ('R','G','B','A'), PIX_FMT_RGBA ),
+    {VLC_FOURCC('R','G','B','A'), PIX_FMT_RGBA, 0xff000000, 0x00ff0000, 0x0000ff00},
 #endif
-    VLC_FF( ('G','R','E','Y'), PIX_FMT_GRAY8 ),
+    {VLC_FOURCC('G','R','E','Y'), PIX_FMT_GRAY8, 0, 0, 0},
 
-    { 0, 0 }
+    { 0, 0, 0, 0, 0 }
 };
 
 static inline int TestFfmpegChroma( const int i_ffmpeg_id, const vlc_fourcc_t i_vlc_fourcc )
@@ -104,8 +108,13 @@ static inline int GetFfmpegChroma( int *i_ffmpeg_chroma, const video_format_t fm
     {
         if( chroma_table[i].i_chroma == fmt.i_chroma )
         {
-            *i_ffmpeg_chroma =  chroma_table[i].i_chroma_id;
-            return VLC_SUCCESS;
+            if( chroma_table[i].i_rmask == fmt.i_rmask &&
+                chroma_table[i].i_gmask == fmt.i_gmask && 
+                chroma_table[i].i_bmask == fmt.i_bmask )
+            {
+                *i_ffmpeg_chroma = chroma_table[i].i_chroma_id;
+                return VLC_SUCCESS;
+            }
         }
     }
     return VLC_EGENERIC;
@@ -118,6 +127,9 @@ static inline int GetVlcChroma( video_format_t *fmt, const int i_ffmpeg_chroma )
     {
         if( chroma_table[i].i_chroma_id == i_ffmpeg_chroma )
         {
+            fmt->i_rmask = chroma_table[i].i_rmask;
+            fmt->i_gmask = chroma_table[i].i_gmask;
+            fmt->i_bmask = chroma_table[i].i_bmask;
             fmt->i_chroma = chroma_table[i].i_chroma;
             return VLC_SUCCESS;
         }




More information about the vlc-devel mailing list