comparison dec_video.c @ 1973:5216f108cb4f

all error/warn/info messages moved to help_mp-en.h for translation
author arpi
date Wed, 26 Sep 2001 21:35:14 +0000
parents 5ceb384bf163
children dcf6972ef6ca
comparison
equal deleted inserted replaced
1972:78924572fddf 1973:5216f108cb4f
3 #include <stdlib.h> 3 #include <stdlib.h>
4 #include <unistd.h> 4 #include <unistd.h>
5 5
6 #include "config.h" 6 #include "config.h"
7 #include "mp_msg.h" 7 #include "mp_msg.h"
8 #include "help_mp.h"
8 9
9 extern int verbose; // defined in mplayer.c 10 extern int verbose; // defined in mplayer.c
10 extern int divx_quality; 11 extern int divx_quality;
11 12
12 extern double video_time_usage; 13 extern double video_time_usage;
144 return 0; 145 return 0;
145 } 146 }
146 147
147 int uninit_video(sh_video_t *sh_video){ 148 int uninit_video(sh_video_t *sh_video){
148 if(!sh_video->inited) return; 149 if(!sh_video->inited) return;
149 printf("uninit video: %d \n",sh_video->codec->driver); 150 mp_msg(MSGT_DECVIDEO,MSGL_V,"uninit video: %d \n",sh_video->codec->driver);
150 switch(sh_video->codec->driver){ 151 switch(sh_video->codec->driver){
151 #ifdef USE_LIBAVCODEC 152 #ifdef USE_LIBAVCODEC
152 case VFM_FFMPEG: 153 case VFM_FFMPEG:
153 if (avcodec_close(&lavc_context) < 0) 154 if (avcodec_close(&lavc_context) < 0)
154 mp_msg(MSGT_DECVIDEO,MSGL_ERR, "could not close codec\n"); 155 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec);
155 break; 156 break;
156 #endif 157 #endif
157 #ifdef USE_DIRECTSHOW 158 #ifdef USE_DIRECTSHOW
158 case VFM_DSHOW: // Win32/DirectShow 159 case VFM_DSHOW: // Win32/DirectShow
159 DS_VideoDecoder_Close(); 160 DS_VideoDecoder_Close();
177 178
178 switch(sh_video->codec->driver){ 179 switch(sh_video->codec->driver){
179 #ifdef USE_WIN32DLL 180 #ifdef USE_WIN32DLL
180 case VFM_VFW: { 181 case VFM_VFW: {
181 if(!init_video_codec(sh_video,0)) { 182 if(!init_video_codec(sh_video,0)) {
182 // GUI_MSG( mplUnknowError )
183 return 0; 183 return 0;
184 } 184 }
185 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n"); 185 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n");
186 break; 186 break;
187 } 187 }
188 case VFM_VFWEX: { 188 case VFM_VFWEX: {
189 if(!init_video_codec(sh_video,1)) { 189 if(!init_video_codec(sh_video,1)) {
190 // GUI_MSG( mplUnknowError )
191 return 0; 190 return 0;
192 } 191 }
193 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32Ex video codec init OK!\n"); 192 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32Ex video codec init OK!\n");
194 break; 193 break;
195 } 194 }
196 case VFM_DSHOW: { // Win32/DirectShow 195 case VFM_DSHOW: { // Win32/DirectShow
197 #ifndef USE_DIRECTSHOW 196 #ifndef USE_DIRECTSHOW
198 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT directshow support!\n"); 197 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoDShowSupport);
199 return 0; 198 return 0;
200 // GUI_MSG( mplCompileWithoutDSSupport )
201 #else 199 #else
202 int bpp; 200 int bpp;
203 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){ 201 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){
204 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){ 202 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){
205 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll); 203 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_video->codec->dll);
206 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); 204 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
207 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n"); 205 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n");
208 // mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); 206 // mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n");
209 return 0; 207 return 0;
210 // #ifdef HAVE_GUI
211 // if ( !nogui )
212 // {
213 // strcpy( mplShMem->items.videodata.codecdll,sh_video->codec->dll );
214 // mplSendMessage( mplDSCodecNotFound );
215 // usec_sleep( 10000 );
216 // }
217 // #endif
218 } 208 }
219 209
220 switch(out_fmt){ 210 switch(out_fmt){
221 case IMGFMT_YUY2: 211 case IMGFMT_YUY2:
222 case IMGFMT_UYVY: 212 case IMGFMT_UYVY:
246 } 236 }
247 #else /* !USE_WIN32DLL */ 237 #else /* !USE_WIN32DLL */
248 case VFM_VFW: 238 case VFM_VFW:
249 case VFM_DSHOW: 239 case VFM_DSHOW:
250 case VFM_VFWEX: 240 case VFM_VFWEX:
251 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Support for win32 codecs disabled, or unavailable on non-x86 platforms!\n"); 241 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoWin32Support);
252 return 0; 242 return 0;
253 #endif /* !USE_WIN32DLL */ 243 #endif /* !USE_WIN32DLL */
254 case VFM_ODIVX: { // OpenDivX 244 case VFM_ODIVX: { // OpenDivX
255 mp_msg(MSGT_DECVIDEO,MSGL_V,"OpenDivX video codec\n"); 245 mp_msg(MSGT_DECVIDEO,MSGL_V,"OpenDivX video codec\n");
256 { DEC_PARAM dec_param; 246 { DEC_PARAM dec_param;
270 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); 260 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n");
271 break; 261 break;
272 } 262 }
273 case VFM_DIVX4: { // DivX4Linux 263 case VFM_DIVX4: { // DivX4Linux
274 #ifndef NEW_DECORE 264 #ifndef NEW_DECORE
275 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT DivX4Linux (libdivxdecore.so) support!\n"); 265 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoDivx4Support);
276 return 0; 266 return 0;
277 #else 267 #else
278 mp_msg(MSGT_DECVIDEO,MSGL_V,"DivX4Linux video codec\n"); 268 mp_msg(MSGT_DECVIDEO,MSGL_V,"DivX4Linux video codec\n");
279 { DEC_PARAM dec_param; 269 { DEC_PARAM dec_param;
280 DEC_SET dec_set; 270 DEC_SET dec_set;
305 break; 295 break;
306 #endif 296 #endif
307 } 297 }
308 case VFM_FFMPEG: { // FFmpeg's libavcodec 298 case VFM_FFMPEG: { // FFmpeg's libavcodec
309 #ifndef USE_LIBAVCODEC 299 #ifndef USE_LIBAVCODEC
310 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT libavcodec support!\n"); 300 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoLAVCsupport);
311 return 0; 301 return 0;
312 #else 302 #else
313 mp_msg(MSGT_DECVIDEO,MSGL_V,"FFmpeg's libavcodec video codec\n"); 303 mp_msg(MSGT_DECVIDEO,MSGL_V,"FFmpeg's libavcodec video codec\n");
314 if(!avcodec_inited){ 304 if(!avcodec_inited){
315 avcodec_init(); 305 avcodec_init();
316 avcodec_register_all(); 306 avcodec_register_all();
317 avcodec_inited=1; 307 avcodec_inited=1;
318 } 308 }
319 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_video->codec->dll); 309 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_video->codec->dll);
320 if(!lavc_codec){ 310 if(!lavc_codec){
321 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Can't find codec '%s' in libavcodec...\n",sh_video->codec->dll); 311 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_video->codec->dll);
322 return 0; 312 return 0;
323 } 313 }
324 memset(&lavc_context, 0, sizeof(lavc_context)); 314 memset(&lavc_context, 0, sizeof(lavc_context));
325 // sh_video->disp_h/=2; // !! 315 // sh_video->disp_h/=2; // !!
326 lavc_context.width=sh_video->disp_w; 316 lavc_context.width=sh_video->disp_w;
327 lavc_context.height=sh_video->disp_h; 317 lavc_context.height=sh_video->disp_h;
328 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height); 318 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height);
329 /* open it */ 319 /* open it */
330 if (avcodec_open(&lavc_context, lavc_codec) < 0) { 320 if (avcodec_open(&lavc_context, lavc_codec) < 0) {
331 mp_msg(MSGT_DECVIDEO,MSGL_ERR, "could not open codec\n"); 321 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantOpenCodec);
332 return 0; 322 return 0;
333 } 323 }
334 324
335 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n"); 325 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n");
336 break; 326 break;
340 case VFM_MPEG: { 330 case VFM_MPEG: {
341 // init libmpeg2: 331 // init libmpeg2:
342 #ifdef MPEG12_POSTPROC 332 #ifdef MPEG12_POSTPROC
343 picture->pp_options=divx_quality; 333 picture->pp_options=divx_quality;
344 #else 334 #else
345 if(divx_quality){ 335 if(divx_quality) mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_MpegPPhint);
346 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"WARNING! You requested image postprocessing for an MPEG 1/2 video,\n");
347 mp_msg(MSGT_DECVIDEO,MSGL_HINT," but compiled MPlayer without MPEG 1/2 postprocessing support!\n");
348 mp_msg(MSGT_DECVIDEO,MSGL_HINT," #define MPEG12_POSTPROC in config.h, and recompile libmpeg2!\n");
349 }
350 #endif 336 #endif
351 mpeg2_allocate_image_buffers (picture); 337 mpeg2_allocate_image_buffers (picture);
352 break; 338 break;
353 } 339 }
354 case VFM_RAW: { 340 case VFM_RAW: {
361 unsigned int* pal=(unsigned int*)(((char*)sh_video->bih)+40); 347 unsigned int* pal=(unsigned int*)(((char*)sh_video->bih)+40);
362 //int cols=(sh_video->bih->biSize-40)/4; 348 //int cols=(sh_video->bih->biSize-40)/4;
363 int cols=1<<(sh_video->bih->biBitCount); 349 int cols=1<<(sh_video->bih->biBitCount);
364 int i; 350 int i;
365 if(cols>256) cols=256; 351 if(cols>256) cols=256;
366 printf("RLE: converting palette for %d colors.\n",cols); 352 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols);
367 for(i=0;i<cols;i++){ 353 for(i=0;i<cols;i++){
368 unsigned int c=pal[i]; 354 unsigned int c=pal[i];
369 unsigned int b=c&255; 355 unsigned int b=c&255;
370 unsigned int g=(c>>8)&255; 356 unsigned int g=(c>>8)&255;
371 unsigned int r=(c>>16)&255; 357 unsigned int r=(c>>16)&255;
649 while(1){ 635 while(1){
650 int i=sync_video_packet(d_video); 636 int i=sync_video_packet(d_video);
651 if(i==0x1B3) break; // found it! 637 if(i==0x1B3) break; // found it!
652 if(!i || !skip_video_packet(d_video)){ 638 if(!i || !skip_video_packet(d_video)){
653 if(verbose) mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); 639 if(verbose) mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
654 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPEG: FATAL: EOF while searching for sequence header\n"); 640 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MpegNoSequHdr);
655 return 0; 641 return 0;
656 // GUI_MSG( mplMPEGErrorSeqHeaderSearch )
657 } 642 }
658 } 643 }
659 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); 644 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
660 // sh_video=d_video->sh;sh_video->ds=d_video; 645 // sh_video=d_video->sh;sh_video->ds=d_video;
661 mpeg2_init(); 646 mpeg2_init();
662 // ========= Read & process sequence header & extension ============ 647 // ========= Read & process sequence header & extension ============
663 if(!videobuffer) videobuffer=memalign(8,VIDEOBUFFER_SIZE); 648 if(!videobuffer) videobuffer=memalign(8,VIDEOBUFFER_SIZE);
664 if(!videobuffer){ 649 if(!videobuffer){
665 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory\n"); 650 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
666 return 0; 651 return 0;
667 // GUI_MSG( mplErrorShMemAlloc )
668 } 652 }
669 653
670 if(!read_video_packet(d_video)){ 654 if(!read_video_packet(d_video)){
671 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"FATAL: Cannot read sequence header!\n"); 655 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CannotReadMpegSequHdr);
672 return 0; 656 return 0;
673 // GUI_MSG( mplMPEGErrorCannotReadSeqHeader )
674 } 657 }
675 if(header_process_sequence_header (picture, &videobuffer[4])) { 658 if(header_process_sequence_header (picture, &videobuffer[4])) {
676 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"bad sequence header!\n"); 659 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_BadMpegSequHdr);
677 return 0; 660 return 0;
678 // GUI_MSG( mplMPEGErrorBadSeqHeader )
679 } 661 }
680 if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext. 662 if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext.
681 // videobuf_len=0; 663 // videobuf_len=0;
682 int pos=videobuf_len; 664 int pos=videobuf_len;
683 if(!read_video_packet(d_video)){ 665 if(!read_video_packet(d_video)){
684 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"FATAL: Cannot read sequence header extension!\n"); 666 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CannotReadMpegSequHdrEx);
685 return 0; 667 return 0;
686 // GUI_MSG( mplMPEGErrorCannotReadSeqHeaderExt )
687 } 668 }
688 if(header_process_extension (picture, &videobuffer[pos+4])) { 669 if(header_process_extension (picture, &videobuffer[pos+4])) {
689 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"bad sequence header extension!\n"); 670 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_BadMpegSequHdrEx);
690 return 0; 671 return 0;
691 // GUI_MSG( mplMPEGErrorBadSeqHeaderExt )
692 } 672 }
693 } 673 }
694 // display info: 674 // display info:
695 sh_video->format=picture->mpeg1?0x10000001:0x10000002; // mpeg video 675 sh_video->format=picture->mpeg1?0x10000001:0x10000002; // mpeg video
696 sh_video->fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; 676 sh_video->fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f;