annotate libmpcodecs/dec_video.c @ 6931:da4a3a8e1f08

100l
author arpi
date Mon, 05 Aug 2002 19:38:30 +0000
parents 66427e850216
children b2ba67f6203e
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
1327
b12e1817bcc2 some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents: 1309
diff changeset
14 #include "linux/timer.h"
1496
8c3e93ef116d cleanup...
arpi
parents: 1489
diff changeset
15 #include "linux/shmem.h"
1327
b12e1817bcc2 some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents: 1309
diff changeset
16
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
17 extern int verbose; // defined in mplayer.c
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
18
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
19 #include "stream.h"
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
20 #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
21 #include "parse_es.h"
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
22
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
23 #include "codec-cfg.h"
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
24
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
25 #include "libvo/video_out.h"
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
26
4188
cfd1eed5961d using mp_image.h - not finished...
arpi
parents: 4156
diff changeset
27 #include "stheader.h"
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
28 #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
29 #include "vf.h"
4188
cfd1eed5961d using mp_image.h - not finished...
arpi
parents: 4156
diff changeset
30
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
31 #include "dec_video.h"
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
32
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
33 // ===================================================================
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
34
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
35 extern double video_time_usage;
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
36 extern double vout_time_usage;
4388
b6b429d10296 Support for HW equalizing
nick
parents: 4301
diff changeset
37 extern vo_vaa_t vo_vaa;
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
38
2184
966ec115c87f integrated new postproc code
arpi
parents: 2087
diff changeset
39 #include "postproc/postprocess.h"
966ec115c87f integrated new postproc code
arpi
parents: 2087
diff changeset
40
3144
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
41 #include "cpudetect.h"
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
42
2563
fc124f9db88e more cleanup, warnings fixed
arpi
parents: 2541
diff changeset
43 int divx_quality=0;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
44
5180
7e77d7344208 supports query_format in codecs
arpi
parents: 5171
diff changeset
45 vd_functions_t* mpvdec=NULL;
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
46
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
47 int get_video_quality_max(sh_video_t *sh_video){
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
48 vf_instance_t* vf=sh_video->vfilter;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
49 if(vf){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
50 int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL);
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
51 if(ret>0){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
52 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Using external postprocessing filter, max q = %d\n",ret);
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
53 return ret;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
54 }
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
55 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
56 if(mpvdec){
4967
arpi
parents: 4957
diff changeset
57 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
58 if(ret>0){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
59 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Using codec's postprocessing, max q = %d\n",ret);
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
60 return ret;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
61 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
62 }
6138
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5984
diff changeset
63 // 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
64 return 0;
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
65 }
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
66
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
67 void set_video_quality(sh_video_t *sh_video,int quality){
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
68 vf_instance_t* vf=sh_video->vfilter;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
69 if(vf){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
70 int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality));
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
71 if(ret==CONTROL_TRUE) return; // success
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5507
diff changeset
72 }
4957
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
73 if(mpvdec)
2826b2e5cbd3 new controls added for query/set pp level
arpi
parents: 4953
diff changeset
74 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality));
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
75 }
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
76
4395
817530449706 New logic of HW equalizing:
nick
parents: 4388
diff changeset
77 int set_video_colors(sh_video_t *sh_video,char *item,int value)
817530449706 New logic of HW equalizing:
nick
parents: 4388
diff changeset
78 {
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
79 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
80 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
81
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.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
83 data.value = value;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
84
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
85 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
86 if (vf)
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
87 {
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
88 int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data);
6785
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
89 if (ret == CONTROL_TRUE)
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
90 return(1);
12dcd0f85262 fixed possible 10l bug (vf not initialized yet)
alex
parents: 6780
diff changeset
91 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
92 /* try software control */
6800
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
93 if(mpvdec)
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
94 if( mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER, item, (int *)value)
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
95 == CONTROL_OK) return 1;
6ad5d182153c print warning about unsupported video eq attributes
arpi
parents: 6786
diff changeset
96 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"Video attribute '%s' isn't supported by selected vo & vd! \n",item);
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
97 return 0;
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
98 }
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
99
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
100 int get_video_colors(sh_video_t *sh_video,char *item,int *value)
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
101 {
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
102 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
103 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
104
54578e5a8050 ... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents: 6800
diff changeset
105 data.item = item;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
106
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
107 mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item);
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
108 if (vf)
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
109 {
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
110 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
111 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
112 *value = data.value;
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
113 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
114 }
6786
b16cb6cbff5a eq reworked
alex
parents: 6785
diff changeset
115 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
116 /* try software control */
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
117 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value);
1429
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
118 return 0;
8986d06b2816 contrast/brightness/etc patch (temporary)
arpi
parents: 1422
diff changeset
119 }
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
120
6887
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
121 int set_rectangle(sh_video_t *sh_video,int param,int value)
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
122 {
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
123 vf_instance_t* vf=sh_video->vfilter;
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
124 int data[] = {param, value};
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
125
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
126 mp_dbg(MSGT_DECVIDEO,MSGL_V,"set rectangle \n");
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
127 if (vf)
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
128 {
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
129 int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data);
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
130 if (ret)
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
131 return(1);
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
132 }
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
133 return 0;
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
134 }
66427e850216 Add the control VFCTRL_CHANGE_RECTANGLE
kmkaplan
parents: 6832
diff changeset
135
2049
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 2044
diff changeset
136 void uninit_video(sh_video_t *sh_video){
1654
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
137 if(!sh_video->inited) return;
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1949
diff changeset
138 mp_msg(MSGT_DECVIDEO,MSGL_V,"uninit video: %d \n",sh_video->codec->driver);
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
139 mpvdec->uninit(sh_video);
5737
de47aebf654c filters uninit
arpi
parents: 5643
diff changeset
140 vf_uninit_filter_chain(sh_video->vfilter);
1654
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
141 sh_video->inited=0;
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
142 }
9d85b84e367e dec_video uninit
arpi
parents: 1653
diff changeset
143
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
144 int init_video(sh_video_t *sh_video,char* codecname,int vfm,int status){
6230
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
145 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
146 sh_video->codec=NULL;
5925
3f17793b2cea setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents: 5871
diff changeset
147 sh_video->vf_inited=0;
6230
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
148
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
149 while(1){
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
150 int i;
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
151 // restore original fourcc:
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
152 if(sh_video->bih) sh_video->bih->biCompression=orig_fourcc;
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
153 if(!(sh_video->codec=find_codec(sh_video->format,
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
154 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,
936aa617e829 restore original bih->biCompression if codec init failed
arpi
parents: 6138
diff changeset
155 sh_video->codec,0) )) break;
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
156 // ok we found one codec
5328
014ddf03476d check and set codec selection - impossible to do it at find_codec
arpi
parents: 5266
diff changeset
157 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
158 if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
159 if(vfm>=0 && sh_video->codec->driver!=vfm) continue; // vfm doesn't match
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
160 if(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
161 sh_video->codec->flags|=CODECS_FLAG_SELECTED; // tagging it
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
162 // ok, it matches all rules, let's find the driver!
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
163 for (i=0; mpcodecs_vd_drivers[i] != NULL; i++)
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
164 if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break;
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
165 mpvdec=mpcodecs_vd_drivers[i];
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
166 if(!mpvdec){ // driver not available (==compiled in)
5925
3f17793b2cea setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents: 5871
diff changeset
167 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Requested video codec family [%s] (vfm=%d) not available (enable it at compile time!)\n",
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
168 sh_video->codec->name, sh_video->codec->driver);
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
169 continue;
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
170 }
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
171 // it's available, let's try to init!
6566
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
172 if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
173 // align width/height to n*16
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
174 // FIXME: save orig w/h, and restore if codec init failed!
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
175 if(sh_video->bih){
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
176 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
177 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
178 } else {
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
179 sh_video->disp_w=(sh_video->disp_w+15)&(~15);
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
180 sh_video->disp_h=(sh_video->disp_h+15)&(~15);
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
181 }
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
182 }
a48ad140c3af support the 'align16' codec flag
arpi
parents: 6230
diff changeset
183 // init()
6138
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5984
diff changeset
184 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"Opening video decoder: [%s] %s\n",mpvdec->info->short_name,mpvdec->info->name);
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
185 if(!mpvdec->init(sh_video)){
5925
3f17793b2cea setting vf_inited flag, some printf->mp_msg, some MSGL_FATAL->MSGL_WARN
arpi
parents: 5871
diff changeset
186 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"VDecoder init failed :(\n");
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
187 continue; // try next...
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
188 }
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
189 // Yeah! We got it!
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
190 sh_video->inited=1;
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
191 return 1;
4902
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
192 }
5171
7145d6aba6cd init_video() changed - now it handles codec selection
arpi
parents: 5155
diff changeset
193 return 0;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
194 }
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
195
5224
f992a01ecc0d using -dr instead -vaa_dr
alex
parents: 5180
diff changeset
196 extern int vo_directrendering;
4515
4064940f3f9b optimization
nick
parents: 4494
diff changeset
197
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents: 5328
diff changeset
198 int decode_video(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents: 5328
diff changeset
199 vf_instance_t* vf=sh_video->vfilter;
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
200 mp_image_t *mpi=NULL;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
201 unsigned int t=GetTimer();
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
202 unsigned int t2;
4834
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
203 double tt;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
204
5266
413e450da31c try to uncomment this line - very funny effect (skipping I frames)
arpi
parents: 5224
diff changeset
205 //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
206 mpi=mpvdec->decode(sh_video, start, in_size, drop_frame);
7c4edfe929c8 implemented basic wrapper functions to new libmpcodecs api
arpi
parents: 4901
diff changeset
207
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
208 //------------------------ frame decoded. --------------------
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
209
3160
80df2986ca42 {f}emms is only needed on x86
jkeil
parents: 3144
diff changeset
210 #ifdef ARCH_X86
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6566
diff changeset
211 // some codecs are broken, and doesn't restore MMX state :(
1367
16bedc82bd09 MMX problem workaround for broken (win32) codecs
arpi
parents: 1365
diff changeset
212 // it happens usually with broken/damaged files.
3144
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
213 if(gCpuCaps.has3DNow){
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
214 __asm __volatile ("femms\n\t":::"memory");
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
215 }
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
216 else if(gCpuCaps.hasMMX){
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
217 __asm __volatile ("emms\n\t":::"memory");
ce34f5b40272 runtime cpu detection
michael
parents: 3073
diff changeset
218 }
3160
80df2986ca42 {f}emms is only needed on x86
jkeil
parents: 3144
diff changeset
219 #endif
1367
16bedc82bd09 MMX problem workaround for broken (win32) codecs
arpi
parents: 1365
diff changeset
220
4834
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
221 t2=GetTimer();t=t2-t;
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
222 tt = t*0.000001f;
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
223 video_time_usage+=tt;
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
224
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5519
diff changeset
225 if(!mpi || drop_frame) return 0; // error / skipped frame
5040
568ca851a05b framedrop fix
arpi
parents: 5005
diff changeset
226
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents: 5328
diff changeset
227 //vo_draw_image(video_out,mpi);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents: 5328
diff changeset
228 vf->put_image(vf,mpi);
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5519
diff changeset
229 vf->control(vf,VFCTRL_DRAW_OSD,NULL);
4898
a6b9c1fc6ee9 removed codec dependent parts, only core left
arpi
parents: 4881
diff changeset
230
4834
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
231 t2=GetTimer()-t2;
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
232 tt=t2*0.000001f;
fdb92826250c max & average benchmarks
nick
parents: 4750
diff changeset
233 vout_time_usage+=tt;
1360
3ab0d3f21f51 some cleanup, redundant code removed
arpi
parents: 1352
diff changeset
234
5984
fc19842f703a blit_frame is useless - noticed by Nick K.
arpi
parents: 5925
diff changeset
235 return 1;
1294
0a8e0c7ddd0c video decoder stuff
arpi
parents:
diff changeset
236 }