Mercurial > mplayer.hg
annotate libmpcodecs/vd.c @ 4962:993f274191ff
ACCEPT_WIDTH flag added
author | arpi |
---|---|
date | Wed, 06 Mar 2002 23:40:31 +0000 |
parents | ca6f6b35baf4 |
children | 236b06410b03 |
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; |
4878 | 29 |
30 vd_functions_t* mpcodecs_vd_drivers[] = { | |
31 &mpcodecs_vd_null, | |
4884 | 32 &mpcodecs_vd_cinepak, |
4915
f6990fad0ab3
Qt RPZA decoder interface by Roberto Togni <rtogni@bresciaonline.it>
arpi
parents:
4899
diff
changeset
|
33 &mpcodecs_vd_qtrpza, |
4951 | 34 #ifdef USE_LIBAVCODEC |
35 &mpcodecs_vd_ffmpeg, | |
36 #endif | |
4958 | 37 #ifdef USE_DIRECTSHOW |
38 &mpcodecs_vd_dshow, | |
39 #endif | |
4878 | 40 NULL |
41 }; | |
42 | |
43 int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){ | |
44 | |
45 return 1; | |
46 } | |
47 | |
48 static mp_image_t* static_images[2]; | |
49 static mp_image_t* temp_images[1]; | |
4951 | 50 static mp_image_t* export_images[1]; |
4878 | 51 static int static_idx=0; |
52 | |
53 // mp_imgtype: buffering type, see mp_image.h | |
54 // mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h | |
55 // returns NULL or allocated mp_image_t* | |
56 // Note: buffer allocation may be moved to mpcodecs_config_vo() later... | |
57 mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h){ | |
58 mp_image_t* mpi=NULL; | |
59 // Note: we should call libvo first to check if it supports direct rendering | |
60 // and if not, then fallback to software buffers: | |
61 switch(mp_imgtype){ | |
62 case MP_IMGTYPE_EXPORT: | |
4951 | 63 // mpi=new_mp_image(w,h); |
64 if(!export_images[0]) export_images[0]=new_mp_image(w,h); | |
65 mpi=export_images[0]; | |
4878 | 66 break; |
67 case MP_IMGTYPE_STATIC: | |
68 if(!static_images[0]) static_images[0]=new_mp_image(w,h); | |
69 mpi=static_images[0]; | |
70 break; | |
71 case MP_IMGTYPE_TEMP: | |
72 if(!temp_images[0]) temp_images[0]=new_mp_image(w,h); | |
73 mpi=temp_images[0]; | |
74 break; | |
75 case MP_IMGTYPE_IPB: | |
76 if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame: | |
77 if(!temp_images[0]) temp_images[0]=new_mp_image(w,h); | |
78 mpi=temp_images[0]; | |
79 break; | |
80 } | |
81 case MP_IMGTYPE_IP: | |
82 if(!static_images[static_idx]) static_images[static_idx]=new_mp_image(w,h); | |
83 mpi=static_images[static_idx]; | |
84 static_idx^=1; | |
85 break; | |
86 } | |
87 if(mpi){ | |
88 mpi->type=mp_imgtype; | |
89 mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE); | |
90 mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE); | |
4951 | 91 if((mpi->width!=w || mpi->height!=h) && !(mpi->flags&MP_IMGFLAG_DIRECT)){ |
92 mpi->width=w; | |
93 mpi->height=h; | |
94 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ | |
95 // need to re-allocate buffer memory: | |
96 free(mpi->planes[0]); | |
97 mpi->flags&=~MP_IMGFLAG_ALLOCATED; | |
98 } | |
99 } | |
4878 | 100 if(!mpi->bpp){ |
101 mp_image_setfmt(mpi,sh->codec->outfmt[sh->outfmtidx]); | |
102 if(!(mpi->flags&(MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_DIRECT)) | |
103 && mpi->type>MP_IMGTYPE_EXPORT){ | |
104 // 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
|
105 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
|
106 mpi->width,mpi->height,mpi->bpp, |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
107 (mpi->flags&MP_IMGFLAG_YUV)?"YUV":"RGB", |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
108 (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed", |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
109 mpi->bpp*mpi->width*mpi->height/8); |
4878 | 110 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*mpi->height/8); |
111 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
112 // 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
|
113 if(!mpi->stride[0]) mpi->stride[0]=mpi->width; |
4878 | 114 if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->width/2; |
115 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height; | |
116 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
|
117 } else { |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
118 if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8; |
4878 | 119 } |
120 mpi->flags|=MP_IMGFLAG_ALLOCATED; | |
121 } | |
122 } | |
123 } | |
124 return mpi; | |
125 } | |
126 |