Mercurial > mplayer.hg
annotate libmpcodecs/vd.c @ 6284:30a2f1807c5b
big html tags
author | jonas |
---|---|
date | Mon, 03 Jun 2002 17:29:52 +0000 |
parents | af0b011c9440 |
children | d253cf4f43a9 |
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 | |
5607 | 16 #include "img_format.h" |
4878 | 17 |
18 #include "stream.h" | |
19 #include "demuxer.h" | |
20 #include "stheader.h" | |
6057
31e465fda59c
various openbsd and general warning fixes - patch by Bj«Órn Sandell <biorn@dce.chalmers.se>
arpi
parents:
5925
diff
changeset
|
21 #include "dec_video.h" |
4878 | 22 |
23 #include "vd.h" | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5483
diff
changeset
|
24 #include "vf.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5483
diff
changeset
|
25 |
4878 | 26 //#include "vd_internal.h" |
27 | |
28 extern vd_functions_t mpcodecs_vd_null; | |
4885 | 29 extern vd_functions_t mpcodecs_vd_cinepak; |
4915
f6990fad0ab3
Qt RPZA decoder interface by Roberto Togni <rtogni@bresciaonline.it>
arpi
parents:
4899
diff
changeset
|
30 extern vd_functions_t mpcodecs_vd_qtrpza; |
4951 | 31 extern vd_functions_t mpcodecs_vd_ffmpeg; |
4958 | 32 extern vd_functions_t mpcodecs_vd_dshow; |
4968 | 33 extern vd_functions_t mpcodecs_vd_vfw; |
34 extern vd_functions_t mpcodecs_vd_vfwex; | |
35 extern vd_functions_t mpcodecs_vd_odivx; | |
36 extern vd_functions_t mpcodecs_vd_divx4; | |
4969 | 37 extern vd_functions_t mpcodecs_vd_raw; |
38 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
|
39 extern vd_functions_t mpcodecs_vd_msrle; |
4987 | 40 extern vd_functions_t mpcodecs_vd_msvidc; |
41 extern vd_functions_t mpcodecs_vd_fli; | |
4989 | 42 extern vd_functions_t mpcodecs_vd_qtrle; |
43 extern vd_functions_t mpcodecs_vd_qtsmc; | |
44 extern vd_functions_t mpcodecs_vd_roqvideo; | |
45 extern vd_functions_t mpcodecs_vd_cyuv; | |
46 extern vd_functions_t mpcodecs_vd_nuv; | |
4998 | 47 extern vd_functions_t mpcodecs_vd_mpng; |
5029 | 48 extern vd_functions_t mpcodecs_vd_ijpg; |
4998 | 49 extern vd_functions_t mpcodecs_vd_libmpeg2; |
5235
3e04fd1074d3
added HuffYUV support, courtesy of Roberto Togni <rtogni@bresciaonline.it>
melanson
parents:
5224
diff
changeset
|
50 extern vd_functions_t mpcodecs_vd_huffyuv; |
5264 | 51 extern vd_functions_t mpcodecs_vd_zlib; |
5476 | 52 extern vd_functions_t mpcodecs_vd_mpegpes; |
4878 | 53 |
54 vd_functions_t* mpcodecs_vd_drivers[] = { | |
55 &mpcodecs_vd_null, | |
4884 | 56 &mpcodecs_vd_cinepak, |
4915
f6990fad0ab3
Qt RPZA decoder interface by Roberto Togni <rtogni@bresciaonline.it>
arpi
parents:
4899
diff
changeset
|
57 &mpcodecs_vd_qtrpza, |
4951 | 58 #ifdef USE_LIBAVCODEC |
59 &mpcodecs_vd_ffmpeg, | |
60 #endif | |
4968 | 61 #ifdef USE_WIN32DLL |
4958 | 62 #ifdef USE_DIRECTSHOW |
63 &mpcodecs_vd_dshow, | |
64 #endif | |
4968 | 65 &mpcodecs_vd_vfw, |
66 &mpcodecs_vd_vfwex, | |
67 #endif | |
68 #ifdef USE_DIVX | |
69 &mpcodecs_vd_odivx, | |
70 #ifdef NEW_DECORE | |
71 &mpcodecs_vd_divx4, | |
72 #endif | |
73 #endif | |
4969 | 74 &mpcodecs_vd_raw, |
5193
abea2deab4d6
MPlayer now has a Microsoft RLE decoder to call its own...only supports
melanson
parents:
5180
diff
changeset
|
75 &mpcodecs_vd_msrle, |
4987 | 76 &mpcodecs_vd_msvidc, |
77 &mpcodecs_vd_fli, | |
4989 | 78 &mpcodecs_vd_qtrle, |
79 &mpcodecs_vd_qtsmc, | |
80 &mpcodecs_vd_roqvideo, | |
81 &mpcodecs_vd_cyuv, | |
82 &mpcodecs_vd_nuv, | |
4969 | 83 #ifdef USE_XANIM |
84 &mpcodecs_vd_xanim, | |
85 #endif | |
4998 | 86 #ifdef HAVE_PNG |
87 &mpcodecs_vd_mpng, | |
88 #endif | |
5029 | 89 #ifdef HAVE_JPEG |
90 &mpcodecs_vd_ijpg, | |
91 #endif | |
4998 | 92 &mpcodecs_vd_libmpeg2, |
5235
3e04fd1074d3
added HuffYUV support, courtesy of Roberto Togni <rtogni@bresciaonline.it>
melanson
parents:
5224
diff
changeset
|
93 &mpcodecs_vd_huffyuv, |
5264 | 94 #ifdef HAVE_ZLIB |
95 &mpcodecs_vd_zlib, | |
96 #endif | |
5476 | 97 &mpcodecs_vd_mpegpes, |
4878 | 98 NULL |
99 }; | |
100 | |
4971 | 101 #include "libvo/video_out.h" |
102 | |
5075 | 103 // libvo opts: |
104 int fullscreen=0; | |
105 int vidmode=0; | |
106 int softzoom=0; | |
107 int flip=-1; | |
108 int opt_screen_size_x=0; | |
109 int opt_screen_size_y=0; | |
110 int screen_size_xy=0; | |
111 float movie_aspect=-1.0; | |
112 int vo_flags=0; | |
5483 | 113 int vd_use_slices=1; |
5075 | 114 |
5180 | 115 extern vd_functions_t* mpvdec; // FIXME! |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
116 extern int divx_quality; |
5180 | 117 |
4878 | 118 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
|
119 int i,j; |
5075 | 120 unsigned int out_fmt=0; |
121 int screen_size_x=0;//SCREEN_SIZE_X; | |
122 int screen_size_y=0;//SCREEN_SIZE_Y; | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5483
diff
changeset
|
123 // vo_functions_t* video_out=sh->video_out; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5483
diff
changeset
|
124 vf_instance_t* vf=sh->vfilter; |
5075 | 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 |
6138
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
6057
diff
changeset
|
138 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"VDec: vo config request - %d x %d (preferred csp: %s) \n", |
5004 | 139 w,h,vo_format_name(preferred_outfmt)); |
5075 | 140 |
5925
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5903
diff
changeset
|
141 // if(!vf) return 1; // temp hack |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
142 |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
143 if(get_video_quality_max(sh)<=0 && divx_quality){ |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
144 // user wants postprocess but no pp filter yet: |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
145 sh->vfilter=vf=vf_open_filter(vf,"pp",NULL); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
146 } |
5077 | 147 |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
148 // check if libvo and codec has common outfmt (no conversion): |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
149 csp_again: |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
150 j=-1; |
5075 | 151 for(i=0;i<CODECS_MAX_OUTFMT;i++){ |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
152 int flags; |
5075 | 153 out_fmt=sh->codec->outfmt[i]; |
154 if(out_fmt==(signed int)0xFFFFFFFF) continue; | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
155 flags=vf->query_format(vf,out_fmt); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
156 mp_msg(MSGT_CPLAYER,MSGL_V,"vo_debug: query(%s) returned 0x%X (i=%d) \n",vo_format_name(out_fmt),flags,i); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
157 if((flags&2) || (flags && j<0)){ |
5180 | 158 // check (query) if codec really support this outfmt... |
159 if(mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)==CONTROL_FALSE) | |
160 continue; | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
161 j=i; vo_flags=flags; if(flags&2) break; |
5180 | 162 } |
5075 | 163 } |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
164 if(j<0){ |
5075 | 165 // TODO: no match - we should use conversion... |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
166 if(strcmp(vf->info->name,"scale")){ |
5710 | 167 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"Couldn't find matching colorspace - retrying with -vop scale...\n"); |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
168 vf=vf_open_filter(vf,"scale",NULL); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
169 goto csp_again; |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
170 } |
5925
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5903
diff
changeset
|
171 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_VOincompCodec); |
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5903
diff
changeset
|
172 sh->vf_inited=-1; |
5075 | 173 return 0; // failed |
174 } | |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
175 out_fmt=sh->codec->outfmt[j]; |
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
176 sh->outfmtidx=j; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
177 sh->vfilter=vf; |
5075 | 178 |
179 // autodetect flipping | |
180 if(flip==-1){ | |
181 flip=0; | |
5131
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
182 if(sh->codec->outflags[j]&CODECS_FLAG_FLIP) |
cff03e88d331
prefer outfmt with no conversion (see vo's query flags)
arpi
parents:
5077
diff
changeset
|
183 if(!(sh->codec->outflags[j]&CODECS_FLAG_NOFLIP)) |
5075 | 184 flip=1; |
185 } | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
186 if(vo_flags&VFCAP_FLIPPED) flip^=1; |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
187 if(flip && !(vo_flags&VFCAP_FLIP)){ |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
188 // we need to flip, but no flipping filter avail. |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
189 sh->vfilter=vf=vf_open_filter(vf,"flip",NULL); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5549
diff
changeset
|
190 } |
5075 | 191 |
192 // time to do aspect ratio corrections... | |
193 | |
194 if(movie_aspect>-1.0) sh->aspect = movie_aspect; // cmdline overrides autodetect | |
195 // if(!sh->aspect) sh->aspect=1.0; | |
5903 | 196 |
197 if(opt_screen_size_x||opt_screen_size_y){ | |
198 screen_size_x = opt_screen_size_x; | |
199 screen_size_y = opt_screen_size_y; | |
200 if(!vidmode){ | |
5075 | 201 if(!screen_size_x) screen_size_x=SCREEN_SIZE_X; |
202 if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y; | |
203 if(screen_size_x<=8) screen_size_x*=sh->disp_w; | |
204 if(screen_size_y<=8) screen_size_y*=sh->disp_h; | |
5903 | 205 } |
5075 | 206 } else { |
207 // check source format aspect, calculate prescale ::atmos | |
208 screen_size_x=sh->disp_w; | |
209 screen_size_y=sh->disp_h; | |
5903 | 210 if(screen_size_xy>0){ |
211 if(screen_size_xy<=8){ | |
212 // -xy means x+y scale | |
213 screen_size_x*=screen_size_xy; | |
214 screen_size_y*=screen_size_xy; | |
215 } else { | |
216 // -xy means forced width while keeping correct aspect | |
217 screen_size_x=screen_size_xy; | |
218 screen_size_y=screen_size_xy*sh->disp_h/sh->disp_w; | |
219 } | |
220 } | |
5075 | 221 if(sh->aspect>0.01){ |
5903 | 222 int w; |
5075 | 223 mp_msg(MSGT_CPLAYER,MSGL_INFO,"Movie-Aspect is %.2f:1 - prescaling to correct movie aspect.\n", |
224 sh->aspect); | |
5903 | 225 w=(int)((float)screen_size_y*sh->aspect); w+=w%2; // round |
226 // we don't like horizontal downscale || user forced width: | |
227 if(w<screen_size_x || screen_size_xy>8){ | |
228 screen_size_y=(int)((float)screen_size_x*(1.0/sh->aspect)); | |
5075 | 229 screen_size_y+=screen_size_y%2; // round |
5903 | 230 } else screen_size_x=w; // keep new width |
5075 | 231 } else { |
232 mp_msg(MSGT_CPLAYER,MSGL_INFO,"Movie-Aspect is undefined - no prescaling applied.\n"); | |
233 } | |
234 } | |
235 | |
236 // Time to config libvo! | |
237 mp_msg(MSGT_CPLAYER,MSGL_V,"video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", | |
238 sh->disp_w,sh->disp_h, | |
239 screen_size_x,screen_size_y, | |
240 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), | |
241 "MPlayer",out_fmt); | |
242 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5483
diff
changeset
|
243 // memset(&vtune,0,sizeof(vo_tune_info_t)); |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5483
diff
changeset
|
244 if(vf->config(vf,sh->disp_w,sh->disp_h, |
5075 | 245 screen_size_x,screen_size_y, |
246 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5483
diff
changeset
|
247 out_fmt)==0){ |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5483
diff
changeset
|
248 // "MPlayer",out_fmt,&vtune)){ |
5925
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5903
diff
changeset
|
249 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_CannotInitVO); |
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5903
diff
changeset
|
250 sh->vf_inited=-1; |
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5903
diff
changeset
|
251 return 0; |
5075 | 252 } |
253 | |
5925
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5903
diff
changeset
|
254 sh->vf_inited=1; |
4878 | 255 return 1; |
256 } | |
257 | |
258 // mp_imgtype: buffering type, see mp_image.h | |
259 // mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h | |
260 // returns NULL or allocated mp_image_t* | |
261 // Note: buffer allocation may be moved to mpcodecs_config_vo() later... | |
262 mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h){ | |
6234
af0b011c9440
setting mpi's w/h to disp_w/h. it fixes mpeg1 crash when height%16!=0
arpi
parents:
6138
diff
changeset
|
263 mp_image_t* mpi=vf_get_image(sh->vfilter,sh->codec->outfmt[sh->outfmtidx],mp_imgtype,mp_imgflag,w,h); |
af0b011c9440
setting mpi's w/h to disp_w/h. it fixes mpeg1 crash when height%16!=0
arpi
parents:
6138
diff
changeset
|
264 mpi->x=mpi->y=0; |
af0b011c9440
setting mpi's w/h to disp_w/h. it fixes mpeg1 crash when height%16!=0
arpi
parents:
6138
diff
changeset
|
265 mpi->w=sh->disp_w; |
af0b011c9440
setting mpi's w/h to disp_w/h. it fixes mpeg1 crash when height%16!=0
arpi
parents:
6138
diff
changeset
|
266 mpi->h=sh->disp_h; |
af0b011c9440
setting mpi's w/h to disp_w/h. it fixes mpeg1 crash when height%16!=0
arpi
parents:
6138
diff
changeset
|
267 return mpi; |
4878 | 268 } |
269 |