Mercurial > mplayer.hg
annotate libmpcodecs/vd_raw.c @ 10040:901cb1391c13
Fixed a lot of typos.
author | lumag |
---|---|
date | Thu, 01 May 2003 12:30:44 +0000 |
parents | 4f6bbaf09dbc |
children | 794b55a44528 |
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){ |
7773 | 34 case 1: sh->bih->biCompression=IMGFMT_BGR1; break; |
35 case 4: sh->bih->biCompression=IMGFMT_BGR4; break; | |
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 } | |
6502 | 46 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format); |
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; | |
7773 | 58 int frame_size; |
59 | |
4969 | 60 if(len<=0) return NULL; // skipped frame |
7773 | 61 |
4969 | 62 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, |
63 sh->disp_w, sh->disp_h); | |
64 if(!mpi) return NULL; | |
65 | |
66 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
67 // TODO !!! | |
68 mpi->planes[0]=data; | |
69 mpi->stride[0]=mpi->width; | |
7773 | 70 frame_size=mpi->stride[0]*mpi->h; |
6667 | 71 if(mpi->flags&MP_IMGFLAG_YUV) { |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
72 // Support for some common Planar YUV formats |
6480 | 73 /* YV12,I420,IYUV */ |
5953
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
74 int cb=2, cr=1; |
5966 | 75 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
|
76 cb=1; cr=2; |
1ab2605a9e44
fixed raw i420/iyuv to some extent, so that cb/cr channels are no
rfelker
parents:
5899
diff
changeset
|
77 } |
6667 | 78 mpi->planes[cb]=mpi->planes[0]+mpi->width*mpi->height; |
79 mpi->stride[cb]=mpi->chroma_width; | |
80 mpi->planes[cr]=mpi->planes[cb]+mpi->chroma_width*mpi->chroma_height; | |
81 mpi->stride[cr]=mpi->chroma_width; | |
7773 | 82 frame_size+=2*mpi->chroma_width*mpi->chroma_height; |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
83 } |
4969 | 84 } else { |
85 mpi->planes[0]=data; | |
86 mpi->stride[0]=mpi->width*(mpi->bpp/8); | |
6229 | 87 // .AVI files has uncompressed lines 4-byte aligned: |
88 if(sh->format==0 || sh->format==3) mpi->stride[0]=(mpi->stride[0]+3)&(~3); | |
5899 | 89 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){ |
90 // export palette: | |
7782 | 91 mpi->planes[1]=sh->bih ? (unsigned char*)(sh->bih+1) : NULL; |
92 #if 0 | |
93 printf("Exporting palette: %p !!\n",mpi->planes[1]); | |
94 { unsigned char* p=mpi->planes[1]; | |
95 int i; | |
96 for(i=0;i<64;i++) printf("%3d: %02X %02X %02X (%02X)\n",i,p[4*i],p[4*i+1],p[4*i+2],p[4*i+3]); | |
97 } | |
98 #endif | |
5899 | 99 } |
7773 | 100 frame_size=mpi->stride[0]*mpi->h; |
101 if(mpi->bpp<8) frame_size=frame_size*mpi->bpp/8; | |
102 } | |
103 | |
104 if(len<frame_size){ | |
105 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Frame too small! (%d<%d) Wrong format?\n", | |
106 len,frame_size); | |
107 return NULL; | |
4969 | 108 } |
109 | |
110 return mpi; | |
111 } |