comparison libmpcodecs/dec_video.c @ 4901:6b2c6ce84aea

dec_video.c added
author arpi
date Fri, 01 Mar 2002 00:25:43 +0000
parents dec_video.c@a6b9c1fc6ee9
children 7c4edfe929c8
comparison
equal deleted inserted replaced
4900:260edd600949 4901:6b2c6ce84aea
1
2 #include "config.h"
3
4 #include <stdio.h>
5 #ifdef HAVE_MALLOC_H
6 #include <malloc.h>
7 #endif
8 #include <stdlib.h>
9 #include <unistd.h>
10
11 #include "mp_msg.h"
12 #include "help_mp.h"
13
14 #include "linux/timer.h"
15 #include "linux/shmem.h"
16
17 extern int verbose; // defined in mplayer.c
18
19 #include "stream.h"
20 #include "demuxer.h"
21 #include "parse_es.h"
22
23 #include "codec-cfg.h"
24
25 #include "libvo/video_out.h"
26
27 #include "stheader.h"
28
29 #include "dec_video.h"
30
31 // ===================================================================
32
33 extern int benchmark;
34 extern double video_time_usage;
35 extern double vout_time_usage;
36 extern double max_video_time_usage;
37 extern double max_vout_time_usage;
38 extern double cur_video_time_usage;
39 extern double cur_vout_time_usage;
40 extern vo_vaa_t vo_vaa;
41
42 #include "postproc/postprocess.h"
43
44 #include "cpudetect.h"
45
46 int divx_quality=0;
47
48 int get_video_quality_max(sh_video_t *sh_video){
49 // switch(sh_video->codec->driver){
50 return 0;
51 }
52
53 void set_video_quality(sh_video_t *sh_video,int quality){
54 // switch(sh_video->codec->driver){
55 }
56
57 int set_video_colors(sh_video_t *sh_video,char *item,int value)
58 {
59 if(vo_vaa.get_video_eq)
60 {
61 vidix_video_eq_t veq;
62 if(vo_vaa.get_video_eq(&veq) == 0)
63 {
64 int v_hw_equ_cap = veq.cap;
65 if(v_hw_equ_cap != 0)
66 {
67 if(vo_vaa.set_video_eq)
68 {
69 vidix_video_eq_t veq;
70 veq.flags = VEQ_FLG_ITU_R_BT_601; /* Fixme please !!! */
71 if(strcmp(item,"Brightness") == 0)
72 {
73 if(!(v_hw_equ_cap & VEQ_CAP_BRIGHTNESS)) goto try_sw_control;
74 veq.brightness = value*10;
75 veq.cap = VEQ_CAP_BRIGHTNESS;
76 }
77 else
78 if(strcmp(item,"Contrast") == 0)
79 {
80 if(!(v_hw_equ_cap & VEQ_CAP_CONTRAST)) goto try_sw_control;
81 veq.contrast = value*10;
82 veq.cap = VEQ_CAP_CONTRAST;
83 }
84 else
85 if(strcmp(item,"Saturation") == 0)
86 {
87 if(!(v_hw_equ_cap & VEQ_CAP_SATURATION)) goto try_sw_control;
88 veq.saturation = value*10;
89 veq.cap = VEQ_CAP_SATURATION;
90 }
91 else
92 if(strcmp(item,"Hue") == 0)
93 {
94 if(!(v_hw_equ_cap & VEQ_CAP_HUE)) goto try_sw_control;
95 veq.hue = value*10;
96 veq.cap = VEQ_CAP_HUE;
97 }
98 else goto try_sw_control;;
99 vo_vaa.set_video_eq(&veq);
100 }
101 return 1;
102 }
103 }
104 }
105 try_sw_control:
106
107
108 return 0;
109 }
110
111 void uninit_video(sh_video_t *sh_video){
112 if(!sh_video->inited) return;
113 mp_msg(MSGT_DECVIDEO,MSGL_V,"uninit video: %d \n",sh_video->codec->driver);
114 // switch(sh_video->codec->driver){
115 sh_video->inited=0;
116 }
117
118 int init_video(sh_video_t *sh_video,int *pitches)
119 {
120 unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx];
121 pitches[0] = pitches[1] =pitches[2] = 0; /* fake unknown */
122
123 sh_video->our_out_buffer=NULL;
124 sh_video->our_out_buffer_size=0U;
125
126 sh_video->image=new_mp_image(sh_video->disp_w,sh_video->disp_h);
127 mp_image_setfmt(sh_video->image,out_fmt);
128
129 //switch(sh_video->codec->driver)
130
131
132 sh_video->inited=1;
133 return 1;
134 }
135
136 extern int vaa_use_dr;
137
138 static int use_dr=0,use_dr_422=0;
139 static bes_da_t bda;
140 void init_video_vaa( unsigned width )
141 {
142 unsigned adp;
143 memset(&bda,0,sizeof(bes_da_t));
144 if(vo_vaa.query_bes_da)
145 use_dr = vo_vaa.query_bes_da(&bda) ? 0 : 1;
146 if(!vaa_use_dr) use_dr = 0;
147 if(use_dr)
148 {
149 uint32_t sstride,dstride;
150 sstride=width*2;
151 adp = bda.dest.pitch.y-1;
152 dstride=(width*2+adp)&~adp;
153 if(sstride == dstride) use_dr_422 = 1;
154 }
155 }
156
157 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){
158 mp_image_t *mpi=NULL;
159 int blit_frame=0;
160 unsigned int t=GetTimer();
161 unsigned int t2;
162 double tt;
163
164
165 //------------------------ frame decoded. --------------------
166
167 #ifdef ARCH_X86
168 // some codecs is broken, and doesn't restore MMX state :(
169 // it happens usually with broken/damaged files.
170 if(gCpuCaps.has3DNow){
171 __asm __volatile ("femms\n\t":::"memory");
172 }
173 else if(gCpuCaps.hasMMX){
174 __asm __volatile ("emms\n\t":::"memory");
175 }
176 #endif
177
178 t2=GetTimer();t=t2-t;
179 tt = t*0.000001f;
180 video_time_usage+=tt;
181 if(benchmark)
182 {
183 if(tt > max_video_time_usage) max_video_time_usage=tt;
184 cur_video_time_usage=tt;
185 }
186
187 if(mpi){
188 // if(planar)
189 // video_out->draw_slice(mpi->planes,mpi->stride,sh_video->disp_w,sh_video->disp_h,0,0);
190 // else
191 // video_out->draw_frame(mpi->planes);
192
193 t2=GetTimer()-t2;
194 tt=t2*0.000001f;
195 vout_time_usage+=tt;
196 if(benchmark)
197 {
198 if(tt > max_vout_time_usage) max_vout_time_usage = tt;
199 cur_vout_time_usage=tt;
200 }
201 blit_frame=1;
202 }
203
204 return blit_frame;
205 }
206
207