Added utility function colorspace_to_pixfmt().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34926 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
#define TRACE(a...)
|
#define TRACE(a...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// this function will try to find the best colorspaces for both the ff-codec and
|
// this function will try to find the best colorspaces for both the ff-codec and
|
||||||
// the Media Kit sides.
|
// the Media Kit sides.
|
||||||
gfx_convert_func resolve_colorspace(color_space colorSpace, PixelFormat pixelFormat)
|
gfx_convert_func resolve_colorspace(color_space colorSpace, PixelFormat pixelFormat)
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ CPUCapabilities cpu;
|
|||||||
return gfx_conv_yuv410p_rgb32_c;
|
return gfx_conv_yuv410p_rgb32_c;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixelFormat == PIX_FMT_YUV411P) {
|
if (pixelFormat == PIX_FMT_YUV411P) {
|
||||||
// if (cpu.HasMMX()) {
|
// if (cpu.HasMMX()) {
|
||||||
// TRACE("resolve_colorspace: gfx_conv_yuv411p_rgb32_mmx\n");
|
// TRACE("resolve_colorspace: gfx_conv_yuv411p_rgb32_mmx\n");
|
||||||
@@ -44,7 +44,7 @@ CPUCapabilities cpu;
|
|||||||
return gfx_conv_yuv411p_rgb32_c;
|
return gfx_conv_yuv411p_rgb32_c;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixelFormat == PIX_FMT_YUV420P || pixelFormat == PIX_FMT_YUVJ420P) {
|
if (pixelFormat == PIX_FMT_YUV420P || pixelFormat == PIX_FMT_YUVJ420P) {
|
||||||
if (cpu.HasSSE2()) {
|
if (cpu.HasSSE2()) {
|
||||||
TRACE("resolve_colorspace: gfx_conv_yuv420p_rgba32_sse2\n");
|
TRACE("resolve_colorspace: gfx_conv_yuv420p_rgba32_sse2\n");
|
||||||
@@ -54,7 +54,7 @@ CPUCapabilities cpu;
|
|||||||
return gfx_conv_YCbCr420p_RGB32_c;
|
return gfx_conv_YCbCr420p_RGB32_c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixelFormat == PIX_FMT_YUV422P || pixelFormat == PIX_FMT_YUVJ422P) {
|
if (pixelFormat == PIX_FMT_YUV422P || pixelFormat == PIX_FMT_YUVJ422P) {
|
||||||
if (cpu.HasSSE2()) {
|
if (cpu.HasSSE2()) {
|
||||||
return gfx_conv_yuv422p_rgba32_sse2;
|
return gfx_conv_yuv422p_rgba32_sse2;
|
||||||
@@ -95,7 +95,7 @@ CPUCapabilities cpu;
|
|||||||
return gfx_conv_yuv411p_ycbcr422_c;
|
return gfx_conv_yuv411p_ycbcr422_c;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixelFormat == PIX_FMT_YUV420P || pixelFormat == PIX_FMT_YUVJ420P) {
|
if (pixelFormat == PIX_FMT_YUV420P || pixelFormat == PIX_FMT_YUVJ420P) {
|
||||||
// if (cpu.HasMMX()) {
|
// if (cpu.HasMMX()) {
|
||||||
// TRACE("resolve_colorspace: gfx_conv_yuv420p_ycbcr422_mmx\n");
|
// TRACE("resolve_colorspace: gfx_conv_yuv420p_ycbcr422_mmx\n");
|
||||||
@@ -105,7 +105,7 @@ CPUCapabilities cpu;
|
|||||||
return gfx_conv_yuv420p_ycbcr422_c;
|
return gfx_conv_yuv420p_ycbcr422_c;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixelFormat == PIX_FMT_YUYV422) {
|
if (pixelFormat == PIX_FMT_YUYV422) {
|
||||||
// if (cpu.HasMMX()) {
|
// if (cpu.HasMMX()) {
|
||||||
// TRACE("resolve_colorspace: PIX_FMT_YUV422 => B_YCbCr422: gfx_conv_null_mmx\n");
|
// TRACE("resolve_colorspace: PIX_FMT_YUV422 => B_YCbCr422: gfx_conv_null_mmx\n");
|
||||||
@@ -115,10 +115,10 @@ CPUCapabilities cpu;
|
|||||||
return gfx_conv_null_c;
|
return gfx_conv_null_c;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("resolve_colorspace: %s => B_YCbCr422: NULL\n", pixfmt_to_string(pixelFormat));
|
TRACE("resolve_colorspace: %s => B_YCbCr422: NULL\n", pixfmt_to_string(pixelFormat));
|
||||||
return gfx_conv_null_c;
|
return gfx_conv_null_c;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
TRACE("resolve_colorspace: default: NULL !!!\n");
|
TRACE("resolve_colorspace: default: NULL !!!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -248,19 +248,67 @@ pixfmt_to_colorspace(int p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PixelFormat
|
||||||
|
colorspace_to_pixfmt(color_space format)
|
||||||
|
{
|
||||||
|
switch(format) {
|
||||||
|
default:
|
||||||
|
case B_NO_COLOR_SPACE:
|
||||||
|
return PIX_FMT_NONE;
|
||||||
|
|
||||||
|
// NOTE: See pixfmt_to_colorspace() for what these are.
|
||||||
|
case B_YUV420:
|
||||||
|
return PIX_FMT_YUV420P;
|
||||||
|
case B_YUV422:
|
||||||
|
return PIX_FMT_YUV422P;
|
||||||
|
case B_RGB24_BIG:
|
||||||
|
return PIX_FMT_RGB24;
|
||||||
|
case B_RGB24:
|
||||||
|
return PIX_FMT_BGR24;
|
||||||
|
case B_YUV444:
|
||||||
|
return PIX_FMT_YUV444P;
|
||||||
|
case B_RGBA32_BIG:
|
||||||
|
case B_RGB32_BIG:
|
||||||
|
return PIX_FMT_BGR32;
|
||||||
|
case B_YUV9:
|
||||||
|
return PIX_FMT_YUV410P;
|
||||||
|
case B_YUV12:
|
||||||
|
return PIX_FMT_YUV411P;
|
||||||
|
// TODO: YCbCr color spaces! These are not the same as YUV!
|
||||||
|
case B_RGB16_BIG:
|
||||||
|
return PIX_FMT_RGB565;
|
||||||
|
case B_RGB15_BIG:
|
||||||
|
return PIX_FMT_RGB555;
|
||||||
|
case B_GRAY8:
|
||||||
|
return PIX_FMT_GRAY8;
|
||||||
|
case B_GRAY1:
|
||||||
|
return PIX_FMT_MONOBLACK;
|
||||||
|
case B_CMAP8:
|
||||||
|
return PIX_FMT_PAL8;
|
||||||
|
case B_RGBA32:
|
||||||
|
case B_RGB32:
|
||||||
|
return PIX_FMT_RGB32;
|
||||||
|
case B_RGB16:
|
||||||
|
return PIX_FMT_BGR565;
|
||||||
|
case B_RGB15:
|
||||||
|
return PIX_FMT_BGR555;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define BEGIN_TAG "\033[31m"
|
#define BEGIN_TAG "\033[31m"
|
||||||
#define END_TAG "\033[0m"
|
#define END_TAG "\033[0m"
|
||||||
|
|
||||||
void dump_ffframe(AVFrame *frame, const char *name)
|
void dump_ffframe(AVFrame *frame, const char *name)
|
||||||
{
|
{
|
||||||
const char *picttypes[] = {"no pict type", "intra", "predicted", "bidir pre", "s(gmc)-vop"};
|
const char *picttypes[] = {"no pict type", "intra", "predicted", "bidir pre", "s(gmc)-vop"};
|
||||||
printf(BEGIN_TAG"AVFrame(%s) pts:%-10lld cnum:%-5d dnum:%-5d %s%s, ]\n"END_TAG,
|
printf(BEGIN_TAG"AVFrame(%s) pts:%-10lld cnum:%-5d dnum:%-5d %s%s, ]\n"END_TAG,
|
||||||
name,
|
name,
|
||||||
frame->pts,
|
frame->pts,
|
||||||
frame->coded_picture_number,
|
frame->coded_picture_number,
|
||||||
frame->display_picture_number,
|
frame->display_picture_number,
|
||||||
// frame->quality,
|
// frame->quality,
|
||||||
frame->key_frame?"keyframe, ":"",
|
frame->key_frame?"keyframe, ":"",
|
||||||
picttypes[frame->pict_type]);
|
picttypes[frame->pict_type]);
|
||||||
// printf(BEGIN_TAG"\t\tlinesize[] = {%ld, %ld, %ld, %ld}\n"END_TAG, frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]);
|
// printf(BEGIN_TAG"\t\tlinesize[] = {%ld, %ld, %ld, %ld}\n"END_TAG, frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,14 @@ extern "C" {
|
|||||||
// will become:
|
// will become:
|
||||||
typedef void (*gfx_convert_func) (AVFrame *in, AVFrame *out, int width, int height);
|
typedef void (*gfx_convert_func) (AVFrame *in, AVFrame *out, int width, int height);
|
||||||
|
|
||||||
// this function will try to find the best colorspaces for both the ff-codec and
|
// this function will try to find the best colorspaces for both the ff-codec and
|
||||||
// the Media Kit sides.
|
// the Media Kit sides.
|
||||||
gfx_convert_func resolve_colorspace(color_space cs, PixelFormat pixelFormat);
|
gfx_convert_func resolve_colorspace(color_space cs, PixelFormat pixelFormat);
|
||||||
|
|
||||||
const char *pixfmt_to_string(int p);
|
const char *pixfmt_to_string(int format);
|
||||||
|
|
||||||
color_space pixfmt_to_colorspace(int p);
|
color_space pixfmt_to_colorspace(int format);
|
||||||
|
PixelFormat colorspace_to_pixfmt(color_space format);
|
||||||
|
|
||||||
void dump_ffframe(AVFrame *frame, const char *name);
|
void dump_ffframe(AVFrame *frame, const char *name);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user