Mercurial > mplayer.hg
comparison libmpcodecs/vd.c @ 4878:eff8a76e515f
libmpcodecs core - initial version
author | arpi |
---|---|
date | Thu, 28 Feb 2002 00:57:30 +0000 |
parents | |
children | c758cf9360d9 |
comparison
equal
deleted
inserted
replaced
4877:9d97874d8691 | 4878:eff8a76e515f |
---|---|
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; | |
25 | |
26 vd_functions_t* mpcodecs_vd_drivers[] = { | |
27 &mpcodecs_vd_null, | |
28 NULL | |
29 }; | |
30 | |
31 int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){ | |
32 | |
33 return 1; | |
34 } | |
35 | |
36 static mp_image_t* static_images[2]; | |
37 static mp_image_t* temp_images[1]; | |
38 static int static_idx=0; | |
39 | |
40 // mp_imgtype: buffering type, see mp_image.h | |
41 // mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h | |
42 // returns NULL or allocated mp_image_t* | |
43 // Note: buffer allocation may be moved to mpcodecs_config_vo() later... | |
44 mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h){ | |
45 mp_image_t* mpi=NULL; | |
46 // Note: we should call libvo first to check if it supports direct rendering | |
47 // and if not, then fallback to software buffers: | |
48 switch(mp_imgtype){ | |
49 case MP_IMGTYPE_EXPORT: | |
50 mpi=new_mp_image(w,h); | |
51 break; | |
52 case MP_IMGTYPE_STATIC: | |
53 if(!static_images[0]) static_images[0]=new_mp_image(w,h); | |
54 mpi=static_images[0]; | |
55 break; | |
56 case MP_IMGTYPE_TEMP: | |
57 if(!temp_images[0]) temp_images[0]=new_mp_image(w,h); | |
58 mpi=temp_images[0]; | |
59 break; | |
60 case MP_IMGTYPE_IPB: | |
61 if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame: | |
62 if(!temp_images[0]) temp_images[0]=new_mp_image(w,h); | |
63 mpi=temp_images[0]; | |
64 break; | |
65 } | |
66 case MP_IMGTYPE_IP: | |
67 if(!static_images[static_idx]) static_images[static_idx]=new_mp_image(w,h); | |
68 mpi=static_images[static_idx]; | |
69 static_idx^=1; | |
70 break; | |
71 } | |
72 if(mpi){ | |
73 mpi->type=mp_imgtype; | |
74 mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE); | |
75 mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE); | |
76 if(!mpi->bpp){ | |
77 mp_image_setfmt(mpi,sh->codec->outfmt[sh->outfmtidx]); | |
78 if(!(mpi->flags&(MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_DIRECT)) | |
79 && mpi->type>MP_IMGTYPE_EXPORT){ | |
80 // non-direct and not yet allocaed image. allocate it! | |
81 printf("*** Allocating mp_image_t, %d bytes\n",mpi->bpp*mpi->width*mpi->height/8); | |
82 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*mpi->height/8); | |
83 if(!mpi->stride[0]) mpi->stride[0]=mpi->width; | |
84 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
85 // YV12/I420. feel free to add other planar formats here... | |
86 if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->width/2; | |
87 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height; | |
88 mpi->planes[2]=mpi->planes[1]+mpi->width*mpi->height/4; | |
89 } | |
90 mpi->flags|=MP_IMGFLAG_ALLOCATED; | |
91 } | |
92 } | |
93 } | |
94 return mpi; | |
95 } | |
96 |