Mercurial > mplayer.hg
annotate libmpcodecs/vd_raw.c @ 7195:a5b2566f3c2b
print only fatal/error/warning to stderr, others go to stdout
(actually reversed Nick's r1.10 commit)
author | arpi |
---|---|
date | Sat, 31 Aug 2002 13:44:03 +0000 |
parents | 28677d779205 |
children | e7dd97c4c840 |
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 "A'rpi", | |
13 "A'rpi & Alex", | |
14 "uncompressed" | |
15 }; | |
16 | |
17 LIBVD_EXTERN(raw) | |
18 | |
19 // to set/get/query special features/parameters | |
20 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
21 switch(cmd){ | |
22 case VDCTRL_QUERY_FORMAT: | |
6502 | 23 if( (*((int*)arg)) == (sh->bih ? sh->bih->biCompression : sh->format) ) return CONTROL_TRUE; |
4969 | 24 return CONTROL_FALSE; |
25 } | |
26 return CONTROL_UNKNOWN; | |
27 } | |
28 | |
29 // init driver | |
30 static int init(sh_video_t *sh){ | |
31 // set format fourcc for raw RGB: | |
6502 | 32 if(sh->bih && sh->bih->biCompression==0){ // set based on bit depth |
4969 | 33 switch(sh->bih->biBitCount){ |
6229 | 34 case 8: sh->bih->biCompression=IMGFMT_BGR8; break; |
35 case 15: sh->bih->biCompression=IMGFMT_BGR15; break; | |
36 // workaround bitcount==16 => bgr15 case for avi files: | |
37 case 16: sh->bih->biCompression=(sh->format)?IMGFMT_BGR16:IMGFMT_BGR15; break; | |
38 case 24: sh->bih->biCompression=IMGFMT_BGR24; break; | |
39 case 32: sh->bih->biCompression=IMGFMT_BGR32; break; | |
4969 | 40 default: |
41 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount); | |
42 } | |
43 } | |
6502 | 44 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format); |
4969 | 45 } |
46 | |
47 // uninit driver | |
48 static void uninit(sh_video_t *sh){ | |
49 } | |
50 | |
51 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
52 | |
53 // decode a frame | |
54 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
55 mp_image_t* mpi; | |
56 if(len<=0) return NULL; // skipped frame | |
57 | |
58 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, | |
59 sh->disp_w, sh->disp_h); | |
60 if(!mpi) return NULL; | |
61 | |
62 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
63 // TODO !!! | |
64 mpi->planes[0]=data; | |
65 mpi->stride[0]=mpi->width; | |
6667 | 66 if(mpi->flags&MP_IMGFLAG_YUV) { |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
67 // Support for some common Planar YUV formats |
6480 | 68 /* YV12,I420,IYUV */ |
5953
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
69 int cb=2, cr=1; |
5966 | 70 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
|
71 cb=1; cr=2; |
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
72 } |
6667 | 73 mpi->planes[cb]=mpi->planes[0]+mpi->width*mpi->height; |
74 mpi->stride[cb]=mpi->chroma_width; | |
75 mpi->planes[cr]=mpi->planes[cb]+mpi->chroma_width*mpi->chroma_height; | |
76 mpi->stride[cr]=mpi->chroma_width; | |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
77 } |
4969 | 78 } else { |
79 mpi->planes[0]=data; | |
80 mpi->stride[0]=mpi->width*(mpi->bpp/8); | |
6229 | 81 // .AVI files has uncompressed lines 4-byte aligned: |
82 if(sh->format==0 || sh->format==3) mpi->stride[0]=(mpi->stride[0]+3)&(~3); | |
5899 | 83 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){ |
84 // export palette: | |
6502 | 85 mpi->planes[1]=sh->bih ? (((unsigned char*)&sh->bih)+40) : NULL; |
5899 | 86 } |
4969 | 87 } |
88 | |
89 return mpi; | |
90 } |