Mercurial > mplayer.hg
annotate libmpcodecs/vd_raw.c @ 6284:30a2f1807c5b
big html tags
author | jonas |
---|---|
date | Mon, 03 Jun 2002 17:29:52 +0000 |
parents | b03cdd8adb32 |
children | 0dcaa477d200 |
rev | line source |
---|---|
4969 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 | |
4 #include "config.h" | |
5 #include "mp_msg.h" | |
6 | |
7 #include "vd_internal.h" | |
8 | |
9 static vd_info_t info = { | |
10 "RAW Uncompressed Video", | |
11 "raw", | |
12 VFM_RAW, | |
13 "A'rpi", | |
14 "A'rpi & Alex", | |
15 "uncompressed" | |
16 }; | |
17 | |
18 LIBVD_EXTERN(raw) | |
19 | |
20 // to set/get/query special features/parameters | |
21 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
22 switch(cmd){ | |
23 case VDCTRL_QUERY_FORMAT: | |
6229 | 24 if( (*((int*)arg)) == sh->bih->biCompression ) return CONTROL_TRUE; |
4969 | 25 return CONTROL_FALSE; |
26 } | |
27 return CONTROL_UNKNOWN; | |
28 } | |
29 | |
30 // init driver | |
31 static int init(sh_video_t *sh){ | |
6229 | 32 if(!sh->bih) return 0; // bih is required |
4969 | 33 // set format fourcc for raw RGB: |
6229 | 34 if(sh->bih->biCompression==0){ // set based on bit depth |
4969 | 35 switch(sh->bih->biBitCount){ |
6229 | 36 case 8: sh->bih->biCompression=IMGFMT_BGR8; break; |
37 case 15: sh->bih->biCompression=IMGFMT_BGR15; break; | |
38 // workaround bitcount==16 => bgr15 case for avi files: | |
39 case 16: sh->bih->biCompression=(sh->format)?IMGFMT_BGR16:IMGFMT_BGR15; break; | |
40 case 24: sh->bih->biCompression=IMGFMT_BGR24; break; | |
41 case 32: sh->bih->biCompression=IMGFMT_BGR32; break; | |
4969 | 42 default: |
43 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount); | |
44 } | |
45 } | |
6229 | 46 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih->biCompression); |
4969 | 47 } |
48 | |
49 // uninit driver | |
50 static void uninit(sh_video_t *sh){ | |
51 } | |
52 | |
53 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
54 | |
55 // decode a frame | |
56 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
57 mp_image_t* mpi; | |
58 if(len<=0) return NULL; // skipped frame | |
59 | |
60 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, | |
61 sh->disp_w, sh->disp_h); | |
62 if(!mpi) return NULL; | |
63 | |
64 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
65 // TODO !!! | |
66 mpi->planes[0]=data; | |
67 mpi->stride[0]=mpi->width; | |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
68 if(mpi->bpp == 12 && mpi->flags&MP_IMGFLAG_YUV) { |
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
69 // Support for some common Planar YUV formats |
5953
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
70 int cb=2, cr=1; |
5966 | 71 if(mpi->flags&MP_IMGFLAG_SWAPPED) { |
5953
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
72 cb=1; cr=2; |
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
73 } |
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
74 mpi->planes[cb]=data+mpi->width*mpi->height; |
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
75 mpi->stride[cb]=mpi->width/2; |
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
76 mpi->planes[cr]=data+5*mpi->width*mpi->height/4; |
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
77 mpi->stride[cr]=mpi->width/2; |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
78 } |
4969 | 79 } else { |
80 mpi->planes[0]=data; | |
81 mpi->stride[0]=mpi->width*(mpi->bpp/8); | |
6229 | 82 // .AVI files has uncompressed lines 4-byte aligned: |
83 if(sh->format==0 || sh->format==3) mpi->stride[0]=(mpi->stride[0]+3)&(~3); | |
5899 | 84 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){ |
85 // export palette: | |
86 mpi->planes[1]=((unsigned char*)&sh->bih)+40; | |
87 } | |
4969 | 88 } |
89 | |
90 return mpi; | |
91 } | |
92 |