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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
1 #include <stdio.h>
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
2 #include <stdlib.h>
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
3
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
4 #include "config.h"
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
5 #include "mp_msg.h"
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
6
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
7 #include "vd_internal.h"
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
8
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
9 static vd_info_t info = {
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
10 "RAW Uncompressed Video",
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
11 "raw",
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
12 VFM_RAW,
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
13 "A'rpi",
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
14 "A'rpi & Alex",
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
15 "uncompressed"
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
16 };
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
17
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
18 LIBVD_EXTERN(raw)
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
19
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
20 // to set/get/query special features/parameters
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
21 static int control(sh_video_t *sh,int cmd,void* arg,...){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
22 switch(cmd){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
23 case VDCTRL_QUERY_FORMAT:
6502
01ada897cc89 don't require sh->bih (should fix v4l)
arpi
parents: 6480
diff changeset
24 if( (*((int*)arg)) == (sh->bih ? sh->bih->biCompression : sh->format) ) return CONTROL_TRUE;
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
25 return CONTROL_FALSE;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
26 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
27 return CONTROL_UNKNOWN;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
28 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
29
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
30 // init driver
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
31 static int init(sh_video_t *sh){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
32 // set format fourcc for raw RGB:
6502
01ada897cc89 don't require sh->bih (should fix v4l)
arpi
parents: 6480
diff changeset
33 if(sh->bih && sh->bih->biCompression==0){ // set based on bit depth
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
34 switch(sh->bih->biBitCount){
6229
b03cdd8adb32 - modify bih->biCompression instead of sh->format
arpi
parents: 5966
diff changeset
35 case 8: sh->bih->biCompression=IMGFMT_BGR8; break;
b03cdd8adb32 - modify bih->biCompression instead of sh->format
arpi
parents: 5966
diff changeset
36 case 15: sh->bih->biCompression=IMGFMT_BGR15; break;
b03cdd8adb32 - modify bih->biCompression instead of sh->format
arpi
parents: 5966
diff changeset
37 // workaround bitcount==16 => bgr15 case for avi files:
b03cdd8adb32 - modify bih->biCompression instead of sh->format
arpi
parents: 5966
diff changeset
38 case 16: sh->bih->biCompression=(sh->format)?IMGFMT_BGR16:IMGFMT_BGR15; break;
b03cdd8adb32 - modify bih->biCompression instead of sh->format
arpi
parents: 5966
diff changeset
39 case 24: sh->bih->biCompression=IMGFMT_BGR24; break;
b03cdd8adb32 - modify bih->biCompression instead of sh->format
arpi
parents: 5966
diff changeset
40 case 32: sh->bih->biCompression=IMGFMT_BGR32; break;
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
41 default:
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
42 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
43 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
44 }
6502
01ada897cc89 don't require sh->bih (should fix v4l)
arpi
parents: 6480
diff changeset
45 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format);
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
46 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
47
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
48 // uninit driver
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
49 static void uninit(sh_video_t *sh){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
50 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
51
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
52 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
53
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
54 // decode a frame
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
55 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
56 mp_image_t* mpi;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
57 if(len<=0) return NULL; // skipped frame
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
58
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
59 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
60 sh->disp_w, sh->disp_h);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
61 if(!mpi) return NULL;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
62
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
63 if(mpi->flags&MP_IMGFLAG_PLANAR){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
64 // TODO !!!
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
65 mpi->planes[0]=data;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
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
0dcaa477d200 yvu9 support
alex
parents: 6229
diff changeset
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
7779ad600a71 better fix for i420/iyuv as suggested by arpi
rfelker
parents: 5953
diff changeset
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
0dcaa477d200 yvu9 support
alex
parents: 6229
diff changeset
79 else if (mpi->bpp==9 && mpi->flags&MP_IMGFLAG_YUV) {
0dcaa477d200 yvu9 support
alex
parents: 6229
diff changeset
80 /* YVU9 ! */
0dcaa477d200 yvu9 support
alex
parents: 6229
diff changeset
81 mpi->stride[1]=mpi->stride[2]=mpi->width/4;
0dcaa477d200 yvu9 support
alex
parents: 6229
diff changeset
82 mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height;
0dcaa477d200 yvu9 support
alex
parents: 6229
diff changeset
83 mpi->planes[1]=mpi->planes[2]+(mpi->width>>2)*(mpi->height>>2);
0dcaa477d200 yvu9 support
alex
parents: 6229
diff changeset
84 }
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
85 } else {
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
86 mpi->planes[0]=data;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
87 mpi->stride[0]=mpi->width*(mpi->bpp/8);
6229
b03cdd8adb32 - modify bih->biCompression instead of sh->format
arpi
parents: 5966
diff changeset
88 // .AVI files has uncompressed lines 4-byte aligned:
b03cdd8adb32 - modify bih->biCompression instead of sh->format
arpi
parents: 5966
diff changeset
89 if(sh->format==0 || sh->format==3) mpi->stride[0]=(mpi->stride[0]+3)&(~3);
5899
a79f46ea2a6a 8bpp raw avi support
arpi
parents: 5271
diff changeset
90 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){
a79f46ea2a6a 8bpp raw avi support
arpi
parents: 5271
diff changeset
91 // export palette:
6502
01ada897cc89 don't require sh->bih (should fix v4l)
arpi
parents: 6480
diff changeset
92 mpi->planes[1]=sh->bih ? (((unsigned char*)&sh->bih)+40) : NULL;
5899
a79f46ea2a6a 8bpp raw avi support
arpi
parents: 5271
diff changeset
93 }
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
94 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
95
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
96 return mpi;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
97 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
98