Mercurial > mplayer.hg
annotate libmpcodecs/vd.c @ 4968:236b06410b03
vfw, vfwex, odivx, divx4 added
author | arpi |
---|---|
date | Thu, 07 Mar 2002 00:44:58 +0000 |
parents | ca6f6b35baf4 |
children | db86fcf25ede |
rev | line source |
---|---|
4878 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 | |
5 #include "config.h" | |
6 #include "mp_msg.h" | |
7 | |
8 #ifdef HAVE_MALLOC_H | |
9 #include <malloc.h> | |
10 #endif | |
11 | |
12 #include "codec-cfg.h" | |
13 //#include "mp_image.h" | |
14 | |
15 #include "../libvo/img_format.h" | |
16 | |
17 #include "stream.h" | |
18 #include "demuxer.h" | |
19 #include "stheader.h" | |
20 | |
21 #include "vd.h" | |
22 //#include "vd_internal.h" | |
23 | |
24 extern vd_functions_t mpcodecs_vd_null; | |
4885 | 25 extern vd_functions_t mpcodecs_vd_cinepak; |
4915
f6990fad0ab3
Qt RPZA decoder interface by Roberto Togni <rtogni@bresciaonline.it>
arpi
parents:
4899
diff
changeset
|
26 extern vd_functions_t mpcodecs_vd_qtrpza; |
4951 | 27 extern vd_functions_t mpcodecs_vd_ffmpeg; |
4958 | 28 extern vd_functions_t mpcodecs_vd_dshow; |
4968 | 29 extern vd_functions_t mpcodecs_vd_vfw; |
30 extern vd_functions_t mpcodecs_vd_vfwex; | |
31 extern vd_functions_t mpcodecs_vd_odivx; | |
32 extern vd_functions_t mpcodecs_vd_divx4; | |
4878 | 33 |
34 vd_functions_t* mpcodecs_vd_drivers[] = { | |
35 &mpcodecs_vd_null, | |
4884 | 36 &mpcodecs_vd_cinepak, |
4915
f6990fad0ab3
Qt RPZA decoder interface by Roberto Togni <rtogni@bresciaonline.it>
arpi
parents:
4899
diff
changeset
|
37 &mpcodecs_vd_qtrpza, |
4951 | 38 #ifdef USE_LIBAVCODEC |
39 &mpcodecs_vd_ffmpeg, | |
40 #endif | |
4968 | 41 #ifdef USE_WIN32DLL |
4958 | 42 #ifdef USE_DIRECTSHOW |
43 &mpcodecs_vd_dshow, | |
44 #endif | |
4968 | 45 &mpcodecs_vd_vfw, |
46 &mpcodecs_vd_vfwex, | |
47 #endif | |
48 #ifdef USE_DIVX | |
49 &mpcodecs_vd_odivx, | |
50 #ifdef NEW_DECORE | |
51 &mpcodecs_vd_divx4, | |
52 #endif | |
53 #endif | |
4878 | 54 NULL |
55 }; | |
56 | |
57 int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){ | |
58 | |
59 return 1; | |
60 } | |
61 | |
62 static mp_image_t* static_images[2]; | |
63 static mp_image_t* temp_images[1]; | |
4951 | 64 static mp_image_t* export_images[1]; |
4878 | 65 static int static_idx=0; |
66 | |
67 // mp_imgtype: buffering type, see mp_image.h | |
68 // mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h | |
69 // returns NULL or allocated mp_image_t* | |
70 // Note: buffer allocation may be moved to mpcodecs_config_vo() later... | |
71 mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h){ | |
72 mp_image_t* mpi=NULL; | |
4968 | 73 int w2=(mp_imgflag&MP_IMGFLAG_ACCEPT_STRIDE)?((w+15)&(~15)):w; |
4878 | 74 // Note: we should call libvo first to check if it supports direct rendering |
75 // and if not, then fallback to software buffers: | |
76 switch(mp_imgtype){ | |
77 case MP_IMGTYPE_EXPORT: | |
4951 | 78 // mpi=new_mp_image(w,h); |
4968 | 79 if(!export_images[0]) export_images[0]=new_mp_image(w2,h); |
4951 | 80 mpi=export_images[0]; |
4878 | 81 break; |
82 case MP_IMGTYPE_STATIC: | |
4968 | 83 if(!static_images[0]) static_images[0]=new_mp_image(w2,h); |
4878 | 84 mpi=static_images[0]; |
85 break; | |
86 case MP_IMGTYPE_TEMP: | |
4968 | 87 if(!temp_images[0]) temp_images[0]=new_mp_image(w2,h); |
4878 | 88 mpi=temp_images[0]; |
89 break; | |
90 case MP_IMGTYPE_IPB: | |
91 if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame: | |
4968 | 92 if(!temp_images[0]) temp_images[0]=new_mp_image(w2,h); |
4878 | 93 mpi=temp_images[0]; |
94 break; | |
95 } | |
96 case MP_IMGTYPE_IP: | |
4968 | 97 if(!static_images[static_idx]) static_images[static_idx]=new_mp_image(w2,h); |
4878 | 98 mpi=static_images[static_idx]; |
99 static_idx^=1; | |
100 break; | |
101 } | |
102 if(mpi){ | |
103 mpi->type=mp_imgtype; | |
104 mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE); | |
105 mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE); | |
4968 | 106 if((mpi->width!=w2 || mpi->height!=h) && !(mpi->flags&MP_IMGFLAG_DIRECT)){ |
107 mpi->width=w2; | |
4951 | 108 mpi->height=h; |
109 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ | |
110 // need to re-allocate buffer memory: | |
111 free(mpi->planes[0]); | |
112 mpi->flags&=~MP_IMGFLAG_ALLOCATED; | |
113 } | |
114 } | |
4878 | 115 if(!mpi->bpp){ |
116 mp_image_setfmt(mpi,sh->codec->outfmt[sh->outfmtidx]); | |
117 if(!(mpi->flags&(MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_DIRECT)) | |
118 && mpi->type>MP_IMGTYPE_EXPORT){ | |
119 // non-direct and not yet allocaed image. allocate it! | |
4899
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
120 printf("*** Allocating mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n", |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
121 mpi->width,mpi->height,mpi->bpp, |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
122 (mpi->flags&MP_IMGFLAG_YUV)?"YUV":"RGB", |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
123 (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed", |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
124 mpi->bpp*mpi->width*mpi->height/8); |
4878 | 125 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*mpi->height/8); |
126 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
127 // YV12/I420. feel free to add other planar formats here... | |
4899
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
128 if(!mpi->stride[0]) mpi->stride[0]=mpi->width; |
4878 | 129 if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->width/2; |
130 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height; | |
131 mpi->planes[2]=mpi->planes[1]+mpi->width*mpi->height/4; | |
4899
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
132 } else { |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
133 if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8; |
4878 | 134 } |
135 mpi->flags|=MP_IMGFLAG_ALLOCATED; | |
136 } | |
137 } | |
138 } | |
139 return mpi; | |
140 } | |
141 |