2010-01-30 16:57:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer 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
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2012-12-31 00:58:25 +00:00
|
|
|
#include <assert.h>
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
#include <string.h>
|
2012-12-31 00:58:25 +00:00
|
|
|
|
|
|
|
#include <libavutil/pixfmt.h>
|
|
|
|
#include <libavutil/pixdesc.h>
|
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/img_format.h"
|
2012-12-31 00:58:25 +00:00
|
|
|
#include "video/mp_image.h"
|
|
|
|
#include "video/fmt-conversion.h"
|
2001-10-31 22:04:28 +00:00
|
|
|
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
#define FMT(string, id) \
|
|
|
|
{string, id},
|
|
|
|
|
|
|
|
#define FMT_ENDIAN(string, id) \
|
|
|
|
{string, id}, \
|
|
|
|
{string "le", MP_CONCAT(id, _LE)}, \
|
|
|
|
{string "be", MP_CONCAT(id, _BE)}, \
|
2012-08-21 17:20:36 +00:00
|
|
|
|
|
|
|
struct mp_imgfmt_entry mp_imgfmt_list[] = {
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("y8", IMGFMT_Y8)
|
|
|
|
FMT_ENDIAN("y16", IMGFMT_Y16)
|
2012-12-26 23:58:45 +00:00
|
|
|
FMT("ya8", IMGFMT_YA8)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("yuyv", IMGFMT_YUYV)
|
|
|
|
FMT("uyvy", IMGFMT_UYVY)
|
|
|
|
FMT("nv12", IMGFMT_NV12)
|
|
|
|
FMT("nv21", IMGFMT_NV21)
|
|
|
|
FMT("444p", IMGFMT_444P)
|
|
|
|
FMT("422p", IMGFMT_422P)
|
|
|
|
FMT("440p", IMGFMT_440P)
|
|
|
|
FMT("420p", IMGFMT_420P)
|
|
|
|
FMT("411p", IMGFMT_411P)
|
|
|
|
FMT("410p", IMGFMT_410P)
|
|
|
|
FMT_ENDIAN("444p16", IMGFMT_444P16)
|
|
|
|
FMT_ENDIAN("444p14", IMGFMT_444P14)
|
|
|
|
FMT_ENDIAN("444p12", IMGFMT_444P12)
|
|
|
|
FMT_ENDIAN("444p10", IMGFMT_444P10)
|
|
|
|
FMT_ENDIAN("444p9", IMGFMT_444P9)
|
|
|
|
FMT_ENDIAN("422p16", IMGFMT_422P16)
|
|
|
|
FMT_ENDIAN("422p14", IMGFMT_422P14)
|
|
|
|
FMT_ENDIAN("422p12", IMGFMT_422P12)
|
|
|
|
FMT_ENDIAN("422p10", IMGFMT_422P10)
|
|
|
|
FMT_ENDIAN("422p9", IMGFMT_422P9)
|
|
|
|
FMT_ENDIAN("420p16", IMGFMT_420P16)
|
|
|
|
FMT_ENDIAN("420p14", IMGFMT_420P14)
|
|
|
|
FMT_ENDIAN("420p12", IMGFMT_420P12)
|
|
|
|
FMT_ENDIAN("420p10", IMGFMT_420P10)
|
|
|
|
FMT_ENDIAN("420p9", IMGFMT_420P9)
|
2012-12-26 23:58:45 +00:00
|
|
|
FMT("444ap", IMGFMT_444AP)
|
|
|
|
FMT("422ap", IMGFMT_422AP)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("420ap", IMGFMT_420AP)
|
2012-12-26 23:58:45 +00:00
|
|
|
FMT_ENDIAN("444ap9", IMGFMT_444AP9)
|
|
|
|
FMT_ENDIAN("444ap10", IMGFMT_444AP10)
|
|
|
|
FMT_ENDIAN("444ap16", IMGFMT_444AP16)
|
|
|
|
FMT_ENDIAN("422ap9", IMGFMT_422AP9)
|
|
|
|
FMT_ENDIAN("422ap10", IMGFMT_422AP10)
|
|
|
|
FMT_ENDIAN("422ap16", IMGFMT_422AP16)
|
|
|
|
FMT_ENDIAN("420ap9", IMGFMT_420AP9)
|
|
|
|
FMT_ENDIAN("420ap10", IMGFMT_420AP10)
|
|
|
|
FMT_ENDIAN("420ap16", IMGFMT_420AP16)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("argb", IMGFMT_ARGB)
|
2012-12-26 23:58:45 +00:00
|
|
|
FMT("0rgb", IMGFMT_0RGB)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("bgra", IMGFMT_BGRA)
|
|
|
|
FMT("bgr0", IMGFMT_BGR0)
|
|
|
|
FMT("abgr", IMGFMT_ABGR)
|
2012-12-26 23:58:45 +00:00
|
|
|
FMT("0bgr", IMGFMT_0BGR)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("rgba", IMGFMT_RGBA)
|
2012-12-26 23:58:45 +00:00
|
|
|
FMT("rgb0", IMGFMT_RGB0)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("rgb32", IMGFMT_RGB32)
|
|
|
|
FMT("bgr32", IMGFMT_BGR32)
|
|
|
|
FMT("bgr24", IMGFMT_BGR24)
|
|
|
|
FMT("rgb24", IMGFMT_RGB24)
|
|
|
|
FMT_ENDIAN("rgb48", IMGFMT_RGB48)
|
2012-12-26 23:58:45 +00:00
|
|
|
FMT_ENDIAN("rgba64", IMGFMT_RGBA64)
|
|
|
|
FMT_ENDIAN("bgra64", IMGFMT_BGRA64)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("rgb8", IMGFMT_RGB8)
|
|
|
|
FMT("bgr8", IMGFMT_BGR8)
|
|
|
|
FMT("rgb4_byte", IMGFMT_RGB4_BYTE)
|
|
|
|
FMT("bgr4_byte", IMGFMT_BGR4_BYTE)
|
|
|
|
FMT("rgb4", IMGFMT_RGB4)
|
|
|
|
FMT("bgr4", IMGFMT_BGR4)
|
|
|
|
FMT("mono", IMGFMT_MONO)
|
2013-02-25 23:44:38 +00:00
|
|
|
FMT("mono_w", IMGFMT_MONO_W)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT_ENDIAN("rgb12", IMGFMT_RGB12)
|
|
|
|
FMT_ENDIAN("rgb15", IMGFMT_RGB15)
|
|
|
|
FMT_ENDIAN("rgb16", IMGFMT_RGB16)
|
|
|
|
FMT_ENDIAN("bgr12", IMGFMT_BGR12)
|
|
|
|
FMT_ENDIAN("bgr15", IMGFMT_BGR15)
|
|
|
|
FMT_ENDIAN("bgr16", IMGFMT_BGR16)
|
|
|
|
FMT("pal8", IMGFMT_PAL8)
|
|
|
|
FMT("gbrp", IMGFMT_GBRP)
|
2012-12-26 23:58:45 +00:00
|
|
|
FMT_ENDIAN("gbrp9", IMGFMT_GBRP9)
|
|
|
|
FMT_ENDIAN("gbrp10", IMGFMT_GBRP10)
|
|
|
|
FMT_ENDIAN("gbrp12", IMGFMT_GBRP12)
|
|
|
|
FMT_ENDIAN("gbrp14", IMGFMT_GBRP14)
|
|
|
|
FMT_ENDIAN("gbrp16", IMGFMT_GBRP16)
|
2013-05-01 14:16:03 +00:00
|
|
|
FMT_ENDIAN("xyz12", IMGFMT_XYZ12)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
FMT("vdpau_mpeg1", IMGFMT_VDPAU_MPEG1)
|
|
|
|
FMT("vdpau_mpeg2", IMGFMT_VDPAU_MPEG2)
|
|
|
|
FMT("vdpau_h264", IMGFMT_VDPAU_H264)
|
|
|
|
FMT("vdpau_wmv3", IMGFMT_VDPAU_WMV3)
|
|
|
|
FMT("vdpau_vc1", IMGFMT_VDPAU_VC1)
|
|
|
|
FMT("vdpau_mpeg4", IMGFMT_VDPAU_MPEG4)
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-27 23:49:45 +00:00
|
|
|
FMT("vdpau", IMGFMT_VDPAU)
|
video: add vaapi decode and output support
This is based on the MPlayer VA API patches. To be exact it's based on
a very stripped down version of commit f1ad459a263f8537f6c from
git://gitorious.org/vaapi/mplayer.git.
This doesn't contain useless things like benchmarking hacks and the
demo code for GLX interop. Also, unlike in the original patch, decoding
and video output are split into separate source files (the separation
between decoding and display also makes pixel format hacks unnecessary).
On the other hand, some features not present in the original patch were
added, like screenshot support.
VA API is rather bad for actual video output. Dealing with older libva
versions or the completely broken vdpau backend doesn't help. OSD is
low quality and should be rather slow. In some cases, only either OSD
or subtitles can be shown at the same time (because OSD is drawn first,
OSD is prefered).
Also, libva can't decide whether it accepts straight or premultiplied
alpha for OSD sub-pictures: the vdpau backend seems to assume
premultiplied, while a native vaapi driver uses straight. So I picked
straight alpha. It doesn't matter much, because the blending code for
straight alpha I added to img_convert.c is probably buggy, and ASS
subtitles might be blended incorrectly.
Really good video output with VA API would probably use OpenGL and the
GL interop features, but at this point you might just use vo_opengl.
(Patches for making HW decoding with vo_opengl have a chance of being
accepted.)
Despite these issues, decoding seems to work ok. I still got tearing
on the Intel system I tested (Intel(R) Core(TM) i3-2350M). It was also
tested with the vdpau vaapi wrapper on a nvidia system; however this
was rather broken. (Fortunately, there is no reason to use mpv's VAAPI
support over native VDPAU.)
2013-08-09 12:01:30 +00:00
|
|
|
FMT("vaapi", IMGFMT_VAAPI)
|
|
|
|
FMT("vaapi_mpeg2_idct", IMGFMT_VAAPI_MPEG2_IDCT)
|
|
|
|
FMT("vaapi_mpeg2_moco", IMGFMT_VAAPI_MPEG2_MOCO)
|
2012-08-28 21:58:48 +00:00
|
|
|
{0}
|
2012-08-21 17:20:36 +00:00
|
|
|
};
|
|
|
|
|
2012-08-28 21:58:48 +00:00
|
|
|
unsigned int mp_imgfmt_from_name(bstr name, bool allow_hwaccel)
|
2012-08-21 17:20:36 +00:00
|
|
|
{
|
2013-01-17 15:10:26 +00:00
|
|
|
int img_fmt = 0;
|
2012-08-28 21:58:48 +00:00
|
|
|
for(struct mp_imgfmt_entry *p = mp_imgfmt_list; p->name; ++p) {
|
2013-01-17 15:10:26 +00:00
|
|
|
if(bstr_equals0(name, p->name)) {
|
|
|
|
img_fmt = p->fmt;
|
|
|
|
break;
|
2012-08-28 21:58:48 +00:00
|
|
|
}
|
2012-08-21 17:20:36 +00:00
|
|
|
}
|
2013-01-17 15:10:26 +00:00
|
|
|
if (!img_fmt) {
|
|
|
|
char *t = bstrdup0(NULL, name);
|
|
|
|
img_fmt = pixfmt2imgfmt(av_get_pix_fmt(t));
|
|
|
|
talloc_free(t);
|
|
|
|
}
|
|
|
|
if (!img_fmt && bstr_equals0(name, "yv12"))
|
|
|
|
img_fmt = IMGFMT_420P; // old alias for UI
|
|
|
|
if (!allow_hwaccel && IMGFMT_IS_HWACCEL(img_fmt))
|
|
|
|
return 0;
|
|
|
|
return img_fmt;
|
2012-08-21 17:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *mp_imgfmt_to_name(unsigned int fmt)
|
|
|
|
{
|
|
|
|
struct mp_imgfmt_entry *p = mp_imgfmt_list;
|
|
|
|
for(; p->name; ++p) {
|
|
|
|
if(p->fmt == fmt)
|
|
|
|
return p->name;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-12-31 00:58:25 +00:00
|
|
|
|
|
|
|
static struct mp_imgfmt_desc get_avutil_fmt(enum PixelFormat fmt)
|
|
|
|
{
|
|
|
|
const AVPixFmtDescriptor *pd = &av_pix_fmt_descriptors[fmt];
|
|
|
|
int mpfmt = pixfmt2imgfmt(fmt);
|
|
|
|
if (!pd || !mpfmt)
|
|
|
|
return (struct mp_imgfmt_desc) {0};
|
|
|
|
|
|
|
|
struct mp_imgfmt_desc desc = {
|
|
|
|
.id = mpfmt,
|
|
|
|
.avformat = fmt,
|
2013-03-03 10:14:44 +00:00
|
|
|
.name = mp_imgfmt_to_name(mpfmt),
|
2012-12-31 00:58:25 +00:00
|
|
|
.chroma_xs = pd->log2_chroma_w,
|
|
|
|
.chroma_ys = pd->log2_chroma_h,
|
|
|
|
};
|
|
|
|
|
|
|
|
int planedepth[4] = {0};
|
|
|
|
int el_size = (pd->flags & PIX_FMT_BITSTREAM) ? 1 : 8;
|
|
|
|
for (int c = 0; c < pd->nb_components; c++) {
|
|
|
|
AVComponentDescriptor d = pd->comp[c];
|
|
|
|
// multiple components per plane -> Y is definitive, ignore chroma
|
|
|
|
if (!desc.bpp[d.plane])
|
|
|
|
desc.bpp[d.plane] = (d.step_minus1 + 1) * el_size;
|
|
|
|
planedepth[d.plane] += d.depth_minus1 + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int p = 0; p < 4; p++) {
|
|
|
|
if (desc.bpp[p])
|
|
|
|
desc.num_planes++;
|
|
|
|
}
|
|
|
|
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
// Packed RGB formats are the only formats that have less than 8 bits per
|
|
|
|
// component, and still require endian dependent access.
|
|
|
|
if (pd->comp[0].depth_minus1 + 1 <= 8 &&
|
2013-05-06 18:54:23 +00:00
|
|
|
!(mpfmt >= IMGFMT_RGB12_LE && mpfmt <= IMGFMT_BGR16_BE))
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
{
|
|
|
|
desc.flags |= MP_IMGFLAG_LE | MP_IMGFLAG_BE;
|
|
|
|
} else {
|
|
|
|
desc.flags |= (pd->flags & PIX_FMT_BE) ? MP_IMGFLAG_BE : MP_IMGFLAG_LE;
|
|
|
|
}
|
2012-12-31 00:58:25 +00:00
|
|
|
|
|
|
|
desc.plane_bits = planedepth[0];
|
|
|
|
|
2013-05-01 21:58:48 +00:00
|
|
|
if (mpfmt == IMGFMT_XYZ12_LE || mpfmt == IMGFMT_XYZ12_BE) {
|
|
|
|
desc.flags |= MP_IMGFLAG_XYZ;
|
|
|
|
} else if (!(pd->flags & PIX_FMT_RGB) && fmt != PIX_FMT_MONOBLACK &&
|
|
|
|
fmt != PIX_FMT_PAL8)
|
2012-12-31 00:58:25 +00:00
|
|
|
{
|
|
|
|
desc.flags |= MP_IMGFLAG_YUV;
|
2012-12-24 00:10:57 +00:00
|
|
|
} else {
|
|
|
|
desc.flags |= MP_IMGFLAG_RGB;
|
2012-12-31 00:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PIX_FMT_ALPHA
|
|
|
|
if (pd->flags & PIX_FMT_ALPHA)
|
|
|
|
desc.flags |= MP_IMGFLAG_ALPHA;
|
|
|
|
#else
|
|
|
|
if (desc.num_planes > 3)
|
|
|
|
desc.flags |= MP_IMGFLAG_ALPHA;
|
|
|
|
#endif
|
|
|
|
|
2012-12-26 22:12:30 +00:00
|
|
|
if (desc.num_planes == pd->nb_components)
|
2012-12-31 00:58:25 +00:00
|
|
|
desc.flags |= MP_IMGFLAG_PLANAR;
|
|
|
|
|
2013-01-14 17:37:17 +00:00
|
|
|
if (!(pd->flags & PIX_FMT_HWACCEL) && !(pd->flags & PIX_FMT_BITSTREAM)) {
|
|
|
|
desc.flags |= MP_IMGFLAG_BYTE_ALIGNED;
|
|
|
|
for (int p = 0; p < desc.num_planes; p++)
|
|
|
|
desc.bytes[p] = desc.bpp[p] / 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((desc.flags & MP_IMGFLAG_YUV) && (desc.flags & MP_IMGFLAG_BYTE_ALIGNED))
|
|
|
|
{
|
2012-12-31 00:58:25 +00:00
|
|
|
bool same_depth = true;
|
|
|
|
for (int p = 0; p < desc.num_planes; p++) {
|
|
|
|
same_depth &= planedepth[p] == planedepth[0] &&
|
|
|
|
desc.bpp[p] == desc.bpp[0];
|
|
|
|
}
|
|
|
|
if (same_depth && pd->nb_components == desc.num_planes)
|
|
|
|
desc.flags |= MP_IMGFLAG_YUV_P;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int p = 0; p < desc.num_planes; p++) {
|
|
|
|
desc.xs[p] = (p == 1 || p == 2) ? desc.chroma_xs : 0;
|
|
|
|
desc.ys[p] = (p == 1 || p == 2) ? desc.chroma_ys : 0;
|
|
|
|
}
|
|
|
|
|
2012-12-25 21:29:49 +00:00
|
|
|
desc.align_x = 1 << desc.chroma_xs;
|
|
|
|
desc.align_y = 1 << desc.chroma_ys;
|
|
|
|
|
|
|
|
if ((desc.bpp[0] % 8) != 0)
|
|
|
|
desc.align_x = 8 / desc.bpp[0]; // expect power of 2
|
|
|
|
|
2012-12-31 00:58:25 +00:00
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mp_imgfmt_desc mp_imgfmt_get_desc(unsigned int out_fmt)
|
|
|
|
{
|
|
|
|
struct mp_imgfmt_desc fmt = {0};
|
|
|
|
enum PixelFormat avfmt = imgfmt2pixfmt(out_fmt);
|
|
|
|
if (avfmt != PIX_FMT_NONE)
|
|
|
|
fmt = get_avutil_fmt(avfmt);
|
|
|
|
if (!fmt.id) {
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_V, "mp_image: unknown out_fmt: 0x%X\n",
|
|
|
|
out_fmt);
|
|
|
|
}
|
|
|
|
return fmt;
|
|
|
|
}
|
2012-12-25 13:54:42 +00:00
|
|
|
|
|
|
|
// Find a format that is MP_IMGFLAG_YUV_P with the following configuration.
|
|
|
|
int mp_imgfmt_find_yuv_planar(int xs, int ys, int planes, int component_bits)
|
|
|
|
{
|
|
|
|
for (int n = IMGFMT_START + 1; n < IMGFMT_END; n++) {
|
|
|
|
struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(n);
|
|
|
|
if (desc.id && (desc.flags & MP_IMGFLAG_YUV_P)) {
|
|
|
|
if (desc.num_planes == planes && desc.chroma_xs == xs &&
|
|
|
|
desc.chroma_ys == ys && desc.plane_bits == component_bits &&
|
|
|
|
(desc.flags & MP_IMGFLAG_NE))
|
|
|
|
return desc.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|