Mercurial > mplayer.hg
annotate libmpcodecs/vd.c @ 4910:e99d47acfce6
strike period over, commiting stuff. next commit will be rewrite. (?) - Gabu
author | jonas |
---|---|
date | Fri, 01 Mar 2002 22:27:01 +0000 |
parents | c84d841ef43b |
children | f6990fad0ab3 |
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; |
4878 | 26 |
27 vd_functions_t* mpcodecs_vd_drivers[] = { | |
28 &mpcodecs_vd_null, | |
4884 | 29 &mpcodecs_vd_cinepak, |
4878 | 30 NULL |
31 }; | |
32 | |
33 int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){ | |
34 | |
35 return 1; | |
36 } | |
37 | |
38 static mp_image_t* static_images[2]; | |
39 static mp_image_t* temp_images[1]; | |
40 static int static_idx=0; | |
41 | |
42 // mp_imgtype: buffering type, see mp_image.h | |
43 // mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h | |
44 // returns NULL or allocated mp_image_t* | |
45 // Note: buffer allocation may be moved to mpcodecs_config_vo() later... | |
46 mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h){ | |
47 mp_image_t* mpi=NULL; | |
48 // Note: we should call libvo first to check if it supports direct rendering | |
49 // and if not, then fallback to software buffers: | |
50 switch(mp_imgtype){ | |
51 case MP_IMGTYPE_EXPORT: | |
52 mpi=new_mp_image(w,h); | |
53 break; | |
54 case MP_IMGTYPE_STATIC: | |
55 if(!static_images[0]) static_images[0]=new_mp_image(w,h); | |
56 mpi=static_images[0]; | |
57 break; | |
58 case MP_IMGTYPE_TEMP: | |
59 if(!temp_images[0]) temp_images[0]=new_mp_image(w,h); | |
60 mpi=temp_images[0]; | |
61 break; | |
62 case MP_IMGTYPE_IPB: | |
63 if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame: | |
64 if(!temp_images[0]) temp_images[0]=new_mp_image(w,h); | |
65 mpi=temp_images[0]; | |
66 break; | |
67 } | |
68 case MP_IMGTYPE_IP: | |
69 if(!static_images[static_idx]) static_images[static_idx]=new_mp_image(w,h); | |
70 mpi=static_images[static_idx]; | |
71 static_idx^=1; | |
72 break; | |
73 } | |
74 if(mpi){ | |
75 mpi->type=mp_imgtype; | |
76 mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE); | |
77 mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE); | |
78 if(!mpi->bpp){ | |
79 mp_image_setfmt(mpi,sh->codec->outfmt[sh->outfmtidx]); | |
80 if(!(mpi->flags&(MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_DIRECT)) | |
81 && mpi->type>MP_IMGTYPE_EXPORT){ | |
82 // 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
|
83 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
|
84 mpi->width,mpi->height,mpi->bpp, |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
85 (mpi->flags&MP_IMGFLAG_YUV)?"YUV":"RGB", |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
86 (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed", |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
87 mpi->bpp*mpi->width*mpi->height/8); |
4878 | 88 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*mpi->height/8); |
89 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
90 // 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
|
91 if(!mpi->stride[0]) mpi->stride[0]=mpi->width; |
4878 | 92 if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->width/2; |
93 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height; | |
94 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
|
95 } else { |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
96 if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8; |
4878 | 97 } |
98 mpi->flags|=MP_IMGFLAG_ALLOCATED; | |
99 } | |
100 } | |
101 } | |
102 return mpi; | |
103 } | |
104 |