Mercurial > mplayer.hg
annotate libmpcodecs/vd_raw.c @ 7017:f310b4e5c94b
Applied patch by Remi Guyomarch <rguyom at pobox com>.
1) document vb_qoffset instead of two times vb_qfactor
2) document "gray" and "mpeg_quant"
3) add 1 space to line-up with other options
author | diego |
---|---|
date | Thu, 15 Aug 2002 22:43:27 +0000 |
parents | 15efad628385 |
children | 28677d779205 |
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: | |
6502 | 24 if( (*((int*)arg)) == (sh->bih ? sh->bih->biCompression : sh->format) ) 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){ | |
32 // set format fourcc for raw RGB: | |
6502 | 33 if(sh->bih && sh->bih->biCompression==0){ // set based on bit depth |
4969 | 34 switch(sh->bih->biBitCount){ |
6229 | 35 case 8: sh->bih->biCompression=IMGFMT_BGR8; break; |
36 case 15: sh->bih->biCompression=IMGFMT_BGR15; break; | |
37 // workaround bitcount==16 => bgr15 case for avi files: | |
38 case 16: sh->bih->biCompression=(sh->format)?IMGFMT_BGR16:IMGFMT_BGR15; break; | |
39 case 24: sh->bih->biCompression=IMGFMT_BGR24; break; | |
40 case 32: sh->bih->biCompression=IMGFMT_BGR32; break; | |
4969 | 41 default: |
42 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount); | |
43 } | |
44 } | |
6502 | 45 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format); |
4969 | 46 } |
47 | |
48 // uninit driver | |
49 static void uninit(sh_video_t *sh){ | |
50 } | |
51 | |
52 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
53 | |
54 // decode a frame | |
55 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
56 mp_image_t* mpi; | |
57 if(len<=0) return NULL; // skipped frame | |
58 | |
59 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, | |
60 sh->disp_w, sh->disp_h); | |
61 if(!mpi) return NULL; | |
62 | |
63 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
64 // TODO !!! | |
65 mpi->planes[0]=data; | |
66 mpi->stride[0]=mpi->width; | |
6667 | 67 if(mpi->flags&MP_IMGFLAG_YUV) { |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
68 // Support for some common Planar YUV formats |
6480 | 69 /* YV12,I420,IYUV */ |
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 } |
6667 | 74 mpi->planes[cb]=mpi->planes[0]+mpi->width*mpi->height; |
75 mpi->stride[cb]=mpi->chroma_width; | |
76 mpi->planes[cr]=mpi->planes[cb]+mpi->chroma_width*mpi->chroma_height; | |
77 mpi->stride[cr]=mpi->chroma_width; | |
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: | |
6502 | 86 mpi->planes[1]=sh->bih ? (((unsigned char*)&sh->bih)+40) : NULL; |
5899 | 87 } |
4969 | 88 } |
89 | |
90 return mpi; | |
91 } |