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