Mercurial > mplayer.hg
comparison mplayer.c @ 1248:3f7f48067d3b
optional libavcodec (ffmpeg) support
author | arpi |
---|---|
date | Sat, 30 Jun 2001 00:16:39 +0000 |
parents | 7f69c1dd1e91 |
children | 76263a48a57b |
comparison
equal
deleted
inserted
replaced
1247:429aacbe23a7 | 1248:3f7f48067d3b |
---|---|
61 #include "spudec.h" | 61 #include "spudec.h" |
62 | 62 |
63 #ifdef USE_DIRECTSHOW | 63 #ifdef USE_DIRECTSHOW |
64 #include "DirectShow/DS_VideoDec.h" | 64 #include "DirectShow/DS_VideoDec.h" |
65 #include "DirectShow/DS_AudioDec.h" | 65 #include "DirectShow/DS_AudioDec.h" |
66 #endif | |
67 | |
68 #ifdef USE_LIBAVCODEC | |
69 #include "libavcodec/avcodec.h" | |
70 AVCodec *lavc_codec=NULL; | |
71 AVCodecContext lavc_context; | |
72 AVPicture lavc_picture; | |
66 #endif | 73 #endif |
67 | 74 |
68 #include "opendivx/decore.h" | 75 #include "opendivx/decore.h" |
69 | 76 |
70 | 77 |
1277 | 1284 |
1278 } | 1285 } |
1279 if(verbose) printf("INFO: OpenDivX video codec init OK!\n"); | 1286 if(verbose) printf("INFO: OpenDivX video codec init OK!\n"); |
1280 break; | 1287 break; |
1281 } | 1288 } |
1289 case 5: { // FFmpeg's libavcodec | |
1290 #ifndef USE_LIBAVCODEC | |
1291 fprintf(stderr,"MPlayer was compiled WITHOUT libavcodec support!\n"); | |
1292 exit(1); | |
1293 #else | |
1294 if(verbose) printf("FFmpeg's libavcodec video codec\n"); | |
1295 avcodec_init(); | |
1296 avcodec_register_all(); | |
1297 lavc_codec = avcodec_find_decoder_by_name(sh_video->codec->dll); | |
1298 if(!lavc_codec){ | |
1299 fprintf(stderr,"Can't find codec '%s' in libavcodec...\n",sh_video->codec->dll); | |
1300 exit(1); | |
1301 } | |
1302 memset(&lavc_context, 0, sizeof(lavc_context)); | |
1303 lavc_context.width=sh_video->disp_w; | |
1304 lavc_context.height=sh_video->disp_h; | |
1305 printf("libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height); | |
1306 /* open it */ | |
1307 if (avcodec_open(&lavc_context, lavc_codec) < 0) { | |
1308 fprintf(stderr, "could not open codec\n"); | |
1309 exit(1); | |
1310 } | |
1311 | |
1312 if(verbose) printf("INFO: libavcodec init OK!\n"); | |
1313 break; | |
1314 #endif | |
1315 } | |
1316 | |
1282 case 1: { | 1317 case 1: { |
1283 // init libmpeg2: | 1318 // init libmpeg2: |
1284 #ifdef MPEG12_POSTPROC | 1319 #ifdef MPEG12_POSTPROC |
1285 picture->pp_options=divx_quality; | 1320 picture->pp_options=divx_quality; |
1286 #else | 1321 #else |
1707 video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0); | 1742 video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0); |
1708 } else | 1743 } else |
1709 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); | 1744 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); |
1710 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | 1745 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; |
1711 } | 1746 } |
1747 break; | |
1748 } | |
1749 #endif | |
1750 #ifdef USE_LIBAVCODEC | |
1751 case 5: { // libavcodec | |
1752 unsigned char* start=NULL; | |
1753 unsigned int t=GetTimer(); | |
1754 unsigned int t2; | |
1755 int got_picture=0; | |
1756 int in_size=ds_get_packet(d_video,&start); | |
1757 if(in_size<0){ eof=1;break;} | |
1758 if(in_size>max_framesize) max_framesize=in_size; | |
1759 | |
1760 if(d_video->flags) if(verbose) printf("***keyframe***\n"); | |
1761 | |
1762 if(drop_frame<2){ | |
1763 int ret = avcodec_decode_video(&lavc_context, &lavc_picture, | |
1764 &got_picture, start, in_size); | |
1765 if(ret<0) fprintf(stderr, "Error while decoding frame!\n"); | |
1766 } | |
1767 | |
1768 current_module="draw_frame"; | |
1769 | |
1770 if(!drop_frame && got_picture){ | |
1771 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; | |
1772 video_out->draw_slice(lavc_picture.data,lavc_picture.linesize,sh_video->disp_w,sh_video->disp_h,0,0); | |
1773 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | |
1774 } | |
1775 | |
1712 break; | 1776 break; |
1713 } | 1777 } |
1714 #endif | 1778 #endif |
1715 case 2: { | 1779 case 2: { |
1716 HRESULT ret; | 1780 HRESULT ret; |