Mercurial > mplayer.hg
annotate libmpcodecs/dec_video.c @ 5849:77a529bfc80e
some fixes
author | arpi |
---|---|
date | Fri, 26 Apr 2002 20:32:03 +0000 |
parents | de47aebf654c |
children | c03422eaaadf |
rev | line source |
---|---|
2775 | 1 |
2 #include "config.h" | |
1294 | 3 |
4 #include <stdio.h> | |
2775 | 5 #ifdef HAVE_MALLOC_H |
6 #include <malloc.h> | |
7 #endif | |
1294 | 8 #include <stdlib.h> |
1430 | 9 #include <unistd.h> |
1294 | 10 |
1567 | 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 | 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 | 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 | 17 extern int verbose; // defined in mplayer.c |
18 | |
1294 | 19 #include "stream.h" |
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 | 22 |
23 #include "codec-cfg.h" | |
24 | |
25 #include "libvo/video_out.h" | |
26 | |
4188 | 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 | 30 |
2563 | 31 #include "dec_video.h" |
32 | |
33 // =================================================================== | |
34 | |
35 extern double video_time_usage; | |
36 extern double vout_time_usage; | |
4388 | 37 extern vo_vaa_t vo_vaa; |
2563 | 38 |
2184 | 39 #include "postproc/postprocess.h" |
40 | |
3144 | 41 #include "cpudetect.h" |
42 | |
2563 | 43 int divx_quality=0; |
1294 | 44 |
5180 | 45 vd_functions_t* mpvdec=NULL; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
46 |
1429 | 47 int get_video_quality_max(sh_video_t *sh_video){ |
5519 | 48 vf_instance_t* vf=sh_video->vfilter; |
49 if(vf){ | |
50 int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL); | |
51 if(ret>0){ | |
52 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Using external postprocessing filter, max q = %d\n",ret); | |
53 return ret; | |
54 } | |
55 } | |
4957 | 56 if(mpvdec){ |
4967 | 57 int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL); |
5519 | 58 if(ret>0){ |
59 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Using codec's postprocessing, max q = %d\n",ret); | |
60 return ret; | |
61 } | |
4957 | 62 } |
5519 | 63 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Sorry, postprocessing is not available\n"); |
64 return 0; | |
1429 | 65 } |
66 | |
67 void set_video_quality(sh_video_t *sh_video,int quality){ | |
5519 | 68 vf_instance_t* vf=sh_video->vfilter; |
69 if(vf){ | |
70 int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
71 if(ret==CONTROL_TRUE) return; // success | |
72 } | |
4957 | 73 if(mpvdec) |
74 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
1429 | 75 } |
76 | |
4395 | 77 int set_video_colors(sh_video_t *sh_video,char *item,int value) |
78 { | |
79 if(vo_vaa.get_video_eq) | |
4388 | 80 { |
4395 | 81 vidix_video_eq_t veq; |
82 if(vo_vaa.get_video_eq(&veq) == 0) | |
4388 | 83 { |
4395 | 84 int v_hw_equ_cap = veq.cap; |
85 if(v_hw_equ_cap != 0) | |
86 { | |
87 if(vo_vaa.set_video_eq) | |
88 { | |
89 vidix_video_eq_t veq; | |
90 veq.flags = VEQ_FLG_ITU_R_BT_601; /* Fixme please !!! */ | |
91 if(strcmp(item,"Brightness") == 0) | |
92 { | |
93 if(!(v_hw_equ_cap & VEQ_CAP_BRIGHTNESS)) goto try_sw_control; | |
94 veq.brightness = value*10; | |
95 veq.cap = VEQ_CAP_BRIGHTNESS; | |
96 } | |
97 else | |
98 if(strcmp(item,"Contrast") == 0) | |
99 { | |
100 if(!(v_hw_equ_cap & VEQ_CAP_CONTRAST)) goto try_sw_control; | |
101 veq.contrast = value*10; | |
102 veq.cap = VEQ_CAP_CONTRAST; | |
103 } | |
104 else | |
105 if(strcmp(item,"Saturation") == 0) | |
106 { | |
107 if(!(v_hw_equ_cap & VEQ_CAP_SATURATION)) goto try_sw_control; | |
108 veq.saturation = value*10; | |
109 veq.cap = VEQ_CAP_SATURATION; | |
110 } | |
111 else | |
112 if(strcmp(item,"Hue") == 0) | |
113 { | |
114 if(!(v_hw_equ_cap & VEQ_CAP_HUE)) goto try_sw_control; | |
115 veq.hue = value*10; | |
116 veq.cap = VEQ_CAP_HUE; | |
117 } | |
118 else goto try_sw_control;; | |
119 vo_vaa.set_video_eq(&veq); | |
120 } | |
121 return 1; | |
122 } | |
4388 | 123 } |
124 } | |
4395 | 125 try_sw_control: |
5005
24d5713afe2f
old temp vars removed, in-codecs equalizer support added, error message if -vfm N/A
arpi
parents:
4971
diff
changeset
|
126 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER,item,(int)value); |
1429 | 127 return 0; |
128 } | |
1294 | 129 |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
130 void uninit_video(sh_video_t *sh_video){ |
1654 | 131 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
|
132 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
|
133 mpvdec->uninit(sh_video); |
5737 | 134 vf_uninit_filter_chain(sh_video->vfilter); |
1654 | 135 sh_video->inited=0; |
136 } | |
137 | |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
138 int init_video(sh_video_t *sh_video,char* codecname,int vfm,int status){ |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
139 sh_video->codec=NULL; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
140 while((sh_video->codec=find_codec(sh_video->format, |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
141 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL, |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
142 sh_video->codec,0) )){ |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
143 // ok we found one codec |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
144 int i; |
5328
014ddf03476d
check and set codec selection - impossible to do it at find_codec
arpi
parents:
5266
diff
changeset
|
145 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
|
146 if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
147 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
|
148 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
|
149 sh_video->codec->flags|=CODECS_FLAG_SELECTED; // tagging it |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
150 // ok, it matches all rules, let's find the driver! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
151 for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
152 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
|
153 mpvdec=mpcodecs_vd_drivers[i]; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
154 if(!mpvdec){ // driver not available (==compiled in) |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
155 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Requested video codec family [%s] (vfm=%d) not available (enable it at compile time!)\n", |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
156 sh_video->codec->name, sh_video->codec->driver); |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
157 continue; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
158 } |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
159 // it's available, let's try to init! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
160 printf("Opening Video Decoder: [%s] %s\n",mpvdec->info->short_name,mpvdec->info->name); |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
161 if(!mpvdec->init(sh_video)){ |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
162 printf("VDecoder init failed :(\n"); |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
163 continue; // try next... |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
164 } |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
165 // Yeah! We got it! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
166 sh_video->inited=1; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
167 return 1; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
168 } |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
169 return 0; |
1294 | 170 } |
171 | |
5224 | 172 extern int vo_directrendering; |
4515 | 173 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5328
diff
changeset
|
174 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
|
175 vf_instance_t* vf=sh_video->vfilter; |
4898 | 176 mp_image_t *mpi=NULL; |
1294 | 177 int blit_frame=0; |
1360 | 178 unsigned int t=GetTimer(); |
179 unsigned int t2; | |
4834 | 180 double tt; |
1360 | 181 |
5266
413e450da31c
try to uncomment this line - very funny effect (skipping I frames)
arpi
parents:
5224
diff
changeset
|
182 //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
|
183 mpi=mpvdec->decode(sh_video, start, in_size, drop_frame); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
184 |
1294 | 185 //------------------------ frame decoded. -------------------- |
186 | |
3160 | 187 #ifdef ARCH_X86 |
1367 | 188 // some codecs is broken, and doesn't restore MMX state :( |
189 // it happens usually with broken/damaged files. | |
3144 | 190 if(gCpuCaps.has3DNow){ |
191 __asm __volatile ("femms\n\t":::"memory"); | |
192 } | |
193 else if(gCpuCaps.hasMMX){ | |
194 __asm __volatile ("emms\n\t":::"memory"); | |
195 } | |
3160 | 196 #endif |
1367 | 197 |
4834 | 198 t2=GetTimer();t=t2-t; |
199 tt = t*0.000001f; | |
200 video_time_usage+=tt; | |
4898 | 201 |
5643 | 202 if(!mpi || drop_frame) return 0; // error / skipped frame |
5040 | 203 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
5328
diff
changeset
|
204 //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
|
205 vf->put_image(vf,mpi); |
5643 | 206 vf->control(vf,VFCTRL_DRAW_OSD,NULL); |
4898 | 207 |
4834 | 208 t2=GetTimer()-t2; |
209 tt=t2*0.000001f; | |
210 vout_time_usage+=tt; | |
1360 | 211 blit_frame=1; |
212 | |
1294 | 213 return blit_frame; |
214 } |