Mercurial > mplayer.hg
annotate libmpcodecs/vd.c @ 5373:b476f5d1c91e
10l to nick - ACCEPT_WIDTH fixed
author | arpi |
---|---|
date | Wed, 27 Mar 2002 21:49:19 +0000 |
parents | b87743434e1f |
children | ac09ea252466 |
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" | |
5075 | 7 #include "help_mp.h" |
4878 | 8 |
9 #ifdef HAVE_MALLOC_H | |
10 #include <malloc.h> | |
11 #endif | |
12 | |
13 #include "codec-cfg.h" | |
14 //#include "mp_image.h" | |
15 | |
16 #include "../libvo/img_format.h" | |
17 | |
18 #include "stream.h" | |
19 #include "demuxer.h" | |
20 #include "stheader.h" | |
21 | |
22 #include "vd.h" | |
23 //#include "vd_internal.h" | |
24 | |
25 extern vd_functions_t mpcodecs_vd_null; | |
4885 | 26 extern vd_functions_t mpcodecs_vd_cinepak; |
4915
f6990fad0ab3
Qt RPZA decoder interface by Roberto Togni <rtogni@bresciaonline.it>
arpi
parents:
4899
diff
changeset
|
27 extern vd_functions_t mpcodecs_vd_qtrpza; |
4951 | 28 extern vd_functions_t mpcodecs_vd_ffmpeg; |
4958 | 29 extern vd_functions_t mpcodecs_vd_dshow; |
4968 | 30 extern vd_functions_t mpcodecs_vd_vfw; |
31 extern vd_functions_t mpcodecs_vd_vfwex; | |
32 extern vd_functions_t mpcodecs_vd_odivx; | |
33 extern vd_functions_t mpcodecs_vd_divx4; | |
4969 | 34 extern vd_functions_t mpcodecs_vd_raw; |
35 extern vd_functions_t mpcodecs_vd_xanim; | |
5193
abea2deab4d6
MPlayer now has a Microsoft RLE decoder to call its own...only supports
melanson
parents:
5180
diff
changeset
|
36 extern vd_functions_t mpcodecs_vd_msrle; |
4987 | 37 extern vd_functions_t mpcodecs_vd_msvidc; |
38 extern vd_functions_t mpcodecs_vd_fli; | |
4989 | 39 extern vd_functions_t mpcodecs_vd_qtrle; |
40 extern vd_functions_t mpcodecs_vd_qtsmc; | |
41 extern vd_functions_t mpcodecs_vd_roqvideo; | |
42 extern vd_functions_t mpcodecs_vd_cyuv; | |
43 extern vd_functions_t mpcodecs_vd_nuv; | |
4998 | 44 extern vd_functions_t mpcodecs_vd_mpng; |
5029 | 45 extern vd_functions_t mpcodecs_vd_ijpg; |
4998 | 46 extern vd_functions_t mpcodecs_vd_libmpeg2; |
5235
3e04fd1074d3
added HuffYUV support, courtesy of Roberto Togni <rtogni@bresciaonline.it>
melanson
parents:
5224
diff
changeset
|
47 extern vd_functions_t mpcodecs_vd_huffyuv; |
5264 | 48 extern vd_functions_t mpcodecs_vd_zlib; |
4878 | 49 |
50 vd_functions_t* mpcodecs_vd_drivers[] = { | |
51 &mpcodecs_vd_null, | |
4884 | 52 &mpcodecs_vd_cinepak, |
4915
f6990fad0ab3
Qt RPZA decoder interface by Roberto Togni <rtogni@bresciaonline.it>
arpi
parents:
4899
diff
changeset
|
53 &mpcodecs_vd_qtrpza, |
4951 | 54 #ifdef USE_LIBAVCODEC |
55 &mpcodecs_vd_ffmpeg, | |
56 #endif | |
4968 | 57 #ifdef USE_WIN32DLL |
4958 | 58 #ifdef USE_DIRECTSHOW |
59 &mpcodecs_vd_dshow, | |
60 #endif | |
4968 | 61 &mpcodecs_vd_vfw, |
62 &mpcodecs_vd_vfwex, | |
63 #endif | |
64 #ifdef USE_DIVX | |
65 &mpcodecs_vd_odivx, | |
66 #ifdef NEW_DECORE | |
67 &mpcodecs_vd_divx4, | |
68 #endif | |
69 #endif | |
4969 | 70 &mpcodecs_vd_raw, |
5193
abea2deab4d6
MPlayer now has a Microsoft RLE decoder to call its own...only supports
melanson
parents:
5180
diff
changeset
|
71 &mpcodecs_vd_msrle, |
4987 | 72 &mpcodecs_vd_msvidc, |
73 &mpcodecs_vd_fli, | |
4989 | 74 &mpcodecs_vd_qtrle, |
75 &mpcodecs_vd_qtsmc, | |
76 &mpcodecs_vd_roqvideo, | |
77 &mpcodecs_vd_cyuv, | |
78 &mpcodecs_vd_nuv, | |
4969 | 79 #ifdef USE_XANIM |
80 &mpcodecs_vd_xanim, | |
81 #endif | |
4998 | 82 #ifdef HAVE_PNG |
83 &mpcodecs_vd_mpng, | |
84 #endif | |
5029 | 85 #ifdef HAVE_JPEG |
86 &mpcodecs_vd_ijpg, | |
87 #endif | |
4998 | 88 &mpcodecs_vd_libmpeg2, |
5235
3e04fd1074d3
added HuffYUV support, courtesy of Roberto Togni <rtogni@bresciaonline.it>
melanson
parents:
5224
diff
changeset
|
89 &mpcodecs_vd_huffyuv, |
5264 | 90 #ifdef HAVE_ZLIB |
91 &mpcodecs_vd_zlib, | |
92 #endif | |
4878 | 93 NULL |
94 }; | |
95 | |
4971 | 96 #include "libvo/video_out.h" |
5224 | 97 extern int vo_directrendering; |
4971 | 98 |
5075 | 99 // libvo opts: |
100 int fullscreen=0; | |
101 int vidmode=0; | |
102 int softzoom=0; | |
103 int flip=-1; | |
104 int opt_screen_size_x=0; | |
105 int opt_screen_size_y=0; | |
106 int screen_size_xy=0; | |
107 float movie_aspect=-1.0; | |
108 int vo_flags=0; | |
109 | |
110 static vo_tune_info_t vtune; | |
111 | |
5156
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
112 static mp_image_t* static_images[2]; |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
113 static mp_image_t* temp_images[1]; |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
114 static mp_image_t* export_images[1]; |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
115 static int static_idx=0; |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
116 |
5180 | 117 extern vd_functions_t* mpvdec; // FIXME! |
118 | |
4878 | 119 int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){ |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
120 int i,j; |
5075 | 121 unsigned int out_fmt=0; |
122 int screen_size_x=0;//SCREEN_SIZE_X; | |
123 int screen_size_y=0;//SCREEN_SIZE_Y; | |
124 vo_functions_t* video_out=sh->video_out; | |
125 | |
5365
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
126 #if 1 |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
127 if(!(sh->disp_w && sh->disp_h)) |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
128 mp_msg(MSGT_DECVIDEO,MSGL_WARN, |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
129 "VDec: codec didn't set sh->disp_w and sh->disp_h, trying to workaround!\n"); |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
130 /* XXX: HACK, if sh->disp_* aren't set, |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
131 * but we have w and h, set them :: atmos */ |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
132 if(!sh->disp_w && w) |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
133 sh->disp_w=w; |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
134 if(!sh->disp_h && h) |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
135 sh->disp_h=h; |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
136 #endif |
b87743434e1f
Issue a warning in VDec if disp_w and disp_h weren't set by codec and try workaround.
atmos4
parents:
5315
diff
changeset
|
137 |
5004 | 138 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"VDec: vo config request - %d x %d, %s \n", |
139 w,h,vo_format_name(preferred_outfmt)); | |
5075 | 140 |
5077 | 141 if(!video_out) return 1; // temp hack |
142 | |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
143 // check if libvo and codec has common outfmt (no conversion): |
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
144 j=-1; |
5075 | 145 for(i=0;i<CODECS_MAX_OUTFMT;i++){ |
146 out_fmt=sh->codec->outfmt[i]; | |
147 if(out_fmt==(signed int)0xFFFFFFFF) continue; | |
148 vo_flags=video_out->control(VOCTRL_QUERY_FORMAT, &out_fmt); | |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
149 mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: query(%s) returned 0x%X (i=%d) \n",vo_format_name(out_fmt),vo_flags,i); |
5180 | 150 if((vo_flags&2) || (vo_flags && j<0)){ |
151 // check (query) if codec really support this outfmt... | |
152 if(mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)==CONTROL_FALSE) | |
153 continue; | |
154 j=i; if(vo_flags&2) break; | |
155 } | |
5075 | 156 } |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
157 if(j<0){ |
5075 | 158 // TODO: no match - we should use conversion... |
159 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_VOincompCodec); | |
160 return 0; // failed | |
161 } | |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
162 out_fmt=sh->codec->outfmt[j]; |
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
163 sh->outfmtidx=j; |
5075 | 164 |
165 // autodetect flipping | |
166 if(flip==-1){ | |
167 flip=0; | |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
168 if(sh->codec->outflags[j]&CODECS_FLAG_FLIP) |
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
169 if(!(sh->codec->outflags[j]&CODECS_FLAG_NOFLIP)) |
5075 | 170 flip=1; |
171 } | |
172 | |
173 // time to do aspect ratio corrections... | |
174 | |
175 if(movie_aspect>-1.0) sh->aspect = movie_aspect; // cmdline overrides autodetect | |
176 // if(!sh->aspect) sh->aspect=1.0; | |
177 screen_size_x = opt_screen_size_x; | |
178 screen_size_y = opt_screen_size_y; | |
179 if(screen_size_xy||screen_size_x||screen_size_y){ | |
180 if(screen_size_xy>0){ | |
181 if(screen_size_xy<=8){ | |
182 screen_size_x=screen_size_xy*sh->disp_w; | |
183 screen_size_y=screen_size_xy*sh->disp_h; | |
184 } else { | |
185 screen_size_x=screen_size_xy; | |
186 screen_size_y=screen_size_xy*sh->disp_h/sh->disp_w; | |
187 } | |
188 } else if(!vidmode){ | |
189 if(!screen_size_x) screen_size_x=SCREEN_SIZE_X; | |
190 if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y; | |
191 if(screen_size_x<=8) screen_size_x*=sh->disp_w; | |
192 if(screen_size_y<=8) screen_size_y*=sh->disp_h; | |
193 } | |
194 } else { | |
195 // check source format aspect, calculate prescale ::atmos | |
196 screen_size_x=sh->disp_w; | |
197 screen_size_y=sh->disp_h; | |
198 if(sh->aspect>0.01){ | |
199 mp_msg(MSGT_CPLAYER,MSGL_INFO,"Movie-Aspect is %.2f:1 - prescaling to correct movie aspect.\n", | |
200 sh->aspect); | |
201 screen_size_x=(int)((float)sh->disp_h*sh->aspect); | |
202 screen_size_x+=screen_size_x%2; // round | |
203 if(screen_size_x<sh->disp_w){ | |
204 screen_size_x=sh->disp_w; | |
205 screen_size_y=(int)((float)sh->disp_w*(1.0/sh->aspect)); | |
206 screen_size_y+=screen_size_y%2; // round | |
207 } | |
208 } else { | |
209 mp_msg(MSGT_CPLAYER,MSGL_INFO,"Movie-Aspect is undefined - no prescaling applied.\n"); | |
210 } | |
211 } | |
212 | |
5172 | 213 if(video_out->get_info) |
5156
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
214 { const vo_info_t *info = video_out->get_info(); |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
215 mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name, |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
216 sh->disp_w,sh->disp_h, |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
217 screen_size_x,screen_size_y, |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
218 vo_format_name(out_fmt), |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
219 fullscreen?"fs ":"", |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
220 vidmode?"vm ":"", |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
221 softzoom?"zoom ":"", |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
222 (flip==1)?"flip ":""); |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
223 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Description: %s\n",info->name); |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
224 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Author: %s\n", info->author); |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
225 if(info->comment && strlen(info->comment) > 0) |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
226 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment); |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
227 } |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
228 |
5075 | 229 // Time to config libvo! |
230 mp_msg(MSGT_CPLAYER,MSGL_V,"video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", | |
231 sh->disp_w,sh->disp_h, | |
232 screen_size_x,screen_size_y, | |
233 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), | |
234 "MPlayer",out_fmt); | |
235 | |
5077 | 236 memset(&vtune,0,sizeof(vo_tune_info_t)); |
5075 | 237 if(video_out->config(sh->disp_w,sh->disp_h, |
238 screen_size_x,screen_size_y, | |
239 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), | |
240 "MPlayer",out_fmt,&vtune)){ | |
241 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CannotInitVO); | |
242 return 0; // exit_player(MSGTR_Exit_error); | |
243 } | |
244 | |
5156
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
245 #define FREE_MPI(mpi) if(mpi){if(mpi->flags&MP_IMGFLAG_ALLOCATED) free(mpi->planes[0]); free(mpi); mpi=NULL;} |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
246 FREE_MPI(static_images[0]) |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
247 FREE_MPI(static_images[1]) |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
248 FREE_MPI(temp_images[0]) |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
249 FREE_MPI(export_images[0]) |
1c250c1da93c
libvo printfs added (moved from mplayer.c), mpi buffers free'd to fix multifile playback
arpi
parents:
5131
diff
changeset
|
250 #undef FREE_MPI |
4878 | 251 return 1; |
252 } | |
253 | |
254 // mp_imgtype: buffering type, see mp_image.h | |
255 // mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h | |
256 // returns NULL or allocated mp_image_t* | |
257 // Note: buffer allocation may be moved to mpcodecs_config_vo() later... | |
258 mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h){ | |
259 mp_image_t* mpi=NULL; | |
5315 | 260 int w2=w; //(mp_imgflag&MP_IMGFLAG_ACCEPT_STRIDE)?((w+15)&(~15)):w; |
4878 | 261 // Note: we should call libvo first to check if it supports direct rendering |
262 // and if not, then fallback to software buffers: | |
263 switch(mp_imgtype){ | |
264 case MP_IMGTYPE_EXPORT: | |
4951 | 265 // mpi=new_mp_image(w,h); |
4968 | 266 if(!export_images[0]) export_images[0]=new_mp_image(w2,h); |
4951 | 267 mpi=export_images[0]; |
4878 | 268 break; |
269 case MP_IMGTYPE_STATIC: | |
4968 | 270 if(!static_images[0]) static_images[0]=new_mp_image(w2,h); |
4878 | 271 mpi=static_images[0]; |
272 break; | |
273 case MP_IMGTYPE_TEMP: | |
4968 | 274 if(!temp_images[0]) temp_images[0]=new_mp_image(w2,h); |
4878 | 275 mpi=temp_images[0]; |
276 break; | |
277 case MP_IMGTYPE_IPB: | |
278 if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame: | |
4968 | 279 if(!temp_images[0]) temp_images[0]=new_mp_image(w2,h); |
4878 | 280 mpi=temp_images[0]; |
281 break; | |
282 } | |
283 case MP_IMGTYPE_IP: | |
4968 | 284 if(!static_images[static_idx]) static_images[static_idx]=new_mp_image(w2,h); |
4878 | 285 mpi=static_images[static_idx]; |
286 static_idx^=1; | |
287 break; | |
288 } | |
289 if(mpi){ | |
290 mpi->type=mp_imgtype; | |
4971 | 291 mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT); |
292 mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH|MP_IMGFLAG_ALIGNED_STRIDE|MP_IMGFLAG_DRAW_CALLBACK); | |
4968 | 293 if((mpi->width!=w2 || mpi->height!=h) && !(mpi->flags&MP_IMGFLAG_DIRECT)){ |
294 mpi->width=w2; | |
4951 | 295 mpi->height=h; |
296 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ | |
297 // need to re-allocate buffer memory: | |
298 free(mpi->planes[0]); | |
299 mpi->flags&=~MP_IMGFLAG_ALLOCATED; | |
300 } | |
301 } | |
4971 | 302 if(!mpi->bpp) mp_image_setfmt(mpi,sh->codec->outfmt[sh->outfmtidx]); |
303 if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){ | |
304 | |
305 // check libvo first! | |
306 vo_functions_t* vo=sh->video_out; | |
5224 | 307 if(vo && vo_directrendering) vo->control(VOCTRL_GET_IMAGE,mpi); |
4971 | 308 |
309 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
4878 | 310 // non-direct and not yet allocaed image. allocate it! |
311 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*mpi->height/8); | |
312 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
313 // 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
|
314 if(!mpi->stride[0]) mpi->stride[0]=mpi->width; |
4878 | 315 if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->width/2; |
5315 | 316 if(mpi->flags&MP_IMGFLAG_SWAPPED){ |
317 // I420/IYUV (Y,U,V) | |
318 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height; | |
319 mpi->planes[2]=mpi->planes[1]+(mpi->width>>1)*(mpi->height>>1); | |
320 } else { | |
321 // YV12,YVU9 (Y,V,U) | |
322 mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height; | |
323 mpi->planes[1]=mpi->planes[2]+(mpi->width>>1)*(mpi->height>>1); | |
324 } | |
4899
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
325 } else { |
c84d841ef43b
fixed stride for packed formats, more detailed printf at image allocation
arpi
parents:
4885
diff
changeset
|
326 if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8; |
4878 | 327 } |
328 mpi->flags|=MP_IMGFLAG_ALLOCATED; | |
4971 | 329 } |
330 if(!(mpi->flags&MP_IMGFLAG_TYPE_DISPLAYED)){ | |
331 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"*** %s mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n", | |
332 (mpi->flags&MP_IMGFLAG_DIRECT)?"Direct Rendering":"Allocating", | |
333 mpi->width,mpi->height,mpi->bpp, | |
334 (mpi->flags&MP_IMGFLAG_YUV)?"YUV":"RGB", | |
335 (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed", | |
336 mpi->bpp*mpi->width*mpi->height/8); | |
337 mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED; | |
338 } | |
339 | |
4878 | 340 } |
341 } | |
342 return mpi; | |
343 } | |
344 |