Mercurial > mplayer.hg
annotate libmpcodecs/dec_video.c @ 5405:c7455d4079ae
using interleaveBytes() for G200 draw_slice
author | arpi |
---|---|
date | Sat, 30 Mar 2002 17:40:22 +0000 |
parents | 014ddf03476d |
children | d0d029fda134 |
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" |
4188 | 29 |
2563 | 30 #include "dec_video.h" |
31 | |
32 // =================================================================== | |
33 | |
34 extern double video_time_usage; | |
35 extern double vout_time_usage; | |
4388 | 36 extern vo_vaa_t vo_vaa; |
2563 | 37 |
2184 | 38 #include "postproc/postprocess.h" |
39 | |
3144 | 40 #include "cpudetect.h" |
41 | |
2563 | 42 int divx_quality=0; |
1294 | 43 |
5180 | 44 vd_functions_t* mpvdec=NULL; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
45 |
1429 | 46 int get_video_quality_max(sh_video_t *sh_video){ |
4957 | 47 if(mpvdec){ |
4967 | 48 int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL); |
4957 | 49 if(ret>=0) return ret; |
50 } | |
1429 | 51 return 0; |
52 } | |
53 | |
54 void set_video_quality(sh_video_t *sh_video,int quality){ | |
4957 | 55 if(mpvdec) |
56 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
1429 | 57 } |
58 | |
4395 | 59 int set_video_colors(sh_video_t *sh_video,char *item,int value) |
60 { | |
61 if(vo_vaa.get_video_eq) | |
4388 | 62 { |
4395 | 63 vidix_video_eq_t veq; |
64 if(vo_vaa.get_video_eq(&veq) == 0) | |
4388 | 65 { |
4395 | 66 int v_hw_equ_cap = veq.cap; |
67 if(v_hw_equ_cap != 0) | |
68 { | |
69 if(vo_vaa.set_video_eq) | |
70 { | |
71 vidix_video_eq_t veq; | |
72 veq.flags = VEQ_FLG_ITU_R_BT_601; /* Fixme please !!! */ | |
73 if(strcmp(item,"Brightness") == 0) | |
74 { | |
75 if(!(v_hw_equ_cap & VEQ_CAP_BRIGHTNESS)) goto try_sw_control; | |
76 veq.brightness = value*10; | |
77 veq.cap = VEQ_CAP_BRIGHTNESS; | |
78 } | |
79 else | |
80 if(strcmp(item,"Contrast") == 0) | |
81 { | |
82 if(!(v_hw_equ_cap & VEQ_CAP_CONTRAST)) goto try_sw_control; | |
83 veq.contrast = value*10; | |
84 veq.cap = VEQ_CAP_CONTRAST; | |
85 } | |
86 else | |
87 if(strcmp(item,"Saturation") == 0) | |
88 { | |
89 if(!(v_hw_equ_cap & VEQ_CAP_SATURATION)) goto try_sw_control; | |
90 veq.saturation = value*10; | |
91 veq.cap = VEQ_CAP_SATURATION; | |
92 } | |
93 else | |
94 if(strcmp(item,"Hue") == 0) | |
95 { | |
96 if(!(v_hw_equ_cap & VEQ_CAP_HUE)) goto try_sw_control; | |
97 veq.hue = value*10; | |
98 veq.cap = VEQ_CAP_HUE; | |
99 } | |
100 else goto try_sw_control;; | |
101 vo_vaa.set_video_eq(&veq); | |
102 } | |
103 return 1; | |
104 } | |
4388 | 105 } |
106 } | |
4395 | 107 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
|
108 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER,item,(int)value); |
1429 | 109 return 0; |
110 } | |
1294 | 111 |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
112 void uninit_video(sh_video_t *sh_video){ |
1654 | 113 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
|
114 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
|
115 mpvdec->uninit(sh_video); |
1654 | 116 sh_video->inited=0; |
117 } | |
118 | |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
119 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
|
120 sh_video->codec=NULL; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
121 while((sh_video->codec=find_codec(sh_video->format, |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
122 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL, |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
123 sh_video->codec,0) )){ |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
124 // ok we found one codec |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
125 int i; |
5328
014ddf03476d
check and set codec selection - impossible to do it at find_codec
arpi
parents:
5266
diff
changeset
|
126 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
|
127 if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
128 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
|
129 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
|
130 sh_video->codec->flags|=CODECS_FLAG_SELECTED; // tagging it |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
131 // ok, it matches all rules, let's find the driver! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
132 for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
133 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
|
134 mpvdec=mpcodecs_vd_drivers[i]; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
135 if(!mpvdec){ // driver not available (==compiled in) |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
136 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
|
137 sh_video->codec->name, sh_video->codec->driver); |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
138 continue; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
139 } |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
140 // it's available, let's try to init! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
141 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
|
142 if(!mpvdec->init(sh_video)){ |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
143 printf("VDecoder init failed :(\n"); |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
144 continue; // try next... |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
145 } |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
146 // Yeah! We got it! |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
147 sh_video->inited=1; |
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
148 return 1; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
149 } |
5171
7145d6aba6cd
init_video() changed - now it handles codec selection
arpi
parents:
5155
diff
changeset
|
150 return 0; |
1294 | 151 } |
152 | |
5224 | 153 extern int vo_directrendering; |
4515 | 154 |
1294 | 155 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ |
4898 | 156 mp_image_t *mpi=NULL; |
1294 | 157 int blit_frame=0; |
1360 | 158 unsigned int t=GetTimer(); |
159 unsigned int t2; | |
4834 | 160 double tt; |
1360 | 161 |
4971 | 162 sh_video->video_out=video_out; |
5266
413e450da31c
try to uncomment this line - very funny effect (skipping I frames)
arpi
parents:
5224
diff
changeset
|
163 |
413e450da31c
try to uncomment this line - very funny effect (skipping I frames)
arpi
parents:
5224
diff
changeset
|
164 //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
|
165 mpi=mpvdec->decode(sh_video, start, in_size, drop_frame); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
166 |
1294 | 167 //------------------------ frame decoded. -------------------- |
168 | |
3160 | 169 #ifdef ARCH_X86 |
1367 | 170 // some codecs is broken, and doesn't restore MMX state :( |
171 // it happens usually with broken/damaged files. | |
3144 | 172 if(gCpuCaps.has3DNow){ |
173 __asm __volatile ("femms\n\t":::"memory"); | |
174 } | |
175 else if(gCpuCaps.hasMMX){ | |
176 __asm __volatile ("emms\n\t":::"memory"); | |
177 } | |
3160 | 178 #endif |
1367 | 179 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
180 if(!mpi) return 0; // error / skipped frame |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
181 |
4834 | 182 t2=GetTimer();t=t2-t; |
183 tt = t*0.000001f; | |
184 video_time_usage+=tt; | |
4898 | 185 |
5040 | 186 if(drop_frame) return 0; |
187 | |
4971 | 188 if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){ |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
189 // blit frame: |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
190 if(mpi->flags&MP_IMGFLAG_PLANAR) |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
191 video_out->draw_slice(mpi->planes,mpi->stride,sh_video->disp_w,sh_video->disp_h,0,0); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
192 else |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
193 video_out->draw_frame(mpi->planes); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
194 } |
4898 | 195 |
4834 | 196 t2=GetTimer()-t2; |
197 tt=t2*0.000001f; | |
198 vout_time_usage+=tt; | |
1360 | 199 blit_frame=1; |
200 | |
1294 | 201 return blit_frame; |
202 } | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
203 |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
204 |