Mercurial > mplayer.hg
annotate libmpcodecs/dec_video.c @ 4965:923605707de6
sorry, 10l:)
author | pontscho |
---|---|
date | Thu, 07 Mar 2002 00:03:51 +0000 |
parents | 2826b2e5cbd3 |
children | f88dfc3de52c |
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 // =================================================================== | |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
33 // temp hack: |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
34 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
35 #ifdef FF_POSTPROCESS |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
36 #ifndef MBC |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
37 #define MBC 48 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
38 #define MBR 36 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
39 #endif |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
40 int quant_store[MBR+1][MBC+1]; // [Review] |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
41 #endif |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
42 |
4953 | 43 //int avcodec_inited=0; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
44 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
45 // =================================================================== |
2563 | 46 |
4844
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
47 extern int benchmark; |
2563 | 48 extern double video_time_usage; |
49 extern double vout_time_usage; | |
4834 | 50 extern double max_video_time_usage; |
51 extern double max_vout_time_usage; | |
4838 | 52 extern double cur_video_time_usage; |
53 extern double cur_vout_time_usage; | |
4388 | 54 extern vo_vaa_t vo_vaa; |
2563 | 55 |
2184 | 56 #include "postproc/postprocess.h" |
57 | |
3144 | 58 #include "cpudetect.h" |
59 | |
2563 | 60 int divx_quality=0; |
1294 | 61 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
62 static vd_functions_t* mpvdec=NULL; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
63 |
1429 | 64 int get_video_quality_max(sh_video_t *sh_video){ |
4957 | 65 if(mpvdec){ |
66 int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL); | |
67 if(ret>=0) return ret; | |
68 } | |
1429 | 69 return 0; |
70 } | |
71 | |
72 void set_video_quality(sh_video_t *sh_video,int quality){ | |
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: |
2938
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
126 |
4898 | 127 |
1429 | 128 return 0; |
129 } | |
1294 | 130 |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
131 void uninit_video(sh_video_t *sh_video){ |
1654 | 132 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
|
133 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
|
134 mpvdec->uninit(sh_video); |
1654 | 135 sh_video->inited=0; |
136 } | |
137 | |
4453 | 138 int init_video(sh_video_t *sh_video,int *pitches) |
139 { | |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
140 //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
|
141 int i; |
4453 | 142 pitches[0] = pitches[1] =pitches[2] = 0; /* fake unknown */ |
1294 | 143 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
144 //sh_video->our_out_buffer=NULL; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
145 //sh_video->our_out_buffer_size=0U; |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
146 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
147 for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
148 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
|
149 mpvdec=mpcodecs_vd_drivers[i]; break; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
150 } |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
151 if(!mpvdec) return 0; // no such driver |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
152 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
153 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
|
154 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
155 if(!mpvdec->init(sh_video)){ |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
156 printf("VDecoder init failed :(\n"); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
157 return 0; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
158 } |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
159 |
1654 | 160 sh_video->inited=1; |
1294 | 161 return 1; |
162 } | |
163 | |
4494 | 164 extern int vaa_use_dr; |
4515 | 165 |
4741 | 166 static int use_dr=0,use_dr_422=0; |
4515 | 167 static bes_da_t bda; |
4741 | 168 void init_video_vaa( unsigned width ) |
4515 | 169 { |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
170 unsigned adp; |
4515 | 171 memset(&bda,0,sizeof(bes_da_t)); |
172 if(vo_vaa.query_bes_da) | |
173 use_dr = vo_vaa.query_bes_da(&bda) ? 0 : 1; | |
174 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
|
175 if(use_dr) |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
176 { |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
177 uint32_t sstride,dstride; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
178 sstride=width*2; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
179 adp = bda.dest.pitch.y-1; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
180 dstride=(width*2+adp)&~adp; |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4741
diff
changeset
|
181 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
|
182 } |
4515 | 183 } |
184 | |
1294 | 185 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ |
4898 | 186 mp_image_t *mpi=NULL; |
1294 | 187 int blit_frame=0; |
1360 | 188 unsigned int t=GetTimer(); |
189 unsigned int t2; | |
4834 | 190 double tt; |
1360 | 191 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
192 mpi=mpvdec->decode(sh_video, start, in_size, drop_frame); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
193 |
1294 | 194 //------------------------ frame decoded. -------------------- |
195 | |
3160 | 196 #ifdef ARCH_X86 |
1367 | 197 // some codecs is broken, and doesn't restore MMX state :( |
198 // it happens usually with broken/damaged files. | |
3144 | 199 if(gCpuCaps.has3DNow){ |
200 __asm __volatile ("femms\n\t":::"memory"); | |
201 } | |
202 else if(gCpuCaps.hasMMX){ | |
203 __asm __volatile ("emms\n\t":::"memory"); | |
204 } | |
3160 | 205 #endif |
1367 | 206 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
207 if(!mpi) return 0; // error / skipped frame |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
208 |
4834 | 209 t2=GetTimer();t=t2-t; |
210 tt = t*0.000001f; | |
211 video_time_usage+=tt; | |
4844
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
212 if(benchmark) |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
213 { |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
214 if(tt > max_video_time_usage) max_video_time_usage=tt; |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
215 cur_video_time_usage=tt; |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
216 } |
4898 | 217 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
218 if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALBACK))){ |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
219 // blit frame: |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
220 if(mpi->flags&MP_IMGFLAG_PLANAR) |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
221 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
|
222 else |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
223 video_out->draw_frame(mpi->planes); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
224 } |
4898 | 225 |
4834 | 226 t2=GetTimer()-t2; |
227 tt=t2*0.000001f; | |
228 vout_time_usage+=tt; | |
4844
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
229 if(benchmark) |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
230 { |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
231 if(tt > max_vout_time_usage) max_vout_time_usage = tt; |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
232 cur_vout_time_usage=tt; |
76acf5bbda78
exclude benchmark stuff execution from normal playback
nick
parents:
4838
diff
changeset
|
233 } |
1360 | 234 blit_frame=1; |
235 | |
1294 | 236 return blit_frame; |
237 } | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
238 |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
239 |