Mercurial > mplayer.hg
comparison dec_video.c @ 1360:3ab0d3f21f51
some cleanup, redundant code removed
author | arpi |
---|---|
date | Fri, 20 Jul 2001 02:14:14 +0000 |
parents | 5ac130627602 |
children | 11673118f37f |
comparison
equal
deleted
inserted
replaced
1359:e0188a73c02a | 1360:3ab0d3f21f51 |
---|---|
257 return 1; | 257 return 1; |
258 } | 258 } |
259 | 259 |
260 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ | 260 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ |
261 unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx]; | 261 unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx]; |
262 int planar=(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420); | |
262 int blit_frame=0; | 263 int blit_frame=0; |
264 | |
265 uint8_t* planes_[3]; | |
266 uint8_t** planes=planes_; | |
267 int stride_[3]; | |
268 int* stride=stride_; | |
269 | |
270 unsigned int t=GetTimer(); | |
271 unsigned int t2; | |
263 | 272 |
264 //-------------------- Decode a frame: ----------------------- | 273 //-------------------- Decode a frame: ----------------------- |
265 switch(sh_video->codec->driver){ | 274 switch(sh_video->codec->driver){ |
266 case 3: { | 275 case 3: { |
267 // OpenDivX | 276 // OpenDivX |
268 unsigned int t=GetTimer(); | |
269 unsigned int t2; | |
270 DEC_FRAME dec_frame; | 277 DEC_FRAME dec_frame; |
271 #ifdef NEW_DECORE | 278 #ifdef NEW_DECORE |
272 DEC_PICTURE dec_pic; | 279 DEC_PICTURE dec_pic; |
273 #endif | 280 #endif |
274 // let's decode | 281 // let's decode |
279 #ifdef NEW_DECORE | 286 #ifdef NEW_DECORE |
280 dec_frame.bmp=&dec_pic; | 287 dec_frame.bmp=&dec_pic; |
281 dec_pic.y=dec_pic.u=dec_pic.v=NULL; | 288 dec_pic.y=dec_pic.u=dec_pic.v=NULL; |
282 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | 289 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); |
283 #else | 290 #else |
291 opendivx_src[0]=NULL; | |
284 decore(0x123, 0, &dec_frame, NULL); | 292 decore(0x123, 0, &dec_frame, NULL); |
285 #endif | 293 #endif |
286 | 294 |
287 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; | 295 if(!drop_frame) |
288 | 296 |
289 // let's display | 297 // let's display |
290 #ifdef NEW_DECORE | 298 #ifdef NEW_DECORE |
291 if(dec_pic.y){ | 299 if(dec_pic.y){ |
292 void* src[3]; | 300 planes[0]=dec_pic.y; |
293 int stride[3]; | 301 planes[1]=dec_pic.u; |
294 src[0]=dec_pic.y; | 302 planes[2]=dec_pic.v; |
295 src[1]=dec_pic.u; | |
296 src[2]=dec_pic.v; | |
297 stride[0]=dec_pic.stride_y; | 303 stride[0]=dec_pic.stride_y; |
298 stride[1]=stride[2]=dec_pic.stride_uv; | 304 stride[1]=stride[2]=dec_pic.stride_uv; |
299 video_out->draw_slice(src,stride, | 305 blit_frame=2; |
300 sh_video->disp_w,sh_video->disp_h,0,0); | |
301 blit_frame=1; | |
302 } | 306 } |
303 #else | 307 #else |
304 if(opendivx_src[0]){ | 308 if(opendivx_src[0]){ |
305 video_out->draw_slice(opendivx_src,opendivx_stride, | 309 planes=opendivx_src; stride=opendivx_stride; |
306 sh_video->disp_w,sh_video->disp_h,0,0); | 310 blit_frame=2; |
307 opendivx_src[0]=NULL; | |
308 blit_frame=1; | |
309 } | 311 } |
310 #endif | 312 #endif |
311 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | |
312 | 313 |
313 break; | 314 break; |
314 } | 315 } |
315 #ifdef NEW_DECORE | 316 #ifdef NEW_DECORE |
316 case 7: { | 317 case 7: { |
317 // DivX4Linux | 318 // DivX4Linux |
318 unsigned int t=GetTimer(); | |
319 unsigned int t2; | |
320 DEC_FRAME dec_frame; | 319 DEC_FRAME dec_frame; |
321 // let's decode | 320 // let's decode |
322 dec_frame.length = in_size; | 321 dec_frame.length = in_size; |
323 dec_frame.bitstream = start; | 322 dec_frame.bitstream = start; |
324 dec_frame.render_flag = drop_frame?0:1; | 323 dec_frame.render_flag = drop_frame?0:1; |
325 dec_frame.bmp=sh_video->our_out_buffer; | 324 dec_frame.bmp=sh_video->our_out_buffer; |
326 dec_frame.stride=sh_video->disp_w; | 325 dec_frame.stride=sh_video->disp_w; |
327 // printf("Decoding DivX4 frame\n"); | 326 // printf("Decoding DivX4 frame\n"); |
328 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | 327 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); |
329 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; | 328 if(!drop_frame) blit_frame=3; |
330 | |
331 if(!drop_frame && sh_video->our_out_buffer){ | |
332 // printf("Displaying DivX4 frame\n"); | |
333 if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){ | |
334 uint8_t* dst[3]; | |
335 int stride[3]; | |
336 stride[0]=sh_video->disp_w; | |
337 stride[1]=stride[2]=sh_video->disp_w/2; | |
338 dst[0]=sh_video->our_out_buffer; | |
339 dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h; | |
340 dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4; | |
341 video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
342 } else | |
343 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); | |
344 blit_frame=1; | |
345 } | |
346 | |
347 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | |
348 | |
349 break; | 329 break; |
350 } | 330 } |
351 #endif | 331 #endif |
352 #ifdef USE_DIRECTSHOW | 332 #ifdef USE_DIRECTSHOW |
353 case 4: { // W32/DirectShow | 333 case 4: { // W32/DirectShow |
354 unsigned int t=GetTimer(); | |
355 unsigned int t2; | |
356 | |
357 if(drop_frame<2) DS_VideoDecoder_DecodeFrame(start, in_size, 0, !drop_frame); | 334 if(drop_frame<2) DS_VideoDecoder_DecodeFrame(start, in_size, 0, !drop_frame); |
358 | 335 if(!drop_frame) blit_frame=3; |
359 if(!drop_frame && sh_video->our_out_buffer){ | |
360 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; | |
361 if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){ | |
362 uint8_t* dst[3]; | |
363 int stride[3]; | |
364 stride[0]=sh_video->disp_w; | |
365 stride[1]=stride[2]=sh_video->disp_w/2; | |
366 dst[0]=sh_video->our_out_buffer; | |
367 dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h; | |
368 dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4; | |
369 video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
370 } else | |
371 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); | |
372 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | |
373 blit_frame=1; | |
374 } | |
375 break; | 336 break; |
376 } | 337 } |
377 #endif | 338 #endif |
378 #ifdef USE_LIBAVCODEC | 339 #ifdef USE_LIBAVCODEC |
379 case 5: { // libavcodec | 340 case 5: { // libavcodec |
380 unsigned int t=GetTimer(); | |
381 unsigned int t2; | |
382 int got_picture=0; | 341 int got_picture=0; |
383 | |
384 if(drop_frame<2 && in_size>0){ | 342 if(drop_frame<2 && in_size>0){ |
385 int ret = avcodec_decode_video(&lavc_context, &lavc_picture, | 343 int ret = avcodec_decode_video(&lavc_context, &lavc_picture, |
386 &got_picture, start, in_size); | 344 &got_picture, start, in_size); |
387 if(ret<0) fprintf(stderr, "Error while decoding frame!\n"); | 345 if(ret<0) fprintf(stderr, "Error while decoding frame!\n"); |
346 if(!drop_frame && got_picture){ | |
347 planes=lavc_picture.data; | |
348 stride=lavc_picture.linesize; | |
349 blit_frame=2; | |
350 } | |
388 } | 351 } |
389 | 352 break; |
390 if(!drop_frame && got_picture){ | 353 } |
391 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; | 354 #endif |
392 video_out->draw_slice(lavc_picture.data,lavc_picture.linesize,sh_video->disp_w,sh_video->disp_h,0,0); | 355 #ifdef ARCH_X86 |
393 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | |
394 blit_frame=1; | |
395 } | |
396 | |
397 break; | |
398 } | |
399 #endif | |
400 case 6: | 356 case 6: |
401 case 2: | 357 case 2: |
402 #ifdef ARCH_X86 | |
403 { | 358 { |
404 HRESULT ret; | 359 HRESULT ret; |
405 unsigned int t=GetTimer(); | |
406 unsigned int t2; | |
407 | 360 |
408 if(in_size){ | 361 if(!in_size) break; |
362 | |
409 sh_video->bih->biSizeImage = in_size; | 363 sh_video->bih->biSizeImage = in_size; |
410 | 364 |
411 // sh_video->bih->biWidth = 1280; | 365 // sh_video->bih->biWidth = 1280; |
412 // sh_video->o_bih.biWidth = 1280; | 366 // sh_video->o_bih.biWidth = 1280; |
413 // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), | 367 // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), |
426 sh_video->bih, start, | 380 sh_video->bih, start, |
427 &sh_video->o_bih, | 381 &sh_video->o_bih, |
428 drop_frame ? 0 : sh_video->our_out_buffer); | 382 drop_frame ? 0 : sh_video->our_out_buffer); |
429 | 383 |
430 if(ret){ printf("Error decompressing frame, err=%d\n",(int)ret);break; } | 384 if(ret){ printf("Error decompressing frame, err=%d\n",(int)ret);break; } |
431 } | 385 |
432 // current_module="draw_frame"; | 386 if(!drop_frame) blit_frame=3; |
433 if(!drop_frame){ | 387 break; |
434 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; | 388 } |
435 // if(out_fmt==IMGFMT_YV12){ | |
436 if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){ | |
437 uint8_t* dst[3]; | |
438 int stride[3]; | |
439 stride[0]=sh_video->disp_w; | |
440 stride[1]=stride[2]=sh_video->disp_w/2; | |
441 dst[0]=sh_video->our_out_buffer; | |
442 dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h; | |
443 dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4; | |
444 video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
445 } else | |
446 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); | |
447 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | |
448 blit_frame=1; | |
449 } | |
450 break; | |
451 } | |
452 #else | |
453 printf("Win32 video codec unavailable on non-x86 CPU -> force nosound :(\n"); | |
454 break; | |
455 #endif | 389 #endif |
456 case 1: { | 390 case 1: { |
457 int t=0; | 391 int t=0; |
458 | |
459 t-=GetTimer(); | 392 t-=GetTimer(); |
460 mpeg2_decode_data(video_out, start, start+in_size,drop_frame); | 393 mpeg2_decode_data(video_out, start, start+in_size,drop_frame); |
461 t+=GetTimer(); video_time_usage+=t*0.000001; | 394 t+=GetTimer(); video_time_usage+=t*0.000001; |
462 blit_frame=1; | 395 if(!drop_frame) blit_frame=1; |
463 | |
464 break; | 396 break; |
465 } | 397 } |
466 } // switch | 398 } // switch |
467 //------------------------ frame decoded. -------------------- | 399 //------------------------ frame decoded. -------------------- |
468 | 400 |
401 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; | |
402 | |
403 switch(blit_frame){ | |
404 case 3: | |
405 if(planar){ | |
406 stride[0]=sh_video->disp_w; | |
407 stride[1]=stride[2]=sh_video->disp_w/2; | |
408 planes[0]=sh_video->our_out_buffer; | |
409 planes[2]=planes[0]+sh_video->disp_w*sh_video->disp_h; | |
410 planes[1]=planes[2]+sh_video->disp_w*sh_video->disp_h/4; | |
411 } else | |
412 planes[0]=sh_video->our_out_buffer; | |
413 case 2: | |
414 if(planar) | |
415 video_out->draw_slice(planes,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
416 else | |
417 video_out->draw_frame(planes); | |
418 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | |
419 blit_frame=1; | |
420 break; | |
421 } | |
422 | |
469 return blit_frame; | 423 return blit_frame; |
470 } | 424 } |