Mercurial > mplayer.hg
annotate libmpcodecs/vd_raw.c @ 6664:b802dd0812f1
edit-list support for video - fixes various A-V sync problems (TODO: seeking)
author | arpi |
---|---|
date | Sun, 07 Jul 2002 15:21:30 +0000 |
parents | 01ada897cc89 |
children | 15efad628385 |
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; | |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
67 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
|
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 } |
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 } |
6480 | 79 else if (mpi->bpp==9 && mpi->flags&MP_IMGFLAG_YUV) { |
80 /* YVU9 ! */ | |
81 mpi->stride[1]=mpi->stride[2]=mpi->width/4; | |
82 mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height; | |
83 mpi->planes[1]=mpi->planes[2]+(mpi->width>>2)*(mpi->height>>2); | |
84 } | |
4969 | 85 } else { |
86 mpi->planes[0]=data; | |
87 mpi->stride[0]=mpi->width*(mpi->bpp/8); | |
6229 | 88 // .AVI files has uncompressed lines 4-byte aligned: |
89 if(sh->format==0 || sh->format==3) mpi->stride[0]=(mpi->stride[0]+3)&(~3); | |
5899 | 90 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){ |
91 // export palette: | |
6502 | 92 mpi->planes[1]=sh->bih ? (((unsigned char*)&sh->bih)+40) : NULL; |
5899 | 93 } |
4969 | 94 } |
95 | |
96 return mpi; | |
97 } | |
98 |