comparison dec_video.c @ 1349:3db173705860

DivX4Linux support
author arpi
date Thu, 19 Jul 2001 22:43:19 +0000
parents b12e1817bcc2
children 5ac130627602
comparison
equal deleted inserted replaced
1348:e7778832010d 1349:3db173705860
43 AVCodec *lavc_codec=NULL; 43 AVCodec *lavc_codec=NULL;
44 AVCodecContext lavc_context; 44 AVCodecContext lavc_context;
45 AVPicture lavc_picture; 45 AVPicture lavc_picture;
46 #endif 46 #endif
47 47
48 #ifndef NEW_DECORE
48 #include "opendivx/decore.h" 49 #include "opendivx/decore.h"
50 #else
51 #include <decore.h>
52 #endif
49 53
50 //**************************************************************************// 54 //**************************************************************************//
51 // The OpenDivX stuff: 55 // The OpenDivX stuff:
52 //**************************************************************************// 56 //**************************************************************************//
53 57
154 #endif /* !ARCH_X86 */ 158 #endif /* !ARCH_X86 */
155 case 3: { // OpenDivX 159 case 3: { // OpenDivX
156 if(verbose) printf("OpenDivX video codec\n"); 160 if(verbose) printf("OpenDivX video codec\n");
157 { DEC_PARAM dec_param; 161 { DEC_PARAM dec_param;
158 DEC_SET dec_set; 162 DEC_SET dec_set;
163 memset(&dec_param,0,sizeof(dec_param));
159 #ifdef NEW_DECORE 164 #ifdef NEW_DECORE
160 DEC_MEM_REQS dec_mem;
161 dec_param.output_format=DEC_USER; 165 dec_param.output_format=DEC_USER;
162 #else 166 #else
163 dec_param.color_depth = 32; 167 dec_param.color_depth = 32;
164 #endif 168 #endif
165 dec_param.x_dim = sh_video->bih->biWidth; 169 dec_param.x_dim = sh_video->bih->biWidth;
166 dec_param.y_dim = sh_video->bih->biHeight; 170 dec_param.y_dim = sh_video->bih->biHeight;
167 #ifdef NEW_DECORE
168 // 0.50-CVS new malloc scheme
169 decore(0x123, DEC_OPT_MEMORY_REQS, &dec_param, &dec_mem);
170 dec_param.buffers.mp4_edged_ref_buffers=malloc(dec_mem.mp4_edged_ref_buffers_size);
171 dec_param.buffers.mp4_edged_for_buffers=malloc(dec_mem.mp4_edged_for_buffers_size);
172 dec_param.buffers.mp4_display_buffers=malloc(dec_mem.mp4_display_buffers_size);
173 dec_param.buffers.mp4_state=malloc(dec_mem.mp4_state_size);
174 dec_param.buffers.mp4_tables=malloc(dec_mem.mp4_tables_size);
175 dec_param.buffers.mp4_stream=malloc(dec_mem.mp4_stream_size);
176 #endif
177 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); 171 decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
178
179 dec_set.postproc_level = divx_quality; 172 dec_set.postproc_level = divx_quality;
180 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); 173 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
181 174 }
175 if(verbose) printf("INFO: OpenDivX video codec init OK!\n");
176 break;
177 }
178 case 7: { // DivX4Linux
179 if(verbose) printf("DivX4Linux video codec\n");
180 { DEC_PARAM dec_param;
181 DEC_SET dec_set;
182 int bits=16;
183 memset(&dec_param,0,sizeof(dec_param));
184 switch(out_fmt){
185 case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break;
186 case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break;
187 case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break;
188 case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break;
189 case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break;
190 case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break;
191 case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break;
192 case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break;
193 default:
194 fprintf(stderr,"Unsupported out_fmt: 0x%X\n",out_fmt);
195 return 0;
196 }
197 dec_param.x_dim = sh_video->bih->biWidth;
198 dec_param.y_dim = sh_video->bih->biHeight;
199 decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
200 dec_set.postproc_level = divx_quality;
201 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
202 // sh_video->our_out_buffer = shmem_alloc(((bits*dec_param.x_dim+7)/8)*dec_param.y_dim);
203 sh_video->our_out_buffer = shmem_alloc(dec_param.x_dim*dec_param.y_dim*5);
182 } 204 }
183 if(verbose) printf("INFO: OpenDivX video codec init OK!\n"); 205 if(verbose) printf("INFO: OpenDivX video codec init OK!\n");
184 break; 206 break;
185 } 207 }
186 case 5: { // FFmpeg's libavcodec 208 case 5: { // FFmpeg's libavcodec
245 DEC_PICTURE dec_pic; 267 DEC_PICTURE dec_pic;
246 #endif 268 #endif
247 // let's decode 269 // let's decode
248 dec_frame.length = in_size; 270 dec_frame.length = in_size;
249 dec_frame.bitstream = start; 271 dec_frame.bitstream = start;
250 dec_frame.render_flag = 1; 272 dec_frame.render_flag = drop_frame?0:1;
273
251 #ifdef NEW_DECORE 274 #ifdef NEW_DECORE
252 dec_frame.bmp=&dec_pic; 275 dec_frame.bmp=&dec_pic;
253 dec_pic.y=dec_pic.u=dec_pic.v=NULL; 276 dec_pic.y=dec_pic.u=dec_pic.v=NULL;
254 #endif 277 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL);
278 #else
255 decore(0x123, 0, &dec_frame, NULL); 279 decore(0x123, 0, &dec_frame, NULL);
280 #endif
281
256 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; 282 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
257 283
284 // let's display
258 #ifdef NEW_DECORE 285 #ifdef NEW_DECORE
259 if(dec_pic.y){ 286 if(dec_pic.y){
260 void* src[3]; 287 void* src[3];
261 int stride[3]; 288 int stride[3];
262 src[0]=dec_pic.y; 289 src[0]=dec_pic.y;
274 sh_video->disp_w,sh_video->disp_h,0,0); 301 sh_video->disp_w,sh_video->disp_h,0,0);
275 opendivx_src[0]=NULL; 302 opendivx_src[0]=NULL;
276 blit_frame=1; 303 blit_frame=1;
277 } 304 }
278 #endif 305 #endif
306 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
307
308 break;
309 }
310 case 7: {
311 // DivX4Linux
312 unsigned int t=GetTimer();
313 unsigned int t2;
314 DEC_FRAME dec_frame;
315 // let's decode
316 dec_frame.length = in_size;
317 dec_frame.bitstream = start;
318 dec_frame.render_flag = drop_frame?0:1;
319 dec_frame.bmp=sh_video->our_out_buffer;
320 dec_frame.stride=sh_video->disp_w;
321 // printf("Decoding DivX4 frame\n");
322 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL);
323 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
324
325 if(!drop_frame && sh_video->our_out_buffer){
326 // printf("Displaying DivX4 frame\n");
327 if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){
328 uint8_t* dst[3];
329 int stride[3];
330 stride[0]=sh_video->disp_w;
331 stride[1]=stride[2]=sh_video->disp_w/2;
332 dst[0]=sh_video->our_out_buffer;
333 dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h;
334 dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4;
335 video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0);
336 } else
337 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer);
338 blit_frame=1;
339 }
340
279 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; 341 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
280 342
281 break; 343 break;
282 } 344 }
283 #ifdef USE_DIRECTSHOW 345 #ifdef USE_DIRECTSHOW