Mercurial > mplayer.hg
annotate libmpcodecs/dec_video.c @ 8051:1b0d3175ef5f
removed dummy config(), query_format()
author | arpi |
---|---|
date | Sat, 02 Nov 2002 17:43:42 +0000 |
parents | b9da278e4c92 |
children | 9fc45fe0d444 |
rev | line source |
---|---|
2775 | 1 |
2 #include "config.h" | |
1294 | 3 |
4 #include <stdio.h> | |
2775 | 5 #ifdef HAVE_MALLOC_H |
6 #include <malloc.h> | |
7 #endif | |
1294 | 8 #include <stdlib.h> |
1430 | 9 #include <unistd.h> |
1294 | 10 |
1567 | 11 #include "mp_msg.h" |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
12 #include "help_mp.h" |
1294 | 13 |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1309
diff
changeset
|
14 #include "linux/timer.h" |
1496 | 15 #include "linux/shmem.h" |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1309
diff
changeset
|
16 |
1294 | 17 #include "stream.h" |
18 #include "demuxer.h" | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
19 #include "parse_es.h" |
1294 | 20 |
21 #include "codec-cfg.h" | |
22 | |
23 #include "libvo/video_out.h" | |
24 | |
4188 | 25 #include "stheader.h" |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
26 #include "vd.h" |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5328
diff
changeset
|
27 #include "vf.h" |
4188 | 28 |
2563 | 29 #include "dec_video.h" |
30 | |
31 // =================================================================== | |
32 | |
33 extern double video_time_usage; | |
34 extern double vout_time_usage; | |
35 | |
2184 | 36 #include "postproc/postprocess.h" |
37 | |
3144 | 38 #include "cpudetect.h" |
39 | |
2563 | 40 int divx_quality=0; |
1294 | 41 |
5180 | 42 vd_functions_t* mpvdec=NULL; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
43 |
1429 | 44 int get_video_quality_max(sh_video_t *sh_video){ |
5519 | 45 vf_instance_t* vf=sh_video->vfilter; |
46 if(vf){ | |
47 int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL); | |
48 if(ret>0){ | |
6989 | 49 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingExternalPP,ret); |
5519 | 50 return ret; |
51 } | |
52 } | |
4957 | 53 if(mpvdec){ |
4967 | 54 int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL); |
5519 | 55 if(ret>0){ |
6989 | 56 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingCodecPP,ret); |
5519 | 57 return ret; |
58 } | |
4957 | 59 } |
6138
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5984
diff
changeset
|
60 // mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Sorry, postprocessing is not available\n"); |
5519 | 61 return 0; |
1429 | 62 } |
63 | |
64 void set_video_quality(sh_video_t *sh_video,int quality){ | |
5519 | 65 vf_instance_t* vf=sh_video->vfilter; |
66 if(vf){ | |
67 int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
68 if(ret==CONTROL_TRUE) return; // success | |
69 } | |
4957 | 70 if(mpvdec) |
71 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
1429 | 72 } |
73 | |
4395 | 74 int set_video_colors(sh_video_t *sh_video,char *item,int value) |
75 { | |
6780 | 76 vf_instance_t* vf=sh_video->vfilter; |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
77 vf_equalizer_t data; |
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
78 |
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
79 data.item = item; |
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
80 data.value = value; |
6786 | 81 |
82 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set video colors %s=%d \n", item, value); | |
6785 | 83 if (vf) |
84 { | |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
85 int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data); |
6785 | 86 if (ret == CONTROL_TRUE) |
87 return(1); | |
88 } | |
6780 | 89 /* try software control */ |
6800 | 90 if(mpvdec) |
91 if( mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER, item, (int *)value) | |
92 == CONTROL_OK) return 1; | |
6989 | 93 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_VideoAttributeNotSupportedByVO_VD,item); |
6780 | 94 return 0; |
95 } | |
96 | |
97 int get_video_colors(sh_video_t *sh_video,char *item,int *value) | |
98 { | |
99 vf_instance_t* vf=sh_video->vfilter; | |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
100 vf_equalizer_t data; |
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
101 |
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
102 data.item = item; |
6786 | 103 |
104 mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item); | |
105 if (vf) | |
106 { | |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
107 int ret = vf->control(vf, VFCTRL_GET_EQUALIZER, &data); |
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
108 if (ret == CONTROL_TRUE){ |
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
109 *value = data.value; |
6786 | 110 return(1); |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6800
diff
changeset
|
111 } |
6786 | 112 } |
6780 | 113 /* try software control */ |
114 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value); | |
1429 | 115 return 0; |
116 } | |
1294 | 117 |
6887 | 118 int set_rectangle(sh_video_t *sh_video,int param,int value) |
119 { | |
120 vf_instance_t* vf=sh_video->vfilter; | |
121 int data[] = {param, value}; | |
122 | |
123 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set rectangle \n"); | |
124 if (vf) | |
125 { | |
126 int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data); | |
127 if (ret) | |
128 return(1); | |
129 } | |
130 return 0; | |
131 } | |
132 | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
133 void uninit_video(sh_video_t *sh_video){ |
1654 | 134 if(!sh_video->inited) return; |
7180
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
135 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_UninitVideoStr,sh_video->codec->drv); |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
136 mpvdec->uninit(sh_video); |
5737 | 137 vf_uninit_filter_chain(sh_video->vfilter); |
1654 | 138 sh_video->inited=0; |
139 } | |
140 | |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
141 void vfm_help(){ |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
142 int i; |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
143 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_AvailableVideoFm); |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
144 mp_msg(MSGT_DECVIDEO,MSGL_INFO," vfm: info: (comment)\n"); |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
145 for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
146 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"%8s %s (%s)\n", |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
147 mpcodecs_vd_drivers[i]->info->short_name, |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
148 mpcodecs_vd_drivers[i]->info->name, |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
149 mpcodecs_vd_drivers[i]->info->comment); |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
150 } |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
151 |
7180
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
152 int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status){ |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
153 unsigned int orig_fourcc=sh_video->bih?sh_video->bih->biCompression:0; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
154 sh_video->codec=NULL; |
5925
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5871
diff
changeset
|
155 sh_video->vf_inited=0; |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
156 |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
157 while(1){ |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
158 int i; |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
159 // restore original fourcc: |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
160 if(sh_video->bih) sh_video->bih->biCompression=orig_fourcc; |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
161 if(!(sh_video->codec=find_codec(sh_video->format, |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
162 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL, |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
163 sh_video->codec,0) )) break; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
164 // ok we found one codec |
5328
014ddf03476d
check and set codec selection - impossible to do it at find_codec
arpi
parents:
5266
diff
changeset
|
165 if(sh_video->codec->flags&CODECS_FLAG_SELECTED) continue; // already tried & failed |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
166 if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc |
7180
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
167 if(vfm && strcmp(sh_video->codec->drv,vfm)) continue; // vfm doesn't match |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
168 if(sh_video->codec->status<status) continue; // too unstable |
5328
014ddf03476d
check and set codec selection - impossible to do it at find_codec
arpi
parents:
5266
diff
changeset
|
169 sh_video->codec->flags|=CODECS_FLAG_SELECTED; // tagging it |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
170 // ok, it matches all rules, let's find the driver! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
171 for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) |
7180
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
172 // if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break; |
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
173 if(!strcmp(mpcodecs_vd_drivers[i]->info->short_name,sh_video->codec->drv)) break; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
174 mpvdec=mpcodecs_vd_drivers[i]; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
175 if(!mpvdec){ // driver not available (==compiled in) |
7180
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
176 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_VideoCodecFamilyNotAvailableStr, |
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
177 sh_video->codec->name, sh_video->codec->drv); |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
178 continue; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
179 } |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
180 // it's available, let's try to init! |
6566 | 181 if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){ |
182 // align width/height to n*16 | |
183 // FIXME: save orig w/h, and restore if codec init failed! | |
184 if(sh_video->bih){ | |
185 sh_video->disp_w=sh_video->bih->biWidth=(sh_video->bih->biWidth+15)&(~15); | |
186 sh_video->disp_h=sh_video->bih->biHeight=(sh_video->bih->biHeight+15)&(~15); | |
187 } else { | |
188 sh_video->disp_w=(sh_video->disp_w+15)&(~15); | |
189 sh_video->disp_h=(sh_video->disp_h+15)&(~15); | |
190 } | |
191 } | |
192 // init() | |
6989 | 193 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_OpeningVideoDecoder,mpvdec->info->short_name,mpvdec->info->name); |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
194 if(!mpvdec->init(sh_video)){ |
6989 | 195 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_VDecoderInitFailed); |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
196 continue; // try next... |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
197 } |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
198 // Yeah! We got it! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
199 sh_video->inited=1; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
200 return 1; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
201 } |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
202 return 0; |
1294 | 203 } |
204 | |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
205 int init_best_video_codec(sh_video_t *sh_video,char** video_codec_list,char** video_fm_list){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
206 char* vc_l_default[2]={"",(char*)NULL}; |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
207 // hack: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
208 if(!video_codec_list) video_codec_list=vc_l_default; |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
209 // Go through the codec.conf and find the best codec... |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
210 sh_video->inited=0; |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
211 codecs_reset_selection(0); |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
212 while(!sh_video->inited && *video_codec_list){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
213 char* video_codec=*(video_codec_list++); |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
214 if(video_codec[0]){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
215 if(video_codec[0]=='-'){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
216 // disable this codec: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
217 select_codec(video_codec+1,0); |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
218 } else { |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
219 // forced codec by name: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
220 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_ForcedVideoCodec,video_codec); |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
221 init_video(sh_video,video_codec,NULL,-1); |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
222 } |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
223 } else { |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
224 int status; |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
225 // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING. |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
226 if(video_fm_list){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
227 char** fmlist=video_fm_list; |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
228 // try first the preferred codec families: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
229 while(!sh_video->inited && *fmlist){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
230 char* video_fm=*(fmlist++); |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
231 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_TryForceVideoFmtStr,video_fm); |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
232 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
233 if(init_video(sh_video,NULL,video_fm,status)) break; |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
234 } |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
235 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
236 if(!sh_video->inited) |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
237 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
238 if(init_video(sh_video,NULL,NULL,status)) break; |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
239 } |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
240 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
241 |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
242 if(!sh_video->inited){ |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
243 mp_msg(MSGT_DECVIDEO,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf")); |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
244 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format); |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
245 return 0; // failed |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
246 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
247 |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
248 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"Selected video codec: [%s] vfm:%s (%s)\n", |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
249 sh_video->codec->name,sh_video->codec->drv,sh_video->codec->info); |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
250 return 1; // success |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
251 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
252 |
5224 | 253 extern int vo_directrendering; |
4515 | 254 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5328
diff
changeset
|
255 int decode_video(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ |
7210
09c8c9cca9e4
100l... sh->vcodec may be changed by mpvdec->decode()
arpi
parents:
7191
diff
changeset
|
256 vf_instance_t* vf; |
4898 | 257 mp_image_t *mpi=NULL; |
1360 | 258 unsigned int t=GetTimer(); |
259 unsigned int t2; | |
4834 | 260 double tt; |
7368 | 261 int ret; |
1360 | 262 |
5266
413e450da31c
try to uncomment this line - very funny effect (skipping I frames)
arpi
parents:
5224
diff
changeset
|
263 //if(!(sh_video->ds->flags&1) || sh_video->ds->pack_no<5) |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
264 mpi=mpvdec->decode(sh_video, start, in_size, drop_frame); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
265 |
1294 | 266 //------------------------ frame decoded. -------------------- |
267 | |
3160 | 268 #ifdef ARCH_X86 |
6780 | 269 // some codecs are broken, and doesn't restore MMX state :( |
1367 | 270 // it happens usually with broken/damaged files. |
3144 | 271 if(gCpuCaps.has3DNow){ |
272 __asm __volatile ("femms\n\t":::"memory"); | |
273 } | |
274 else if(gCpuCaps.hasMMX){ | |
275 __asm __volatile ("emms\n\t":::"memory"); | |
276 } | |
3160 | 277 #endif |
1367 | 278 |
4834 | 279 t2=GetTimer();t=t2-t; |
280 tt = t*0.000001f; | |
281 video_time_usage+=tt; | |
4898 | 282 |
5643 | 283 if(!mpi || drop_frame) return 0; // error / skipped frame |
5040 | 284 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5328
diff
changeset
|
285 //vo_draw_image(video_out,mpi); |
7210
09c8c9cca9e4
100l... sh->vcodec may be changed by mpvdec->decode()
arpi
parents:
7191
diff
changeset
|
286 vf=sh_video->vfilter; |
7368 | 287 ret = vf->put_image(vf,mpi); // apply video filters and call the leaf vo/ve |
288 if(ret>0) vf->control(vf,VFCTRL_DRAW_OSD,NULL); | |
4898 | 289 |
4834 | 290 t2=GetTimer()-t2; |
291 tt=t2*0.000001f; | |
292 vout_time_usage+=tt; | |
1360 | 293 |
7368 | 294 return ret; |
1294 | 295 } |