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:
Stephan Aßmus
2010-01-07 01:10:28 +00:00
parent ead6198972
commit 2a0cb284c4
2 changed files with 67 additions and 18 deletions
+63 -15
View File
@@ -16,7 +16,7 @@
#define TRACE(a...)
#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.
gfx_convert_func resolve_colorspace(color_space colorSpace, PixelFormat pixelFormat)
{
@@ -34,7 +34,7 @@ CPUCapabilities cpu;
return gfx_conv_yuv410p_rgb32_c;
// }
}
if (pixelFormat == PIX_FMT_YUV411P) {
// if (cpu.HasMMX()) {
// TRACE("resolve_colorspace: gfx_conv_yuv411p_rgb32_mmx\n");
@@ -44,7 +44,7 @@ CPUCapabilities cpu;
return gfx_conv_yuv411p_rgb32_c;
// }
}
if (pixelFormat == PIX_FMT_YUV420P || pixelFormat == PIX_FMT_YUVJ420P) {
if (cpu.HasSSE2()) {
TRACE("resolve_colorspace: gfx_conv_yuv420p_rgba32_sse2\n");
@@ -54,7 +54,7 @@ CPUCapabilities cpu;
return gfx_conv_YCbCr420p_RGB32_c;
}
}
if (pixelFormat == PIX_FMT_YUV422P || pixelFormat == PIX_FMT_YUVJ422P) {
if (cpu.HasSSE2()) {
return gfx_conv_yuv422p_rgba32_sse2;
@@ -95,7 +95,7 @@ CPUCapabilities cpu;
return gfx_conv_yuv411p_ycbcr422_c;
// }
}
if (pixelFormat == PIX_FMT_YUV420P || pixelFormat == PIX_FMT_YUVJ420P) {
// if (cpu.HasMMX()) {
// TRACE("resolve_colorspace: gfx_conv_yuv420p_ycbcr422_mmx\n");
@@ -105,7 +105,7 @@ CPUCapabilities cpu;
return gfx_conv_yuv420p_ycbcr422_c;
// }
}
if (pixelFormat == PIX_FMT_YUYV422) {
// if (cpu.HasMMX()) {
// TRACE("resolve_colorspace: PIX_FMT_YUV422 => B_YCbCr422: gfx_conv_null_mmx\n");
@@ -115,10 +115,10 @@ CPUCapabilities cpu;
return gfx_conv_null_c;
// }
}
TRACE("resolve_colorspace: %s => B_YCbCr422: NULL\n", pixfmt_to_string(pixelFormat));
return gfx_conv_null_c;
default:
TRACE("resolve_colorspace: default: NULL !!!\n");
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 END_TAG "\033[0m"
void dump_ffframe(AVFrame *frame, const char *name)
{
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,
name,
frame->pts,
frame->coded_picture_number,
frame->display_picture_number,
// frame->quality,
frame->key_frame?"keyframe, ":"",
printf(BEGIN_TAG"AVFrame(%s) pts:%-10lld cnum:%-5d dnum:%-5d %s%s, ]\n"END_TAG,
name,
frame->pts,
frame->coded_picture_number,
frame->display_picture_number,
// frame->quality,
frame->key_frame?"keyframe, ":"",
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]);
}
+4 -3
View File
@@ -30,13 +30,14 @@ extern "C" {
// will become:
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.
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);