annotate libmpcodecs/dec_video.c @ 32040:fb341240a2a8

Move stream_dump_type extern declaration to mplayer.h, where it belongs.
author diego
date Thu, 09 Sep 2010 17:10:18 +0000
parents e648473842bd
children dcdcbe7f6713
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30378
diff changeset
17 */
2775
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2716
diff changeset
18
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2716
diff changeset
19 #include "config.h"
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
20
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
21 #include <stdio.h>
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
22 #include <stdlib.h>
1430
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1429
diff changeset
23 #include <unistd.h>
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
24
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1547
diff changeset
25 #include "mp_msg.h"
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1949
diff changeset
26 #include "help_mp.h"
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
27
9380
edfe34c5405d linux->osdep
arpi
parents: 8152
diff changeset
28 #include "osdep/timer.h"
edfe34c5405d linux->osdep
arpi
parents: 8152
diff changeset
29 #include "osdep/shmem.h"
1327
b12e1817bcc2 some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents: 1309
diff changeset
30
22599
4faee1254928 Add explicit location for headers from the stream/ directory.
diego
parents: 22498
diff changeset
31 #include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22599
diff changeset
32 #include "libmpdemux/demuxer.h"
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22599
diff changeset
33 #include "libmpdemux/parse_es.h"
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
34
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
35 #include "codec-cfg.h"
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
36
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
37 #include "libvo/video_out.h"
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
38
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22599
diff changeset
39 #include "libmpdemux/stheader.h"
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
40 #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
41 #include "vf.h"
31927
6e0b5a97e00f EOSD/ASS code factorization
cigaes
parents: 31246
diff changeset
42 #include "eosd.h"
4188
cfd1eed5961d using mp_image.h - not finished...
arpi
parents: 4156
diff changeset
43
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
44 #include "dec_video.h"
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
45
27397
d47744b95b78 Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents: 27341
diff changeset
46 #ifdef CONFIG_DYNAMIC_PLUGINS
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
47 #include <dlfcn.h>
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
48 #endif
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
49
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
50 // ===================================================================
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
51
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
52 extern double video_time_usage;
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
53 extern double vout_time_usage;
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
54
3144
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
55 #include "cpudetect.h"
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
56
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
57 int field_dominance = -1;
22086
8bf15e2ca61e Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents: 22012
diff changeset
58
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
59 int divx_quality = 0;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
60
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
61 const vd_functions_t *mpvdec = NULL;
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
62
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
63 int get_video_quality_max(sh_video_t *sh_video)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
64 {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
65 vf_instance_t *vf = sh_video->vfilter;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
66 if (vf) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
67 int ret = vf->control(vf, VFCTRL_QUERY_MAX_PP_LEVEL, NULL);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
68 if (ret > 0) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
69 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_UsingExternalPP, ret);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
70 return ret;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
71 }
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
72 }
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
73 if (mpvdec) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
74 int ret = mpvdec->control(sh_video, VDCTRL_QUERY_MAX_PP_LEVEL, NULL);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
75 if (ret > 0) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
76 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_UsingCodecPP, ret);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
77 return ret;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
78 }
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
79 }
6138
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5984
diff changeset
80 // mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Sorry, postprocessing is not available\n");
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
81 return 0;
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
82 }
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
83
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
84 void set_video_quality(sh_video_t *sh_video, int quality)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
85 {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
86 vf_instance_t *vf = sh_video->vfilter;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
87 if (vf) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
88 int ret = vf->control(vf, VFCTRL_SET_PP_LEVEL, (void *) (&quality));
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
89 if (ret == CONTROL_TRUE)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
90 return; // success
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
91 }
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
92 if (mpvdec)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
93 mpvdec->control(sh_video, VDCTRL_SET_PP_LEVEL, (void *) (&quality));
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
94 }
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
95
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
96 int set_video_colors(sh_video_t *sh_video, const char *item, int value)
4395
817530449706 New logic of HW equalizing:
nick
parents: 4388
diff changeset
97 {
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
98 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
99 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
100
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
101 data.item = item;
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
102 data.value = value;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
103
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
104 mp_dbg(MSGT_DECVIDEO, MSGL_V, "set video colors %s=%d \n", item, value);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
105 if (vf) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
106 int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
107 if (ret == CONTROL_TRUE)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
108 return 1;
6785
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
109 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
110 /* try software control */
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
111 if (mpvdec)
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
112 if (mpvdec->control(sh_video, VDCTRL_SET_EQUALIZER, item,
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
113 (int *) value) == CONTROL_OK)
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
114 return 1;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
115 mp_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_VideoAttributeNotSupportedByVO_VD,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
116 item);
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
117 return 0;
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
118 }
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
119
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
120 int get_video_colors(sh_video_t *sh_video, const char *item, int *value)
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
121 {
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
122 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
123 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
124
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
125 data.item = item;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
126
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
127 mp_dbg(MSGT_DECVIDEO, MSGL_V, "get video colors %s \n", item);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
128 if (vf) {
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
129 int ret = vf->control(vf, VFCTRL_GET_EQUALIZER, &data);
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
130 if (ret == CONTROL_TRUE) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
131 *value = data.value;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
132 return 1;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
133 }
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
134 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
135 /* try software control */
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
136 if (mpvdec)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
137 return mpvdec->control(sh_video, VDCTRL_GET_EQUALIZER, item, value);
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
138 return 0;
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
139 }
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
140
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
141 int set_rectangle(sh_video_t *sh_video, int param, int value)
6887
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
142 {
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
143 vf_instance_t *vf = sh_video->vfilter;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
144 int data[] = { param, value };
6887
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
145
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
146 mp_dbg(MSGT_DECVIDEO, MSGL_V, "set rectangle \n");
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
147 if (vf) {
6887
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
148 int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data);
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
149 if (ret)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
150 return 1;
6887
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
151 }
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
152 return 0;
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
153 }
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
154
11977
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
155 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
156 {
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
157 sh_video->timer = 0;
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
158 sh_video->next_frame_time = 0;
30378
8339bca8e4b4 Move the resync-related code into more consistent places instead of having it
reimar
parents: 29168
diff changeset
159 sh_video->num_buffered_pts = 0;
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
160 sh_video->last_pts = MP_NOPTS_VALUE;
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
161 if (mpvdec)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
162 mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL);
11977
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
163 }
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
164
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
165 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
166 {
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
167 int ret;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
168
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
169 if (!mpvdec)
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
170 return -1;
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
171 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
172 if (ret >= 10)
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
173 return ret - 10;
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
174 return -1;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
175 }
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
176
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
177 void uninit_video(sh_video_t *sh_video)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
178 {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
179 if (!sh_video->initialized)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
180 return;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
181 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
182 mpvdec->uninit(sh_video);
27397
d47744b95b78 Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents: 27341
diff changeset
183 #ifdef CONFIG_DYNAMIC_PLUGINS
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
184 if (sh_video->dec_handle)
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
185 dlclose(sh_video->dec_handle);
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
186 #endif
5737
de47aebf654c filters uninit
arpi
parents: 5643
diff changeset
187 vf_uninit_filter_chain(sh_video->vfilter);
31927
6e0b5a97e00f EOSD/ASS code factorization
cigaes
parents: 31246
diff changeset
188 eosd_uninit();
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
189 sh_video->initialized = 0;
1654
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
190 }
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
191
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
192 void vfm_help(void)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
193 {
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
194 int i;
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
195 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
196 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_DRIVERS\n");
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
197 mp_msg(MSGT_DECVIDEO, MSGL_INFO, " vfm: info: (comment)\n");
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
198 for (i = 0; mpcodecs_vd_drivers[i] != NULL; i++)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
199 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "%8s %s (%s)\n",
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
200 mpcodecs_vd_drivers[i]->info->short_name,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
201 mpcodecs_vd_drivers[i]->info->name,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
202 mpcodecs_vd_drivers[i]->info->comment);
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
203 }
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
204
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
205 static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
206 int status, stringset_t *selected)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
207 {
16325
attila
parents: 16321
diff changeset
208 int force = 0;
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
209 unsigned int orig_fourcc = sh_video->bih ? sh_video->bih->biCompression : 0;
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
210 sh_video->codec = NULL;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
211 sh_video->vf_initialized = 0;
16321
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
212 if (codecname && codecname[0] == '+') {
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
213 codecname = &codecname[1];
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
214 force = 1;
16321
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
215 }
6230
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
216
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
217 while (1) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
218 int i;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
219 int orig_w, orig_h;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
220 // restore original fourcc:
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
221 if (sh_video->bih)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
222 sh_video->bih->biCompression = orig_fourcc;
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
223 if (!(sh_video->codec =
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
224 find_video_codec(sh_video->format,
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
225 sh_video->bih ? ((unsigned int *) &sh_video->bih->biCompression) : NULL,
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
226 sh_video->codec, force)))
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
227 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
228 // ok we found one codec
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
229 if (stringset_test(selected, sh_video->codec->name))
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
230 continue; // already tried & failed
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
231 if (codecname && strcmp(sh_video->codec->name, codecname))
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
232 continue; // -vc
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
233 if (vfm && strcmp(sh_video->codec->drv, vfm))
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
234 continue; // vfm doesn't match
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
235 if (!force && sh_video->codec->status < status)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
236 continue; // too unstable
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
237 stringset_add(selected, sh_video->codec->name); // tagging it
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
238 // ok, it matches all rules, let's find the driver!
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
239 for (i = 0; mpcodecs_vd_drivers[i] != NULL; i++)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
240 // if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
241 if (!strcmp
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
242 (mpcodecs_vd_drivers[i]->info->short_name,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
243 sh_video->codec->drv))
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
244 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
245 mpvdec = mpcodecs_vd_drivers[i];
27397
d47744b95b78 Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents: 27341
diff changeset
246 #ifdef CONFIG_DYNAMIC_PLUGINS
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
247 if (!mpvdec) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
248 /* try to open shared decoder plugin */
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
249 int buf_len;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
250 char *buf;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
251 vd_functions_t *funcs_sym;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
252 vd_info_t *info_sym;
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
253
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
254 buf_len = strlen(MPLAYER_LIBDIR) +
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
255 strlen(sh_video->codec->drv) + 16;
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
256 buf = malloc(buf_len);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
257 if (!buf)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
258 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
259 snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", MPLAYER_LIBDIR,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
260 sh_video->codec->drv);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
261 mp_msg(MSGT_DECVIDEO, MSGL_DBG2,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
262 "Trying to open external plugin: %s\n", buf);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
263 sh_video->dec_handle = dlopen(buf, RTLD_LAZY);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
264 if (!sh_video->dec_handle)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
265 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
266 snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
267 funcs_sym = dlsym(sh_video->dec_handle, buf);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
268 if (!funcs_sym || !funcs_sym->info || !funcs_sym->init
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
269 || !funcs_sym->uninit || !funcs_sym->control
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
270 || !funcs_sym->decode)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
271 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
272 info_sym = funcs_sym->info;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
273 if (strcmp(info_sym->short_name, sh_video->codec->drv))
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
274 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
275 free(buf);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
276 mpvdec = funcs_sym;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
277 mp_msg(MSGT_DECVIDEO, MSGL_V,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
278 "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n",
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
279 MPLAYER_LIBDIR, sh_video->codec->drv);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
280 }
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
281 #endif
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
282 if (!mpvdec) { // driver not available (==compiled in)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
283 mp_msg(MSGT_DECVIDEO, MSGL_WARN,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
284 MSGTR_VideoCodecFamilyNotAvailableStr,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
285 sh_video->codec->name, sh_video->codec->drv);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
286 continue;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
287 }
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
288 orig_w = sh_video->bih ? sh_video->bih->biWidth : sh_video->disp_w;
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
289 orig_h = sh_video->bih ? sh_video->bih->biHeight : sh_video->disp_h;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
290 sh_video->disp_w = orig_w;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
291 sh_video->disp_h = orig_h;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
292 // it's available, let's try to init!
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
293 if (sh_video->codec->flags & CODECS_FLAG_ALIGN16) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
294 // align width/height to n*16
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
295 sh_video->disp_w = (sh_video->disp_w + 15) & (~15);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
296 sh_video->disp_h = (sh_video->disp_h + 15) & (~15);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
297 }
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
298 if (sh_video->bih) {
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
299 sh_video->bih->biWidth = sh_video->disp_w;
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
300 sh_video->bih->biHeight = sh_video->disp_h;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
301 }
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
302 // init()
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
303 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_OpeningVideoDecoder,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
304 mpvdec->info->short_name, mpvdec->info->name);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
305 // clear vf init error, it is no longer relevant
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
306 if (sh_video->vf_initialized < 0)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
307 sh_video->vf_initialized = 0;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
308 if (!mpvdec->init(sh_video)) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
309 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_VDecoderInitFailed);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
310 sh_video->disp_w = orig_w;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
311 sh_video->disp_h = orig_h;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
312 if (sh_video->bih) {
31989
e648473842bd cosmetics: Repair some of the damage that 'indent' caused.
diego
parents: 31972
diff changeset
313 sh_video->bih->biWidth = sh_video->disp_w;
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
314 sh_video->bih->biHeight = sh_video->disp_h;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
315 }
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
316 continue; // try next...
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
317 }
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
318 // Yeah! We got it!
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
319 sh_video->initialized = 1;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
320 return 1;
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
321 }
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
322 return 0;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
323 }
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
324
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
325 int init_best_video_codec(sh_video_t *sh_video, char **video_codec_list,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
326 char **video_fm_list)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
327 {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
328 char *vc_l_default[2] = { "", (char *) NULL };
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
329 stringset_t selected;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
330 // hack:
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
331 if (!video_codec_list)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
332 video_codec_list = vc_l_default;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
333 // Go through the codec.conf and find the best codec...
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
334 sh_video->initialized = 0;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
335 stringset_init(&selected);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
336 while (!sh_video->initialized && *video_codec_list) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
337 char *video_codec = *(video_codec_list++);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
338 if (video_codec[0]) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
339 if (video_codec[0] == '-') {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
340 // disable this codec:
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
341 stringset_add(&selected, video_codec + 1);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
342 } else {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
343 // forced codec by name:
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
344 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_ForcedVideoCodec,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
345 video_codec);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
346 init_video(sh_video, video_codec, NULL, -1, &selected);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
347 }
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
348 } else {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
349 int status;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
350 // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING.
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
351 if (video_fm_list) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
352 char **fmlist = video_fm_list;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
353 // try first the preferred codec families:
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
354 while (!sh_video->initialized && *fmlist) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
355 char *video_fm = *(fmlist++);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
356 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_TryForceVideoFmtStr,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
357 video_fm);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
358 for (status = CODECS_STATUS__MAX;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
359 status >= CODECS_STATUS__MIN; --status)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
360 if (init_video
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
361 (sh_video, NULL, video_fm, status, &selected))
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
362 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
363 }
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
364 }
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
365 if (!sh_video->initialized)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
366 for (status = CODECS_STATUS__MAX; status >= CODECS_STATUS__MIN;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
367 --status)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
368 if (init_video(sh_video, NULL, NULL, status, &selected))
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
369 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
370 }
7506
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
371 }
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
372 stringset_free(&selected);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
373
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
374 if (!sh_video->initialized) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
375 mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantFindVideoCodec,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
376 sh_video->format);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
377 return 0; // failed
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
378 }
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
379
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
380 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_SelectedVideoCodec,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
381 sh_video->codec->name, sh_video->codec->drv, sh_video->codec->info);
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
382 return 1; // success
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
383 }
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
384
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
385 void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
31972
96559880e475 Improve A/V sync when not using -correct-pts.
cehoyos
parents: 31953
diff changeset
386 int drop_frame, double pts, int *full_frame)
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
387 {
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
388 mp_image_t *mpi = NULL;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
389 unsigned int t = GetTimer();
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
390 unsigned int t2;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
391 double tt;
31953
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
392 int delay;
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
393 int got_picture = 1;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
394
31953
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
395 mpi = mpvdec->decode(sh_video, start, in_size, drop_frame);
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
396
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
397 //------------------------ frame decoded. --------------------
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
398
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
399 if (mpi && mpi->type == MP_IMGTYPE_INCOMPLETE) {
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
400 got_picture = 0;
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
401 mpi = NULL;
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
402 }
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
403
31972
96559880e475 Improve A/V sync when not using -correct-pts.
cehoyos
parents: 31953
diff changeset
404 if (full_frame)
96559880e475 Improve A/V sync when not using -correct-pts.
cehoyos
parents: 31953
diff changeset
405 *full_frame = got_picture;
96559880e475 Improve A/V sync when not using -correct-pts.
cehoyos
parents: 31953
diff changeset
406
31953
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
407 delay = get_current_video_decoder_lag(sh_video);
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
408 if (correct_pts && pts != MP_NOPTS_VALUE
2b390c08ed07 Improve correct-pts with PAFF streams.
cehoyos
parents: 31927
diff changeset
409 && (got_picture || sh_video->num_buffered_pts < delay)) {
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
410 if (sh_video->num_buffered_pts ==
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
411 sizeof(sh_video->buffered_pts) / sizeof(double))
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
412 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n");
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
413 else {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
414 int i, j;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
415 for (i = 0; i < sh_video->num_buffered_pts; i++)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
416 if (sh_video->buffered_pts[i] < pts)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
417 break;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
418 for (j = sh_video->num_buffered_pts; j > i; j--)
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
419 sh_video->buffered_pts[j] = sh_video->buffered_pts[j - 1];
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
420 sh_video->buffered_pts[i] = pts;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
421 sh_video->num_buffered_pts++;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
422 }
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
423 }
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
424
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27757
diff changeset
425 #if HAVE_MMX
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
426 // some codecs are broken, and doesn't restore MMX state :(
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
427 // it happens usually with broken/damaged files.
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
428 if (gCpuCaps.has3DNow) {
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
429 __asm__ volatile ("femms\n\t":::"memory");
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
430 } else if (gCpuCaps.hasMMX) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
431 __asm__ volatile ("emms\n\t":::"memory");
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
432 }
3160
80df2986ca42 {f}emms is only needed on x86
jkeil
parents: 3144
diff changeset
433 #endif
1367
16bedc82bd09 MMX problem workaround for broken (win32) codecs
arpi
parents: 1365
diff changeset
434
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
435 t2 = GetTimer();
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
436 t = t2 - t;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
437 tt = t * 0.000001f;
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
438 video_time_usage += tt;
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
439
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
440 if (!mpi || drop_frame)
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
441 return NULL; // error / skipped frame
5040
568ca851a05b framedrop fix
arpi
parents: 5005
diff changeset
442
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
443 if (field_dominance == 0)
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
444 mpi->fields |= MP_IMGFIELD_TOP_FIRST;
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
445 else if (field_dominance == 1)
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
446 mpi->fields &= ~MP_IMGFIELD_TOP_FIRST;
22086
8bf15e2ca61e Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents: 22012
diff changeset
447
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
448 if (correct_pts) {
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
449 if (sh_video->num_buffered_pts) {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
450 sh_video->num_buffered_pts--;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
451 sh_video->pts = sh_video->buffered_pts[sh_video->num_buffered_pts];
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
452 } else {
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
453 mp_msg(MSGT_CPLAYER, MSGL_ERR,
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
454 "No pts value from demuxer to " "use for frame!\n");
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
455 sh_video->pts = MP_NOPTS_VALUE;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
456 }
31246
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
457 if (delay >= 0) {
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
458 // limit buffered pts only afterwards so we do not get confused
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
459 // by packets that produce no output (e.g. a single field of a
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
460 // H.264 frame).
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
461 if (delay > sh_video->num_buffered_pts)
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
462 #if 0
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
463 // this is disabled because vd_ffmpeg reports the same lag
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
464 // after seek even when there are no buffered frames,
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
465 // leading to incorrect error messages
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
466 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n");
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
467 #else
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
468 ;
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
469 #endif
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
470 else
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
471 sh_video->num_buffered_pts = delay;
cc6ee3017097 Limit buffered PTS only when we actually got a frame from the decoder.
reimar
parents: 31171
diff changeset
472 }
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
473 }
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
474 return mpi;
20902
bfb6eacd9c4a Update OSD contents only after the correct values for the frame are known.
uau
parents: 19521
diff changeset
475 }
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
476
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
477 int filter_video(sh_video_t *sh_video, void *frame, double pts)
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
478 {
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
479 mp_image_t *mpi = frame;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
480 unsigned int t2 = GetTimer();
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
481 vf_instance_t *vf = sh_video->vfilter;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
482 // apply video filters and call the leaf vo/ve
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
483 int ret = vf->put_image(vf, mpi, pts);
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
484 if (ret > 0) {
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
485 // draw EOSD first so it ends up below the OSD.
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
486 // Note that changing this is will not work right with vf_ass and the
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
487 // vos currently always draw the EOSD first in paused mode.
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
488 #ifdef CONFIG_ASS
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
489 vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
19521
0be2d3583f4f Add VFCTRL_DRAW_EOSD.
eugeni
parents: 19130
diff changeset
490 #endif
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
491 vf->control(vf, VFCTRL_DRAW_OSD, NULL);
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
492 }
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
493
31171
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
494 t2 = GetTimer() - t2;
fe3b2b2a085f cosmetics: K&R coding style
diego
parents: 30692
diff changeset
495 vout_time_usage += t2 * 0.000001;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
496
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
497 return ret;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
498 }