aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar atmosfear <atmosfear@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-04-14 17:55:20 +0000
committerGravatar atmosfear <atmosfear@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-04-14 17:55:20 +0000
commit39a20fba347f37703f019fd1243a15a1900e609a (patch)
tree3c16182bb998c0c71aa1aea38b84b9d266878db2
parenta8cabd5ed891a21fbca49b652f7f4766f5b9c9ef (diff)
- applied overlay patch by Jens H
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@409 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--DOCS/codecs.conf2
-rw-r--r--codec-cfg.c65
-rw-r--r--codec-cfg.h9
-rw-r--r--dll_init.c68
-rw-r--r--libvo/img_format.h54
-rw-r--r--libvo/video_out.h14
-rw-r--r--libvo/vo_sdl.c35
-rw-r--r--libvo/vo_xv.c66
8 files changed, 210 insertions, 103 deletions
diff --git a/DOCS/codecs.conf b/DOCS/codecs.conf
index 4923a72b48..69ba492fbb 100644
--- a/DOCS/codecs.conf
+++ b/DOCS/codecs.conf
@@ -250,7 +250,7 @@ videocodec asv2
fourcc ASV2
driver vfw
dll "asusasv2.dll"
-; out YVYU
+ out YVYU
out BGR32,BGR24,BGR15 flip
audiocodec divx
diff --git a/codec-cfg.c b/codec-cfg.c
index 967c0f82cb..bd5ae21935 100644
--- a/codec-cfg.c
+++ b/codec-cfg.c
@@ -15,7 +15,7 @@
#include <assert.h>
#include <string.h>
-#include "libvo/video_out.h"
+#include "libvo/img_format.h"
#include "codec-cfg.h"
#define PRINT_LINENUM printf(" at line %d\n", line_num)
@@ -99,38 +99,35 @@ static int add_to_format(char *s, unsigned int *fourcc, unsigned int *fourccmap)
return 1;
}
+
static int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt,
unsigned char *outflags)
{
- static char *fmtstr[] = {
- "YUY2",
- "YV12",
- "RGB8",
- "RGB15",
- "RGB16",
- "RGB24",
- "RGB32",
- "BGR8",
- "BGR15",
- "BGR16",
- "BGR24",
- "BGR32",
- NULL
- };
- static unsigned int fmtnum[] = {
- IMGFMT_YUY2,
- IMGFMT_YV12,
- IMGFMT_RGB|8,
- IMGFMT_RGB|15,
- IMGFMT_RGB|16,
- IMGFMT_RGB|24,
- IMGFMT_RGB|32,
- IMGFMT_BGR|8,
- IMGFMT_BGR|15,
- IMGFMT_BGR|16,
- IMGFMT_BGR|24,
- IMGFMT_BGR|32
+ static struct {
+ const char *name;
+ const unsigned int num;
+ } fmt_table[] = {
+ "YV12", IMGFMT_YV12,
+ "I420", IMGFMT_I420,
+ "IYUV", IMGFMT_IYUV,
+
+ "YUY2", IMGFMT_YUY2,
+ "UYVY", IMGFMT_UYVY,
+ "YVYU", IMGFMT_YVYU,
+
+ "RGB8", IMGFMT_RGB|8,
+ "RGB15", IMGFMT_RGB|15,
+ "RGB16", IMGFMT_RGB|16,
+ "RGB24", IMGFMT_RGB|24,
+ "RGB32", IMGFMT_RGB|32,
+ "BGR8", IMGFMT_BGR|8,
+ "BGR15", IMGFMT_BGR|15,
+ "BGR16", IMGFMT_BGR|16,
+ "BGR24", IMGFMT_BGR|24,
+ "BGR32", IMGFMT_BGR|32,
+ NULL, 0
};
+
static char *flagstr[] = {
"flip",
"noflip",
@@ -165,15 +162,15 @@ static int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt,
}
do {
- for (j = 0; fmtstr[j] != NULL; j++)
- if (!strncmp(sfmt, fmtstr[j], strlen(fmtstr[j])))
+ for (j = 0; fmt_table[j].name != NULL; j++)
+ if (!strncmp(sfmt, fmt_table[j].name, strlen(fmt_table[j].name)))
break;
- if (fmtstr[j] == NULL)
+ if (fmt_table[j].name == NULL)
goto err_out_parse_error;
- outfmt[i] = fmtnum[j];
+ outfmt[i] = fmt_table[j].num;
outflags[i] = flags;
++i;
- sfmt+=strlen(fmtstr[j]);
+ sfmt+=strlen(fmt_table[j].name);
} while ((*(sfmt++) == ',') && --freeslots);
if (!freeslots)
diff --git a/codec-cfg.h b/codec-cfg.h
index 23816ceeef..5c237fc8bf 100644
--- a/codec-cfg.h
+++ b/codec-cfg.h
@@ -1,15 +1,6 @@
#ifndef __CODEC_CFG_H
#define __CODEC_CFG_H
-#ifndef IMGFMT_YV12
-#define IMGFMT_YV12 0x32315659
-#define IMGFMT_YUY2 (('2'<<24)|('Y'<<16)|('U'<<8)|'Y')
-#define IMGFMT_RGB_MASK 0xFFFFFF00
-#define IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8))
-#define IMGFMT_BGR_MASK 0xFFFFFF00
-#define IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8))
-#endif
-
#define CODECS_MAX_FOURCC 16
#define CODECS_MAX_OUTFMT 16
diff --git a/dll_init.c b/dll_init.c
index 232cb41db0..a3d2d09f42 100644
--- a/dll_init.c
+++ b/dll_init.c
@@ -138,23 +138,61 @@ int init_video_codec(){
// sh_video->o_bih.biPlanes=3;
// sh_video->o_bih.biBitCount=16;
- if(outfmt==IMGFMT_YUY2)
- sh_video->o_bih.biBitCount=16;
- else
- sh_video->o_bih.biBitCount=outfmt&0xFF;// //24;
- if(sh_video->o_bih.biBitCount==15) ++sh_video->o_bih.biBitCount;
-
- sh_video->o_bih.biSizeImage=sh_video->o_bih.biWidth*sh_video->o_bih.biHeight*(sh_video->o_bih.biBitCount/8);
-
- if(!(sh_video->codec->outflags[sh_video->outfmtidx]&CODECS_FLAG_FLIP))
- sh_video->o_bih.biHeight=-sh_video->bih.biHeight; // flip image!
+ switch (outfmt) {
+
+/* planar format */
+ case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ sh_video->o_bih.biBitCount=12;
+
+/* packed format */
+ case IMGFMT_YUY2:
+ case IMGFMT_UYVY:
+ case IMGFMT_YVYU:
+ sh_video->o_bih.biBitCount=16;
+ break;
+
+/* rgb/bgr format */
+ case IMGFMT_RGB8:
+ case IMGFMT_BGR8:
+ sh_video->o_bih.biBitCount=8;
+ break;
+
+ case IMGFMT_RGB15:
+ case IMGFMT_RGB16:
+ case IMGFMT_BGR15:
+ case IMGFMT_BGR16:
+ sh_video->o_bih.biBitCount=16;
+ break;
+
+ case IMGFMT_RGB24:
+ case IMGFMT_BGR24:
+ sh_video->o_bih.biBitCount=24;
+ break;
+
+ case IMGFMT_RGB32:
+ case IMGFMT_BGR32:
+ sh_video->o_bih.biBitCount=32;
+ break;
+
+ default:
+ printf("unsupported image format: 0x%x\n", outfmt);
+ return 0;
+ }
- if(outfmt==IMGFMT_YUY2 && !(sh_video->codec->outflags[sh_video->outfmtidx]&CODECS_FLAG_YUVHACK))
- sh_video->o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
+ sh_video->o_bih.biSizeImage = sh_video->o_bih.biWidth * sh_video->o_bih.biHeight * (sh_video->o_bih.biBitCount/8);
-// sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
+ if(!(sh_video->codec->outflags[sh_video->outfmtidx]&CODECS_FLAG_FLIP)) {
+ sh_video->o_bih.biHeight=-sh_video->bih.biHeight; // flip image!
+ }
+ // this looks suspicious :-)
+ if(!(outfmt == IMGFMT_YUY2 && (sh_video->codec->outflags[sh_video->outfmtidx] & CODECS_FLAG_YUVHACK))
+ && (outfmt & IMGFMT_RGB_MASK) != IMGFMT_RGB && (outfmt & IMGFMT_BGR_MASK ) != IMGFMT_BGR) {
+ sh_video->o_bih.biCompression = outfmt;
+ }
if(verbose) {
printf("Starting decompression, format:\n");
@@ -163,7 +201,7 @@ int init_video_codec(){
printf(" biHeight %d\n", sh_video->bih.biHeight);
printf(" biPlanes %d\n", sh_video->bih.biPlanes);
printf(" biBitCount %d\n", sh_video->bih.biBitCount);
- printf(" biCompression %d='%.4s'\n", sh_video->bih.biCompression, &sh_video->bih.biCompression);
+ printf(" biCompression 0x%x ('%.4s')\n", sh_video->bih.biCompression, &sh_video->bih.biCompression);
printf(" biSizeImage %d\n", sh_video->bih.biSizeImage);
printf("Dest fmt:\n");
printf(" biSize %d\n", sh_video->o_bih.biSize);
@@ -171,7 +209,7 @@ int init_video_codec(){
printf(" biHeight %d\n", sh_video->o_bih.biHeight);
printf(" biPlanes %d\n", sh_video->o_bih.biPlanes);
printf(" biBitCount %d\n", sh_video->o_bih.biBitCount);
- printf(" biCompression %d='%.4s'\n", sh_video->o_bih.biCompression, &sh_video->o_bih.biCompression);
+ printf(" biCompression 0x%x ('%.4s')\n", sh_video->o_bih.biCompression, &sh_video->o_bih.biCompression);
printf(" biSizeImage %d\n", sh_video->o_bih.biSizeImage);
}
diff --git a/libvo/img_format.h b/libvo/img_format.h
new file mode 100644
index 0000000000..7d5b9c6a30
--- /dev/null
+++ b/libvo/img_format.h
@@ -0,0 +1,54 @@
+
+#ifndef __IMG_FORMAT_H
+#define __IMG_FORMAT_H
+
+/* RGB/BGR Formats */
+
+#define IMGFMT_RGB_MASK 0xFFFFFF00
+#define IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8))
+#define IMGFMT_RGB8 (IMGFMT_RGB|8)
+#define IMGFMT_RGB15 (IMGFMT_RGB|15)
+#define IMGFMT_RGB16 (IMGFMT_RGB|16)
+#define IMGFMT_RGB24 (IMGFMT_RGB|24)
+#define IMGFMT_RGB32 (IMGFMT_RGB|32)
+
+#define IMGFMT_BGR_MASK 0xFFFFFF00
+#define IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8))
+#define IMGFMT_BGR8 (IMGFMT_BGR|8)
+#define IMGFMT_BGR15 (IMGFMT_BGR|15)
+#define IMGFMT_BGR16 (IMGFMT_BGR|16)
+#define IMGFMT_BGR24 (IMGFMT_BGR|24)
+#define IMGFMT_BGR32 (IMGFMT_BGR|32)
+
+
+/* Planar YUV Formats */
+
+#define IMGFMT_YVU9 0x39555659
+#define IMGFMT_IF09 0x39304649
+#define IMGFMT_YV12 0x32315659
+#define IMGFMT_I420 0x30323449
+#define IMGFMT_IYUV 0x56555949
+#define IMGFMT_CLPL 0x4C504C43
+
+/* Packed YUV Formats */
+
+#define IMGFMT_IYU1 0x31555949
+#define IMGFMT_IYU2 0x32555949
+#define IMGFMT_UYVY 0x59565955
+#define IMGFMT_UYNV 0x564E5955
+#define IMGFMT_cyuv 0x76757963
+#define IMGFMT_YUY2 0x32595559
+#define IMGFMT_YUNV 0x564E5559
+#define IMGFMT_YVYU 0x55595659
+#define IMGFMT_Y41P 0x50313459
+#define IMGFMT_Y211 0x31313259
+#define IMGFMT_Y41T 0x54313459
+#define IMGFMT_Y42T 0x54323459
+#define IMGFMT_V422 0x32323456
+#define IMGFMT_V655 0x35353656
+#define IMGFMT_CLJR 0x524A4C43
+#define IMGFMT_YUVP 0x50565559
+#define IMGFMT_UYVP 0x50565955
+
+
+#endif
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 0eb6cbacee..c6bbcb9303 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -9,19 +9,7 @@
#include <inttypes.h>
#include "font_load.h"
-
-#define IMGFMT_YV12 0x32315659
-//#define IMGFMT_YUY2 (('Y'<<24)|('U'<<16)|('Y'<<8)|'2')
-#define IMGFMT_YUY2 (('2'<<24)|('Y'<<16)|('U'<<8)|'Y')
-
-#define IMGFMT_RGB_MASK 0xFFFFFF00
-#define IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8))
-#define IMGFMT_BGR_MASK 0xFFFFFF00
-#define IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8))
-#define IMGFMT_RGB15 (IMGFMT_RGB|15)
-#define IMGFMT_RGB16 (IMGFMT_RGB|16)
-#define IMGFMT_RGB24 (IMGFMT_RGB|24)
-#define IMGFMT_RGB32 (IMGFMT_RGB|32)
+#include "img_format.h"
#define VO_EVENT_EXPOSE 1
#define VO_EVENT_RESIZE 2
diff --git a/libvo/vo_sdl.c b/libvo/vo_sdl.c
index 3b41322d11..1b757a5c3b 100644
--- a/libvo/vo_sdl.c
+++ b/libvo/vo_sdl.c
@@ -146,14 +146,21 @@ static struct sdl_priv_s {
//void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride);
static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
- struct sdl_priv_s *priv = &sdl_priv;
- int x,y;
+ struct sdl_priv_s *priv = &sdl_priv;
+ int x,y;
- if (priv->format==IMGFMT_YV12)
- vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->width*y0+x0,priv->width);
- else
- vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0),2*priv->width);
-
+ switch(priv->format) {
+ case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->width*y0+x0,priv->width);
+ break;
+ case IMGFMT_YUY2:
+ case IMGFMT_UYVY:
+ case IMGFMT_YVYU:
+ vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0),2*priv->width);
+ break;
+ }
}
@@ -380,6 +387,10 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
sdl_format=SDL_YUY2_OVERLAY;
printf("SDL: Using YUY2 image format\n");
break;
+ case IMGFMT_UYVY:
+ sdl_format=SDL_UYVY_OVERLAY;
+ printf("SDL: Using UYVY image format\n");
+ break;
default:
printf("SDL: Unsupported image format (0x%X)\n",format);
return -1;
@@ -472,6 +483,8 @@ static uint32_t draw_frame(uint8_t *src[])
switch(priv->format){
case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
dst = (uint8_t *) *(priv->overlay->pixels);
memcpy (dst, src[0], priv->framePlaneY);
dst += priv->framePlaneY;
@@ -479,14 +492,16 @@ static uint32_t draw_frame(uint8_t *src[])
dst += priv->framePlaneUV;
memcpy (dst, src[1], priv->framePlaneUV);
break;
+
case IMGFMT_YUY2:
+ case IMGFMT_UYVY:
+ case IMGFMT_YVYU:
dst = (uint8_t *) *(priv->overlay->pixels);
memcpy (dst, src[0], priv->width*priv->height*2);
break;
}
SDL_UnlockYUVOverlay (priv->overlay);
-
return 0;
}
@@ -711,7 +726,11 @@ query_format(uint32_t format)
{
switch(format){
case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
case IMGFMT_YUY2:
+ case IMGFMT_UYVY:
+ case IMGFMT_YVYU:
// case IMGFMT_RGB|24:
// case IMGFMT_BGR|24:
return 1;
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 422ef6f06a..31f9e24416 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -265,10 +265,18 @@ static void check_events(void)
static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
int x,y;
- if (xv_format==IMGFMT_YV12)
- vo_draw_alpha_yv12(w,h,src,srca,stride,xvimage[0]->data+image_width*y0+x0,image_width);
- else
- vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[0]->data+2*(image_width*y0+x0),2*image_width);
+ switch (xv_format) {
+ case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ vo_draw_alpha_yv12(w,h,src,srca,stride,xvimage[0]->data+image_width*y0+x0,image_width);
+ break;
+ case IMGFMT_YUY2:
+ case IMGFMT_UYVY:
+ case IMGFMT_YVYU:
+ vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[0]->data+2*(image_width*y0+x0),2*image_width);
+ break;
+ }
}
@@ -332,43 +340,55 @@ static uint32_t draw_frame(uint8_t *src[])
{
int foo;
- if(xv_format==IMGFMT_YUY2)
- {
- // YUY2 packed, flipped
+ switch (xv_format) {
+ case IMGFMT_YUY2:
+ case IMGFMT_UYVY:
+ case IMGFMT_YVYU:
+
+ // YUY2 packed, flipped
#if 0
- int i;
- unsigned short *s=(unsigned short *)src[0];
- unsigned short *d=(unsigned short *)xvimage[0]->data;
- s+=image_width*image_height;
- for(i=0;i<image_height;i++)
- {
- s-=image_width;
- memcpy(d,s,image_width*2);
- d+=image_width;
- }
+ int i;
+ unsigned short *s=(unsigned short *)src[0];
+ unsigned short *d=(unsigned short *)xvimage[0]->data;
+ s+=image_width*image_height;
+ for(i=0;i<image_height;i++) {
+ s-=image_width;
+ memcpy(d,s,image_width*2);
+ d+=image_width;
+ }
#else
- memcpy(xvimage[0]->data,src[0],image_width*image_height*2);
+ memcpy(xvimage[0]->data,src[0],image_width*image_height*2);
#endif
- }
- else
- {
+ break;
+
+ case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+
// YV12 planar
memcpy(xvimage[0]->data,src[0],image_width*image_height);
memcpy(xvimage[0]->data+image_width*image_height,src[2],image_width*image_height/4);
memcpy(xvimage[0]->data+image_width*image_height*5/4,src[1],image_width*image_height/4);
- }
+ break;
+ }
return 0;
}
static uint32_t query_format(uint32_t format)
{
+
+// umm, this is a kludge, we need to ask the server.. (see init function above)
+ return 1;
+/*
switch(format)
{
case IMGFMT_YV12:
- case IMGFMT_YUY2: return 1;
+ case IMGFMT_YUY2:
+ return 1;
}
return 0;
+*/
}
static void uninit(void) {