Mercurial > mplayer.hg
annotate libmpcodecs/dec_video.c @ 5155:ff8d788ecfde
init_video_vaa() removed
author | arpi |
---|---|
date | Sun, 17 Mar 2002 02:29:41 +0000 |
parents | 23879c23ec67 |
children | 7145d6aba6cd |
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 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
44 static vd_functions_t* mpvdec=NULL; |
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 | |
4453 | 119 int init_video(sh_video_t *sh_video,int *pitches) |
120 { | |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
121 //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
|
122 int i; |
5076 | 123 //pitches[0] = pitches[1] =pitches[2] = 0; /* fake unknown */ |
1294 | 124 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
125 //sh_video->our_out_buffer=NULL; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
126 //sh_video->our_out_buffer_size=0U; |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
127 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
128 for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
129 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
|
130 mpvdec=mpcodecs_vd_drivers[i]; break; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
131 } |
5005
24d5713afe2f
old temp vars removed, in-codecs equalizer support added, error message if -vfm N/A
arpi
parents:
4971
diff
changeset
|
132 if(!mpvdec){ |
24d5713afe2f
old temp vars removed, in-codecs equalizer support added, error message if -vfm N/A
arpi
parents:
4971
diff
changeset
|
133 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
|
134 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
|
135 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
|
136 } |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
137 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
138 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
|
139 |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
140 if(!mpvdec->init(sh_video)){ |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
141 printf("VDecoder init failed :(\n"); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
142 return 0; |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
143 } |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
144 |
1654 | 145 sh_video->inited=1; |
1294 | 146 return 1; |
147 } | |
148 | |
4494 | 149 extern int vaa_use_dr; |
4515 | 150 |
1294 | 151 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ |
4898 | 152 mp_image_t *mpi=NULL; |
1294 | 153 int blit_frame=0; |
1360 | 154 unsigned int t=GetTimer(); |
155 unsigned int t2; | |
4834 | 156 double tt; |
1360 | 157 |
4971 | 158 sh_video->video_out=video_out; |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
159 mpi=mpvdec->decode(sh_video, start, in_size, drop_frame); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
160 |
1294 | 161 //------------------------ frame decoded. -------------------- |
162 | |
3160 | 163 #ifdef ARCH_X86 |
1367 | 164 // some codecs is broken, and doesn't restore MMX state :( |
165 // it happens usually with broken/damaged files. | |
3144 | 166 if(gCpuCaps.has3DNow){ |
167 __asm __volatile ("femms\n\t":::"memory"); | |
168 } | |
169 else if(gCpuCaps.hasMMX){ | |
170 __asm __volatile ("emms\n\t":::"memory"); | |
171 } | |
3160 | 172 #endif |
1367 | 173 |
4902
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
174 if(!mpi) return 0; // error / skipped frame |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
175 |
4834 | 176 t2=GetTimer();t=t2-t; |
177 tt = t*0.000001f; | |
178 video_time_usage+=tt; | |
4898 | 179 |
5040 | 180 if(drop_frame) return 0; |
181 | |
4971 | 182 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
|
183 // blit frame: |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
184 if(mpi->flags&MP_IMGFLAG_PLANAR) |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
185 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
|
186 else |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
187 video_out->draw_frame(mpi->planes); |
7c4edfe929c8
implemented basic wrapper functions to new libmpcodecs api
arpi
parents:
4901
diff
changeset
|
188 } |
4898 | 189 |
4834 | 190 t2=GetTimer()-t2; |
191 tt=t2*0.000001f; | |
192 vout_time_usage+=tt; | |
1360 | 193 blit_frame=1; |
194 | |
1294 | 195 return blit_frame; |
196 } | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
197 |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
198 |