annotate libmpcodecs/dec_video.c @ 19052:6866e768aef8

Streamline GUI build.
author diego
date Thu, 13 Jul 2006 03:05:08 +0000
parents d9a75b26da6c
children 39d8fd7e7543
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2775
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2716
diff changeset
1
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2716
diff changeset
2 #include "config.h"
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
3
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
4 #include <stdio.h>
2775
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2716
diff changeset
5 #ifdef HAVE_MALLOC_H
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2716
diff changeset
6 #include <malloc.h>
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2716
diff changeset
7 #endif
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
8 #include <stdlib.h>
1430
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1429
diff changeset
9 #include <unistd.h>
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
10
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1547
diff changeset
11 #include "mp_msg.h"
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1949
diff changeset
12 #include "help_mp.h"
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
13
9380
edfe34c5405d linux->osdep
arpi
parents: 8152
diff changeset
14 #include "osdep/timer.h"
edfe34c5405d linux->osdep
arpi
parents: 8152
diff changeset
15 #include "osdep/shmem.h"
1327
b12e1817bcc2 some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents: 1309
diff changeset
16
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
17 #include "stream.h"
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
18 #include "demuxer.h"
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1367
diff changeset
19 #include "parse_es.h"
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
20
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
21 #include "codec-cfg.h"
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
22
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
23 #include "libvo/video_out.h"
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
24
4188
cfd1eed5961d using mp_image.h - not finished...
arpi
parents: 4156
diff changeset
25 #include "stheader.h"
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
26 #include "vd.h"
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents: 5328
diff changeset
27 #include "vf.h"
4188
cfd1eed5961d using mp_image.h - not finished...
arpi
parents: 4156
diff changeset
28
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
29 #include "dec_video.h"
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
30
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
31 #ifdef DYNAMIC_PLUGINS
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
32 #include <dlfcn.h>
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
33 #endif
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
34
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
35 // ===================================================================
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
36
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
37 extern double video_time_usage;
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
38 extern double vout_time_usage;
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
39
3144
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
40 #include "cpudetect.h"
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
41
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
42 int divx_quality=0;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
43
5180
7e77d7344208 supports query_format in codecs
arpi
parents: 5171
diff changeset
44 vd_functions_t* mpvdec=NULL;
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
45
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
46 int get_video_quality_max(sh_video_t *sh_video){
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
47 vf_instance_t* vf=sh_video->vfilter;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
48 if(vf){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
49 int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL);
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
50 if(ret>0){
6989
b2ba67f6203e messages moved from dec_??d?o.c
jaf
parents: 6887
diff changeset
51 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingExternalPP,ret);
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
52 return ret;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
53 }
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
54 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
55 if(mpvdec){
4967
arpi
parents: 4957
diff changeset
56 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
57 if(ret>0){
6989
b2ba67f6203e messages moved from dec_??d?o.c
jaf
parents: 6887
diff changeset
58 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingCodecPP,ret);
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
59 return ret;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
60 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
61 }
6138
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5984
diff changeset
62 // 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
63 return 0;
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
64 }
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
65
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
66 void set_video_quality(sh_video_t *sh_video,int quality){
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
67 vf_instance_t* vf=sh_video->vfilter;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
68 if(vf){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
69 int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality));
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
70 if(ret==CONTROL_TRUE) return; // success
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
71 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
72 if(mpvdec)
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
73 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality));
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
74 }
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
75
4395
817530449706 New logic of HW equalizing:
nick
parents: 4388
diff changeset
76 int set_video_colors(sh_video_t *sh_video,char *item,int value)
817530449706 New logic of HW equalizing:
nick
parents: 4388
diff changeset
77 {
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
78 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
79 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
80
54578e5a8050 ... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents: 6800
diff changeset
81 data.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
82 data.value = value;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
83
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
84 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
85 if (vf)
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
86 {
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
87 int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data);
6785
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
88 if (ret == CONTROL_TRUE)
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
89 return(1);
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
90 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
91 /* try software control */
6800
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
92 if(mpvdec)
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
93 if( mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER, item, (int *)value)
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
94 == CONTROL_OK) return 1;
18190
11d7992b37cf Add properties for the tv input color controls.
albeu
parents: 17910
diff changeset
95 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_VideoAttributeNotSupportedByVO_VD,item);
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
96 return 0;
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
97 }
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
98
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
99 int get_video_colors(sh_video_t *sh_video,char *item,int *value)
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
100 {
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
101 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
102 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
103
54578e5a8050 ... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents: 6800
diff changeset
104 data.item = item;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
105
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
106 mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item);
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
107 if (vf)
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
108 {
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
109 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
110 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
111 *value = data.value;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
112 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
113 }
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
114 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
115 /* try software control */
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
116 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value);
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
117 return 0;
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
118 }
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
119
6887
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
120 int set_rectangle(sh_video_t *sh_video,int param,int value)
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
121 {
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
122 vf_instance_t* vf=sh_video->vfilter;
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
123 int data[] = {param, value};
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
124
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
125 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set rectangle \n");
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
126 if (vf)
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
127 {
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
128 int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data);
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
129 if (ret)
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
130 return(1);
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
131 }
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
132 return 0;
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
133 }
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
134
11977
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
135 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
136 {
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
137 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
138 }
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 10683
diff changeset
139
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
140 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
141 {
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
142 int ret;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
143
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
144 if (!mpvdec)
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
145 return -1;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
146 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
147 if (ret >= 10)
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
148 return ret-10;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
149 return -1;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
150 }
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
151
2049
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 2044
diff changeset
152 void uninit_video(sh_video_t *sh_video){
1654
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
153 if(!sh_video->inited) return;
7180
28677d779205 -afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents: 7124
diff changeset
154 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
155 mpvdec->uninit(sh_video);
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
156 #ifdef DYNAMIC_PLUGINS
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
157 if (sh_video->dec_handle)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
158 dlclose(sh_video->dec_handle);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
159 #endif
5737
de47aebf654c filters uninit
arpi
parents: 5643
diff changeset
160 vf_uninit_filter_chain(sh_video->vfilter);
1654
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
161 sh_video->inited=0;
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
162 }
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
163
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16793
diff changeset
164 void vfm_help(void){
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
165 int i;
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
166 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
167 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
168 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
169 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
170 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
171 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
172 mpcodecs_vd_drivers[i]->info->name,
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
173 mpcodecs_vd_drivers[i]->info->comment);
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
174 }
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
175
7180
28677d779205 -afm/-vfm migration from ID (int) to NAME (string) - simplifies code and makes dlopen()'ing possible
arpi
parents: 7124
diff changeset
176 int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status){
16325
attila
parents: 16321
diff changeset
177 int force = 0;
6230
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
178 unsigned int orig_fourcc=sh_video->bih?sh_video->bih->biCompression:0;
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
179 sh_video->codec=NULL;
5925
3f17793b2cea setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents: 5871
diff changeset
180 sh_video->vf_inited=0;
16321
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
181 if (codecname && codecname[0] == '+') {
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
182 codecname = &codecname[1];
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
183 force = 1;
efbfac98cab1 Allow forcing of demuxers and codecs by prepending '+'
reimar
parents: 15789
diff changeset
184 }
6230
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
185
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
186 while(1){
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
187 int i;
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
188 // restore original fourcc:
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
189 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
190 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
191 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
192 sh_video->codec,force) )) break;
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
193 // ok we found one codec
5328
014ddf03476d check and set codec selection - impossible to do it at find_codec
arpi
parents: 5266
diff changeset
194 if(sh_video->codec->flags&CODECS_FLAG_SELECTED) continue; // already tried & failed
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
195 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
196 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
197 if(!force && sh_video->codec->status<status) continue; // too unstable
5328
014ddf03476d check and set codec selection - impossible to do it at find_codec
arpi
parents: 5266
diff changeset
198 sh_video->codec->flags|=CODECS_FLAG_SELECTED; // tagging it
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
199 // ok, it matches all rules, let's find the driver!
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
200 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
201 // 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
202 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
203 mpvdec=mpcodecs_vd_drivers[i];
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
204 #ifdef DYNAMIC_PLUGINS
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
205 if (!mpvdec)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
206 {
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
207 /* try to open shared decoder plugin */
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
208 int buf_len;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
209 char *buf;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
210 vd_functions_t *funcs_sym;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
211 vd_info_t *info_sym;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
212
10272
7b0bc557987b renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents: 9426
diff changeset
213 buf_len = strlen(MPLAYER_LIBDIR)+strlen(sh_video->codec->drv)+16;
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
214 buf = malloc(buf_len);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
215 if (!buf)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
216 break;
10272
7b0bc557987b renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents: 9426
diff changeset
217 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
218 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
219 sh_video->dec_handle = dlopen(buf, RTLD_LAZY);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
220 if (!sh_video->dec_handle)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
221 break;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
222 snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
223 funcs_sym = dlsym(sh_video->dec_handle, buf);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
224 if (!funcs_sym || !funcs_sym->info || !funcs_sym->init ||
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
225 !funcs_sym->uninit || !funcs_sym->control || !funcs_sym->decode)
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
226 break;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
227 info_sym = funcs_sym->info;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
228 if (strcmp(info_sym->short_name, sh_video->codec->drv))
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
229 break;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
230 free(buf);
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
231 mpvdec = funcs_sym;
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
232 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
233 MPLAYER_LIBDIR, sh_video->codec->drv);
8152
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
234 }
4b02f73cb4b9 dlopen() support for ad and vd
alex
parents: 8123
diff changeset
235 #endif
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
236 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
237 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
238 sh_video->codec->name, sh_video->codec->drv);
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
239 continue;
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
240 }
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
241 // it's available, let's try to init!
6566
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
242 if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
243 // align width/height to n*16
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
244 // FIXME: save orig w/h, and restore if codec init failed!
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
245 if(sh_video->bih){
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
246 sh_video->disp_w=sh_video->bih->biWidth=(sh_video->bih->biWidth+15)&(~15);
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
247 sh_video->disp_h=sh_video->bih->biHeight=(sh_video->bih->biHeight+15)&(~15);
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
248 } else {
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
249 sh_video->disp_w=(sh_video->disp_w+15)&(~15);
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
250 sh_video->disp_h=(sh_video->disp_h+15)&(~15);
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
251 }
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
252 }
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
253 // init()
6989
b2ba67f6203e messages moved from dec_??d?o.c
jaf
parents: 6887
diff changeset
254 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_OpeningVideoDecoder,mpvdec->info->short_name,mpvdec->info->name);
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
255 if(!mpvdec->init(sh_video)){
6989
b2ba67f6203e messages moved from dec_??d?o.c
jaf
parents: 6887
diff changeset
256 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_VDecoderInitFailed);
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
257 continue; // try next...
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
258 }
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
259 // Yeah! We got it!
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
260 sh_video->inited=1;
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
261 return 1;
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
262 }
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
263 return 0;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
264 }
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
265
18889
e60c8c7399d2 get_path as const, patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 18237
diff changeset
266 extern char *get_path(const char *filename);
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 8027
diff changeset
267
7506
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
268 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
269 char* vc_l_default[2]={"",(char*)NULL};
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
270 // hack:
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
271 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
272 // Go through the codec.conf and find the best codec...
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
273 sh_video->inited=0;
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
274 codecs_reset_selection(0);
7506
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
275 while(!sh_video->inited && *video_codec_list){
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
276 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
277 if(video_codec[0]){
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
278 if(video_codec[0]=='-'){
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
279 // disable this codec:
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
280 select_codec(video_codec+1,0);
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
281 } else {
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
282 // forced codec by name:
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
283 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_ForcedVideoCodec,video_codec);
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
284 init_video(sh_video,video_codec,NULL,-1);
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
285 }
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
286 } else {
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
287 int status;
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
288 // 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
289 if(video_fm_list){
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
290 char** fmlist=video_fm_list;
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
291 // try first the preferred codec families:
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
292 while(!sh_video->inited && *fmlist){
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
293 char* video_fm=*(fmlist++);
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
294 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
295 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status)
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
296 if(init_video(sh_video,NULL,video_fm,status)) break;
7506
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
297 }
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
298 }
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
299 if(!sh_video->inited)
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
300 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status)
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
301 if(init_video(sh_video,NULL,NULL,status)) break;
7506
c1cb94198e05 -vc/-vfm accepts codec/driver _list_ now. empty list element for -vc means
arpi
parents: 7502
diff changeset
302 }
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
303 }
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
304
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
305 if(!sh_video->inited){
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
306 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format);
10683
aefe3c85ee19 codecs.conf is obsolete.
diego
parents: 10272
diff changeset
307 mp_msg(MSGT_DECAUDIO,MSGL_HINT, MSGTR_RTFMCodecs);
7502
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
308 return 0; // failed
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
309 }
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
310
16793
8d4fb5469efb Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents: 16325
diff changeset
311 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
312 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
313 return 1; // success
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
314 }
6a2b6f3d619c best audio/video codec selection & init moved to libmpcodecs
arpi
parents: 7368
diff changeset
315
5224
f992a01ecc0d using -dr instead -vaa_dr
alex
parents: 5180
diff changeset
316 extern int vo_directrendering;
4515
4064940f3f9b optimization
nick
parents: 4494
diff changeset
317
17910
5ae29dc47c17 feed something (hopefully correct timestamps) into the video filter chain
michael
parents: 17906
diff changeset
318 int decode_video(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame, double pts){
7210
09c8c9cca9e4 100l... sh->vcodec may be changed by mpvdec->decode()
arpi
parents: 7191
diff changeset
319 vf_instance_t* vf;
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
320 mp_image_t *mpi=NULL;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
321 unsigned int t=GetTimer();
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
322 unsigned int t2;
4834
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
323 double tt;
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7210
diff changeset
324 int ret;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
325
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
326 if (correct_pts) {
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
327 int delay = get_current_video_decoder_lag(sh_video);
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
328 if (delay >= 0) {
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
329 if (delay > sh_video->num_buffered_pts)
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
330 #if 0
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
331 // this is disabled because vd_ffmpeg reports the same lag
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
332 // after seek even when there are no buffered frames,
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
333 // leading to incorrect error messages
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
334 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n");
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
335 #else
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
336 ;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
337 #endif
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
338 else
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
339 sh_video->num_buffered_pts = delay;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
340 }
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
341 if (sh_video->num_buffered_pts ==
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
342 sizeof(sh_video->buffered_pts)/sizeof(double))
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
343 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n");
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
344 else {
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
345 int i, j;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
346 for (i = 0; i < sh_video->num_buffered_pts; i++)
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
347 if (sh_video->buffered_pts[i] < pts)
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
348 break;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
349 for (j = sh_video->num_buffered_pts; j > i; j--)
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
350 sh_video->buffered_pts[j] = sh_video->buffered_pts[j-1];
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
351 sh_video->buffered_pts[i] = pts;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
352 sh_video->num_buffered_pts++;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
353 }
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
354 }
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
355
5266
413e450da31c try to uncomment this line - very funny effect (skipping I frames)
arpi
parents: 5224
diff changeset
356 //if(!(sh_video->ds->flags&1) || sh_video->ds->pack_no<5)
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
357 mpi=mpvdec->decode(sh_video, start, in_size, drop_frame);
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
358
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
359 //------------------------ frame decoded. --------------------
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
360
3160
80df2986ca42 {f}emms is only needed on x86
jkeil
parents: 3144
diff changeset
361 #ifdef ARCH_X86
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
362 // some codecs are broken, and doesn't restore MMX state :(
1367
16bedc82bd09 MMX problem workaround for broken (win32) codecs
arpi
parents: 1365
diff changeset
363 // it happens usually with broken/damaged files.
3144
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
364 if(gCpuCaps.has3DNow){
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
365 __asm __volatile ("femms\n\t":::"memory");
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
366 }
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
367 else if(gCpuCaps.hasMMX){
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
368 __asm __volatile ("emms\n\t":::"memory");
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
369 }
3160
80df2986ca42 {f}emms is only needed on x86
jkeil
parents: 3144
diff changeset
370 #endif
1367
16bedc82bd09 MMX problem workaround for broken (win32) codecs
arpi
parents: 1365
diff changeset
371
4834
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
372 t2=GetTimer();t=t2-t;
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
373 tt = t*0.000001f;
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
374 video_time_usage+=tt;
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
375
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5519
diff changeset
376 if(!mpi || drop_frame) return 0; // error / skipped frame
5040
568ca851a05b framedrop fix
arpi
parents: 5005
diff changeset
377
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
378 if (correct_pts) {
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
379 sh_video->num_buffered_pts--;
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
380 pts = sh_video->buffered_pts[sh_video->num_buffered_pts];
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
381 }
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18889
diff changeset
382
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents: 5328
diff changeset
383 //vo_draw_image(video_out,mpi);
7210
09c8c9cca9e4 100l... sh->vcodec may be changed by mpvdec->decode()
arpi
parents: 7191
diff changeset
384 vf=sh_video->vfilter;
17910
5ae29dc47c17 feed something (hopefully correct timestamps) into the video filter chain
michael
parents: 17906
diff changeset
385 ret = vf->put_image(vf,mpi, pts); // apply video filters and call the leaf vo/ve
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7210
diff changeset
386 if(ret>0) vf->control(vf,VFCTRL_DRAW_OSD,NULL);
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
387
4834
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
388 t2=GetTimer()-t2;
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
389 tt=t2*0.000001f;
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
390 vout_time_usage+=tt;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
391
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7210
diff changeset
392 return ret;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
393 }