Mercurial > mplayer.hg
annotate libmpcodecs/dec_video.c @ 5016:a17d9e37c93c
applied patch from KotH
author | gabucino |
---|---|
date | Sun, 10 Mar 2002 07:44:09 +0000 |
parents | 24d5713afe2f |
children | 568ca851a05b |
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 | |
4844
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
34 extern int benchmark; |
2563 | 35 extern double video_time_usage; |
36 extern double vout_time_usage; | |
4834 | 37 extern double max_video_time_usage; |
38 extern double max_vout_time_usage; | |
4838 | 39 extern double cur_video_time_usage; |
40 extern double cur_vout_time_usage; | |
4388 | 41 extern vo_vaa_t vo_vaa; |
2563 | 42 |
2184 | 43 #include "postproc/postprocess.h" |
44 | |
3144 | 45 #include "cpudetect.h" |
46 | |
2563 | 47 int divx_quality=0; |
1294 | 48 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
49 static vd_functions_t* mpvdec=NULL; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
50 |
1429 | 51 int get_video_quality_max(sh_video_t *sh_video){ |
4957 | 52 if(mpvdec){ |
4967 | 53 int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL); |
4957 | 54 if(ret>=0) return ret; |
55 } | |
1429 | 56 return 0; |
57 } | |
58 | |
59 void set_video_quality(sh_video_t *sh_video,int quality){ | |
4957 | 60 if(mpvdec) |
61 mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality)); | |
1429 | 62 } |
63 | |
4395 | 64 int set_video_colors(sh_video_t *sh_video,char *item,int value) |
65 { | |
66 if(vo_vaa.get_video_eq) | |
4388 | 67 { |
4395 | 68 vidix_video_eq_t veq; |
69 if(vo_vaa.get_video_eq(&veq) == 0) | |
4388 | 70 { |
4395 | 71 int v_hw_equ_cap = veq.cap; |
72 if(v_hw_equ_cap != 0) | |
73 { | |
74 if(vo_vaa.set_video_eq) | |
75 { | |
76 vidix_video_eq_t veq; | |
77 veq.flags = VEQ_FLG_ITU_R_BT_601; /* Fixme please !!! */ | |
78 if(strcmp(item,"Brightness") == 0) | |
79 { | |
80 if(!(v_hw_equ_cap & VEQ_CAP_BRIGHTNESS)) goto try_sw_control; | |
81 veq.brightness = value*10; | |
82 veq.cap = VEQ_CAP_BRIGHTNESS; | |
83 } | |
84 else | |
85 if(strcmp(item,"Contrast") == 0) | |
86 { | |
87 if(!(v_hw_equ_cap & VEQ_CAP_CONTRAST)) goto try_sw_control; | |
88 veq.contrast = value*10; | |
89 veq.cap = VEQ_CAP_CONTRAST; | |
90 } | |
91 else | |
92 if(strcmp(item,"Saturation") == 0) | |
93 { | |
94 if(!(v_hw_equ_cap & VEQ_CAP_SATURATION)) goto try_sw_control; | |
95 veq.saturation = value*10; | |
96 veq.cap = VEQ_CAP_SATURATION; | |
97 } | |
98 else | |
99 if(strcmp(item,"Hue") == 0) | |
100 { | |
101 if(!(v_hw_equ_cap & VEQ_CAP_HUE)) goto try_sw_control; | |
102 veq.hue = value*10; | |
103 veq.cap = VEQ_CAP_HUE; | |
104 } | |
105 else goto try_sw_control;; | |
106 vo_vaa.set_video_eq(&veq); | |
107 } | |
108 return 1; | |
109 } | |
4388 | 110 } |
111 } | |
4395 | 112 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
|
113 if(mpvdec) return mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER,item,(int)value); |
1429 | 114 return 0; |
115 } | |
1294 | 116 |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
117 void uninit_video(sh_video_t *sh_video){ |
1654 | 118 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
|
119 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
|
120 mpvdec->uninit(sh_video); |
1654 | 121 sh_video->inited=0; |
122 } | |
123 | |
4453 | 124 int init_video(sh_video_t *sh_video,int *pitches) |
125 { | |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
126 //unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx]; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
127 int i; |
4453 | 128 pitches[0] = pitches[1] =pitches[2] = 0; /* fake unknown */ |
1294 | 129 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
130 //sh_video->our_out_buffer=NULL; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
131 //sh_video->our_out_buffer_size=0U; |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
132 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
133 for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
134 if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver){ |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
135 mpvdec=mpcodecs_vd_drivers[i]; break; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
136 } |
5005
24d5713afe2f
old temp vars removed, in-codecs equalizer support added, error message if -vfm N/A
arpi
parents:
4971
diff
changeset
|
137 if(!mpvdec){ |
24d5713afe2f
old temp vars removed, in-codecs equalizer support added, error message if -vfm N/A
arpi
parents:
4971
diff
changeset
|
138 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Requested video codec family [%s] (vfm=%d) not available (enable it at compile time!)\n", |
24d5713afe2f
old temp vars removed, in-codecs equalizer support added, error message if -vfm N/A
arpi
parents:
4971
diff
changeset
|
139 sh_video->codec->name, sh_video->codec->driver); |
24d5713afe2f
old temp vars removed, in-codecs equalizer support added, error message if -vfm N/A
arpi
parents:
4971
diff
changeset
|
140 return 0; // no such driver |
24d5713afe2f
old temp vars removed, in-codecs equalizer support added, error message if -vfm N/A
arpi
parents:
4971
diff
changeset
|
141 } |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
142 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
143 printf("Selecting Video Decoder: [%s] %s\n",mpvdec->info->short_name,mpvdec->info->name); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
144 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
145 if(!mpvdec->init(sh_video)){ |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
146 printf("VDecoder init failed :(\n"); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
147 return 0; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
148 } |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
149 |
1654 | 150 sh_video->inited=1; |
1294 | 151 return 1; |
152 } | |
153 | |
4494 | 154 extern int vaa_use_dr; |
4515 | 155 |
4741 | 156 static int use_dr=0,use_dr_422=0; |
4515 | 157 static bes_da_t bda; |
4741 | 158 void init_video_vaa( unsigned width ) |
4515 | 159 { |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
160 unsigned adp; |
4515 | 161 memset(&bda,0,sizeof(bes_da_t)); |
162 if(vo_vaa.query_bes_da) | |
163 use_dr = vo_vaa.query_bes_da(&bda) ? 0 : 1; | |
164 if(!vaa_use_dr) use_dr = 0; | |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
165 if(use_dr) |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
166 { |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
167 uint32_t sstride,dstride; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
168 sstride=width*2; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
169 adp = bda.dest.pitch.y-1; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
170 dstride=(width*2+adp)&~adp; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
171 if(sstride == dstride) use_dr_422 = 1; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
172 } |
4515 | 173 } |
174 | |
1294 | 175 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ |
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 |
4971 | 182 sh_video->video_out=video_out; |
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 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
198 if(!mpi) return 0; // error / skipped frame |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
199 |
4834 | 200 t2=GetTimer();t=t2-t; |
201 tt = t*0.000001f; | |
202 video_time_usage+=tt; | |
4844
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
203 if(benchmark) |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
204 { |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
205 if(tt > max_video_time_usage) max_video_time_usage=tt; |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
206 cur_video_time_usage=tt; |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
207 } |
4898 | 208 |
4971 | 209 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
|
210 // blit frame: |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
211 if(mpi->flags&MP_IMGFLAG_PLANAR) |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
212 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
|
213 else |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
214 video_out->draw_frame(mpi->planes); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
215 } |
4898 | 216 |
4834 | 217 t2=GetTimer()-t2; |
218 tt=t2*0.000001f; | |
219 vout_time_usage+=tt; | |
4844
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
220 if(benchmark) |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
221 { |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
222 if(tt > max_vout_time_usage) max_vout_time_usage = tt; |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
223 cur_vout_time_usage=tt; |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
224 } |
1360 | 225 blit_frame=1; |
226 | |
1294 | 227 return blit_frame; |
228 } | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
229 |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
230 |