Mercurial > mplayer.hg
annotate libmpcodecs/dec_video.c @ 22601:ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
author | diego |
---|---|
date | Thu, 15 Mar 2007 17:51:32 +0000 |
parents | 4faee1254928 |
children | 09cdda17770f |
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 |
9380 | 14 #include "osdep/timer.h" |
15 #include "osdep/shmem.h" | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1309
diff
changeset
|
16 |
22599
4faee1254928
Add explicit location for headers from the stream/ directory.
diego
parents:
22498
diff
changeset
|
17 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22599
diff
changeset
|
18 #include "libmpdemux/demuxer.h" |
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22599
diff
changeset
|
19 #include "libmpdemux/parse_es.h" |
1294 | 20 |
21 #include "codec-cfg.h" | |
22 | |
23 #include "libvo/video_out.h" | |
24 | |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22599
diff
changeset
|
25 #include "libmpdemux/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 | |
8152 | 31 #ifdef DYNAMIC_PLUGINS |
32 #include <dlfcn.h> | |
33 #endif | |
34 | |
2563 | 35 // =================================================================== |
36 | |
37 extern double video_time_usage; | |
38 extern double vout_time_usage; | |
39 | |
3144 | 40 #include "cpudetect.h" |
41 | |
22086
8bf15e2ca61e
Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents:
22012
diff
changeset
|
42 int field_dominance=-1; |
8bf15e2ca61e
Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents:
22012
diff
changeset
|
43 |
2563 | 44 int divx_quality=0; |
1294 | 45 |
5180 | 46 vd_functions_t* mpvdec=NULL; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
47 |
1429 | 48 int get_video_quality_max(sh_video_t *sh_video){ |
5519 | 49 vf_instance_t* vf=sh_video->vfilter; |
50 if(vf){ | |
51 int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL); | |
52 if(ret>0){ | |
6989 | 53 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingExternalPP,ret); |
5519 | 54 return ret; |
55 } | |
56 } | |
4957 | 57 if(mpvdec){ |
4967 | 58 int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL); |
5519 | 59 if(ret>0){ |
6989 | 60 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingCodecPP,ret); |
5519 | 61 return ret; |
62 } | |
4957 | 63 } |
6138
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5984
diff
changeset
|
64 // mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Sorry, postprocessing is not available\n"); |
5519 | 65 return 0; |
1429 | 66 } |
67 | |
68 void set_video_quality(sh_video_t *sh_video,int quality){ | |
5519 | 69 vf_instance_t* vf=sh_video->vfilter; |
70 if(vf){ | |
71 int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
72 if(ret==CONTROL_TRUE) return; // success | |
73 } | |
4957 | 74 if(mpvdec) |
75 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
1429 | 76 } |
77 | |
4395 | 78 int set_video_colors(sh_video_t *sh_video,char *item,int value) |
79 { | |
6780 | 80 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
|
81 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
|
82 |
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
|
83 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
|
84 data.value = value; |
6786 | 85 |
86 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set video colors %s=%d \n", item, value); | |
6785 | 87 if (vf) |
88 { | |
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
|
89 int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data); |
6785 | 90 if (ret == CONTROL_TRUE) |
91 return(1); | |
92 } | |
6780 | 93 /* try software control */ |
6800 | 94 if(mpvdec) |
95 if( mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER, item, (int *)value) | |
96 == CONTROL_OK) return 1; | |
18190 | 97 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_VideoAttributeNotSupportedByVO_VD,item); |
6780 | 98 return 0; |
99 } | |
100 | |
101 int get_video_colors(sh_video_t *sh_video,char *item,int *value) | |
102 { | |
103 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
|
104 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
|
105 |
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
|
106 data.item = item; |
6786 | 107 |
108 mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item); | |
109 if (vf) | |
110 { | |
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 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
|
112 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
|
113 *value = data.value; |
6786 | 114 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
|
115 } |
6786 | 116 } |
6780 | 117 /* try software control */ |
118 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value); | |
1429 | 119 return 0; |
120 } | |
1294 | 121 |
6887 | 122 int set_rectangle(sh_video_t *sh_video,int param,int value) |
123 { | |
124 vf_instance_t* vf=sh_video->vfilter; | |
125 int data[] = {param, value}; | |
126 | |
127 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set rectangle \n"); | |
128 if (vf) | |
129 { | |
130 int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data); | |
131 if (ret) | |
132 return(1); | |
133 } | |
134 return 0; | |
135 } | |
136 | |
11977
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
10683
diff
changeset
|
137 void resync_video_stream(sh_video_t *sh_video) |
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
10683
diff
changeset
|
138 { |
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
10683
diff
changeset
|
139 if(mpvdec) mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL); |
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
10683
diff
changeset
|
140 } |
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
10683
diff
changeset
|
141 |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
142 int get_current_video_decoder_lag(sh_video_t *sh_video) |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
143 { |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
144 int ret; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
145 |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
146 if (!mpvdec) |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
147 return -1; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
148 ret = mpvdec->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL); |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
149 if (ret >= 10) |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
150 return ret-10; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
151 return -1; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
152 } |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
153 |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
154 void uninit_video(sh_video_t *sh_video){ |
1654 | 155 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
|
156 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
|
157 mpvdec->uninit(sh_video); |
8152 | 158 #ifdef DYNAMIC_PLUGINS |
159 if (sh_video->dec_handle) | |
160 dlclose(sh_video->dec_handle); | |
161 #endif | |
5737 | 162 vf_uninit_filter_chain(sh_video->vfilter); |
1654 | 163 sh_video->inited=0; |
164 } | |
165 | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16793
diff
changeset
|
166 void vfm_help(void){ |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
167 int i; |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
168 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_AvailableVideoFm); |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
18190
diff
changeset
|
169 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_DRIVERS\n"); |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 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
|
174 mpcodecs_vd_drivers[i]->info->name, |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
175 mpcodecs_vd_drivers[i]->info->comment); |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
176 } |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
177 |
7180
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
178 int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status){ |
16325 | 179 int force = 0; |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
180 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
|
181 sh_video->codec=NULL; |
5925
3f17793b2cea
setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents:
5871
diff
changeset
|
182 sh_video->vf_inited=0; |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
183 if (codecname && codecname[0] == '+') { |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
184 codecname = &codecname[1]; |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
185 force = 1; |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
186 } |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
187 |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
188 while(1){ |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
189 int i; |
22012
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
190 int orig_w, orig_h; |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
191 // restore original fourcc: |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
192 if(sh_video->bih) sh_video->bih->biCompression=orig_fourcc; |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
193 if(!(sh_video->codec=find_video_codec(sh_video->format, |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
194 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL, |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
195 sh_video->codec,force) )) break; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
196 // ok we found one codec |
5328
014ddf03476d
check and set codec selection - impossible to do it at find_codec
arpi
parents:
5266
diff
changeset
|
197 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
|
198 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
|
199 if(vfm && strcmp(sh_video->codec->drv,vfm)) continue; // vfm doesn't match |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
200 if(!force && 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
|
201 sh_video->codec->flags|=CODECS_FLAG_SELECTED; // tagging it |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
202 // ok, it matches all rules, let's find the driver! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
203 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
|
204 // 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
|
205 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
|
206 mpvdec=mpcodecs_vd_drivers[i]; |
8152 | 207 #ifdef DYNAMIC_PLUGINS |
208 if (!mpvdec) | |
209 { | |
210 /* try to open shared decoder plugin */ | |
211 int buf_len; | |
212 char *buf; | |
213 vd_functions_t *funcs_sym; | |
214 vd_info_t *info_sym; | |
215 | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9426
diff
changeset
|
216 buf_len = strlen(MPLAYER_LIBDIR)+strlen(sh_video->codec->drv)+16; |
8152 | 217 buf = malloc(buf_len); |
218 if (!buf) | |
219 break; | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9426
diff
changeset
|
220 snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", MPLAYER_LIBDIR, sh_video->codec->drv); |
8152 | 221 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf); |
222 sh_video->dec_handle = dlopen(buf, RTLD_LAZY); | |
223 if (!sh_video->dec_handle) | |
224 break; | |
225 snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv); | |
226 funcs_sym = dlsym(sh_video->dec_handle, buf); | |
227 if (!funcs_sym || !funcs_sym->info || !funcs_sym->init || | |
228 !funcs_sym->uninit || !funcs_sym->control || !funcs_sym->decode) | |
229 break; | |
230 info_sym = funcs_sym->info; | |
231 if (strcmp(info_sym->short_name, sh_video->codec->drv)) | |
232 break; | |
233 free(buf); | |
234 mpvdec = funcs_sym; | |
235 mp_msg(MSGT_DECVIDEO, MSGL_V, "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n", | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9426
diff
changeset
|
236 MPLAYER_LIBDIR, sh_video->codec->drv); |
8152 | 237 } |
238 #endif | |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
239 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
|
240 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
|
241 sh_video->codec->name, sh_video->codec->drv); |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
242 continue; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
243 } |
22012
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
244 orig_w = sh_video->bih ? sh_video->bih->biWidth : sh_video->disp_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
245 orig_h = sh_video->bih ? sh_video->bih->biHeight : sh_video->disp_h; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
246 sh_video->disp_w = orig_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
247 sh_video->disp_h = orig_h; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
248 // it's available, let's try to init! |
6566 | 249 if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){ |
250 // align width/height to n*16 | |
251 sh_video->disp_w=(sh_video->disp_w+15)&(~15); | |
252 sh_video->disp_h=(sh_video->disp_h+15)&(~15); | |
22012
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
253 } |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
254 if (sh_video->bih) { |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
255 sh_video->bih->biWidth = sh_video->disp_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
256 sh_video->bih->biHeight = sh_video->disp_h; |
6566 | 257 } |
258 // init() | |
6989 | 259 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_OpeningVideoDecoder,mpvdec->info->short_name,mpvdec->info->name); |
22405
1b1761cbba3b
Discard earlier failure in building filter chain when trying a new codec.
reimar
parents:
22086
diff
changeset
|
260 // clear vf init error, it is no longer relevant |
1b1761cbba3b
Discard earlier failure in building filter chain when trying a new codec.
reimar
parents:
22086
diff
changeset
|
261 if (sh_video->vf_inited < 0) |
1b1761cbba3b
Discard earlier failure in building filter chain when trying a new codec.
reimar
parents:
22086
diff
changeset
|
262 sh_video->vf_inited = 0; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
263 if(!mpvdec->init(sh_video)){ |
6989 | 264 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_VDecoderInitFailed); |
22012
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
265 sh_video->disp_w=orig_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
266 sh_video->disp_h=orig_h; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
267 if (sh_video->bih) { |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
268 sh_video->bih->biWidth = sh_video->disp_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
269 sh_video->bih->biHeight = sh_video->disp_h; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
270 } |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
271 continue; // try next... |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
272 } |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
273 // Yeah! We got it! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
274 sh_video->inited=1; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
275 return 1; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
276 } |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
277 return 0; |
1294 | 278 } |
279 | |
18889
e60c8c7399d2
get_path as const, patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18237
diff
changeset
|
280 extern char *get_path(const char *filename); |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
281 |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
282 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
|
283 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
|
284 // hack: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
285 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
|
286 // 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
|
287 sh_video->inited=0; |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
288 codecs_reset_selection(0); |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
289 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
|
290 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
|
291 if(video_codec[0]){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
292 if(video_codec[0]=='-'){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
293 // disable this codec: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
294 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
|
295 } else { |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
296 // forced codec by name: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
297 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
|
298 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
|
299 } |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
300 } else { |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
301 int status; |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
302 // 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
|
303 if(video_fm_list){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
304 char** fmlist=video_fm_list; |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
305 // 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
|
306 while(!sh_video->inited && *fmlist){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
307 char* video_fm=*(fmlist++); |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
308 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
|
309 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
|
310 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
|
311 } |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
312 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
313 if(!sh_video->inited) |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
314 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
|
315 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
|
316 } |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
317 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
318 |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
319 if(!sh_video->inited){ |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
320 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format); |
10683 | 321 mp_msg(MSGT_DECAUDIO,MSGL_HINT, MSGTR_RTFMCodecs); |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
322 return 0; // failed |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
323 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
324 |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16325
diff
changeset
|
325 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_SelectedVideoCodec, |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
326 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
|
327 return 1; // success |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
328 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
329 |
5224 | 330 extern int vo_directrendering; |
4515 | 331 |
22497 | 332 void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size, |
333 int drop_frame, double pts) | |
334 { | |
335 mp_image_t *mpi = NULL; | |
336 unsigned int t = GetTimer(); | |
337 unsigned int t2; | |
338 double tt; | |
1360 | 339 |
22498
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
340 if (correct_pts && pts != MP_NOPTS_VALUE) { |
22497 | 341 int delay = get_current_video_decoder_lag(sh_video); |
342 if (delay >= 0) { | |
343 if (delay > sh_video->num_buffered_pts) | |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
344 #if 0 |
22497 | 345 // this is disabled because vd_ffmpeg reports the same lag |
346 // after seek even when there are no buffered frames, | |
347 // leading to incorrect error messages | |
348 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n"); | |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
349 #else |
22497 | 350 ; |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
351 #endif |
22497 | 352 else |
353 sh_video->num_buffered_pts = delay; | |
354 } | |
355 if (sh_video->num_buffered_pts == | |
356 sizeof(sh_video->buffered_pts)/sizeof(double)) | |
357 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n"); | |
358 else { | |
359 int i, j; | |
360 for (i = 0; i < sh_video->num_buffered_pts; i++) | |
361 if (sh_video->buffered_pts[i] < pts) | |
362 break; | |
363 for (j = sh_video->num_buffered_pts; j > i; j--) | |
364 sh_video->buffered_pts[j] = sh_video->buffered_pts[j-1]; | |
365 sh_video->buffered_pts[i] = pts; | |
366 sh_video->num_buffered_pts++; | |
367 } | |
368 } | |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
369 |
22497 | 370 mpi = mpvdec->decode(sh_video, start, in_size, drop_frame); |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
371 |
22497 | 372 //------------------------ frame decoded. -------------------- |
1294 | 373 |
19130
39d8fd7e7543
old 10l: do not try to compile mmx code if we do not have mmx
rfelker
parents:
18917
diff
changeset
|
374 #ifdef HAVE_MMX |
22497 | 375 // some codecs are broken, and doesn't restore MMX state :( |
376 // it happens usually with broken/damaged files. | |
377 if (gCpuCaps.has3DNow) { | |
3144 | 378 __asm __volatile ("femms\n\t":::"memory"); |
22497 | 379 } |
380 else if (gCpuCaps.hasMMX) { | |
3144 | 381 __asm __volatile ("emms\n\t":::"memory"); |
22497 | 382 } |
3160 | 383 #endif |
1367 | 384 |
22497 | 385 t2 = GetTimer(); t = t2-t; |
386 tt = t*0.000001f; | |
387 video_time_usage += tt; | |
4898 | 388 |
22497 | 389 if (!mpi || drop_frame) |
390 return NULL; // error / skipped frame | |
5040 | 391 |
22497 | 392 if (field_dominance == 0) |
393 mpi->fields |= MP_IMGFIELD_TOP_FIRST; | |
394 else if (field_dominance == 1) | |
395 mpi->fields &= ~MP_IMGFIELD_TOP_FIRST; | |
22086
8bf15e2ca61e
Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents:
22012
diff
changeset
|
396 |
22497 | 397 if (correct_pts) { |
22498
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
398 if (sh_video->num_buffered_pts) { |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
399 sh_video->num_buffered_pts--; |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
400 sh_video->pts = sh_video->buffered_pts[sh_video->num_buffered_pts]; |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
401 } |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
402 else { |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
403 mp_msg(MSGT_CPLAYER, MSGL_ERR, "No pts value from demuxer to " |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
404 "use for frame!\n"); |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
405 sh_video->pts = MP_NOPTS_VALUE; |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
406 } |
22497 | 407 } |
408 return mpi; | |
20902
bfb6eacd9c4a
Update OSD contents only after the correct values for the frame are known.
uau
parents:
19521
diff
changeset
|
409 } |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
410 |
22497 | 411 int filter_video(sh_video_t *sh_video, void *frame, double pts) |
412 { | |
413 mp_image_t *mpi = frame; | |
414 unsigned int t2 = GetTimer(); | |
415 vf_instance_t *vf = sh_video->vfilter; | |
416 // apply video filters and call the leaf vo/ve | |
417 int ret = vf->put_image(vf, mpi, pts); | |
418 if (ret > 0) { | |
419 vf->control(vf, VFCTRL_DRAW_OSD, NULL); | |
19521 | 420 #ifdef USE_ASS |
22497 | 421 vf->control(vf, VFCTRL_DRAW_EOSD, NULL); |
19521 | 422 #endif |
22497 | 423 } |
4898 | 424 |
22497 | 425 t2 = GetTimer()-t2; |
20902
bfb6eacd9c4a
Update OSD contents only after the correct values for the frame are known.
uau
parents:
19521
diff
changeset
|
426 vout_time_usage += t2*0.000001; |
1360 | 427 |
22497 | 428 return ret; |
1294 | 429 } |