annotate libmpcodecs/dec_video.c @ 31121:50eb33ac279b

vf_zr requires the lavc MJPEG encoder even when MEncoder has been disabled. This fixes compilation with vo_zr enabled and MEncoder disabled.
author diego
date Fri, 14 May 2010 16:56:43 +0000
parents 3774cf3c7df3
children fe3b2b2a085f
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"
4188
cfd1eed5961d using mp_image.h - not finished...
arpi
parents: 4156
diff changeset
42
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
43 #include "dec_video.h"
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
44
27397
d47744b95b78 Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents: 27341
diff changeset
45 #ifdef CONFIG_DYNAMIC_PLUGINS
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
46 #include <dlfcn.h>
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
47 #endif
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
48
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
49 // ===================================================================
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
50
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
51 extern double video_time_usage;
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
52 extern double vout_time_usage;
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
53
3144
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
54 #include "cpudetect.h"
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
55
22086
8bf15e2ca61e Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents: 22012
diff changeset
56 int field_dominance=-1;
8bf15e2ca61e Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents: 22012
diff changeset
57
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
58 int divx_quality=0;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
59
30692
3774cf3c7df3 Add const to mpvdec declaration
reimar
parents: 30421
diff changeset
60 const vd_functions_t* mpvdec=NULL;
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
61
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
62 int get_video_quality_max(sh_video_t *sh_video){
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
63 vf_instance_t* vf=sh_video->vfilter;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
64 if(vf){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
65 int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL);
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
66 if(ret>0){
6989
b2ba67f6203e messages moved from dec_??d?o.c
jaf
parents: 6887
diff changeset
67 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingExternalPP,ret);
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
68 return ret;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
69 }
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
70 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
71 if(mpvdec){
4967
arpi
parents: 4957
diff changeset
72 int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL);
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
73 if(ret>0){
6989
b2ba67f6203e messages moved from dec_??d?o.c
jaf
parents: 6887
diff changeset
74 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingCodecPP,ret);
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
75 return ret;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
76 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
77 }
6138
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5984
diff changeset
78 // mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Sorry, postprocessing is not available\n");
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
79 return 0;
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
80 }
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
81
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
82 void set_video_quality(sh_video_t *sh_video,int quality){
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
83 vf_instance_t* vf=sh_video->vfilter;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
84 if(vf){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
85 int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality));
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
86 if(ret==CONTROL_TRUE) return; // success
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
87 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
88 if(mpvdec)
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
89 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality));
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
90 }
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
91
25224
abb784e37907 get/set video colors string is constant
reimar
parents: 24242
diff changeset
92 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
93 {
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
94 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
95 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
96
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
97 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
98 data.value = value;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
99
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
100 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set video colors %s=%d \n", item, value);
6785
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
101 if (vf)
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
102 {
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
103 int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data);
6785
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
104 if (ret == CONTROL_TRUE)
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 25962
diff changeset
105 return 1;
6785
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
106 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
107 /* try software control */
6800
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
108 if(mpvdec)
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
109 if( mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER, item, (int *)value)
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
110 == CONTROL_OK) return 1;
18190
11d7992b37cf Add properties for the tv input color controls.
albeu
parents: 17910
diff changeset
111 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_VideoAttributeNotSupportedByVO_VD,item);
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
112 return 0;
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
113 }
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
114
25224
abb784e37907 get/set video colors string is constant
reimar
parents: 24242
diff changeset
115 int get_video_colors(sh_video_t *sh_video,const char *item,int *value)
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
116 {
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
117 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
118 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
119
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
120 data.item = item;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
121
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
122 mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item);
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
123 if (vf)
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
124 {
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
125 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
126 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
127 *value = data.value;
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 25962
diff changeset
128 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
129 }
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
130 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
131 /* try software control */
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
132 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value);
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
133 return 0;
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
134 }
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
135
6887
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
136 int set_rectangle(sh_video_t *sh_video,int param,int value)
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
137 {
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
138 vf_instance_t* vf=sh_video->vfilter;
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
139 int data[] = {param, value};
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
140
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
141 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set rectangle \n");
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
142 if (vf)
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
143 {
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
144 int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data);
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
145 if (ret)
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 25962
diff changeset
146 return 1;
6887
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
147 }
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
148 return 0;
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
149 }
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
150
11977
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
151 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
152 {
30378
8339bca8e4b4 Move the resync-related code into more consistent places instead of having it
reimar
parents: 29168
diff changeset
153 sh_video->timer = 0;
8339bca8e4b4 Move the resync-related code into more consistent places instead of having it
reimar
parents: 29168
diff changeset
154 sh_video->next_frame_time = 0;
8339bca8e4b4 Move the resync-related code into more consistent places instead of having it
reimar
parents: 29168
diff changeset
155 sh_video->num_buffered_pts = 0;
8339bca8e4b4 Move the resync-related code into more consistent places instead of having it
reimar
parents: 29168
diff changeset
156 sh_video->last_pts = MP_NOPTS_VALUE;
11977
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
157 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
158 }
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
159
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
160 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
161 {
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
162 int ret;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
163
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
164 if (!mpvdec)
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
165 return -1;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
166 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
167 if (ret >= 10)
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
168 return ret-10;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
169 return -1;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
170 }
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
171
2049
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 2044
diff changeset
172 void uninit_video(sh_video_t *sh_video){
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
173 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
174 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
175 mpvdec->uninit(sh_video);
27397
d47744b95b78 Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents: 27341
diff changeset
176 #ifdef CONFIG_DYNAMIC_PLUGINS
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
177 if (sh_video->dec_handle)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
178 dlclose(sh_video->dec_handle);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
179 #endif
5737
de47aebf654c filters uninit
arpi
parents: 5643
diff changeset
180 vf_uninit_filter_chain(sh_video->vfilter);
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
181 sh_video->initialized=0;
1654
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
182 }
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
183
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16793
diff changeset
184 void vfm_help(void){
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
185 int i;
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
186 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
187 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
188 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
189 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
190 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
191 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
192 mpcodecs_vd_drivers[i]->info->name,
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
193 mpcodecs_vd_drivers[i]->info->comment);
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
194 }
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
195
25661
293aeec83153 Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents: 25326
diff changeset
196 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
197 stringset_t *selected){
16325
attila
parents: 16321
diff changeset
198 int force = 0;
6230
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
199 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
200 sh_video->codec=NULL;
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
201 sh_video->vf_initialized=0;
16321
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
202 if (codecname && codecname[0] == '+') {
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
203 codecname = &codecname[1];
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
204 force = 1;
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
205 }
6230
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
206
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
207 while(1){
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
208 int i;
22012
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
209 int orig_w, orig_h;
6230
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
210 // restore original fourcc:
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
211 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
212 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
213 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
214 sh_video->codec,force) )) break;
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
215 // ok we found one codec
25661
293aeec83153 Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents: 25326
diff changeset
216 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
217 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
218 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
219 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
220 stringset_add(selected, sh_video->codec->name); // tagging it
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
221 // ok, it matches all rules, let's find the driver!
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
222 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
223 // 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
224 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
225 mpvdec=mpcodecs_vd_drivers[i];
27397
d47744b95b78 Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents: 27341
diff changeset
226 #ifdef CONFIG_DYNAMIC_PLUGINS
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
227 if (!mpvdec)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
228 {
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
229 /* try to open shared decoder plugin */
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
230 int buf_len;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
231 char *buf;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
232 vd_functions_t *funcs_sym;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
233 vd_info_t *info_sym;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
234
10272
7b0bc557987b renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents: 9426
diff changeset
235 buf_len = strlen(MPLAYER_LIBDIR)+strlen(sh_video->codec->drv)+16;
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
236 buf = malloc(buf_len);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
237 if (!buf)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
238 break;
10272
7b0bc557987b renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents: 9426
diff changeset
239 snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", MPLAYER_LIBDIR, sh_video->codec->drv);
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
240 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
241 sh_video->dec_handle = dlopen(buf, RTLD_LAZY);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
242 if (!sh_video->dec_handle)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
243 break;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
244 snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
245 funcs_sym = dlsym(sh_video->dec_handle, buf);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
246 if (!funcs_sym || !funcs_sym->info || !funcs_sym->init ||
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
247 !funcs_sym->uninit || !funcs_sym->control || !funcs_sym->decode)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
248 break;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
249 info_sym = funcs_sym->info;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
250 if (strcmp(info_sym->short_name, sh_video->codec->drv))
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
251 break;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
252 free(buf);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
253 mpvdec = funcs_sym;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
254 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
255 MPLAYER_LIBDIR, sh_video->codec->drv);
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
256 }
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
257 #endif
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
258 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
259 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
260 sh_video->codec->name, sh_video->codec->drv);
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
261 continue;
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
262 }
22012
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
263 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
264 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
265 sh_video->disp_w = orig_w;
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
266 sh_video->disp_h = orig_h;
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
267 // it's available, let's try to init!
6566
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
268 if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
269 // align width/height to n*16
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
270 sh_video->disp_w=(sh_video->disp_w+15)&(~15);
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
271 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
272 }
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
273 if (sh_video->bih) {
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
274 sh_video->bih->biWidth = sh_video->disp_w;
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
275 sh_video->bih->biHeight = sh_video->disp_h;
6566
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
276 }
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
277 // init()
6989
b2ba67f6203e messages moved from dec_??d?o.c
jaf
parents: 6887
diff changeset
278 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
279 // clear vf init error, it is no longer relevant
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
280 if (sh_video->vf_initialized < 0)
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
281 sh_video->vf_initialized = 0;
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
282 if(!mpvdec->init(sh_video)){
6989
b2ba67f6203e messages moved from dec_??d?o.c
jaf
parents: 6887
diff changeset
283 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
284 sh_video->disp_w=orig_w;
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
285 sh_video->disp_h=orig_h;
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
286 if (sh_video->bih) {
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
287 sh_video->bih->biWidth = sh_video->disp_w;
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
288 sh_video->bih->biHeight = sh_video->disp_h;
213b5c14bba7 Implement FIXME: Restore original width/height when CODECS_FLAG_ALIGN16
reimar
parents: 20902
diff changeset
289 }
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
290 continue; // try next...
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
291 }
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
292 // Yeah! We got it!
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
293 sh_video->initialized=1;
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
294 return 1;
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
295 }
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
296 return 0;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
297 }
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
298
7506
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
299 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
300 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
301 stringset_t selected;
7506
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
302 // hack:
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
303 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
304 // Go through the codec.conf and find the best codec...
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
305 sh_video->initialized=0;
25661
293aeec83153 Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents: 25326
diff changeset
306 stringset_init(&selected);
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
307 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
308 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
309 if(video_codec[0]){
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
310 if(video_codec[0]=='-'){
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
311 // disable this codec:
25661
293aeec83153 Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents: 25326
diff changeset
312 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
313 } else {
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
314 // forced codec by name:
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
315 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
316 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
317 }
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
318 } else {
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
319 int status;
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
320 // 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
321 if(video_fm_list){
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
322 char** fmlist=video_fm_list;
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
323 // try first the preferred codec families:
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
324 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
325 char* video_fm=*(fmlist++);
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
326 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
327 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
328 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
329 }
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
330 }
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
331 if(!sh_video->initialized)
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
332 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
333 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
334 }
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
335 }
25661
293aeec83153 Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
reimar
parents: 25326
diff changeset
336 stringset_free(&selected);
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
337
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25661
diff changeset
338 if(!sh_video->initialized){
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
339 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
340 return 0; // failed
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
341 }
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
342
16793
8d4fb5469efb Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents: 16325
diff changeset
343 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
344 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
345 return 1; // success
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
346 }
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
347
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
348 void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
349 int drop_frame, double pts)
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
350 {
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
351 mp_image_t *mpi = NULL;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
352 unsigned int t = GetTimer();
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
353 unsigned int t2;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
354 double tt;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
355
22498
b6b1bd155b58 Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents: 22497
diff changeset
356 if (correct_pts && pts != MP_NOPTS_VALUE) {
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
357 int delay = get_current_video_decoder_lag(sh_video);
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
358 if (delay >= 0) {
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
359 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
360 #if 0
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
361 // this is disabled because vd_ffmpeg reports the same lag
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
362 // after seek even when there are no buffered frames,
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
363 // leading to incorrect error messages
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
364 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
365 #else
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
366 ;
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
367 #endif
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
368 else
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
369 sh_video->num_buffered_pts = delay;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
370 }
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
371 if (sh_video->num_buffered_pts ==
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
372 sizeof(sh_video->buffered_pts)/sizeof(double))
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
373 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n");
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
374 else {
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
375 int i, j;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
376 for (i = 0; i < sh_video->num_buffered_pts; i++)
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
377 if (sh_video->buffered_pts[i] < pts)
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
378 break;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
379 for (j = sh_video->num_buffered_pts; j > i; j--)
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
380 sh_video->buffered_pts[j] = sh_video->buffered_pts[j-1];
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
381 sh_video->buffered_pts[i] = pts;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
382 sh_video->num_buffered_pts++;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
383 }
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
384 }
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
385
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
386 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
387
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
388 //------------------------ frame decoded. --------------------
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
389
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27757
diff changeset
390 #if HAVE_MMX
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
391 // some codecs are broken, and doesn't restore MMX state :(
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
392 // it happens usually with broken/damaged files.
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
393 if (gCpuCaps.has3DNow) {
27757
b5a46071062a Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents: 27754
diff changeset
394 __asm__ volatile ("femms\n\t":::"memory");
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
395 }
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
396 else if (gCpuCaps.hasMMX) {
27757
b5a46071062a Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'.
diego
parents: 27754
diff changeset
397 __asm__ volatile ("emms\n\t":::"memory");
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
398 }
3160
80df2986ca42 {f}emms is only needed on x86
jkeil
parents: 3144
diff changeset
399 #endif
1367
16bedc82bd09 MMX problem workaround for broken (win32) codecs
arpi
parents: 1365
diff changeset
400
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
401 t2 = GetTimer(); t = t2-t;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
402 tt = t*0.000001f;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
403 video_time_usage += tt;
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
404
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
405 if (!mpi || drop_frame)
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
406 return NULL; // error / skipped frame
5040
568ca851a05b framedrop fix
arpi
parents: 5005
diff changeset
407
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
408 if (field_dominance == 0)
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
409 mpi->fields |= MP_IMGFIELD_TOP_FIRST;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
410 else if (field_dominance == 1)
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
411 mpi->fields &= ~MP_IMGFIELD_TOP_FIRST;
22086
8bf15e2ca61e Add global field dominance flag instead of duplicating this "everywhere"
reimar
parents: 22012
diff changeset
412
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
413 if (correct_pts) {
22498
b6b1bd155b58 Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents: 22497
diff changeset
414 if (sh_video->num_buffered_pts) {
b6b1bd155b58 Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents: 22497
diff changeset
415 sh_video->num_buffered_pts--;
b6b1bd155b58 Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents: 22497
diff changeset
416 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
417 }
b6b1bd155b58 Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents: 22497
diff changeset
418 else {
b6b1bd155b58 Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents: 22497
diff changeset
419 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
420 "use for frame!\n");
b6b1bd155b58 Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents: 22497
diff changeset
421 sh_video->pts = MP_NOPTS_VALUE;
b6b1bd155b58 Allow demuxers to return packets with no pts in -correct-pts mode
uau
parents: 22497
diff changeset
422 }
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
423 }
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
424 return mpi;
20902
bfb6eacd9c4a Update OSD contents only after the correct values for the frame are known.
uau
parents: 19521
diff changeset
425 }
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
426
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
427 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
428 {
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
429 mp_image_t *mpi = frame;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
430 unsigned int t2 = GetTimer();
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
431 vf_instance_t *vf = sh_video->vfilter;
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
432 // apply video filters and call the leaf vo/ve
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
433 int ret = vf->put_image(vf, mpi, pts);
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
434 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
435 // 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
436 // 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
437 // vos currently always draw the EOSD first in paused mode.
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26754
diff changeset
438 #ifdef CONFIG_ASS
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
439 vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
19521
0be2d3583f4f Add VFCTRL_DRAW_EOSD.
eugeni
parents: 19130
diff changeset
440 #endif
28806
77d1e5749a09 Swap order of VFCTRL_DRAW_EOSD and VFCTRL_DRAW_OSD so that the EOSD is drawn
reimar
parents: 28594
diff changeset
441 vf->control(vf, VFCTRL_DRAW_OSD, NULL);
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
442 }
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
443
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
444 t2 = GetTimer()-t2;
20902
bfb6eacd9c4a Update OSD contents only after the correct values for the frame are known.
uau
parents: 19521
diff changeset
445 vout_time_usage += t2*0.000001;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
446
22497
af2ea92641a8 Reindent messy functions before working on them
uau
parents: 22405
diff changeset
447 return ret;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
448 }