X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Favcodec%2Fchroma.c;h=9105e652804eda26f666793c7a500974c0b18e4d;hb=9bf41d6aeb35a121ce9c96adb21852ca69eb106b;hp=6e13170a3485f731c4cea5d59f3cc38dc7353ca0;hpb=7f12470415d98e9e0ac725f2bb96b5fa74ef27f1;p=vlc diff --git a/modules/codec/avcodec/chroma.c b/modules/codec/avcodec/chroma.c index 6e13170a34..9105e65280 100644 --- a/modules/codec/avcodec/chroma.c +++ b/modules/codec/avcodec/chroma.c @@ -1,24 +1,24 @@ /***************************************************************************** * chroma.c: libavutil <-> libvlc conversion routines ***************************************************************************** - * Copyright (C) 1999-2008 the VideoLAN team + * Copyright (C) 1999-2008 VLC authors and VideoLAN * $Id$ * * Authors: Laurent Aimar * Gildas Bazin * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 021100301, USA. *****************************************************************************/ @@ -29,17 +29,13 @@ #include #include -#ifdef HAVE_LIBAVCODEC_AVCODEC_H -# include -#elif defined(HAVE_FFMPEG_AVCODEC_H) -# include -#else -# include -#endif -#include "avcodec.h" +#include +#include +#include "avcommon.h" +#include "chroma.h" /***************************************************************************** - * Chroma fourcc -> ffmpeg_id mapping + * Chroma fourcc -> libavutil pixfmt mapping *****************************************************************************/ #if defined(WORDS_BIGENDIAN) # define VLC_RGB_ES( fcc, leid, beid ) \ @@ -69,10 +65,8 @@ static const struct {VLC_CODEC_I444, PIX_FMT_YUV444P, 0, 0, 0 }, {VLC_CODEC_J444, PIX_FMT_YUVJ444P, 0, 0, 0 }, -#if LIBAVUTIL_VERSION_INT >= ((49<<16)+(5<<8)+0) {VLC_CODEC_I440, PIX_FMT_YUV440P, 0, 0, 0 }, {VLC_CODEC_J440, PIX_FMT_YUVJ440P, 0, 0, 0 }, -#endif {VLC_CODEC_I422, PIX_FMT_YUV422P, 0, 0, 0 }, {VLC_CODEC_J422, PIX_FMT_YUVJ422P, 0, 0, 0 }, @@ -85,8 +79,27 @@ static const struct {VLC_CODEC_I410, PIX_FMT_YUV410P, 0, 0, 0 }, {VLC_FOURCC('Y','V','U','9'), PIX_FMT_YUV410P, 0, 0, 0 }, - {VLC_FOURCC('N','V','1','2'), PIX_FMT_NV12, 0, 0, 0 }, - {VLC_FOURCC('N','V','2','1'), PIX_FMT_NV21, 0, 0, 0 }, + {VLC_CODEC_NV12, PIX_FMT_NV12, 0, 0, 0 }, + {VLC_CODEC_NV21, PIX_FMT_NV21, 0, 0, 0 }, + + {VLC_CODEC_I420_9L, PIX_FMT_YUV420P9LE, 0, 0, 0 }, + {VLC_CODEC_I420_9B, PIX_FMT_YUV420P9BE, 0, 0, 0 }, + {VLC_CODEC_I420_10L, PIX_FMT_YUV420P10LE, 0, 0, 0 }, + {VLC_CODEC_I420_10B, PIX_FMT_YUV420P10BE, 0, 0, 0 }, + {VLC_CODEC_I422_9L, PIX_FMT_YUV422P9LE, 0, 0, 0 }, + {VLC_CODEC_I422_9B, PIX_FMT_YUV422P9BE, 0, 0, 0 }, + {VLC_CODEC_I422_10L, PIX_FMT_YUV422P10LE, 0, 0, 0 }, + {VLC_CODEC_I422_10B, PIX_FMT_YUV422P10BE, 0, 0, 0 }, + + {VLC_CODEC_YUV420A, PIX_FMT_YUVA420P, 0, 0, 0 }, + {VLC_CODEC_YUV422A, AV_PIX_FMT_YUVA422P, 0, 0, 0 }, + + {VLC_CODEC_I444_9L, PIX_FMT_YUV444P9LE, 0, 0, 0 }, + {VLC_CODEC_I444_9B, PIX_FMT_YUV444P9BE, 0, 0, 0 }, + {VLC_CODEC_I444_10L, PIX_FMT_YUV444P10LE, 0, 0, 0 }, + {VLC_CODEC_I444_10B, PIX_FMT_YUV444P10BE, 0, 0, 0 }, + {VLC_CODEC_I444_16L, PIX_FMT_YUV444P16LE, 0, 0, 0 }, + {VLC_CODEC_I444_16B, PIX_FMT_YUV444P16BE, 0, 0, 0 }, /* Packed YUV formats */ {VLC_CODEC_YUYV, PIX_FMT_YUYV422, 0, 0, 0 }, @@ -96,47 +109,49 @@ static const struct /* Packed RGB formats */ VLC_RGB( VLC_FOURCC('R','G','B','4'), PIX_FMT_RGB4, PIX_FMT_BGR4, 0x10, 0x06, 0x01 ) - VLC_RGB( VLC_FOURCC('R','G','B','8'), PIX_FMT_RGB8, PIX_FMT_BGR8, 0xC0, 0x38, 0x07 ) + VLC_RGB( VLC_CODEC_RGB8, PIX_FMT_RGB8, PIX_FMT_BGR8, 0xC0, 0x38, 0x07 ) - VLC_RGB( VLC_CODEC_RGB15, PIX_FMT_BGR555, PIX_FMT_RGB555, 0x7c00, 0x03e0, 0x001f ) - VLC_RGB( VLC_CODEC_RGB16, PIX_FMT_BGR565, PIX_FMT_RGB565, 0xf800, 0x07e0, 0x001f ) + VLC_RGB( VLC_CODEC_RGB15, PIX_FMT_RGB555, PIX_FMT_BGR555, 0x7c00, 0x03e0, 0x001f ) + VLC_RGB( VLC_CODEC_RGB16, PIX_FMT_RGB565, PIX_FMT_BGR565, 0xf800, 0x07e0, 0x001f ) VLC_RGB( VLC_CODEC_RGB24, PIX_FMT_BGR24, PIX_FMT_RGB24, 0xff0000, 0x00ff00, 0x0000ff ) VLC_RGB( VLC_CODEC_RGB32, PIX_FMT_RGB32, PIX_FMT_BGR32, 0x00ff0000, 0x0000ff00, 0x000000ff ) VLC_RGB( VLC_CODEC_RGB32, PIX_FMT_RGB32_1, PIX_FMT_BGR32_1, 0xff000000, 0x00ff0000, 0x0000ff00 ) -#if defined(PIX_FMT_RGBA) - {VLC_CODEC_RGBA, PIX_FMT_RGBA, 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 + + {VLC_CODEC_RGBA, PIX_FMT_RGBA, 0, 0, 0 }, + {VLC_CODEC_ARGB, PIX_FMT_ARGB, 0, 0, 0 }, + {VLC_CODEC_BGRA, PIX_FMT_BGRA, 0, 0, 0 }, {VLC_CODEC_GREY, PIX_FMT_GRAY8, 0, 0, 0}, /* Paletized RGB */ {VLC_CODEC_RGBP, PIX_FMT_PAL8, 0, 0, 0}, + {VLC_CODEC_GBR_PLANAR, AV_PIX_FMT_GBRP, 0, 0, 0 }, + /* XYZ */ +#if LIBAVUTIL_VERSION_CHECK(52, 10, 0, 25, 100) + {VLC_CODEC_XYZ12, AV_PIX_FMT_XYZ12, 0xfff0, 0xfff0, 0xfff0}, +#endif { 0, 0, 0, 0, 0 } }; -int TestFfmpegChroma( const int i_ffmpeg_id, const 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 *i_ffmpeg_chroma, const video_format_t fmt ) +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 ) { - 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 ) + 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 ) ) { *i_ffmpeg_chroma = chroma_table[i].i_chroma_id; return VLC_SUCCESS; @@ -146,7 +161,15 @@ int GetFfmpegChroma( int *i_ffmpeg_chroma, const video_format_t fmt ) return VLC_EGENERIC; } -int GetVlcChroma( video_format_t *fmt, const int i_ffmpeg_chroma ) +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 */ for( int i = 0; chroma_table[i].i_chroma != 0; i++ ) @@ -162,3 +185,11 @@ int GetVlcChroma( video_format_t *fmt, const 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; +}