Mercurial > mplayer.hg
annotate libmpcodecs/dec_video.c @ 30195:775e8b3e3d0c
sync with en/mplayer.1 r30197
author | jrash |
---|---|
date | Fri, 08 Jan 2010 11:25:18 +0000 |
parents | 8ee2eb34a851 |
children | 8339bca8e4b4 |
rev | line source |
---|---|
2775 | 1 |
2 #include "config.h" | |
1294 | 3 |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
1430 | 6 #include <unistd.h> |
1294 | 7 |
1567 | 8 #include "mp_msg.h" |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
9 #include "help_mp.h" |
1294 | 10 |
9380 | 11 #include "osdep/timer.h" |
12 #include "osdep/shmem.h" | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1309
diff
changeset
|
13 |
22599
4faee1254928
Add explicit location for headers from the stream/ directory.
diego
parents:
22498
diff
changeset
|
14 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22599
diff
changeset
|
15 #include "libmpdemux/demuxer.h" |
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22599
diff
changeset
|
16 #include "libmpdemux/parse_es.h" |
1294 | 17 |
18 #include "codec-cfg.h" | |
19 | |
20 #include "libvo/video_out.h" | |
21 | |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22599
diff
changeset
|
22 #include "libmpdemux/stheader.h" |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
23 #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
|
24 #include "vf.h" |
4188 | 25 |
2563 | 26 #include "dec_video.h" |
27 | |
27397
d47744b95b78
Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents:
27341
diff
changeset
|
28 #ifdef CONFIG_DYNAMIC_PLUGINS |
8152 | 29 #include <dlfcn.h> |
30 #endif | |
31 | |
2563 | 32 // =================================================================== |
33 | |
34 extern double video_time_usage; | |
35 extern double vout_time_usage; | |
36 | |
3144 | 37 #include "cpudetect.h" |
38 | |
22086
8bf15e2ca61e
Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents:
22012
diff
changeset
|
39 int field_dominance=-1; |
8bf15e2ca61e
Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents:
22012
diff
changeset
|
40 |
2563 | 41 int divx_quality=0; |
1294 | 42 |
5180 | 43 vd_functions_t* mpvdec=NULL; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
44 |
1429 | 45 int get_video_quality_max(sh_video_t *sh_video){ |
5519 | 46 vf_instance_t* vf=sh_video->vfilter; |
47 if(vf){ | |
48 int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL); | |
49 if(ret>0){ | |
6989 | 50 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingExternalPP,ret); |
5519 | 51 return ret; |
52 } | |
53 } | |
4957 | 54 if(mpvdec){ |
4967 | 55 int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL); |
5519 | 56 if(ret>0){ |
6989 | 57 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingCodecPP,ret); |
5519 | 58 return ret; |
59 } | |
4957 | 60 } |
6138
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5984
diff
changeset
|
61 // mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Sorry, postprocessing is not available\n"); |
5519 | 62 return 0; |
1429 | 63 } |
64 | |
65 void set_video_quality(sh_video_t *sh_video,int quality){ | |
5519 | 66 vf_instance_t* vf=sh_video->vfilter; |
67 if(vf){ | |
68 int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
69 if(ret==CONTROL_TRUE) return; // success | |
70 } | |
4957 | 71 if(mpvdec) |
72 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
1429 | 73 } |
74 | |
25224 | 75 int set_video_colors(sh_video_t *sh_video,const char *item,int value) |
4395 | 76 { |
6780 | 77 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
|
78 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
|
79 |
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.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
|
81 data.value = value; |
6786 | 82 |
83 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set video colors %s=%d \n", item, value); | |
6785 | 84 if (vf) |
85 { | |
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
|
86 int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data); |
6785 | 87 if (ret == CONTROL_TRUE) |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
25962
diff
changeset
|
88 return 1; |
6785 | 89 } |
6780 | 90 /* try software control */ |
6800 | 91 if(mpvdec) |
92 if( mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER, item, (int *)value) | |
93 == CONTROL_OK) return 1; | |
18190 | 94 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_VideoAttributeNotSupportedByVO_VD,item); |
6780 | 95 return 0; |
96 } | |
97 | |
25224 | 98 int get_video_colors(sh_video_t *sh_video,const char *item,int *value) |
6780 | 99 { |
100 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
|
101 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
|
102 |
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
|
103 data.item = item; |
6786 | 104 |
105 mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item); | |
106 if (vf) | |
107 { | |
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
|
108 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
|
109 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
|
110 *value = data.value; |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
25962
diff
changeset
|
111 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
|
112 } |
6786 | 113 } |
6780 | 114 /* try software control */ |
115 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value); | |
1429 | 116 return 0; |
117 } | |
1294 | 118 |
6887 | 119 int set_rectangle(sh_video_t *sh_video,int param,int value) |
120 { | |
121 vf_instance_t* vf=sh_video->vfilter; | |
122 int data[] = {param, value}; | |
123 | |
124 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set rectangle \n"); | |
125 if (vf) | |
126 { | |
127 int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data); | |
128 if (ret) | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
25962
diff
changeset
|
129 return 1; |
6887 | 130 } |
131 return 0; | |
132 } | |
133 | |
11977
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
10683
diff
changeset
|
134 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
|
135 { |
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
10683
diff
changeset
|
136 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
|
137 } |
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
10683
diff
changeset
|
138 |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
139 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
|
140 { |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
141 int ret; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
142 |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
143 if (!mpvdec) |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
144 return -1; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
145 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
|
146 if (ret >= 10) |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
147 return ret-10; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
148 return -1; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
149 } |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
150 |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
151 void uninit_video(sh_video_t *sh_video){ |
25962 | 152 if(!sh_video->initialized) return; |
7180
28677d779205
-afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents:
7124
diff
changeset
|
153 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
|
154 mpvdec->uninit(sh_video); |
27397
d47744b95b78
Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents:
27341
diff
changeset
|
155 #ifdef CONFIG_DYNAMIC_PLUGINS |
8152 | 156 if (sh_video->dec_handle) |
157 dlclose(sh_video->dec_handle); | |
158 #endif | |
5737 | 159 vf_uninit_filter_chain(sh_video->vfilter); |
25962 | 160 sh_video->initialized=0; |
1654 | 161 } |
162 | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16793
diff
changeset
|
163 void vfm_help(void){ |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
164 int i; |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 mpcodecs_vd_drivers[i]->info->name, |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
172 mpcodecs_vd_drivers[i]->info->comment); |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
173 } |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
174 |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
175 static int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status, |
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
176 stringset_t *selected){ |
16325 | 177 int force = 0; |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
178 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
|
179 sh_video->codec=NULL; |
25962 | 180 sh_video->vf_initialized=0; |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
181 if (codecname && codecname[0] == '+') { |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
182 codecname = &codecname[1]; |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
183 force = 1; |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
15789
diff
changeset
|
184 } |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
185 |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
186 while(1){ |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
187 int i; |
22012
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
188 int orig_w, orig_h; |
6230
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
189 // restore original fourcc: |
936aa617e829
restore original bih->biCompression if codec init failed
arpi
parents:
6138
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 sh_video->codec,force) )) break; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
194 // ok we found one codec |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
195 if(stringset_test(selected, sh_video->codec->name)) continue; // already tried & failed |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
196 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
|
197 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
|
198 if(!force && sh_video->codec->status<status) continue; // too unstable |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
199 stringset_add(selected, sh_video->codec->name); // tagging it |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
200 // ok, it matches all rules, let's find the driver! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
201 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
|
202 // 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
|
203 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
|
204 mpvdec=mpcodecs_vd_drivers[i]; |
27397
d47744b95b78
Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents:
27341
diff
changeset
|
205 #ifdef CONFIG_DYNAMIC_PLUGINS |
8152 | 206 if (!mpvdec) |
207 { | |
208 /* try to open shared decoder plugin */ | |
209 int buf_len; | |
210 char *buf; | |
211 vd_functions_t *funcs_sym; | |
212 vd_info_t *info_sym; | |
213 | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9426
diff
changeset
|
214 buf_len = strlen(MPLAYER_LIBDIR)+strlen(sh_video->codec->drv)+16; |
8152 | 215 buf = malloc(buf_len); |
216 if (!buf) | |
217 break; | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9426
diff
changeset
|
218 snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", MPLAYER_LIBDIR, sh_video->codec->drv); |
8152 | 219 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf); |
220 sh_video->dec_handle = dlopen(buf, RTLD_LAZY); | |
221 if (!sh_video->dec_handle) | |
222 break; | |
223 snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv); | |
224 funcs_sym = dlsym(sh_video->dec_handle, buf); | |
225 if (!funcs_sym || !funcs_sym->info || !funcs_sym->init || | |
226 !funcs_sym->uninit || !funcs_sym->control || !funcs_sym->decode) | |
227 break; | |
228 info_sym = funcs_sym->info; | |
229 if (strcmp(info_sym->short_name, sh_video->codec->drv)) | |
230 break; | |
231 free(buf); | |
232 mpvdec = funcs_sym; | |
233 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
|
234 MPLAYER_LIBDIR, sh_video->codec->drv); |
8152 | 235 } |
236 #endif | |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
237 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
|
238 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
|
239 sh_video->codec->name, sh_video->codec->drv); |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
240 continue; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
241 } |
22012
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
242 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
|
243 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
|
244 sh_video->disp_w = orig_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
245 sh_video->disp_h = orig_h; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
246 // it's available, let's try to init! |
6566 | 247 if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){ |
248 // align width/height to n*16 | |
249 sh_video->disp_w=(sh_video->disp_w+15)&(~15); | |
250 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
|
251 } |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
252 if (sh_video->bih) { |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
253 sh_video->bih->biWidth = sh_video->disp_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
254 sh_video->bih->biHeight = sh_video->disp_h; |
6566 | 255 } |
256 // init() | |
6989 | 257 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
|
258 // clear vf init error, it is no longer relevant |
25962 | 259 if (sh_video->vf_initialized < 0) |
260 sh_video->vf_initialized = 0; | |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
261 if(!mpvdec->init(sh_video)){ |
6989 | 262 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
|
263 sh_video->disp_w=orig_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
264 sh_video->disp_h=orig_h; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
265 if (sh_video->bih) { |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
266 sh_video->bih->biWidth = sh_video->disp_w; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
267 sh_video->bih->biHeight = sh_video->disp_h; |
213b5c14bba7
Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents:
20902
diff
changeset
|
268 } |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
269 continue; // try next... |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
270 } |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
271 // Yeah! We got it! |
25962 | 272 sh_video->initialized=1; |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
273 return 1; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
274 } |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
275 return 0; |
1294 | 276 } |
277 | |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
278 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
|
279 char* vc_l_default[2]={"",(char*)NULL}; |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
280 stringset_t selected; |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
281 // hack: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
282 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
|
283 // Go through the codec.conf and find the best codec... |
25962 | 284 sh_video->initialized=0; |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
285 stringset_init(&selected); |
25962 | 286 while(!sh_video->initialized && *video_codec_list){ |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
287 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
|
288 if(video_codec[0]){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
289 if(video_codec[0]=='-'){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
290 // disable this codec: |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
291 stringset_add(&selected, video_codec+1); |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
292 } else { |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
293 // forced codec by name: |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
294 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_ForcedVideoCodec,video_codec); |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
295 init_video(sh_video,video_codec,NULL,-1, &selected); |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
296 } |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
297 } else { |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
298 int status; |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
299 // 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
|
300 if(video_fm_list){ |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
301 char** fmlist=video_fm_list; |
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
302 // try first the preferred codec families: |
25962 | 303 while(!sh_video->initialized && *fmlist){ |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
304 char* video_fm=*(fmlist++); |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
305 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
|
306 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
307 if(init_video(sh_video,NULL,video_fm,status, &selected)) break; |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
308 } |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
309 } |
25962 | 310 if(!sh_video->initialized) |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
311 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
312 if(init_video(sh_video,NULL,NULL,status, &selected)) break; |
7506
c1cb94198e05
-vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents:
7502
diff
changeset
|
313 } |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
314 } |
25661
293aeec83153
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents:
25326
diff
changeset
|
315 stringset_free(&selected); |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
316 |
25962 | 317 if(!sh_video->initialized){ |
7502
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
318 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
|
319 return 0; // failed |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
320 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
321 |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16325
diff
changeset
|
322 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
|
323 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
|
324 return 1; // success |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
325 } |
6a2b6f3d619c
best audio/video codec selection & init moved to libmpcodecs
arpi
parents:
7368
diff
changeset
|
326 |
22497 | 327 void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size, |
328 int drop_frame, double pts) | |
329 { | |
330 mp_image_t *mpi = NULL; | |
331 unsigned int t = GetTimer(); | |
332 unsigned int t2; | |
333 double tt; | |
1360 | 334 |
22498
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
335 if (correct_pts && pts != MP_NOPTS_VALUE) { |
22497 | 336 int delay = get_current_video_decoder_lag(sh_video); |
337 if (delay >= 0) { | |
338 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
|
339 #if 0 |
22497 | 340 // this is disabled because vd_ffmpeg reports the same lag |
341 // after seek even when there are no buffered frames, | |
342 // leading to incorrect error messages | |
343 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
|
344 #else |
22497 | 345 ; |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
346 #endif |
22497 | 347 else |
348 sh_video->num_buffered_pts = delay; | |
349 } | |
350 if (sh_video->num_buffered_pts == | |
351 sizeof(sh_video->buffered_pts)/sizeof(double)) | |
352 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n"); | |
353 else { | |
354 int i, j; | |
355 for (i = 0; i < sh_video->num_buffered_pts; i++) | |
356 if (sh_video->buffered_pts[i] < pts) | |
357 break; | |
358 for (j = sh_video->num_buffered_pts; j > i; j--) | |
359 sh_video->buffered_pts[j] = sh_video->buffered_pts[j-1]; | |
360 sh_video->buffered_pts[i] = pts; | |
361 sh_video->num_buffered_pts++; | |
362 } | |
363 } | |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
364 |
22497 | 365 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
|
366 |
22497 | 367 //------------------------ frame decoded. -------------------- |
1294 | 368 |
28290 | 369 #if HAVE_MMX |
22497 | 370 // some codecs are broken, and doesn't restore MMX state :( |
371 // it happens usually with broken/damaged files. | |
372 if (gCpuCaps.has3DNow) { | |
27757
b5a46071062a
Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents:
27754
diff
changeset
|
373 __asm__ volatile ("femms\n\t":::"memory"); |
22497 | 374 } |
375 else if (gCpuCaps.hasMMX) { | |
27757
b5a46071062a
Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents:
27754
diff
changeset
|
376 __asm__ volatile ("emms\n\t":::"memory"); |
22497 | 377 } |
3160 | 378 #endif |
1367 | 379 |
22497 | 380 t2 = GetTimer(); t = t2-t; |
381 tt = t*0.000001f; | |
382 video_time_usage += tt; | |
4898 | 383 |
22497 | 384 if (!mpi || drop_frame) |
385 return NULL; // error / skipped frame | |
5040 | 386 |
22497 | 387 if (field_dominance == 0) |
388 mpi->fields |= MP_IMGFIELD_TOP_FIRST; | |
389 else if (field_dominance == 1) | |
390 mpi->fields &= ~MP_IMGFIELD_TOP_FIRST; | |
22086
8bf15e2ca61e
Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents:
22012
diff
changeset
|
391 |
22497 | 392 if (correct_pts) { |
22498
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
393 if (sh_video->num_buffered_pts) { |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
394 sh_video->num_buffered_pts--; |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
395 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
|
396 } |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
397 else { |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
398 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
|
399 "use for frame!\n"); |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
400 sh_video->pts = MP_NOPTS_VALUE; |
b6b1bd155b58
Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents:
22497
diff
changeset
|
401 } |
22497 | 402 } |
403 return mpi; | |
20902
bfb6eacd9c4a
Update OSD contents only after the correct values for the frame are known.
uau
parents:
19521
diff
changeset
|
404 } |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18889
diff
changeset
|
405 |
22497 | 406 int filter_video(sh_video_t *sh_video, void *frame, double pts) |
407 { | |
408 mp_image_t *mpi = frame; | |
409 unsigned int t2 = GetTimer(); | |
410 vf_instance_t *vf = sh_video->vfilter; | |
411 // apply video filters and call the leaf vo/ve | |
412 int ret = vf->put_image(vf, mpi, pts); | |
413 if (ret > 0) { | |
28806
77d1e5749a09
Swap order of VFCTRL_DRAW_EOSD and VFCTRL_DRAW_OSD so that the EOSD is drawn
reimar
parents:
28594
diff
changeset
|
414 // draw EOSD first so it ends up below the OSD. |
77d1e5749a09
Swap order of VFCTRL_DRAW_EOSD and VFCTRL_DRAW_OSD so that the EOSD is drawn
reimar
parents:
28594
diff
changeset
|
415 // Note that changing this is will not work right with vf_ass and the |
77d1e5749a09
Swap order of VFCTRL_DRAW_EOSD and VFCTRL_DRAW_OSD so that the EOSD is drawn
reimar
parents:
28594
diff
changeset
|
416 // vos currently always draw the EOSD first in paused mode. |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26754
diff
changeset
|
417 #ifdef CONFIG_ASS |
22497 | 418 vf->control(vf, VFCTRL_DRAW_EOSD, NULL); |
19521 | 419 #endif |
28806
77d1e5749a09
Swap order of VFCTRL_DRAW_EOSD and VFCTRL_DRAW_OSD so that the EOSD is drawn
reimar
parents:
28594
diff
changeset
|
420 vf->control(vf, VFCTRL_DRAW_OSD, NULL); |
22497 | 421 } |
4898 | 422 |
22497 | 423 t2 = GetTimer()-t2; |
20902
bfb6eacd9c4a
Update OSD contents only after the correct values for the frame are known.
uau
parents:
19521
diff
changeset
|
424 vout_time_usage += t2*0.000001; |
1360 | 425 |
22497 | 426 return ret; |
1294 | 427 } |