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