aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore17
-rw-r--r--DOCS/man/en/mplayer.122
-rw-r--r--DOCS/man/fr/mplayer.12
-rw-r--r--DOCS/tech/general.txt1
-rw-r--r--DOCS/tech/libmpcodecs.txt22
-rw-r--r--DOCS/tech/libvo.txt1
-rw-r--r--DOCS/tech/realcodecs/TODO2
-rw-r--r--DOCS/tech/realcodecs/audio-codecs.txt3
-rw-r--r--DOCS/tech/realcodecs/video-codecs.txt2
-rw-r--r--DOCS/tech/slave.txt1
-rw-r--r--DOCS/tech/snow.txt1
-rw-r--r--DOCS/tech/subcp.txt2
-rw-r--r--DOCS/tech/swscaler_methods.txt1
-rw-r--r--DOCS/xml/ldp.dsl1
-rw-r--r--DOCS/xml/ru/ports.xml2
-rw-r--r--Makefile90
-rw-r--r--TOOLS/asfinfo.c1
-rw-r--r--TOOLS/avisubdump.c1
-rw-r--r--TOOLS/compare.c1
-rw-r--r--TOOLS/modify_reg.c1
-rw-r--r--TOOLS/realcodecs/cook.c1
-rw-r--r--TOOLS/realcodecs/drv4.c1
-rw-r--r--TOOLS/realcodecs/ra.c1
-rw-r--r--TOOLS/realcodecs/rv30.c1
-rw-r--r--TOOLS/realcodecs/sipr.c1
-rwxr-xr-xTOOLS/w32codec_dl.pl1
-rw-r--r--asxparser.c14
-rw-r--r--asxparser.h4
-rw-r--r--av_opts.c1
-rw-r--r--cfg-common-opts.h68
-rw-r--r--cfg-common.h7
-rw-r--r--cfg-mencoder.h8
-rw-r--r--cfg-mplayer-def.h1
-rw-r--r--cfg-mplayer.h86
-rw-r--r--codec-cfg.c71
-rw-r--r--codec-cfg.h2
-rw-r--r--command.c840
-rw-r--r--command.h2
-rw-r--r--common.mak17
-rwxr-xr-xconfigure53
-rw-r--r--defaultopts.c61
-rw-r--r--defaultopts.h3
-rw-r--r--drivers/radeon_vid.c1
-rw-r--r--edl.c18
-rw-r--r--etc/menu.conf2
-rw-r--r--gui/cfg.c1
-rw-r--r--gui/mplayer/gtk/eq.c1
-rw-r--r--gui/mplayer/gtk/gtk_url.c1
-rw-r--r--gui/mplayer/gtk/pl.c1
-rw-r--r--gui/skin/cut.c1
-rw-r--r--help/help_mp-en.h1
-rw-r--r--help/help_mp-es.h1
-rw-r--r--help/help_mp-hu.h1
-rw-r--r--help/help_mp-pl.h1
-rw-r--r--help/help_mp-sk.h1
-rw-r--r--help/help_mp-sv.h1
-rw-r--r--help/help_mp-uk.h1
-rw-r--r--input/appleir.c14
-rw-r--r--input/ar.c4
-rw-r--r--input/ar.h4
-rw-r--r--input/input.c824
-rw-r--r--input/input.h58
-rw-r--r--input/joystick.c20
-rw-r--r--input/joystick.h2
-rw-r--r--input/lirc.c6
-rw-r--r--libaf/af.h2
-rw-r--r--libaf/af_delay.c2
-rw-r--r--libaf/af_equalizer.c7
-rw-r--r--libaf/af_ladspa.c30
-rw-r--r--libaf/af_lavcac3enc.c6
-rw-r--r--libaf/af_resample.c1
-rw-r--r--libaf/af_scaletempo.c20
-rw-r--r--libaf/af_sweep.c1
-rw-r--r--libaf/filter.c1
-rw-r--r--libaf/format.c2
-rw-r--r--libaf/reorder_ch.c1
-rw-r--r--libaf/window.c1
-rw-r--r--libao2/ao_alsa.c134
-rw-r--r--libao2/ao_alsa5.c46
-rw-r--r--libao2/ao_arts.c13
-rw-r--r--libao2/ao_dxr2.c5
-rw-r--r--libao2/ao_esd.c6
-rw-r--r--libao2/ao_ivtv.c4
-rw-r--r--libao2/ao_jack.c1
-rw-r--r--libao2/ao_mpegpes.c8
-rw-r--r--libao2/ao_openal.c1
-rw-r--r--libao2/ao_oss.c53
-rw-r--r--libao2/ao_pcm.c12
-rw-r--r--libao2/ao_sdl.c20
-rw-r--r--libao2/ao_sgi.c34
-rw-r--r--libao2/ao_sun.c9
-rw-r--r--libao2/ao_v4l2.c4
-rw-r--r--libao2/audio_out.c16
-rw-r--r--libao2/audio_out.h3
-rw-r--r--libass/ass.c1
-rw-r--r--libass/ass_bitmap.c1
-rw-r--r--libass/ass_cache.c13
-rw-r--r--libass/ass_cache.h33
-rw-r--r--libass/ass_cache_template.c88
-rw-r--r--libass/ass_fontconfig.c2
-rw-r--r--libass/ass_render.c12
-rw-r--r--libmenu/menu.c50
-rw-r--r--libmenu/menu.h5
-rw-r--r--libmenu/menu_chapsel.c4
-rw-r--r--libmenu/menu_cmdlist.c18
-rw-r--r--libmenu/menu_console.c18
-rw-r--r--libmenu/menu_dvbin.c4
-rw-r--r--libmenu/menu_filesel.c17
-rw-r--r--libmenu/menu_list.c1
-rw-r--r--libmenu/menu_param.c16
-rw-r--r--libmenu/menu_pt.c8
-rw-r--r--libmenu/menu_txt.c8
-rw-r--r--libmenu/vf_menu.c25
-rw-r--r--libmpcodecs/ad.c54
-rw-r--r--libmpcodecs/ad.h6
-rw-r--r--libmpcodecs/ad_acm.c6
-rw-r--r--libmpcodecs/ad_alaw.c2
-rw-r--r--libmpcodecs/ad_dk3adpcm.c2
-rw-r--r--libmpcodecs/ad_dmo.c4
-rw-r--r--libmpcodecs/ad_dshow.c4
-rw-r--r--libmpcodecs/ad_dvdpcm.c4
-rw-r--r--libmpcodecs/ad_faad.c2
-rw-r--r--libmpcodecs/ad_ffmpeg.c8
-rw-r--r--libmpcodecs/ad_hwac3.c2
-rw-r--r--libmpcodecs/ad_hwmpa.c2
-rw-r--r--libmpcodecs/ad_imaadpcm.c2
-rw-r--r--libmpcodecs/ad_internal.h2
-rw-r--r--libmpcodecs/ad_liba52.c6
-rw-r--r--libmpcodecs/ad_libdca.c2
-rw-r--r--libmpcodecs/ad_libdv.c4
-rw-r--r--libmpcodecs/ad_libmad.c2
-rw-r--r--libmpcodecs/ad_libvorbis.c2
-rw-r--r--libmpcodecs/ad_mp3lib.c2
-rw-r--r--libmpcodecs/ad_mpc.c3
-rw-r--r--libmpcodecs/ad_msadpcm.c2
-rw-r--r--libmpcodecs/ad_msgsm.c2
-rw-r--r--libmpcodecs/ad_pcm.c41
-rw-r--r--libmpcodecs/ad_qtaudio.c2
-rw-r--r--libmpcodecs/ad_realaud.c4
-rw-r--r--libmpcodecs/ad_sample.c2
-rw-r--r--libmpcodecs/ad_speex.c3
-rw-r--r--libmpcodecs/ad_twin.c2
-rw-r--r--libmpcodecs/ae.c2
-rw-r--r--libmpcodecs/ae_lame.c182
-rw-r--r--libmpcodecs/ae_lavc.c9
-rw-r--r--libmpcodecs/ae_pcm.c1
-rw-r--r--libmpcodecs/ae_toolame.c1
-rw-r--r--libmpcodecs/ae_twolame.c1
-rw-r--r--libmpcodecs/dec_audio.c34
-rw-r--r--libmpcodecs/dec_video.c589
-rw-r--r--libmpcodecs/dec_video.h3
-rw-r--r--libmpcodecs/mp_image.h2
-rw-r--r--libmpcodecs/native/xa_gsm.c2
-rw-r--r--libmpcodecs/pullup.c9
-rw-r--r--libmpcodecs/vd.c515
-rw-r--r--libmpcodecs/vd.h6
-rw-r--r--libmpcodecs/vd_dmo.c10
-rw-r--r--libmpcodecs/vd_dshow.c10
-rw-r--r--libmpcodecs/vd_ffmpeg.c181
-rw-r--r--libmpcodecs/vd_hmblck.c2
-rw-r--r--libmpcodecs/vd_ijpg.c4
-rw-r--r--libmpcodecs/vd_internal.h2
-rw-r--r--libmpcodecs/vd_libdv.c2
-rw-r--r--libmpcodecs/vd_libmpeg2.c6
-rw-r--r--libmpcodecs/vd_lzo.c2
-rw-r--r--libmpcodecs/vd_mpegpes.c2
-rw-r--r--libmpcodecs/vd_mpng.c2
-rw-r--r--libmpcodecs/vd_mtga.c3
-rw-r--r--libmpcodecs/vd_null.c3
-rw-r--r--libmpcodecs/vd_qtvideo.c2
-rw-r--r--libmpcodecs/vd_raw.c2
-rw-r--r--libmpcodecs/vd_realvid.c4
-rw-r--r--libmpcodecs/vd_sgi.c3
-rw-r--r--libmpcodecs/vd_theora.c2
-rw-r--r--libmpcodecs/vd_vfw.c4
-rw-r--r--libmpcodecs/vd_xanim.c2
-rw-r--r--libmpcodecs/vd_xvid4.c2
-rw-r--r--libmpcodecs/vd_zrmjpeg.c2
-rw-r--r--libmpcodecs/ve.c5
-rw-r--r--libmpcodecs/ve_lavc.c22
-rw-r--r--libmpcodecs/ve_libdv.c8
-rw-r--r--libmpcodecs/ve_nuv.c10
-rw-r--r--libmpcodecs/ve_qtvideo.c8
-rw-r--r--libmpcodecs/ve_raw.c12
-rw-r--r--libmpcodecs/ve_vfw.c22
-rw-r--r--libmpcodecs/ve_x264.c16
-rw-r--r--libmpcodecs/ve_xvid4.c10
-rw-r--r--libmpcodecs/vf.c71
-rw-r--r--libmpcodecs/vf.h54
-rw-r--r--libmpcodecs/vf_1bpp.c8
-rw-r--r--libmpcodecs/vf_2xsai.c10
-rw-r--r--libmpcodecs/vf_ass.c137
-rw-r--r--libmpcodecs/vf_blackframe.c10
-rw-r--r--libmpcodecs/vf_bmovl.c8
-rw-r--r--libmpcodecs/vf_boxblur.c6
-rw-r--r--libmpcodecs/vf_crop.c17
-rw-r--r--libmpcodecs/vf_cropdetect.c8
-rw-r--r--libmpcodecs/vf_decimate.c6
-rw-r--r--libmpcodecs/vf_delogo.c16
-rw-r--r--libmpcodecs/vf_denoise3d.c8
-rw-r--r--libmpcodecs/vf_detc.c12
-rw-r--r--libmpcodecs/vf_dint.c4
-rw-r--r--libmpcodecs/vf_divtc.c8
-rw-r--r--libmpcodecs/vf_down3dright.c9
-rw-r--r--libmpcodecs/vf_dsize.c3
-rw-r--r--libmpcodecs/vf_dvbscale.c2
-rw-r--r--libmpcodecs/vf_eq.c13
-rw-r--r--libmpcodecs/vf_expand.c74
-rw-r--r--libmpcodecs/vf_field.c6
-rw-r--r--libmpcodecs/vf_fil.c6
-rw-r--r--libmpcodecs/vf_filmdint.c17
-rw-r--r--libmpcodecs/vf_flip.c6
-rw-r--r--libmpcodecs/vf_format.c8
-rw-r--r--libmpcodecs/vf_framestep.c8
-rw-r--r--libmpcodecs/vf_fspp.c12
-rw-r--r--libmpcodecs/vf_geq.c18
-rw-r--r--libmpcodecs/vf_halfpack.c9
-rw-r--r--libmpcodecs/vf_harddup.c8
-rw-r--r--libmpcodecs/vf_hqdn3d.c8
-rw-r--r--libmpcodecs/vf_hue.c13
-rw-r--r--libmpcodecs/vf_il.c2
-rw-r--r--libmpcodecs/vf_ilpack.c7
-rw-r--r--libmpcodecs/vf_ivtc.c10
-rw-r--r--libmpcodecs/vf_kerndeint.c10
-rw-r--r--libmpcodecs/vf_lavc.c10
-rw-r--r--libmpcodecs/vf_lavcdeint.c6
-rw-r--r--libmpcodecs/vf_mcdeint.c10
-rw-r--r--libmpcodecs/vf_mirror.c2
-rw-r--r--libmpcodecs/vf_noformat.c8
-rw-r--r--libmpcodecs/vf_noise.c12
-rw-r--r--libmpcodecs/vf_ow.c10
-rw-r--r--libmpcodecs/vf_palette.c16
-rw-r--r--libmpcodecs/vf_perspective.c8
-rw-r--r--libmpcodecs/vf_phase.c4
-rw-r--r--libmpcodecs/vf_pp.c15
-rw-r--r--libmpcodecs/vf_pp7.c12
-rw-r--r--libmpcodecs/vf_pullup.c14
-rw-r--r--libmpcodecs/vf_qp.c10
-rw-r--r--libmpcodecs/vf_rectangle.c6
-rw-r--r--libmpcodecs/vf_remove_logo.c10
-rw-r--r--libmpcodecs/vf_rgb2bgr.c6
-rw-r--r--libmpcodecs/vf_rgbtest.c6
-rw-r--r--libmpcodecs/vf_rotate.c6
-rw-r--r--libmpcodecs/vf_sab.c8
-rw-r--r--libmpcodecs/vf_scale.c39
-rw-r--r--libmpcodecs/vf_screenshot.c14
-rw-r--r--libmpcodecs/vf_smartblur.c8
-rw-r--r--libmpcodecs/vf_softpulldown.c6
-rw-r--r--libmpcodecs/vf_softskip.c10
-rw-r--r--libmpcodecs/vf_spp.c12
-rw-r--r--libmpcodecs/vf_swapuv.c6
-rw-r--r--libmpcodecs/vf_telecine.c10
-rw-r--r--libmpcodecs/vf_test.c8
-rw-r--r--libmpcodecs/vf_tfields.c30
-rw-r--r--libmpcodecs/vf_tile.c10
-rw-r--r--libmpcodecs/vf_tinterlace.c8
-rw-r--r--libmpcodecs/vf_unsharp.c12
-rw-r--r--libmpcodecs/vf_uspp.c12
-rw-r--r--libmpcodecs/vf_vo.c89
-rw-r--r--libmpcodecs/vf_yadif.c24
-rw-r--r--libmpcodecs/vf_yuvcsp.c8
-rw-r--r--libmpcodecs/vf_yuy2.c8
-rw-r--r--libmpcodecs/vf_yvu9.c8
-rw-r--r--libmpcodecs/vf_zrmjpeg.c7
-rw-r--r--libmpdemux/asfheader.c28
-rw-r--r--libmpdemux/aviheader.c53
-rw-r--r--libmpdemux/aviprint.c1
-rw-r--r--libmpdemux/demux_asf.c6
-rw-r--r--libmpdemux/demux_audio.c2
-rw-r--r--libmpdemux/demux_avi.c39
-rw-r--r--libmpdemux/demux_avs.c2
-rw-r--r--libmpdemux/demux_demuxers.c5
-rw-r--r--libmpdemux/demux_lavf.c22
-rw-r--r--libmpdemux/demux_lmlm4.c4
-rw-r--r--libmpdemux/demux_mkv.c513
-rw-r--r--libmpdemux/demux_mng.c1
-rw-r--r--libmpdemux/demux_mov.c19
-rw-r--r--libmpdemux/demux_mpg.c14
-rw-r--r--libmpdemux/demux_nemesi.c2
-rw-r--r--libmpdemux/demux_nut.c4
-rw-r--r--libmpdemux/demux_ogg.c11
-rw-r--r--libmpdemux/demux_pva.c2
-rw-r--r--libmpdemux/demux_real.c10
-rw-r--r--libmpdemux/demux_rtp.cpp10
-rw-r--r--libmpdemux/demux_ty.c2
-rw-r--r--libmpdemux/demux_ty_osd.c3
-rw-r--r--libmpdemux/demux_viv.c4
-rw-r--r--libmpdemux/demux_xmms.c6
-rw-r--r--libmpdemux/demuxer.c228
-rw-r--r--libmpdemux/demuxer.h81
-rw-r--r--libmpdemux/ebml.h3
-rw-r--r--libmpdemux/extension.c1
-rw-r--r--libmpdemux/mf.c1
-rw-r--r--libmpdemux/mp3_hdr.c4
-rw-r--r--libmpdemux/mp_taglists.c1
-rw-r--r--libmpdemux/muxer.c9
-rw-r--r--libmpdemux/muxer_avi.c8
-rw-r--r--libmpdemux/muxer_lavf.c4
-rw-r--r--libmpdemux/muxer_mpeg.c5
-rw-r--r--libmpdemux/muxer_rawaudio.c6
-rw-r--r--libmpdemux/parse_mp4.c3
-rw-r--r--libmpdemux/parse_mp4.h1
-rw-r--r--libmpdemux/stheader.h40
-rw-r--r--libmpdemux/video.c23
-rw-r--r--libmpdemux/yuv4mpeg.c2
-rw-r--r--libmpdemux/yuv4mpeg.h2
-rw-r--r--libmpdemux/yuv4mpeg_ratio.c1
-rw-r--r--libvo/aclib_template.c1
-rw-r--r--libvo/aspect.c128
-rw-r--r--libvo/aspect.h34
-rw-r--r--libvo/aspecttest.c1
-rw-r--r--libvo/font_load.h1
-rw-r--r--libvo/font_load_ft.c20
-rw-r--r--libvo/gl_common.c2
-rw-r--r--libvo/gl_common.h8
-rw-r--r--libvo/gtf.c2
-rw-r--r--libvo/mga_common.c52
-rw-r--r--libvo/old_vo_defines.h24
-rw-r--r--libvo/old_vo_wrapper.c116
-rw-r--r--libvo/old_vo_wrapper.h29
-rw-r--r--libvo/osd.c1
-rw-r--r--libvo/spuenc.c47
-rw-r--r--libvo/spuenc.h1
-rw-r--r--libvo/sub.c129
-rw-r--r--libvo/sub.h43
-rw-r--r--libvo/vesa_lvo.c22
-rw-r--r--libvo/vesa_lvo.h4
-rw-r--r--libvo/video_out.c348
-rw-r--r--libvo/video_out.h136
-rw-r--r--libvo/video_out_internal.h22
-rw-r--r--libvo/vo_3dfx.c20
-rw-r--r--libvo/vo_aa.c63
-rw-r--r--libvo/vo_bl.c2
-rw-r--r--libvo/vo_caca.c2
-rw-r--r--libvo/vo_corevideo.m7
-rw-r--r--libvo/vo_cvidix.c22
-rw-r--r--libvo/vo_dfbmga.c22
-rw-r--r--libvo/vo_dga.c2
-rw-r--r--libvo/vo_direct3d.c2
-rw-r--r--libvo/vo_directfb2.c22
-rw-r--r--libvo/vo_directx.c22
-rw-r--r--libvo/vo_dxr2.c17
-rw-r--r--libvo/vo_dxr3.c147
-rw-r--r--libvo/vo_fbdev.c26
-rw-r--r--libvo/vo_fbdev2.c2
-rw-r--r--libvo/vo_ggi.c12
-rw-r--r--libvo/vo_gif89a.c3
-rw-r--r--libvo/vo_gl.c35
-rw-r--r--libvo/vo_gl2.c26
-rw-r--r--libvo/vo_ivtv.c4
-rw-r--r--libvo/vo_jpeg.c49
-rw-r--r--libvo/vo_kva.c22
-rw-r--r--libvo/vo_md5sum.c19
-rw-r--r--libvo/vo_mga.c5
-rw-r--r--libvo/vo_mpegpes.c11
-rw-r--r--libvo/vo_null.c4
-rw-r--r--libvo/vo_png.c79
-rw-r--r--libvo/vo_pnm.c55
-rw-r--r--libvo/vo_quartz.c4
-rw-r--r--libvo/vo_s3fb.c2
-rw-r--r--libvo/vo_sdl.c28
-rw-r--r--libvo/vo_svga.c51
-rw-r--r--libvo/vo_tdfx_vid.c45
-rw-r--r--libvo/vo_tdfxfb.c22
-rw-r--r--libvo/vo_tga.c4
-rw-r--r--libvo/vo_v4l2.c4
-rw-r--r--libvo/vo_vdpau.c26
-rw-r--r--libvo/vo_vesa.c110
-rw-r--r--libvo/vo_wii.c2
-rw-r--r--libvo/vo_winvidix.c31
-rw-r--r--libvo/vo_x11.c23
-rw-r--r--libvo/vo_xover.c44
-rw-r--r--libvo/vo_xv.c970
-rw-r--r--libvo/vo_xvidix.c28
-rw-r--r--libvo/vo_xvmc.c22
-rw-r--r--libvo/vo_xvr100.c2
-rw-r--r--libvo/vo_yuv4mpeg.c44
-rw-r--r--libvo/vo_zr.c2
-rw-r--r--libvo/vo_zr2.c2
-rw-r--r--libvo/vosub_vidix.c90
-rw-r--r--libvo/vosub_vidix.h4
-rw-r--r--libvo/w32_common.c17
-rw-r--r--libvo/x11_common.c949
-rw-r--r--libvo/x11_common.h193
-rw-r--r--loader/dmo/DMO_VideoDecoder.c1
-rw-r--r--loader/dshow/DS_VideoDecoder.c4
-rw-r--r--loader/ldt_keeper.c2
-rw-r--r--loader/qtx/qtxsdk/components.h2
-rw-r--r--loader/vfl.c1
-rw-r--r--loader/wrapper.S1
-rw-r--r--loader/wrapper.h1
-rw-r--r--m_config.c212
-rw-r--r--m_config.h7
-rw-r--r--m_option.c8
-rw-r--r--m_option.h29
-rw-r--r--m_property.c6
-rw-r--r--mencoder.c306
-rw-r--r--metadata.h5
-rw-r--r--mixer.c7
-rw-r--r--mp3lib/dct36.c1
-rw-r--r--mp3lib/huffman.h2
-rw-r--r--mp3lib/l2tables.h1
-rw-r--r--mp3lib/layer1.c2
-rw-r--r--mp3lib/layer3.c2
-rw-r--r--mp_core.h165
-rw-r--r--mp_fifo.c121
-rw-r--r--mp_fifo.h13
-rw-r--r--mp_msg.c5
-rw-r--r--mp_msg.h6
-rw-r--r--mp_osd.h5
-rw-r--r--mpcommon.c20
-rw-r--r--mpcommon.h3
-rw-r--r--mplayer.c1938
-rw-r--r--mplayer.h25
-rw-r--r--options.h81
-rw-r--r--osdep/findfiles.c97
-rw-r--r--osdep/findfiles.h2
-rw-r--r--osdep/getch2-os2.c6
-rw-r--r--osdep/getch2-win.c6
-rw-r--r--osdep/getch2.c8
-rw-r--r--osdep/getch2.h3
-rw-r--r--osdep/mmap_anon.c2
-rw-r--r--osdep/mplayer.rc1
-rw-r--r--osdep/priority.c3
-rw-r--r--osdep/priority.h1
-rw-r--r--osdep/shmem.c2
-rw-r--r--osdep/timer-darwin.c18
-rw-r--r--osdep/timer-linux.c47
-rw-r--r--osdep/timer-win2.c14
-rw-r--r--osdep/timer.h9
-rw-r--r--parser-mecmd.c8
-rw-r--r--parser-mpcmd.c18
-rw-r--r--playtree.c4
-rw-r--r--playtree.h7
-rw-r--r--playtreeparser.c23
-rw-r--r--playtreeparser.h7
-rw-r--r--spudec.c21
-rw-r--r--spudec.h4
-rw-r--r--stream/ai_alsa.c26
-rw-r--r--stream/ai_alsa1x.c32
-rw-r--r--stream/ai_oss.c20
-rw-r--r--stream/asf_mmst_streaming.c57
-rw-r--r--stream/asf_streaming.c73
-rw-r--r--stream/audio_in.c12
-rw-r--r--stream/cache2.c13
-rw-r--r--stream/cdinfo.c6
-rw-r--r--stream/network.c44
-rw-r--r--stream/network.h3
-rw-r--r--stream/open.c4
-rw-r--r--stream/realrtsp/asmrp.c1
-rw-r--r--stream/realrtsp/sdpplin.c1
-rw-r--r--stream/stream.c39
-rw-r--r--stream/stream.h32
-rw-r--r--stream/stream_cdda.c6
-rw-r--r--stream/stream_cddb.c74
-rw-r--r--stream/stream_cue.c71
-rw-r--r--stream/stream_dvd.c62
-rw-r--r--stream/stream_dvdnav.c6
-rw-r--r--stream/stream_file.c4
-rw-r--r--stream/stream_live555.c2
-rw-r--r--stream/stream_nemesi.c1
-rw-r--r--stream/stream_netstream.c6
-rw-r--r--stream/stream_radio.c147
-rw-r--r--stream/stream_radio.h12
-rw-r--r--stream/stream_rtsp.c2
-rw-r--r--stream/stream_smb.c4
-rw-r--r--stream/stream_vcd.c6
-rw-r--r--stream/stream_vstream.c4
-rw-r--r--stream/tcp.c20
-rw-r--r--stream/tv.c93
-rw-r--r--stream/tvi_bsdbt848.c62
-rw-r--r--stream/tvi_dshow.c84
-rw-r--r--stream/tvi_vbi.c6
-rw-r--r--stream/url.c22
-rw-r--r--sub_cc.c1
-rw-r--r--sub_cc.h1
-rw-r--r--subdir.mak4
-rw-r--r--subopt-helper.c1
-rw-r--r--subreader.c2
-rw-r--r--subreader.h6
-rw-r--r--talloc.c1758
-rw-r--r--talloc.h183
-rw-r--r--unrar_exec.c1
-rw-r--r--vidix/.gitignore5
-rw-r--r--vidix/drivers.c1
-rw-r--r--vidix/nvidia_vid.c5
-rw-r--r--vidix/sysdep/pci_alpha.c1
-rw-r--r--vobsub.h1
488 files changed, 10692 insertions, 7596 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..411891e554
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+*.o
+*.a
+*.d
+.depend
+
+/ffmpeg
+/config.h
+/config.mak
+/configure.log
+/help_mp.h
+/mencoder
+/mplayer
+/version.h
+/codecs.conf.h
+/codec-cfg
+/codec-cfg-test
+/codecs2html
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index 0f2152eab8..9582c62222 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -865,10 +865,12 @@ Enqueue files given on the command line in the playlist instead of playing them
immediately.
.
.TP
-.B \-fixed\-vo
-Enforces a fixed video system for multiple files (one (un)initialization for
-all files).
+.B \-nofixed\-vo
+\-fixed\-vo enforces a fixed video system for multiple files (one
+(un)initialization for all files).
Therefore only one window will be opened for all files.
+Now enabled by default, use \-nofixed\-vo to disable and create a new window
+whenever the video stream changes.
Currently the following drivers are fixed-vo compliant: gl, gl2, mga, svga, x11,
xmga, xv, xvidix and dfbmga.
.
@@ -1069,6 +1071,11 @@ Turns off LIRC support.
.B \-nomouseinput
Disable mouse button press/\:release input (mozplayerxp's context menu relies
on this option).
+.TP
+.B \-noorderedchapters
+Disable support for Matroska ordered chapters.
+MPlayer will not load or search for video segments from other files,
+and will also ignore any chapter order specified for the main file.
.
.TP
.B \-rtc (RTC only)
@@ -3055,6 +3062,13 @@ VESA framebuffer does not support mode changing.
Override framebuffer mode configuration file (default: /etc/\:fb.modes).
.
.TP
+.B \-force\-window\-position
+Forcefully move MPlayer's video output window to default location whenever
+there is a change in video parameters, video stream or file.
+This used to be the default behavior.
+Currently only affects X11 VOs.
+.
+.TP
.B \-fs (also see \-zoom)
Fullscreen playback (centers movie, and paints black bands around it).
Not supported by all video output drivers.
@@ -4321,8 +4335,6 @@ Each file takes the frame number padded with leading zeros as name.
.IPs z=<0\-9>
Specifies the compression level.
0 is no compression, 9 is maximum compression.
-.IPs outdir=<dirname>
-Specify the directory to save the PNG files to (default: ./).
.IPs alpha (default: noalpha)
Create PNG files with an alpha channel.
Note that MPlayer in general does not support alpha, so this will only
diff --git a/DOCS/man/fr/mplayer.1 b/DOCS/man/fr/mplayer.1
index 5b23beec9b..40c41aaf90 100644
--- a/DOCS/man/fr/mplayer.1
+++ b/DOCS/man/fr/mplayer.1
@@ -4570,8 +4570,6 @@ Ne gère que les formats RGB et BGR 24 bits/pixel.
.IPs z=<0\-9>
Définit le taux de compression.
0 équivaut à pas de compression et 9 à la compression maximale.
-.IPs outdir=<chemin>
-Définit le répertoire où sauver les fichiers PNG (par défaut\ ./).
.IPs alpha (par défaut\ : noalpha)
Crée un fichier PNG avec un canal alpha.
Notez que MPlayer ne gère en général pas les canaux alpha, donc cette
diff --git a/DOCS/tech/general.txt b/DOCS/tech/general.txt
index f4b7f0d713..631ee3f9de 100644
--- a/DOCS/tech/general.txt
+++ b/DOCS/tech/general.txt
@@ -226,4 +226,3 @@ Now, go on:
6.a audio plugins
for details on this, read libao2.txt
-
diff --git a/DOCS/tech/libmpcodecs.txt b/DOCS/tech/libmpcodecs.txt
index 22d29aaf98..5015f5dcc0 100644
--- a/DOCS/tech/libmpcodecs.txt
+++ b/DOCS/tech/libmpcodecs.txt
@@ -153,7 +153,7 @@ vf_info_t* info;
const char *name; // short name of the filter, must be FILTERNAME
const char *author; // name and email/URL of the author(s)
const char *comment; // comment, URL to papers describing algorithm etc.
- int (*open)(struct vf_instance_s* vf,char* args);
+ int (*open)(struct vf_instance* vf,char* args);
// pointer to the open() function:
Sample:
@@ -197,13 +197,13 @@ static int open(vf_instance_t *vf, char* args)
return 1;
}
-Functions in vf_instance_s:
+Functions in vf_instance:
NOTE: All these are optional, their function pointer is either NULL or points
to a default implementation. If you implement them, don't forget to set
vf->FUNCNAME in your open() !
- int (*query_format)(struct vf_instance_s* vf, unsigned int fmt);
+ int (*query_format)(struct vf_instance* vf, unsigned int fmt);
The query_format() function is called one or more times before the config(),
to find out the capabilities and/or support status of a given colorspace (fmt).
@@ -216,7 +216,7 @@ next filter will accept at least one of your possible output colorspaces!
Sample:
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch(fmt){
case IMGFMT_YV12:
@@ -232,7 +232,7 @@ For the more complex case, when you have an N -> M colorspace mapping matrix,
see vf_scale or vf_rgb2bgr for examples.
- int (*config)(struct vf_instance_s* vf,
+ int (*config)(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt);
@@ -257,7 +257,7 @@ Its parameters are already well-known from libvo:
Sample:
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -272,12 +272,12 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,outfmt);
}
- void (*uninit)(struct vf_instance_s* vf);
+ void (*uninit)(struct vf_instance* vf);
Okay, uninit() is the simplest, it's called at the end. You can free your
private buffers etc here.
- int (*put_image)(struct vf_instance_s* vf, mp_image_t *mpi);
+ int (*put_image)(struct vf_instance* vf, mp_image_t *mpi);
Ah, put_image(). This is the main filter function, it should convert/filter/
transform the image data from one format/size/color/whatever to another.
@@ -332,7 +332,7 @@ image:
Ok, the rest is for advanced functionality only:
- int (*control)(struct vf_instance_s* vf, int request, void* data);
+ int (*control)(struct vf_instance* vf, int request, void* data);
You can control the filter at runtime from MPlayer/MEncoder/dec_video:
#define VFCTRL_QUERY_MAX_PP_LEVEL 4 /* test for postprocessing support (max level) */
@@ -343,7 +343,7 @@ You can control the filter at runtime from MPlayer/MEncoder/dec_video:
#define VFCTRL_CHANGE_RECTANGLE 9 /* Change the rectangle boundaries */
- void (*get_image)(struct vf_instance_s* vf, mp_image_t *mpi);
+ void (*get_image)(struct vf_instance* vf, mp_image_t *mpi);
This is for direct rendering support, works the same way as in libvo drivers.
It makes in-place pixel modifications possible.
@@ -359,7 +359,7 @@ order, while put_image is called for display) so the only safe place to save
it is in the mpi struct itself: mpi->priv=(void*)dmpi;
- void (*draw_slice)(struct vf_instance_s* vf, unsigned char** src,
+ void (*draw_slice)(struct vf_instance* vf, unsigned char** src,
int* stride, int w,int h, int x, int y);
It's the good old draw_slice callback, already known from libvo.
diff --git a/DOCS/tech/libvo.txt b/DOCS/tech/libvo.txt
index e80f80d2fb..945aeab952 100644
--- a/DOCS/tech/libvo.txt
+++ b/DOCS/tech/libvo.txt
@@ -171,4 +171,3 @@ Each vo driver _has_ to implement these:
real. This is 'swapbuffers' when doublebuffering.
Try to do as little work here as possible, since that affect jitter/
A-V sync.
-
diff --git a/DOCS/tech/realcodecs/TODO b/DOCS/tech/realcodecs/TODO
index 00f20f13ac..5ba035bfdd 100644
--- a/DOCS/tech/realcodecs/TODO
+++ b/DOCS/tech/realcodecs/TODO
@@ -20,5 +20,3 @@ TODO:
also statistics->streams->video->POST FILTER: ON
(i've found that custommessage calls differ wiht pp on/off, but adding
these calls to mplayer didn't make a pixel difference between outputs)
-
-
diff --git a/DOCS/tech/realcodecs/audio-codecs.txt b/DOCS/tech/realcodecs/audio-codecs.txt
index 6d79815ac0..8a0d958354 100644
--- a/DOCS/tech/realcodecs/audio-codecs.txt
+++ b/DOCS/tech/realcodecs/audio-codecs.txt
@@ -153,6 +153,3 @@ output_buffer points to the output buffer from the last
decode operation.
retval is unknown, returning always 0x18 in a specific sample
-> further investigation needed
-
-
-
diff --git a/DOCS/tech/realcodecs/video-codecs.txt b/DOCS/tech/realcodecs/video-codecs.txt
index 5ef9a51961..2bef957172 100644
--- a/DOCS/tech/realcodecs/video-codecs.txt
+++ b/DOCS/tech/realcodecs/video-codecs.txt
@@ -183,5 +183,3 @@ Transform (internally calls (0x1c,x,y))
]
Free
-
-
diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt
index c15a3a7fa8..e1fed7edee 100644
--- a/DOCS/tech/slave.txt
+++ b/DOCS/tech/slave.txt
@@ -546,4 +546,3 @@ teletext_format int 0 3 X X X 0 - opaque,
3 - transp. inv.
teletext_half_page int 0 2 X X X 0 - off, 1 - top half,
2- bottom half
-
diff --git a/DOCS/tech/snow.txt b/DOCS/tech/snow.txt
index db1b558cb9..be531fcb5c 100644
--- a/DOCS/tech/snow.txt
+++ b/DOCS/tech/snow.txt
@@ -87,4 +87,3 @@ vcodec=snow:vstrict=-2:vpass=2:vbitrate=$B:pred=0:cmp=12:subcmp=12:mbcmp=1:qpel:
Decent, fast options are
vcodec=snow:vstrict=-2:vpass=1:vbitrate=$B:pred=0:cmp=1:subcmp=1:mbcmp=1
vcodec=snow:vstrict=-2:vpass=2:vbitrate=$B:pred=0:cmp=2:subcmp=2:mbcmp=1:refs=2
-
diff --git a/DOCS/tech/subcp.txt b/DOCS/tech/subcp.txt
index df96f31e80..60c370771c 100644
--- a/DOCS/tech/subcp.txt
+++ b/DOCS/tech/subcp.txt
@@ -40,5 +40,3 @@ I tested charmap2enc script only with /usr/share/i18n/charmaps/EUC-KR.gz
--
Artur Zaprzala
-
-
diff --git a/DOCS/tech/swscaler_methods.txt b/DOCS/tech/swscaler_methods.txt
index e37227b982..b2c7077652 100644
--- a/DOCS/tech/swscaler_methods.txt
+++ b/DOCS/tech/swscaler_methods.txt
@@ -66,4 +66,3 @@ m mosaic (blocky) (upscale only)
Notes:
area upscale is identical to bilinear
-
diff --git a/DOCS/xml/ldp.dsl b/DOCS/xml/ldp.dsl
index ef52e849de..20bc32277b 100644
--- a/DOCS/xml/ldp.dsl
+++ b/DOCS/xml/ldp.dsl
@@ -362,4 +362,3 @@
<external-specification id="docbook" document="docbook.dsl">
</style-sheet>
-
diff --git a/DOCS/xml/ru/ports.xml b/DOCS/xml/ru/ports.xml
index 20ddafe126..181b204b8c 100644
--- a/DOCS/xml/ru/ports.xml
+++ b/DOCS/xml/ru/ports.xml
@@ -868,5 +868,3 @@ MPlayer_source_directory
</sect2>
</sect1>
</chapter>
-
-
diff --git a/Makefile b/Makefile
index 0cb776aadf..7131000471 100644
--- a/Makefile
+++ b/Makefile
@@ -334,6 +334,7 @@ SRCS_COMMON-$(ZR) += libmpcodecs/vd_zrmjpeg.c \
SRCS_COMMON = asxparser.c \
codec-cfg.c \
cpudetect.c \
+ defaultopts.c \
edl.c \
find_sub.c \
fmt-conversion.c \
@@ -349,6 +350,7 @@ SRCS_COMMON = asxparser.c \
sub_cc.c \
subopt-helper.c \
subreader.c \
+ talloc.c \
vobsub.c \
libaf/af.c \
libaf/af_center.c \
@@ -509,6 +511,7 @@ SRCS_COMMON = asxparser.c \
libmpdemux/yuv4mpeg_ratio.c \
libvo/osd.c \
libvo/sub.c \
+ osdep/findfiles.c \
osdep/$(GETCH) \
osdep/$(TIMER) \
stream/open.c \
@@ -672,6 +675,7 @@ SRCS_MPLAYER = command.c \
libao2/audio_out.c \
libvo/aspect.c \
libvo/geometry.c \
+ libvo/old_vo_wrapper.c \
libvo/spuenc.c \
libvo/video_out.c \
libvo/vo_mpegpes.c \
@@ -708,10 +712,10 @@ SRCS_MENCODER = mencoder.c \
$(SRCS_MENCODER-yes)
-COMMON_LIBS-$(LIBAVFORMAT_A) += libavformat/libavformat.a
-COMMON_LIBS-$(LIBAVCODEC_A) += libavcodec/libavcodec.a
-COMMON_LIBS-$(LIBAVUTIL_A) += libavutil/libavutil.a
-COMMON_LIBS-$(LIBPOSTPROC_A) += libpostproc/libpostproc.a
+COMMON_LIBS-$(LIBAVFORMAT_A) += ffmpeg/libavformat/libavformat.a
+COMMON_LIBS-$(LIBAVCODEC_A) += ffmpeg/libavcodec/libavcodec.a
+COMMON_LIBS-$(LIBAVUTIL_A) += ffmpeg/libavutil/libavutil.a
+COMMON_LIBS-$(LIBPOSTPROC_A) += ffmpeg/libpostproc/libpostproc.a
COMMON_LIBS-$(LIBSWSCALE_A) += libswscale/libswscale.a
COMMON_LIBS += $(COMMON_LIBS-yes)
@@ -744,22 +748,23 @@ DIRS = . \
libaf \
libao2 \
libass \
- libavcodec \
- libavcodec/alpha \
- libavcodec/arm \
- libavcodec/bfin \
- libavcodec/mlib \
- libavcodec/ppc \
- libavcodec/sh4 \
- libavcodec/sparc \
- libavcodec/x86 \
- libavformat \
- libavutil \
- libavutil/arm \
- libavutil/bfin \
- libavutil/ppc \
- libavutil/sh4 \
- libavutil/x86 \
+ ffmpeg/libavcodec \
+ ffmpeg/libavcodec/alpha \
+ ffmpeg/libavcodec/arm \
+ ffmpeg/libavcodec/bfin \
+ ffmpeg/libavcodec/x86 \
+ ffmpeg/libavcodec/mlib \
+ ffmpeg/libavcodec/ppc \
+ ffmpeg/libavcodec/sh4 \
+ ffmpeg/libavcodec/sparc \
+ ffmpeg/libavformat \
+ ffmpeg/libavutil \
+ ffmpeg/libavutil/arm \
+ ffmpeg/libavutil/bfin \
+ ffmpeg/libavutil/bfin \
+ ffmpeg/libavutil/ppc \
+ ffmpeg/libavutil/sh4 \
+ ffmpeg/libavutil/x86 \
libdvdcss \
libdvdnav \
libdvdnav/vm \
@@ -770,7 +775,7 @@ DIRS = . \
libmpcodecs/native \
libmpdemux \
libmpeg2 \
- libpostproc \
+ ffmpeg/libpostproc \
libswscale \
libswscale/bfin \
libswscale/mlib \
@@ -797,14 +802,14 @@ ADDSUFFIXES = $(foreach suf,$(1),$(addsuffix $(suf),$(2)))
ADD_ALL_DIRS = $(call ADDSUFFIXES,$(1),$(DIRS))
ADD_ALL_EXESUFS = $(1) $(call ADDSUFFIXES,$(EXESUFS_ALL),$(1))
-FFMPEGPARTS = libavcodec \
- libavformat \
- libavutil \
- libpostproc \
+FFMPEGPARTS = ffmpeg/libavcodec \
+ ffmpeg/libavformat \
+ ffmpeg/libavutil \
+ ffmpeg/libpostproc \
libswscale \
-FFMPEGLIBS = $(foreach part, $(FFMPEGPARTS), $(part)/$(part).a)
-FFMPEGFILES = $(foreach part, $(FFMPEGPARTS), $(wildcard $(part)/*.[chS] $(part)/*/*.[chS]))
+FFMPEGLIBS = $(foreach part, $(FFMPEGPARTS), $(part)/$(notdir $(part)).a)
+FFMPEGFILES = $(foreach part, $(FFMPEGPARTS), $(wildcard $(part)/*.[choS] $(part)/*/*.[choS] $(part)/*/*.asm))
@@ -812,21 +817,18 @@ FFMPEGFILES = $(foreach part, $(FFMPEGPARTS), $(wildcard $(part)/*.[chS] $(part)
all: $(ALL_PRG-yes)
-%.d: %.c
- $(MPDEPEND_CMD) > $@
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ -MD -MP -MF $*.d $<
-%.d: %.cpp
- $(MPDEPEND_CMD_CXX) > $@
+%.o: %.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ -MD -MP -MF $*.d $<
-%.d: %.m
- $(MPDEPEND_CMD) > $@
+%.o: %.m
+ $(CC) $(CFLAGS) -c -o $@ -MD -MP -MF $*.d $<
%.ho: %.h
$(CC) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
-%.o: %.m
- $(CC) $(CFLAGS) -c -o $@ $<
-
%-rc.o: %.rc
$(WINDRES) -I. $< $@
@@ -835,6 +837,10 @@ checkheaders: $(ALLHEADERS:.h=.ho)
dep depend: $(DEPS)
for part in $(FFMPEGPARTS); do $(MAKE) -C $$part depend; done
+# dummy to prevent default build rules from being used for FFMPEGFILES
+$(FFMPEGFILES):
+ echo "this shouldn't run"
+
$(FFMPEGLIBS): $(FFMPEGFILES) config.h
$(MAKE) -C $(@D)
touch $@
@@ -845,8 +851,8 @@ mencoder$(EXESUF): $(MENCODER_DEPS)
mplayer$(EXESUF): $(MPLAYER_DEPS)
$(CC) -o $@ $^ $(LDFLAGS_MPLAYER)
-codec-cfg$(EXESUF): codec-cfg.c help_mp.h
- $(HOST_CC) -O -DCODECS2HTML -I. -o $@ $<
+codec-cfg$(EXESUF): codec-cfg.c codec-cfg.h help_mp.h
+ $(HOST_CC) -O -DCODECS2HTML -I. -Iffmpeg -o $@ $<
codecs.conf.h: codec-cfg$(EXESUF) etc/codecs.conf
./$^ > $@
@@ -913,7 +919,9 @@ $(VIDIX_DEPS) $(VIDIX_OBJS): $(VIDIX_PCI_FILES)
install: $(INSTALL_TARGETS-yes)
install-dirs:
- $(INSTALL) -d $(BINDIR) $(CONFDIR) $(LIBDIR)
+ if test ! -d $(BINDIR) ; then $(INSTALL) -d $(BINDIR) ; fi
+ if test ! -d $(CONFDIR) ; then $(INSTALL) -d $(CONFDIR) ; fi
+ if test ! -d $(LIBDIR) ; then $(INSTALL) -d $(LIBDIR) ; fi
install-%: %$(EXESUF) install-dirs
$(INSTALL) -m 755 $(INSTALLSTRIP) $< $(BINDIR)
@@ -935,7 +943,7 @@ install-mencoder-man-en: install-mplayer-man-en
cd $(MANDIR)/man1 && ln -sf mplayer.1 mencoder.1
install-mplayer-man-en:
- $(INSTALL) -d $(MANDIR)/man1
+ if test ! -d $(MANDIR)/man1 ; then $(INSTALL) -d $(MANDIR)/man1 ; fi
$(INSTALL) -m 644 DOCS/man/en/mplayer.1 $(MANDIR)/man1/
define GUI_MAN_RULE
@@ -950,7 +958,7 @@ endef
define MPLAYER_MAN_RULE
install-mplayer-man-$(lang):
- $(INSTALL) -d $(MANDIR)/$(lang)/man1
+ if test ! -d $(MANDIR)/$(lang)/man1 ; then $(INSTALL) -d $(MANDIR)/$(lang)/man1 ; fi
$(INSTALL) -m 644 DOCS/man/$(lang)/mplayer.1 $(MANDIR)/$(lang)/man1/
endef
diff --git a/TOOLS/asfinfo.c b/TOOLS/asfinfo.c
index fc5c76cc79..37eb7c39e7 100644
--- a/TOOLS/asfinfo.c
+++ b/TOOLS/asfinfo.c
@@ -270,4 +270,3 @@ int main(int argc, char* argv[]){
return 0;
}
-
diff --git a/TOOLS/avisubdump.c b/TOOLS/avisubdump.c
index 9606137e0c..8afd12ec5b 100644
--- a/TOOLS/avisubdump.c
+++ b/TOOLS/avisubdump.c
@@ -180,4 +180,3 @@ int main(int argc,char* argv[])
return 0;
}
-
diff --git a/TOOLS/compare.c b/TOOLS/compare.c
index 67aa8ac1c2..8a48bc8255 100644
--- a/TOOLS/compare.c
+++ b/TOOLS/compare.c
@@ -71,4 +71,3 @@ int main(int argc, char **argv)
printf("%d (+/-1)differences found\n", dif);
exit(0);
}
-
diff --git a/TOOLS/modify_reg.c b/TOOLS/modify_reg.c
index 9c4e865883..888d9eac32 100644
--- a/TOOLS/modify_reg.c
+++ b/TOOLS/modify_reg.c
@@ -180,4 +180,3 @@ int main(int argc, char *argv[]) {
}
return 0;
}
-
diff --git a/TOOLS/realcodecs/cook.c b/TOOLS/realcodecs/cook.c
index 0cbd43af54..ede9a33aca 100644
--- a/TOOLS/realcodecs/cook.c
+++ b/TOOLS/realcodecs/cook.c
@@ -426,4 +426,3 @@ void SetDLLAccessPath(ulong p1) {
hexdump((void*)p1, 44);
fprintf(stderr, "--> void\n\n\n");
}
-
diff --git a/TOOLS/realcodecs/drv4.c b/TOOLS/realcodecs/drv4.c
index 39d642a180..ad68c1ac36 100644
--- a/TOOLS/realcodecs/drv4.c
+++ b/TOOLS/realcodecs/drv4.c
@@ -402,4 +402,3 @@ ulong RV20toYUV420Transform(ulong p1,ulong p2,ulong p3,ulong p4,ulong p5) {
// fprintf(stderr, "RV20toYUV420Transform --> 0x%0lx(%ld)\n\n\n", result, result);
return result;
}
-
diff --git a/TOOLS/realcodecs/ra.c b/TOOLS/realcodecs/ra.c
index 6a17911ba5..fd6d55a688 100644
--- a/TOOLS/realcodecs/ra.c
+++ b/TOOLS/realcodecs/ra.c
@@ -392,4 +392,3 @@ void SetDLLAccessPath(ulong p1) {
hexdump((void*)p1, 44);
fprintf(stderr, "--> void\n\n\n");
}
-
diff --git a/TOOLS/realcodecs/rv30.c b/TOOLS/realcodecs/rv30.c
index 41f49eadaa..bf02fe3a78 100644
--- a/TOOLS/realcodecs/rv30.c
+++ b/TOOLS/realcodecs/rv30.c
@@ -537,4 +537,3 @@ void SetDLLAccessPath(ulong p1) {
// hexdump((void*)p1, 44);
fprintf(stderr, "--> void\n\n\n");
}
-
diff --git a/TOOLS/realcodecs/sipr.c b/TOOLS/realcodecs/sipr.c
index 9a3399ea6c..43e0805b2e 100644
--- a/TOOLS/realcodecs/sipr.c
+++ b/TOOLS/realcodecs/sipr.c
@@ -480,4 +480,3 @@ void RASetPwd(ulong p1,ulong p2) {
// hexdump((void*)p1, 44);
fprintf(stderr, "--> void\n\n\n");
}
-
diff --git a/TOOLS/w32codec_dl.pl b/TOOLS/w32codec_dl.pl
index 41f4f9feca..c4a16b6b58 100755
--- a/TOOLS/w32codec_dl.pl
+++ b/TOOLS/w32codec_dl.pl
@@ -166,4 +166,3 @@ sub get_codec
print "No such file!\n";
}
}
-
diff --git a/asxparser.c b/asxparser.c
index 9d4d36c3c6..ba9ba45354 100644
--- a/asxparser.c
+++ b/asxparser.c
@@ -14,8 +14,6 @@
#include "mp_msg.h"
#include "m_config.h"
-extern m_config_t* mconfig;
-
////// List utils
void
@@ -109,8 +107,10 @@ asx_attrib_to_enum(const char* val,char** valid_vals) {
#define asx_warning_body_parse_error(p,e) mp_msg(MSGT_PLAYTREE,MSGL_WARN,"At line %d : error while parsing %s body",p->line,e)
ASX_Parser_t*
-asx_parser_new(void) {
+asx_parser_new(struct m_config *mconfig)
+{
ASX_Parser_t* parser = calloc(1,sizeof(ASX_Parser_t));
+ parser->mconfig = mconfig;
return parser;
}
@@ -426,7 +426,7 @@ asx_parse_param(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) {
return;
}
val = asx_get_attrib("VALUE",attribs);
- if(m_config_get_option(mconfig,name) == NULL) {
+ if(m_config_get_option(parser->mconfig,name) == NULL) {
mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Found unknown param in asx: %s",name);
if(val)
mp_msg(MSGT_PLAYTREE,MSGL_WARN,"=%s\n",val);
@@ -494,7 +494,7 @@ asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) {
mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding playlist %s to element entryref\n",href);
- ptp = play_tree_parser_new(stream,parser->deep+1);
+ ptp = play_tree_parser_new(stream, parser->mconfig, parser->deep+1);
pt = play_tree_parser_get_play_tree(ptp, 1);
@@ -611,11 +611,11 @@ asx_parse_repeat(ASX_Parser_t* parser,char* buffer,char** _attribs) {
play_tree_t*
-asx_parser_build_tree(char* buffer,int deep) {
+asx_parser_build_tree(struct m_config *mconfig, char* buffer,int deep) {
char *element,*asx_body,**asx_attribs,*body = NULL, **attribs;
int r;
play_tree_t *asx,*entry,*list = NULL;
- ASX_Parser_t* parser = asx_parser_new();
+ ASX_Parser_t* parser = asx_parser_new(mconfig);
parser->line = 1;
parser->deep = deep;
diff --git a/asxparser.h b/asxparser.h
index 9763b69902..7b148a7775 100644
--- a/asxparser.h
+++ b/asxparser.h
@@ -14,10 +14,12 @@ struct ASX_Parser_t {
int ret_stack_size;
char* last_body;
int deep;
+ struct m_config *mconfig;
};
+struct m_config;
ASX_Parser_t*
-asx_parser_new(void);
+asx_parser_new(struct m_config *mconfig);
void
asx_parser_free(ASX_Parser_t* parser);
diff --git a/av_opts.c b/av_opts.c
index 2d708ebddc..452253b4de 100644
--- a/av_opts.c
+++ b/av_opts.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
+#include "av_opts.h"
#include "libavcodec/opt.h"
int parse_avopts(void *v, char *str){
diff --git a/cfg-common-opts.h b/cfg-common-opts.h
index a3ad02e85f..a96ff40798 100644
--- a/cfg-common-opts.h
+++ b/cfg-common-opts.h
@@ -1,16 +1,9 @@
-#ifndef MPLAYER_CFG_COMMON_OPTS_H
-#define MPLAYER_CFG_COMMON_OPTS_H
-
-#include "config.h"
-
-#include "osdep/priority.h"
-
// ------------------------- common options --------------------
{"quiet", &quiet, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"noquiet", &quiet, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
{"really-quiet", &verbose, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_PRE_PARSE, 0, -10, NULL},
{"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, NULL},
- {"msglevel", msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
+ {"msglevel", (void *) msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
{"msgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"nomsgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
{"msgmodule", &mp_msg_module, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
@@ -18,11 +11,10 @@
#ifdef CONFIG_ICONV
{"msgcharset", &mp_msg_charset, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
#endif
- {"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL},
#ifdef CONFIG_PRIORITY
{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
#endif
- {"noconfig", noconfig_opts, CONF_TYPE_SUBCONFIG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 0, NULL},
+ {"noconfig", (void *) noconfig_opts, CONF_TYPE_SUBCONFIG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 0, NULL},
// ------------------------- stream options --------------------
@@ -128,11 +120,11 @@
{"loadidx", &index_file_load, CONF_TYPE_STRING, 0, 0, 0, NULL},
// select audio/video/subtitle stream
- {"aid", &audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 8190, NULL},
+ OPT_INTRANGE("aid", audio_id, 0, 0, 8190),
{"ausid", &audio_substream_id, CONF_TYPE_INT, 0, 0, 0, NULL},
- {"vid", &video_id, CONF_TYPE_INT, CONF_RANGE, 0, 8190, NULL},
- {"sid", &dvdsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 8190, NULL},
- {"novideo", &video_id, CONF_TYPE_FLAG, 0, -1, -2, NULL},
+ OPT_INTRANGE("vid", video_id, 0, 0, 8190),
+ OPT_INTRANGE("sid", sub_id, 0, 0, 8190),
+ OPT_FLAG_CONSTANTS("novideo", video_id, 0, -1, -2),
{ "hr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, NULL },
{ "nohr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, NULL},
@@ -154,25 +146,25 @@
{ "extbased", &extension_parsing, CONF_TYPE_FLAG, 0, 0, 1, NULL },
{ "noextbased", &extension_parsing, CONF_TYPE_FLAG, 0, 1, 0, NULL },
- {"mf", mfopts_conf, CONF_TYPE_SUBCONFIG, 0,0,0, NULL},
+ {"mf", (void *) mfopts_conf, CONF_TYPE_SUBCONFIG, 0,0,0, NULL},
#ifdef CONFIG_RADIO
{"radio", radioopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#else
{"radio", "MPlayer was compiled without Radio interface support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
#endif /* CONFIG_RADIO */
#ifdef CONFIG_TV
- {"tv", tvopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ {"tv", (void *) tvopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#else
{"tv", "MPlayer was compiled without TV interface support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
#endif /* CONFIG_TV */
#ifdef CONFIG_PVR
- {"pvr", pvropts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ {"pvr", (void *) pvropts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#else
{"pvr", "MPlayer was compiled without V4L2/PVR interface support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
#endif /* CONFIG_PVR */
- {"vivo", vivoopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ {"vivo", (void *) vivoopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#ifdef CONFIG_DVBIN
- {"dvbin", dvbin_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ {"dvbin", (void *) dvbin_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#endif
// ------------------------- a-v sync options --------------------
@@ -189,7 +181,7 @@
{"srate", &force_srate, CONF_TYPE_INT, CONF_RANGE, 1000, 8*48000, NULL},
{"channels", &audio_output_channels, CONF_TYPE_INT, CONF_RANGE, 1, 6, NULL},
{"format", &audio_output_format, CONF_TYPE_AFMT, 0, 0, 0, NULL},
- {"speed", &playback_speed, CONF_TYPE_FLOAT, CONF_RANGE, 0.01, 100.0, NULL},
+ OPT_FLOATRANGE("speed", playback_speed, 0, 0.01, 100.0),
// set a-v distance
{"delay", &audio_delay, CONF_TYPE_FLOAT, CONF_RANGE, -100.0, 100.0, NULL},
@@ -210,14 +202,14 @@
#endif
// disable audio
- {"sound", &audio_id, CONF_TYPE_FLAG, 0, -2, -1, NULL},
- {"nosound", &audio_id, CONF_TYPE_FLAG, 0, -1, -2, NULL},
+ OPT_FLAG_CONSTANTS("sound", audio_id, 0, -2, -1),
+ OPT_FLAG_CONSTANTS("nosound", audio_id, 0, -1, -2),
{"af*", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
- {"af-adv", audio_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ {"af-adv", (void *) audio_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
{"vop", "-vop has been removed, use -vf instead.\n", CONF_TYPE_PRINT, CONF_NOCFG ,0,0, NULL},
- {"vf*", &vf_settings, CONF_TYPE_OBJ_SETTINGS_LIST, 0, 0, 0, &vf_obj_list},
+ OPT_SETTINGSLIST("vf*", vf_settings, 0, &vf_obj_list),
// select audio/video codec (by name) or codec family (by number):
// {"afm", &audio_family, CONF_TYPE_INT, CONF_MIN, 0, 22, NULL}, // keep ranges in sync
// {"vfm", &video_family, CONF_TYPE_INT, CONF_MIN, 0, 29, NULL}, // with codec-cfg.c
@@ -238,15 +230,15 @@
// scaling:
{"sws", &sws_flags, CONF_TYPE_INT, 0, 0, 2, NULL},
- {"ssf", scaler_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
- {"zoom", &softzoom, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"nozoom", &softzoom, CONF_TYPE_FLAG, 0, 1, 0, NULL},
- {"aspect", &movie_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 3.0, NULL},
- {"noaspect", &movie_aspect, CONF_TYPE_FLAG, 0, 0, 0, NULL},
- {"xy", &screen_size_xy, CONF_TYPE_FLOAT, CONF_RANGE, 0.001, 4096, NULL},
-
- {"flip", &flip, CONF_TYPE_FLAG, 0, -1, 1, NULL},
- {"noflip", &flip, CONF_TYPE_FLAG, 0, -1, 0, NULL},
+ {"ssf", (void *) scaler_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ OPT_FLAG_ON("zoom", softzoom, 0),
+ OPT_FLAG_OFF("nozoom", softzoom, 0),
+ OPT_FLOATRANGE("aspect", movie_aspect, 0, 0.2, 3.0),
+ OPT_FLAG_CONSTANTS("noaspect", movie_aspect, 0, 0, 0),
+ OPT_FLOATRANGE("xy", screen_size_xy, 0, 0.001, 4096),
+
+ OPT_FLAG_CONSTANTS("flip", flip, 0, -1, 1),
+ OPT_FLAG_CONSTANTS("noflip", flip, 0, -1, 0),
{"tsfastparse", "-tsfastparse is no longer a valid option.\n", CONF_TYPE_PRINT, CONF_NOCFG ,0,0, NULL
},
{"tsprog", &ts_prog, CONF_TYPE_INT, CONF_RANGE, 0, 65534, NULL},
@@ -256,15 +248,15 @@
{"tskeepbroken", &ts_keep_broken, CONF_TYPE_FLAG, 0, 0, 1, NULL},
// draw by slices or whole frame (useful with libmpeg2/libavcodec)
- {"slices", &vd_use_slices, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"noslices", &vd_use_slices, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+ OPT_FLAG_ON("slices", vd_use_slices, 0),
+ OPT_FLAG_OFF("noslices", vd_use_slices, 0),
{"field-dominance", &field_dominance, CONF_TYPE_INT, CONF_RANGE, -1, 1, NULL},
#ifdef CONFIG_LIBAVCODEC
- {"lavdopts", lavc_decode_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ {"lavdopts", (void *) lavc_decode_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#endif
#ifdef CONFIG_LIBAVFORMAT
- {"lavfdopts", lavfdopts_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
+ {"lavfdopts", (void *) lavfdopts_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
#endif
#ifdef CONFIG_XVID4
{"xvidopts", xvid_dec_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
@@ -350,5 +342,3 @@
{"fontconfig", "MPlayer was compiled without fontconfig support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
{"nofontconfig", "MPlayer was compiled without fontconfig support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
#endif /* CONFIG_FONTCONFIG */
-
-#endif /* MPLAYER_CFG_COMMON_OPTS_H */
diff --git a/cfg-common.h b/cfg-common.h
index 991234f0c0..bdb6978dad 100644
--- a/cfg-common.h
+++ b/cfg-common.h
@@ -10,12 +10,6 @@ extern char *mp_msg_charset;
extern int mp_msg_color;
extern int mp_msg_module;
-// codec/filter opts: (defined at libmpcodecs/vd.c)
-extern float screen_size_xy;
-extern float movie_aspect;
-extern int softzoom;
-extern int flip;
-
/* defined in codec-cfg.c */
extern char * codecs_file;
@@ -229,7 +223,6 @@ extern int mf_w;
extern int mf_h;
extern double mf_fps;
extern char * mf_type;
-extern m_obj_settings_t* vf_settings;
extern m_obj_list_t vf_obj_list;
const m_option_t mfopts_conf[]={
diff --git a/cfg-mencoder.h b/cfg-mencoder.h
index 31f3a3ca30..6318453ae2 100644
--- a/cfg-mencoder.h
+++ b/cfg-mencoder.h
@@ -184,11 +184,11 @@ const m_option_t mencoder_opts[]={
{"xsize", "-xsize has been removed, use -vf crop=w:h:x:y for cropping.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
// output audio/video codec selection
- {"oac", oac_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
- {"ovc", ovc_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
+ {"oac", (void *) oac_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
+ {"ovc", (void *) ovc_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
// output file format
- {"of", of_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
+ {"of", (void *) of_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
// override audio format tag in output file
{"fafmttag", &force_audiofmttag, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL},
@@ -215,7 +215,7 @@ const m_option_t mencoder_opts[]={
{"noodml", &write_odml, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
// info header strings
- {"info", info_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
+ {"info", (void *) info_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
#ifdef CONFIG_MP3LAME
{"lameopts", lameopts_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
diff --git a/cfg-mplayer-def.h b/cfg-mplayer-def.h
index 4ff64c953a..9ebb69de6b 100644
--- a/cfg-mplayer-def.h
+++ b/cfg-mplayer-def.h
@@ -3,4 +3,3 @@ static char* default_config=
"\n"
//"nosound=nem"
"\n";
-
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 5b297dd450..1e1234a756 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -5,10 +5,10 @@
* config for cfgparser
*/
-#include "cfg-common.h"
+#include <stddef.h>
-extern int key_fifo_size;
-extern unsigned doubleclick_time;
+#include "cfg-common.h"
+#include "options.h"
extern char *fb_mode_cfgfile;
extern char *fb_mode_name;
@@ -16,15 +16,9 @@ extern char *dfb_params;
extern char *lirc_configfile;
-extern float vo_panscanrange;
/* only used at startup (setting these values from configfile) */
extern char *vo_geometry;
-extern int opt_screen_size_x;
-extern int opt_screen_size_y;
-extern int fullscreen;
-extern int vidmode;
-
extern char *ao_outputfilename;
extern int ao_pcm_waveheader;
@@ -49,10 +43,6 @@ extern char * skinName;
extern int guiWinID;
-/* from libvo/aspect.c */
-extern float force_monitor_aspect;
-extern float monitor_pixel_aspect;
-
extern int sws_flags;
int readPPOpt(void *conf, char *arg);
void revertPPOpt(void *conf, char* opt);
@@ -90,12 +80,12 @@ const m_option_t mplayer_opts[]={
//---------------------- libao/libvo options ------------------------
{"o", "Option -o has been renamed to -vo (video-out), use -vo.\n",
CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
- {"vo", &video_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
- {"ao", &audio_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
- {"fixed-vo", &fixed_vo, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL},
- {"nofixed-vo", &fixed_vo, CONF_TYPE_FLAG,CONF_GLOBAL, 1, 0, NULL},
- {"ontop", &vo_ontop, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"noontop", &vo_ontop, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+ OPT_STRINGLIST("vo", video_driver_list, 0),
+ OPT_STRINGLIST("ao", audio_driver_list, 0),
+ OPT_FLAG_ON("fixed-vo", fixed_vo, CONF_GLOBAL),
+ OPT_FLAG_OFF("nofixed-vo", fixed_vo, CONF_GLOBAL),
+ OPT_FLAG_ON("ontop", vo_ontop, 0),
+ OPT_FLAG_OFF("noontop", vo_ontop, 0),
{"rootwin", &vo_rootwin, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"border", &vo_border, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"noborder", &vo_border, CONF_TYPE_FLAG, 0, 1, 0, NULL},
@@ -163,27 +153,29 @@ const m_option_t mplayer_opts[]={
#endif
// force window width/height or resolution (with -vm)
- {"x", &opt_screen_size_x, CONF_TYPE_INT, CONF_RANGE, 0, 4096, NULL},
- {"y", &opt_screen_size_y, CONF_TYPE_INT, CONF_RANGE, 0, 4096, NULL},
+ OPT_INTRANGE("x", screen_size_x, 0, 0, 4096),
+ OPT_INTRANGE("y", screen_size_y, 0, 0, 4096),
// set screen dimensions (when not detectable or virtual!=visible)
- {"screenw", &vo_screenwidth, CONF_TYPE_INT, CONF_RANGE|CONF_OLD, 0, 4096, NULL},
- {"screenh", &vo_screenheight, CONF_TYPE_INT, CONF_RANGE|CONF_OLD, 0, 4096, NULL},
+ OPT_INTRANGE("screenw", vo_screenwidth, CONF_OLD, 0, 4096),
+ OPT_INTRANGE("screenh", vo_screenheight, CONF_OLD, 0, 4096),
// Geometry string
{"geometry", &vo_geometry, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ OPT_FLAG_ON("force-window-position", force_window_position, 0),
+ OPT_FLAG_OFF("noforce-window-position", force_window_position, 0),
// set aspect ratio of monitor - useful for 16:9 TV-out
- {"monitoraspect", &force_monitor_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 9.0, NULL},
- {"monitorpixelaspect", &monitor_pixel_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 9.0, NULL},
+ OPT_FLOATRANGE("monitoraspect", force_monitor_aspect, 0, 0.0, 9.0),
+ OPT_FLOATRANGE("monitorpixelaspect", monitor_pixel_aspect, 0, 0.2, 9.0),
// video mode switching: (x11,xv,dga)
- {"vm", &vidmode, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"novm", &vidmode, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+ OPT_FLAG_ON("vm", vidmode, 0),
+ OPT_FLAG_OFF("novm", vidmode, 0),
// start in fullscreen mode:
- {"fs", &fullscreen, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"nofs", &fullscreen, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+ OPT_FLAG_ON("fs", fullscreen, 0),
+ OPT_FLAG_OFF("nofs", fullscreen, 0),
// set fullscreen switch method (workaround for buggy WMs)
{"fsmode", "-fsmode is obsolete, avoid it and use -fstype instead.\nIf you really want it, try -fsmode-dontuse, but don't report bugs!\n", CONF_TYPE_PRINT, CONF_RANGE, 0, 31, NULL},
{"fsmode-dontuse", &vo_fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
// set bpp (x11+vm, dga, fbdev, vesa, svga?)
- {"bpp", &vo_dbpp, CONF_TYPE_INT, CONF_RANGE, 0, 32, NULL},
+ OPT_INTRANGE("bpp", vo_dbpp, 0, 0, 32),
{"colorkey", &vo_colorkey, CONF_TYPE_INT, 0, 0, 0, NULL},
{"nocolorkey", &vo_colorkey, CONF_TYPE_FLAG, 0, 0, 0x1000000, NULL},
{"double", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1, NULL},
@@ -192,7 +184,7 @@ const m_option_t mplayer_opts[]={
{"vsync", &vo_vsync, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"novsync", &vo_vsync, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"panscan", &vo_panscan, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
- {"panscanrange", &vo_panscanrange, CONF_TYPE_FLOAT, CONF_RANGE, -19.0, 99.0, NULL},
+ OPT_FLOATRANGE("panscanrange", vo_panscanrange, 0, -19.0, 99.0),
{"grabpointer", &vo_grabpointer, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"nograbpointer", &vo_grabpointer, CONF_TYPE_FLAG, 0, 1, 0, NULL},
@@ -214,10 +206,10 @@ const m_option_t mplayer_opts[]={
{"xineramascreen", &xinerama_screen, CONF_TYPE_INT, CONF_RANGE, -2, 32, NULL},
- {"brightness",&vo_gamma_brightness, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
- {"saturation",&vo_gamma_saturation, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
- {"contrast",&vo_gamma_contrast, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
- {"hue",&vo_gamma_hue, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
+ OPT_INTRANGE("brightness", vo_gamma_brightness, 0, -100, 100),
+ OPT_INTRANGE("saturation", vo_gamma_saturation, 0, -100, 100),
+ OPT_INTRANGE("contrast", vo_gamma_contrast, 0, -100, 100),
+ OPT_INTRANGE("hue", vo_gamma_hue, 0, -100, 100),
{"keepaspect", &vo_keepaspect, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"nokeepaspect", &vo_keepaspect, CONF_TYPE_FLAG, 0, 1, 0, NULL},
@@ -250,8 +242,8 @@ const m_option_t mplayer_opts[]={
{"crash-debug", &crash_debug, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"nocrash-debug", &crash_debug, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
#endif
- {"osdlevel", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
- {"osd-duration", &osd_duration, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
+ OPT_INTRANGE("osdlevel", osd_level, 0, 0, 3),
+ OPT_INTRANGE("osd-duration", osd_duration, 0, 0, 3600000),
#ifdef CONFIG_MENU
{"menu", &use_menu, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"nomenu", &use_menu, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
@@ -315,13 +307,16 @@ const m_option_t mplayer_opts[]={
{"guiwid", &guiWinID, CONF_TYPE_INT, 0, 0, 0, NULL},
#endif
- {"noloop", &mpctx_s.loop_times, CONF_TYPE_FLAG, 0, 0, -1, NULL},
- {"loop", &mpctx_s.loop_times, CONF_TYPE_INT, CONF_RANGE, -1, 10000, NULL},
+ OPT_FLAG_CONSTANTS("noloop", loop_times, 0, 0, -1),
+ OPT_INTRANGE("loop", loop_times, 0, -1, 10000),
{"playlist", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ OPT_FLAG_ON("ordered-chapters", ordered_chapters, 0),
+ OPT_FLAG_OFF("noordered-chapters", ordered_chapters, 0),
+
// a-v sync stuff:
- {"correct-pts", &user_correct_pts, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"nocorrect-pts", &user_correct_pts, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+ OPT_FLAG_ON("correct-pts", user_correct_pts, 0),
+ OPT_FLAG_OFF("nocorrect-pts", user_correct_pts, 0),
{"noautosync", &autosync, CONF_TYPE_FLAG, 0, 0, -1, NULL},
{"autosync", &autosync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL},
// {"dapsync", &dapsync, CONF_TYPE_FLAG, 0, 0, 1, NULL},
@@ -343,14 +338,14 @@ const m_option_t mplayer_opts[]={
{"idle", &player_idle_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL},
{"noidle", &player_idle_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 1, 0, NULL},
{"use-stdin", "-use-stdin has been renamed to -noconsolecontrols, use that instead.", CONF_TYPE_PRINT, 0, 0, 0, NULL},
- {"key-fifo-size", &key_fifo_size, CONF_TYPE_INT, CONF_RANGE, 2, 65000, NULL},
+ OPT_INTRANGE("key-fifo-size", key_fifo_size, CONF_GLOBAL, 2, 65000),
{"noconsolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"consolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
{"mouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"nomouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
- {"doubleclick-time", &doubleclick_time, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL},
+ OPT_INTRANGE("doubleclick-time", doubleclick_time, 0, 0, 1000),
#ifdef CONFIG_TV
- {"tvscan", tvscan_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ {"tvscan", (void *) tvscan_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#else
{"tvscan", "MPlayer was compiled without TV interface support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
#endif /* CONFIG_TV */
@@ -363,9 +358,8 @@ const m_option_t mplayer_opts[]={
{"help", help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL},
{"h", help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL},
- {"vd", vd_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+ {"vd", (void *) vd_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
#endif /* MPLAYER_CFG_MPLAYER_H */
-
diff --git a/codec-cfg.c b/codec-cfg.c
index bb604aa19b..db26866fbe 100644
--- a/codec-cfg.c
+++ b/codec-cfg.c
@@ -24,10 +24,12 @@
#include <ctype.h>
#include <assert.h>
#include <string.h>
+#include <stdint.h>
#include "config.h"
#include "mp_msg.h"
#ifdef CODECS2HTML
+#define mp_tmsg mp_msg
#ifdef __GNUC__
#define mp_msg(t, l, m, args...) fprintf(stderr, m, ##args)
#else
@@ -37,9 +39,6 @@
#include "help_mp.h"
-// for mmioFOURCC:
-#include "libmpdemux/aviheader.h"
-
#include "libmpcodecs/img_format.h"
#include "codec-cfg.h"
@@ -47,6 +46,10 @@
#include "codecs.conf.h"
#endif
+#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
+ ( (uint32_t)(uint8_t)(ch0) | ( (uint32_t)(uint8_t)(ch1) << 8 ) | \
+ ( (uint32_t)(uint8_t)(ch2) << 16 ) | ( (uint32_t)(uint8_t)(ch3) << 24 ) )
+
#define PRINT_LINENUM mp_msg(MSGT_CODECCFG,MSGL_ERR," at line %d\n", line_num)
#define MAX_NR_TOKEN 16
@@ -91,13 +94,13 @@ static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
goto err_out_parse_error;
return 1;
err_out_duplicated:
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_DuplicateFourcc);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"duplicated FourCC");
return 0;
err_out_too_many:
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_TooManyFourccs);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"too many FourCCs/formats...");
return 0;
err_out_parse_error:
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseError);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error");
return 0;
}
@@ -110,20 +113,20 @@ static int add_to_format(char *s, char *alias,unsigned int *fourcc, unsigned int
for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++)
/* NOTHING */;
if (i == CODECS_MAX_FOURCC) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_TooManyFourccs);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"too many FourCCs/formats...");
return 0;
}
fourcc[i]=strtoul(s,&endptr,0);
if (*endptr != '\0') {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseErrorFIDNotNumber);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error (format ID not a number?)");
return 0;
}
if(alias){
fourccmap[i]=strtoul(alias,&endptr,0);
if (*endptr != '\0') {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseErrorFIDAliasNotNumber);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error (format ID alias not a number?)");
return 0;
}
} else
@@ -131,7 +134,7 @@ static int add_to_format(char *s, char *alias,unsigned int *fourcc, unsigned int
for (j = 0; j < i; j++)
if (fourcc[j] == fourcc[i]) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_DuplicateFID);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"duplicated format ID");
return 0;
}
@@ -251,10 +254,10 @@ static int add_to_inout(char *sfmt, char *sflags, unsigned int *outfmt,
return 1;
err_out_too_many:
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_TooManyOut);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"too many out...");
return 0;
err_out_parse_error:
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseError);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error");
return 0;
}
@@ -335,7 +338,7 @@ static int validate_codec(codecs_t *c, int type)
/* NOTHING */;
if (i < strlen(tmp_name)) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_InvalidCodecName, c->name);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) name is not valid!\n", c->name);
return 0;
}
@@ -344,13 +347,13 @@ static int validate_codec(codecs_t *c, int type)
#if 0
if (c->fourcc[0] == 0xffffffff) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecLacksFourcc, c->name);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) does not have FourCC/format!\n", c->name);
return 0;
}
#endif
if (!c->drv) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecLacksDriver, c->name);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) does not have a driver!\n", c->name);
return 0;
}
@@ -359,7 +362,7 @@ static int validate_codec(codecs_t *c, int type)
#warning Where are they defined ????????????
if (!c->dll && (c->driver == 4 ||
(c->driver == 2 && type == TYPE_VIDEO))) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecNeedsDLL, c->name);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) needs a 'dll'!\n", c->name);
return 0;
}
#warning Can guid.f1 be 0? How does one know that it was not given?
@@ -367,7 +370,7 @@ static int validate_codec(codecs_t *c, int type)
if (type == TYPE_VIDEO)
if (c->outfmt[0] == 0xffffffff) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecNeedsOutfmt, c->name);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) needs an 'outfmt'!\n", c->name);
return 0;
}
#endif
@@ -385,7 +388,7 @@ static int add_comment(char *s, char **d)
(*d)[pos++] = '\n';
}
if (!(*d = realloc(*d, pos + strlen(s) + 1))) {
- mp_msg(MSGT_CODECCFG,MSGL_FATAL,MSGTR_CantAllocateComment);
+ mp_tmsg(MSGT_CODECCFG,MSGL_FATAL,"Can't allocate memory for comment. ");
return 0;
}
strcpy(*d + pos, s);
@@ -434,7 +437,7 @@ static int get_token(int min, int max)
char c;
if (max >= MAX_NR_TOKEN) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_GetTokenMaxNotLessThanMAX_NR_TOKEN);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"get_token(): max >= MAX_MR_TOKEN!");
goto out_eof;
}
@@ -518,15 +521,15 @@ int parse_codec_cfg(const char *cfgfile)
#endif
}
- mp_msg(MSGT_CODECCFG,MSGL_V,MSGTR_ReadingFile, cfgfile);
+ mp_tmsg(MSGT_CODECCFG,MSGL_V,"Reading %s: ", cfgfile);
if ((fp = fopen(cfgfile, "r")) == NULL) {
- mp_msg(MSGT_CODECCFG,MSGL_V,MSGTR_CantOpenFileError, cfgfile, strerror(errno));
+ mp_tmsg(MSGT_CODECCFG,MSGL_V,"Can't open '%s': %s\n", cfgfile, strerror(errno));
return 0;
}
if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) {
- mp_msg(MSGT_CODECCFG,MSGL_FATAL,MSGTR_CantGetMemoryForLine, strerror(errno));
+ mp_tmsg(MSGT_CODECCFG,MSGL_FATAL,"Can't get memory for 'line': %s\n", strerror(errno));
return 0;
}
read_nextline = 1;
@@ -584,7 +587,7 @@ int parse_codec_cfg(const char *cfgfile)
}
if (!(*codecsp = realloc(*codecsp,
sizeof(codecs_t) * (*nr_codecsp + 2)))) {
- mp_msg(MSGT_CODECCFG,MSGL_FATAL,MSGTR_CantReallocCodecsp, strerror(errno));
+ mp_tmsg(MSGT_CODECCFG,MSGL_FATAL,"Can't realloc '*codecsp': %s\n", strerror(errno));
goto err_out;
}
codec=*codecsp + *nr_codecsp;
@@ -599,19 +602,19 @@ int parse_codec_cfg(const char *cfgfile)
for (i = 0; i < *nr_codecsp - 1; i++) {
if(( (*codecsp)[i].name!=NULL) &&
(!strcmp(token[0], (*codecsp)[i].name)) ) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecNameNotUnique, token[0]);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Codec name '%s' isn't unique.", token[0]);
goto err_out_print_linenum;
}
}
if (!(codec->name = strdup(token[0]))) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CantStrdupName, strerror(errno));
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Can't strdup -> 'name': %s\n", strerror(errno));
goto err_out;
}
} else if (!strcmp(token[0], "info")) {
if (codec->info || get_token(1, 1) < 0)
goto err_out_parse_error;
if (!(codec->info = strdup(token[0]))) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CantStrdupInfo, strerror(errno));
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Can't strdup -> 'info': %s\n", strerror(errno));
goto err_out;
}
} else if (!strcmp(token[0], "comment")) {
@@ -635,14 +638,14 @@ int parse_codec_cfg(const char *cfgfile)
if (get_token(1, 1) < 0)
goto err_out_parse_error;
if (!(codec->drv = strdup(token[0]))) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CantStrdupDriver, strerror(errno));
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Can't strdup -> 'driver': %s\n", strerror(errno));
goto err_out;
}
} else if (!strcmp(token[0], "dll")) {
if (get_token(1, 1) < 0)
goto err_out_parse_error;
if (!(codec->dll = strdup(token[0]))) {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CantStrdupDLL, strerror(errno));
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Can't strdup -> 'dll': %s", strerror(errno));
goto err_out;
}
} else if (!strcmp(token[0], "guid")) {
@@ -711,7 +714,7 @@ int parse_codec_cfg(const char *cfgfile)
}
if (!validate_codec(codec, codec_type))
goto err_out_not_valid;
- mp_msg(MSGT_CODECCFG,MSGL_INFO,MSGTR_AudioVideoCodecTotals, nr_acodecs, nr_vcodecs);
+ mp_tmsg(MSGT_CODECCFG,MSGL_INFO,"%d audio & %d video codecs\n", nr_acodecs, nr_vcodecs);
if(video_codecs) video_codecs[nr_vcodecs].name = NULL;
if(audio_codecs) audio_codecs[nr_acodecs].name = NULL;
out:
@@ -721,7 +724,7 @@ out:
return 1;
err_out_parse_error:
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseError);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error");
err_out_print_linenum:
PRINT_LINENUM;
err_out:
@@ -733,10 +736,10 @@ err_out:
fclose(fp);
return 0;
err_out_not_valid:
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecDefinitionIncorrect);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Codec is not defined correctly.");
goto err_out_print_linenum;
err_out_release_num:
- mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_OutdatedCodecsConf);
+ mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"This codecs.conf is too old and incompatible with this MPlayer release!");
goto err_out_print_linenum;
}
@@ -1020,8 +1023,8 @@ int main(int argc, char* argv[])
nr[1] = nr_acodecs;
printf("/* GENERATED FROM %s, DO NOT EDIT! */\n\n",argv[1]);
- printf("#include <stddef.h>\n",argv[1]);
- printf("#include \"codec-cfg.h\"\n\n",argv[1]);
+ printf("#include <stddef.h>\n");
+ printf("#include \"codec-cfg.h\"\n\n");
for (i=0; i<2; i++) {
printf("const codecs_t %s[] = {\n", nm[i]);
diff --git a/codec-cfg.h b/codec-cfg.h
index b9842d0a99..d964ef74db 100644
--- a/codec-cfg.h
+++ b/codec-cfg.h
@@ -38,7 +38,7 @@ typedef struct {
#endif
-typedef struct codecs_st {
+typedef struct codecs {
unsigned int fourcc[CODECS_MAX_FOURCC];
unsigned int fourccmap[CODECS_MAX_FOURCC];
unsigned int outfmt[CODECS_MAX_OUTFMT];
diff --git a/command.c b/command.c
index ff36cd8c8b..9bcaa884e6 100644
--- a/command.c
+++ b/command.c
@@ -2,8 +2,10 @@
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
+#include <stdbool.h>
#include "config.h"
+#include "talloc.h"
#include "command.h"
#include "input/input.h"
#include "stream/stream.h"
@@ -18,6 +20,7 @@
#include "metadata.h"
#include "libmpcodecs/vf.h"
#include "libmpcodecs/vd.h"
+#include "mp_osd.h"
#include "libvo/video_out.h"
#include "libvo/font_load.h"
#include "playtree.h"
@@ -66,35 +69,38 @@
extern int use_menu;
-static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy)
+static void rescale_input_coordinates(struct MPContext *mpctx, int ix, int iy,
+ double *dx, double *dy)
{
+ struct MPOpts *opts = &mpctx->opts;
+ struct vo *vo = mpctx->video_out;
//remove the borders, if any, and rescale to the range [0,1],[0,1]
if (vo_fs) { //we are in full-screen mode
- if (vo_screenwidth > vo_dwidth) //there are borders along the x axis
- ix -= (vo_screenwidth - vo_dwidth) / 2;
- if (vo_screenheight > vo_dheight) //there are borders along the y axis (usual way)
- iy -= (vo_screenheight - vo_dheight) / 2;
+ if (opts->vo_screenwidth > vo->dwidth) //there are borders along the x axis
+ ix -= (opts->vo_screenwidth - vo->dwidth) / 2;
+ if (opts->vo_screenheight > vo->dheight) //there are borders along the y axis (usual way)
+ iy -= (opts->vo_screenheight - vo->dheight) / 2;
- if (ix < 0 || ix > vo_dwidth) {
+ if (ix < 0 || ix > vo->dwidth) {
*dx = *dy = -1.0;
return;
} //we are on one of the borders
- if (iy < 0 || iy > vo_dheight) {
+ if (iy < 0 || iy > vo->dheight) {
*dx = *dy = -1.0;
return;
} //we are on one of the borders
}
- *dx = (double) ix / (double) vo_dwidth;
- *dy = (double) iy / (double) vo_dheight;
+ *dx = (double) ix / (double) vo->dwidth;
+ *dy = (double) iy / (double) vo->dheight;
mp_msg(MSGT_CPLAYER, MSGL_V,
"\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
- *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth,
- vo_dheight, vo_fs);
+ *dx, *dy, opts->vo_screenwidth, opts->vo_screenheight, vo->dwidth,
+ vo->dheight, vo_fs);
}
-static int sub_source_by_pos(MPContext * mpctx, int pos)
+static int sub_source_by_pos(MPContext *mpctx, int pos)
{
int source = -1;
int top = -1;
@@ -109,7 +115,7 @@ static int sub_source_by_pos(MPContext * mpctx, int pos)
return source;
}
-static int sub_source(MPContext * mpctx)
+static int sub_source(MPContext *mpctx)
{
return sub_source_by_pos(mpctx, mpctx->global_sub_pos);
}
@@ -124,7 +130,7 @@ static int sub_source(MPContext * mpctx)
* which need to be fixed while watching the movie.
*/
-static void log_sub(void)
+static void log_sub(struct MPContext *mpctx)
{
char *fname;
FILE *f;
@@ -140,14 +146,14 @@ static void log_sub(void)
if (subdata->sub_uses_time) {
fprintf(f,
"N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
- filename, vo_sub_last->start / 360000,
+ mpctx->filename, vo_sub_last->start / 360000,
(vo_sub_last->start / 6000) % 60,
(vo_sub_last->start / 100) % 60, vo_sub_last->start % 100,
vo_sub_last->end / 360000, (vo_sub_last->end / 6000) % 60,
(vo_sub_last->end / 100) % 60, vo_sub_last->end % 100);
} else {
- fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start,
- vo_sub_last->end);
+ fprintf(f, "N: %s S: %ld E: %ld\n", mpctx->filename,
+ vo_sub_last->start, vo_sub_last->end);
}
for (i = 0; i < vo_sub_last->lines; i++) {
fprintf(f, "%s\n", vo_sub_last->text[i]);
@@ -164,77 +170,80 @@ static void log_sub(void)
///@{
/// OSD level (RW)
-static int mp_property_osdlevel(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_osdlevel(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
- return m_property_choice(prop, action, arg, &osd_level);
+ return m_property_choice(prop, action, arg, &mpctx->opts.osd_level);
}
/// Loop (RW)
-static int mp_property_loop(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_loop(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
switch (action) {
case M_PROPERTY_PRINT:
if (!arg) return M_PROPERTY_ERROR;
- if (mpctx->loop_times < 0)
+ if (opts->loop_times < 0)
*(char**)arg = strdup("off");
- else if (mpctx->loop_times == 0)
+ else if (opts->loop_times == 0)
*(char**)arg = strdup("inf");
else
break;
return M_PROPERTY_OK;
}
- return m_property_int_range(prop, action, arg, &mpctx->loop_times);
+ return m_property_int_range(prop, action, arg, &opts->loop_times);
}
/// Playback speed (RW)
-static int mp_property_playback_speed(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_playback_speed(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
switch (action) {
case M_PROPERTY_SET:
if (!arg)
return M_PROPERTY_ERROR;
M_PROPERTY_CLAMP(prop, *(float *) arg);
- playback_speed = *(float *) arg;
- build_afilter_chain(mpctx->sh_audio, &ao_data);
+ opts->playback_speed = *(float *) arg;
+ build_afilter_chain(mpctx, mpctx->sh_audio, &ao_data);
return M_PROPERTY_OK;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
- playback_speed += (arg ? *(float *) arg : 0.1) *
+ opts->playback_speed += (arg ? *(float *) arg : 0.1) *
(action == M_PROPERTY_STEP_DOWN ? -1 : 1);
- M_PROPERTY_CLAMP(prop, playback_speed);
- build_afilter_chain(mpctx->sh_audio, &ao_data);
+ M_PROPERTY_CLAMP(prop, opts->playback_speed);
+ build_afilter_chain(mpctx, mpctx->sh_audio, &ao_data);
return M_PROPERTY_OK;
}
- return m_property_float_range(prop, action, arg, &playback_speed);
+ return m_property_float_range(prop, action, arg, &opts->playback_speed);
}
/// filename with path (RO)
-static int mp_property_path(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_path(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
- return m_property_string_ro(prop, action, arg, filename);
+ return m_property_string_ro(prop, action, arg, mpctx->filename);
}
/// filename without path (RO)
-static int mp_property_filename(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_filename(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
char *f;
- if (!filename)
+ if (!mpctx->filename)
return M_PROPERTY_UNAVAILABLE;
- if (((f = strrchr(filename, '/')) || (f = strrchr(filename, '\\'))) && f[1])
+ if (((f = strrchr(mpctx->filename, '/'))
+ || (f = strrchr(mpctx->filename, '\\'))) && f[1])
f++;
else
- f = filename;
+ f = mpctx->filename;
return m_property_string_ro(prop, action, arg, f);
}
/// Demuxer name (RO)
-static int mp_property_demuxer(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_demuxer(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->demuxer)
return M_PROPERTY_UNAVAILABLE;
@@ -243,8 +252,8 @@ static int mp_property_demuxer(m_option_t * prop, int action, void *arg,
}
/// Position in the stream (RW)
-static int mp_property_stream_pos(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_stream_pos(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->demuxer || !mpctx->demuxer->stream)
return M_PROPERTY_UNAVAILABLE;
@@ -263,8 +272,8 @@ static int mp_property_stream_pos(m_option_t * prop, int action, void *arg,
}
/// Stream start offset (RO)
-static int mp_property_stream_start(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_stream_start(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->demuxer || !mpctx->demuxer->stream)
return M_PROPERTY_UNAVAILABLE;
@@ -277,8 +286,8 @@ static int mp_property_stream_start(m_option_t * prop, int action,
}
/// Stream end offset (RO)
-static int mp_property_stream_end(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_stream_end(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->demuxer || !mpctx->demuxer->stream)
return M_PROPERTY_UNAVAILABLE;
@@ -291,8 +300,8 @@ static int mp_property_stream_end(m_option_t * prop, int action, void *arg,
}
/// Stream length (RO)
-static int mp_property_stream_length(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_stream_length(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->demuxer || !mpctx->demuxer->stream)
return M_PROPERTY_UNAVAILABLE;
@@ -306,8 +315,8 @@ static int mp_property_stream_length(m_option_t * prop, int action,
}
/// Media length in seconds (RO)
-static int mp_property_length(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_length(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
double len;
@@ -319,8 +328,8 @@ static int mp_property_length(m_option_t * prop, int action, void *arg,
}
/// Current position in percent (RW)
-static int mp_property_percent_pos(m_option_t * prop, int action,
- void *arg, MPContext * mpctx) {
+static int mp_property_percent_pos(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx) {
int pos;
if (!mpctx->demuxer)
@@ -344,14 +353,14 @@ static int mp_property_percent_pos(m_option_t * prop, int action,
demuxer_get_percent_pos(mpctx->demuxer));
}
- abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR;
- rel_seek_secs = pos / 100.0;
+ mpctx->abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR;
+ mpctx->rel_seek_secs = pos / 100.0;
return M_PROPERTY_OK;
}
/// Current position in seconds (RW)
-static int mp_property_time_pos(m_option_t * prop, int action,
- void *arg, MPContext * mpctx) {
+static int mp_property_time_pos(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx) {
if (!(mpctx->sh_video || (mpctx->sh_audio && mpctx->audio_out)))
return M_PROPERTY_UNAVAILABLE;
@@ -359,34 +368,31 @@ static int mp_property_time_pos(m_option_t * prop, int action,
case M_PROPERTY_SET:
if(!arg) return M_PROPERTY_ERROR;
M_PROPERTY_CLAMP(prop, *(double*)arg);
- abs_seek_pos = SEEK_ABSOLUTE;
- rel_seek_secs = *(double*)arg;
+ mpctx->abs_seek_pos = SEEK_ABSOLUTE;
+ mpctx->rel_seek_secs = *(double*)arg;
return M_PROPERTY_OK;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
- rel_seek_secs += (arg ? *(double*)arg : 10.0) *
+ mpctx->rel_seek_secs += (arg ? *(double*)arg : 10.0) *
(action == M_PROPERTY_STEP_UP ? 1.0 : -1.0);
return M_PROPERTY_OK;
}
return m_property_time_ro(prop, action, arg,
mpctx->sh_video ? mpctx->sh_video->pts :
- playing_audio_pts(mpctx->sh_audio,
- mpctx->d_audio,
- mpctx->audio_out));
+ playing_audio_pts(mpctx));
}
/// Current chapter (RW)
static int mp_property_chapter(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
int chapter = -1;
- float next_pts = 0;
- int chapter_num;
int step_all;
char *chapter_name = NULL;
if (mpctx->demuxer)
- chapter = demuxer_get_current_chapter(mpctx->demuxer);
+ chapter = get_current_chapter(mpctx);
if (chapter < 0)
return M_PROPERTY_UNAVAILABLE;
@@ -399,7 +405,7 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg,
case M_PROPERTY_PRINT: {
if (!arg)
return M_PROPERTY_ERROR;
- chapter_name = demuxer_chapter_display_name(mpctx->demuxer, chapter);
+ chapter_name = chapter_display_name(mpctx, chapter);
if (!chapter_name)
return M_PROPERTY_UNAVAILABLE;
*(char **) arg = chapter_name;
@@ -424,26 +430,27 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg,
default:
return M_PROPERTY_NOT_IMPLEMENTED;
}
- rel_seek_secs = 0;
- abs_seek_pos = 0;
- chapter = demuxer_seek_chapter(mpctx->demuxer, chapter, 1,
- &next_pts, &chapter_num, &chapter_name);
+
+ double next_pts = 0;
+ chapter = seek_chapter(mpctx, chapter, &next_pts, &chapter_name);
+ mpctx->rel_seek_secs = 0;
+ mpctx->abs_seek_pos = 0;
if (chapter >= 0) {
if (next_pts > -1.0) {
- abs_seek_pos = SEEK_ABSOLUTE;
- rel_seek_secs = next_pts;
+ mpctx->abs_seek_pos = SEEK_ABSOLUTE;
+ mpctx->rel_seek_secs = next_pts;
}
if (chapter_name)
- set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
- MSGTR_OSDChapter, chapter + 1, chapter_name);
+ set_osd_msg(OSD_MSG_TEXT, 1, opts->osd_duration,
+ _("Chapter: (%d) %s"), chapter + 1, chapter_name);
}
else if (step_all > 0)
- rel_seek_secs = 1000000000.;
+ mpctx->rel_seek_secs = 1000000000.;
else
- set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
- MSGTR_OSDChapter, 0, MSGTR_Unknown);
+ set_osd_msg(OSD_MSG_TEXT, 1, opts->osd_duration,
+ _("Chapter: (%d) %s"), 0, _("unknown"));
if (chapter_name)
- free(chapter_name);
+ talloc_free(chapter_name);
return M_PROPERTY_OK;
}
@@ -462,6 +469,7 @@ static int mp_property_chapters(m_option_t *prop, int action, void *arg,
static int mp_property_angle(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
int angle = -1;
int angles;
char *angle_name = NULL;
@@ -513,19 +521,19 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
angle = demuxer_set_angle(mpctx->demuxer, angle);
- set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
- MSGTR_OSDAngle, angle, angles);
+ set_osd_msg(OSD_MSG_TEXT, 1, opts->osd_duration,
+ _("Angle: %d/%d"), angle, angles);
if (angle_name)
free(angle_name);
return M_PROPERTY_OK;
}
/// Demuxer meta data
-static int mp_property_metadata(m_option_t * prop, int action, void *arg,
- MPContext * mpctx) {
+static int mp_property_metadata(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx) {
m_property_action_t* ka;
char* meta;
- static m_option_t key_type =
+ static const m_option_t key_type =
{ "metadata", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL };
if (!mpctx->demuxer)
return M_PROPERTY_UNAVAILABLE;
@@ -554,10 +562,31 @@ static int mp_property_metadata(m_option_t * prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
-static int mp_property_pause(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_pause(m_option_t *prop, int action, void *arg,
+ void *ctx)
{
- return m_property_flag_ro(prop, action, arg, mpctx->osd_function == OSD_PAUSE);
+ MPContext *mpctx = ctx;
+
+ switch (action) {
+ case M_PROPERTY_SET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ if (mpctx->paused == (bool)*(int *) arg)
+ return M_PROPERTY_OK;
+ case M_PROPERTY_STEP_UP:
+ case M_PROPERTY_STEP_DOWN:
+ if (mpctx->paused) {
+ unpause_player(mpctx);
+ mpctx->osd_function = OSD_PLAY;
+ }
+ else {
+ pause_player(mpctx);
+ mpctx->osd_function = OSD_PAUSE;
+ }
+ return M_PROPERTY_OK;
+ default:
+ return m_property_flag(prop, action, arg, &mpctx->paused);
+ }
}
@@ -568,8 +597,8 @@ static int mp_property_pause(m_option_t * prop, int action, void *arg,
///@{
/// Volume (RW)
-static int mp_property_volume(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_volume(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_audio)
@@ -624,8 +653,8 @@ static int mp_property_volume(m_option_t * prop, int action, void *arg,
}
/// Mute (RW)
-static int mp_property_mute(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_mute(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_audio)
@@ -652,7 +681,7 @@ static int mp_property_mute(m_option_t * prop, int action, void *arg,
if (!arg)
return M_PROPERTY_ERROR;
if (mpctx->edl_muted) {
- *(char **) arg = strdup(MSGTR_EnabledEdl);
+ *(char **) arg = strdup(_("enabled (EDL)"));
return M_PROPERTY_OK;
}
default:
@@ -662,8 +691,8 @@ static int mp_property_mute(m_option_t * prop, int action, void *arg,
}
/// Audio delay (RW)
-static int mp_property_audio_delay(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_audio_delay(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!(mpctx->sh_audio && mpctx->sh_video))
return M_PROPERTY_UNAVAILABLE;
@@ -686,8 +715,8 @@ static int mp_property_audio_delay(m_option_t * prop, int action,
}
/// Audio codec tag (RO)
-static int mp_property_audio_format(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_audio_format(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->sh_audio)
return M_PROPERTY_UNAVAILABLE;
@@ -695,8 +724,8 @@ static int mp_property_audio_format(m_option_t * prop, int action,
}
/// Audio codec name (RO)
-static int mp_property_audio_codec(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_audio_codec(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->sh_audio || !mpctx->sh_audio->codec)
return M_PROPERTY_UNAVAILABLE;
@@ -704,8 +733,8 @@ static int mp_property_audio_codec(m_option_t * prop, int action,
}
/// Audio bitrate (RO)
-static int mp_property_audio_bitrate(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_audio_bitrate(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->sh_audio)
return M_PROPERTY_UNAVAILABLE;
@@ -713,8 +742,8 @@ static int mp_property_audio_bitrate(m_option_t * prop, int action,
}
/// Samplerate (RO)
-static int mp_property_samplerate(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_samplerate(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_audio)
return M_PROPERTY_UNAVAILABLE;
@@ -729,8 +758,8 @@ static int mp_property_samplerate(m_option_t * prop, int action, void *arg,
}
/// Number of channels (RO)
-static int mp_property_channels(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_channels(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_audio)
return M_PROPERTY_UNAVAILABLE;
@@ -755,8 +784,8 @@ static int mp_property_channels(m_option_t * prop, int action, void *arg,
}
/// Balance (RW)
-static int mp_property_balance(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_balance(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
float bal;
@@ -806,9 +835,10 @@ static int mp_property_balance(m_option_t * prop, int action, void *arg,
}
/// Selected audio id (RW)
-static int mp_property_audio(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_audio(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
int current_id = -1, tmp;
switch (action) {
@@ -817,7 +847,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
return M_PROPERTY_UNAVAILABLE;
if (!arg)
return M_PROPERTY_ERROR;
- *(int *) arg = audio_id;
+ *(int *) arg = opts->audio_id;
return M_PROPERTY_OK;
case M_PROPERTY_PRINT:
if (!mpctx->sh_audio)
@@ -825,16 +855,16 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
if (!arg)
return M_PROPERTY_ERROR;
- if (audio_id < 0)
- *(char **) arg = strdup(MSGTR_Disabled);
+ if (opts->audio_id < 0)
+ *(char **) arg = strdup(_("disabled"));
else {
- char lang[40] = MSGTR_Unknown;
+ char lang[40] = _("unknown");
sh_audio_t* sh = mpctx->sh_audio;
if (sh && sh->lang)
av_strlcpy(lang, sh->lang, 40);
#ifdef CONFIG_DVDREAD
else if (mpctx->stream->type == STREAMTYPE_DVD) {
- int code = dvd_lang_from_aid(mpctx->stream, audio_id);
+ int code = dvd_lang_from_aid(mpctx->stream, opts->audio_id);
if (code) {
lang[0] = code >> 8;
lang[1] = code;
@@ -845,10 +875,10 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
#ifdef CONFIG_DVDNAV
else if (mpctx->stream->type == STREAMTYPE_DVDNAV)
- mp_dvdnav_lang_from_aid(mpctx->stream, audio_id, lang);
+ mp_dvdnav_lang_from_aid(mpctx->stream, opts->audio_id, lang);
#endif
*(char **) arg = malloc(64);
- snprintf(*(char **) arg, 64, "(%d) %s", audio_id, lang);
+ snprintf(*(char **) arg, 64, "(%d) %s", opts->audio_id, lang);
}
return M_PROPERTY_OK;
@@ -861,21 +891,21 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
else
tmp = -1;
current_id = mpctx->demuxer->audio->id;
- audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
- if (audio_id == -2
- || (audio_id > -1
+ opts->audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
+ if (opts->audio_id == -2
+ || (opts->audio_id > -1
&& mpctx->demuxer->audio->id != current_id && current_id != -2))
- uninit_player(INITIALIZED_AO | INITIALIZED_ACODEC);
- if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
+ uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_ACODEC);
+ if (opts->audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
sh_audio_t *sh2;
sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id];
if (sh2) {
sh2->ds = mpctx->demuxer->audio;
mpctx->sh_audio = sh2;
- reinit_audio_chain();
+ reinit_audio_chain(mpctx);
}
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", opts->audio_id);
return M_PROPERTY_OK;
default:
return M_PROPERTY_NOT_IMPLEMENTED;
@@ -884,9 +914,10 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
}
/// Selected video id (RW)
-static int mp_property_video(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_video(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
int current_id = -1, tmp;
switch (action) {
@@ -895,7 +926,7 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
return M_PROPERTY_UNAVAILABLE;
if (!arg)
return M_PROPERTY_ERROR;
- *(int *) arg = video_id;
+ *(int *) arg = opts->video_id;
return M_PROPERTY_OK;
case M_PROPERTY_PRINT:
if (!mpctx->sh_video)
@@ -903,12 +934,12 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
if (!arg)
return M_PROPERTY_ERROR;
- if (video_id < 0)
- *(char **) arg = strdup(MSGTR_Disabled);
+ if (opts->video_id < 0)
+ *(char **) arg = strdup(_("disabled"));
else {
- char lang[40] = MSGTR_Unknown;
+ char lang[40] = _("unknown");
*(char **) arg = malloc(64);
- snprintf(*(char **) arg, 64, "(%d) %s", video_id, lang);
+ snprintf(*(char **) arg, 64, "(%d) %s", opts->video_id, lang);
}
return M_PROPERTY_OK;
@@ -919,22 +950,22 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
tmp = *((int *) arg);
else
tmp = -1;
- video_id = demuxer_switch_video(mpctx->demuxer, tmp);
- if (video_id == -2
- || (video_id > -1 && mpctx->demuxer->video->id != current_id
+ opts->video_id = demuxer_switch_video(mpctx->demuxer, tmp);
+ if (opts->video_id == -2
+ || (opts->video_id > -1 && mpctx->demuxer->video->id != current_id
&& current_id != -2))
- uninit_player(INITIALIZED_VCODEC |
- (fixed_vo && video_id != -2 ? 0 : INITIALIZED_VO));
- if (video_id > -1 && mpctx->demuxer->video->id != current_id) {
+ uninit_player(mpctx, INITIALIZED_VCODEC |
+ (mpctx->opts.fixed_vo && opts->video_id != -2 ? 0 : INITIALIZED_VO));
+ if (opts->video_id > -1 && mpctx->demuxer->video->id != current_id) {
sh_video_t *sh2;
sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id];
if (sh2) {
sh2->ds = mpctx->demuxer->video;
mpctx->sh_video = sh2;
- reinit_video_chain();
+ reinit_video_chain(mpctx);
}
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", opts->video_id);
return M_PROPERTY_OK;
default:
@@ -942,8 +973,8 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
}
}
-static int mp_property_program(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_program(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
demux_program_t prog;
@@ -975,8 +1006,8 @@ static int mp_property_program(m_option_t * prop, int action, void *arg,
///@{
/// Fullscreen state (RW)
-static int mp_property_fullscreen(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_fullscreen(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->video_out)
@@ -996,16 +1027,17 @@ static int mp_property_fullscreen(m_option_t * prop, int action, void *arg,
guiGetEvent(guiIEvent, (char *) MP_CMD_GUI_FULLSCREEN);
else
#endif
- if (vo_config_count)
- mpctx->video_out->control(VOCTRL_FULLSCREEN, 0);
+ if (mpctx->video_out->config_ok)
+ vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0);
+ mpctx->opts.fullscreen = vo_fs;
return M_PROPERTY_OK;
default:
return m_property_flag(prop, action, arg, &vo_fs);
}
}
-static int mp_property_deinterlace(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_deinterlace(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
int deinterlace;
vf_instance_t *vf;
@@ -1035,12 +1067,12 @@ static int mp_property_deinterlace(m_option_t * prop, int action,
}
/// Panscan (RW)
-static int mp_property_panscan(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_panscan(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->video_out
- || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
+ || vo_control(mpctx->video_out, VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
@@ -1049,7 +1081,7 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg,
return M_PROPERTY_ERROR;
M_PROPERTY_CLAMP(prop, *(float *) arg);
vo_panscan = *(float *) arg;
- mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
+ vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL);
return M_PROPERTY_OK;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
@@ -1059,7 +1091,7 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg,
vo_panscan = 1;
else if (vo_panscan < 0)
vo_panscan = 0;
- mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
+ vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL);
return M_PROPERTY_OK;
default:
return m_property_float_range(prop, action, arg, &vo_panscan);
@@ -1069,8 +1101,8 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg,
/// Helper to set vo flags.
/** \ingroup PropertyImplHelper
*/
-static int mp_property_vo_flag(m_option_t * prop, int action, void *arg,
- int vo_ctrl, int *vo_var, MPContext * mpctx)
+static int mp_property_vo_flag(m_option_t *prop, int action, void *arg,
+ int vo_ctrl, int *vo_var, MPContext *mpctx)
{
if (!mpctx->video_out)
@@ -1085,8 +1117,8 @@ static int mp_property_vo_flag(m_option_t * prop, int action, void *arg,
return M_PROPERTY_OK;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
- if (vo_config_count)
- mpctx->video_out->control(vo_ctrl, 0);
+ if (mpctx->video_out->config_ok)
+ vo_control(mpctx->video_out, vo_ctrl, 0);
return M_PROPERTY_OK;
default:
return m_property_flag(prop, action, arg, vo_var);
@@ -1094,32 +1126,32 @@ static int mp_property_vo_flag(m_option_t * prop, int action, void *arg,
}
/// Window always on top (RW)
-static int mp_property_ontop(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_ontop(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
- return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop,
- mpctx);
+ return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP,
+ &mpctx->opts.vo_ontop, mpctx);
}
/// Display in the root window (RW)
-static int mp_property_rootwin(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_rootwin(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN,
&vo_rootwin, mpctx);
}
/// Show window borders (RW)
-static int mp_property_border(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_border(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER,
&vo_border, mpctx);
}
/// Framedropping state (RW)
-static int mp_property_framedropping(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_framedropping(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->sh_video)
@@ -1129,9 +1161,9 @@ static int mp_property_framedropping(m_option_t * prop, int action,
case M_PROPERTY_PRINT:
if (!arg)
return M_PROPERTY_ERROR;
- *(char **) arg = strdup(frame_dropping == 1 ? MSGTR_Enabled :
- (frame_dropping == 2 ? MSGTR_HardFrameDrop :
- MSGTR_Disabled));
+ *(char **) arg = strdup(frame_dropping == 1 ? _("enabled") :
+ (frame_dropping == 2 ? _("hard") :
+ _("disabled")));
return M_PROPERTY_OK;
default:
return m_property_choice(prop, action, arg, &frame_dropping);
@@ -1139,10 +1171,11 @@ static int mp_property_framedropping(m_option_t * prop, int action,
}
/// Color settings, try to use vf/vo then fall back on TV. (RW)
-static int mp_property_gamma(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_gamma(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
- int *gamma = prop->priv, r, val;
+ int *gamma = (int *)((char *)&mpctx->opts + (int)prop->priv);
+ int r, val;
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1196,15 +1229,15 @@ static int mp_property_gamma(m_option_t * prop, int action, void *arg,
}
/// VSync (RW)
-static int mp_property_vsync(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_vsync(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
return m_property_flag(prop, action, arg, &vo_vsync);
}
/// Video codec tag (RO)
-static int mp_property_video_format(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_video_format(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
char* meta;
if (!mpctx->sh_video)
@@ -1238,8 +1271,8 @@ static int mp_property_video_format(m_option_t * prop, int action,
}
/// Video codec name (RO)
-static int mp_property_video_codec(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_video_codec(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->sh_video || !mpctx->sh_video->codec)
return M_PROPERTY_UNAVAILABLE;
@@ -1248,8 +1281,8 @@ static int mp_property_video_codec(m_option_t * prop, int action,
/// Video bitrate (RO)
-static int mp_property_video_bitrate(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_video_bitrate(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1257,8 +1290,8 @@ static int mp_property_video_bitrate(m_option_t * prop, int action,
}
/// Video display width (RO)
-static int mp_property_width(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_width(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1266,8 +1299,8 @@ static int mp_property_width(m_option_t * prop, int action, void *arg,
}
/// Video display height (RO)
-static int mp_property_height(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_height(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1275,8 +1308,8 @@ static int mp_property_height(m_option_t * prop, int action, void *arg,
}
/// Video fps (RO)
-static int mp_property_fps(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_fps(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1284,8 +1317,8 @@ static int mp_property_fps(m_option_t * prop, int action, void *arg,
}
/// Video aspect (RO)
-static int mp_property_aspect(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_aspect(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1299,8 +1332,8 @@ static int mp_property_aspect(m_option_t * prop, int action, void *arg,
///@{
/// Text subtitle position (RW)
-static int mp_property_sub_pos(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_sub_pos(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1318,16 +1351,17 @@ static int mp_property_sub_pos(m_option_t * prop, int action, void *arg,
}
/// Selected subtitles (RW)
-static int mp_property_sub(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_sub(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
demux_stream_t *const d_sub = mpctx->d_sub;
const int global_sub_size = mpctx->global_sub_size;
int source = -1, reset_spu = 0;
char *sub_name;
- if (global_sub_size <= 0)
- return M_PROPERTY_UNAVAILABLE;
+ if (!mpctx->sh_video || global_sub_size <= 0)
+ return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_GET:
@@ -1361,10 +1395,10 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
}
#ifdef CONFIG_DVDNAV
if (mpctx->stream->type == STREAMTYPE_DVDNAV) {
- if (vo_spudec && dvdsub_id >= 0) {
+ if (vo_spudec && opts->sub_id >= 0) {
unsigned char lang[3];
- if (mp_dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) {
- snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
+ if (mp_dvdnav_lang_from_sid(mpctx->stream, opts->sub_id, lang)) {
+ snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang);
return M_PROPERTY_OK;
}
}
@@ -1375,37 +1409,37 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
|| mpctx->demuxer->type == DEMUXER_TYPE_LAVF
|| mpctx->demuxer->type == DEMUXER_TYPE_LAVF_PREFERRED
|| mpctx->demuxer->type == DEMUXER_TYPE_OGG)
- && d_sub && d_sub->sh && dvdsub_id >= 0) {
+ && d_sub && d_sub->sh && opts->sub_id >= 0) {
const char* lang = ((sh_sub_t*)d_sub->sh)->lang;
- if (!lang) lang = MSGTR_Unknown;
- snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
+ if (!lang) lang = _("unknown");
+ snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang);
return M_PROPERTY_OK;
}
if (vo_vobsub && vobsub_id >= 0) {
- const char *language = MSGTR_Unknown;
+ const char *language = _("unknown");
language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id);
snprintf(*(char **) arg, 63, "(%d) %s",
- vobsub_id, language ? language : MSGTR_Unknown);
+ vobsub_id, language ? language : _("unknown"));
return M_PROPERTY_OK;
}
#ifdef CONFIG_DVDREAD
if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD
- && dvdsub_id >= 0) {
+ && opts->sub_id >= 0) {
char lang[3];
- int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id);
+ int code = dvd_lang_from_sid(mpctx->stream, opts->sub_id);
lang[0] = code >> 8;
lang[1] = code;
lang[2] = 0;
- snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
+ snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang);
return M_PROPERTY_OK;
}
#endif
- if (dvdsub_id >= 0) {
- snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown);
+ if (opts->sub_id >= 0) {
+ snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, _("unknown"));
return M_PROPERTY_OK;
}
- snprintf(*(char **) arg, 63, MSGTR_Disabled);
+ snprintf(*(char **) arg, 63, _("disabled"));
return M_PROPERTY_OK;
case M_PROPERTY_SET:
@@ -1446,7 +1480,7 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
subdata = NULL;
vobsub_id = -1;
- dvdsub_id = -1;
+ opts->sub_id = -1;
if (d_sub) {
if (d_sub->id > -2)
reset_spu = 1;
@@ -1471,17 +1505,17 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
vo_osd_changed(OSDTYPE_SUBTITLE);
}
} else if (source == SUB_SOURCE_DEMUX) {
- dvdsub_id =
+ opts->sub_id =
mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX];
- if (d_sub && dvdsub_id < MAX_S_STREAMS) {
+ if (d_sub && opts->sub_id < MAX_S_STREAMS) {
int i = 0;
// default: assume 1:1 mapping of sid and stream id
- d_sub->id = dvdsub_id;
+ d_sub->id = opts->sub_id;
d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
ds_free_packs(d_sub);
for (i = 0; i < MAX_S_STREAMS; i++) {
sh_sub_t *sh = mpctx->demuxer->s_streams[i];
- if (sh && sh->sid == dvdsub_id) {
+ if (sh && sh->sid == opts->sub_id) {
d_sub->id = i;
d_sub->sh = sh;
break;
@@ -1490,7 +1524,7 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
if (d_sub->sh && d_sub->id >= 0) {
sh_sub_t *sh = d_sub->sh;
if (sh->type == 'v')
- init_vo_spudec();
+ init_vo_spudec(mpctx);
#ifdef CONFIG_ASS
else if (ass_enabled)
ass_track = sh->ass_track;
@@ -1505,19 +1539,19 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
if (vo_spudec
&& (mpctx->stream->type == STREAMTYPE_DVD
|| mpctx->stream->type == STREAMTYPE_DVDNAV)
- && dvdsub_id < 0 && reset_spu) {
- dvdsub_id = -2;
- d_sub->id = dvdsub_id;
+ && opts->sub_id < 0 && reset_spu) {
+ opts->sub_id = -2;
+ d_sub->id = opts->sub_id;
}
#endif
- update_subtitles(mpctx->sh_video, d_sub, 1);
+ update_subtitles(mpctx->sh_video, d_sub, 0, 1);
return M_PROPERTY_OK;
}
/// Selected sub source (RW)
-static int mp_property_sub_source(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_sub_source(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
int source;
if (!mpctx->sh_video || mpctx->global_sub_size <= 0)
@@ -1537,16 +1571,16 @@ static int mp_property_sub_source(m_option_t * prop, int action, void *arg,
switch (sub_source(mpctx))
{
case SUB_SOURCE_SUBS:
- snprintf(*(char **) arg, 63, MSGTR_SubSourceFile);
+ snprintf(*(char **) arg, 63, _("file"));
break;
case SUB_SOURCE_VOBSUB:
- snprintf(*(char **) arg, 63, MSGTR_SubSourceVobsub);
+ snprintf(*(char **) arg, 63, _("vobsub"));
break;
case SUB_SOURCE_DEMUX:
- snprintf(*(char **) arg, 63, MSGTR_SubSourceDemux);
+ snprintf(*(char **) arg, 63, _("embedded"));
break;
default:
- snprintf(*(char **) arg, 63, MSGTR_Disabled);
+ snprintf(*(char **) arg, 63, _("disabled"));
}
return M_PROPERTY_OK;
case M_PROPERTY_SET:
@@ -1594,8 +1628,8 @@ static int mp_property_sub_source(m_option_t * prop, int action, void *arg,
}
/// Selected subtitles from specific source (RW)
-static int mp_property_sub_by_type(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_sub_by_type(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
int source, is_cur_source, offset;
if (!mpctx->sh_video || mpctx->global_sub_size <= 0)
@@ -1634,7 +1668,7 @@ static int mp_property_sub_by_type(m_option_t * prop, int action, void *arg,
return mp_property_sub(prop, M_PROPERTY_PRINT, arg, mpctx);
*(char **) arg = malloc(64);
(*(char **) arg)[63] = 0;
- snprintf(*(char **) arg, 63, MSGTR_Disabled);
+ snprintf(*(char **) arg, 63, _("disabled"));
return M_PROPERTY_OK;
case M_PROPERTY_SET:
if (!arg)
@@ -1694,8 +1728,8 @@ static int mp_property_sub_by_type(m_option_t * prop, int action, void *arg,
}
/// Subtitle delay (RW)
-static int mp_property_sub_delay(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_sub_delay(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1703,10 +1737,10 @@ static int mp_property_sub_delay(m_option_t * prop, int action, void *arg,
}
/// Alignment of text subtitles (RW)
-static int mp_property_sub_alignment(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_sub_alignment(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
- char *name[] = { MSGTR_Top, MSGTR_Center, MSGTR_Bottom };
+ char *name[] = { _("top"), _("center"), _("bottom") };
if (!mpctx->sh_video || mpctx->global_sub_pos < 0
|| sub_source(mpctx) != SUB_SOURCE_SUBS)
@@ -1731,8 +1765,8 @@ static int mp_property_sub_alignment(m_option_t * prop, int action,
}
/// Subtitle visibility (RW)
-static int mp_property_sub_visibility(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_sub_visibility(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1753,8 +1787,8 @@ static int mp_property_sub_visibility(m_option_t * prop, int action,
#ifdef CONFIG_ASS
/// Use margins for libass subtitles (RW)
-static int mp_property_ass_use_margins(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_ass_use_margins(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
@@ -1773,8 +1807,8 @@ static int mp_property_ass_use_margins(m_option_t * prop, int action,
#endif
/// Show only forced subtitles (RW)
-static int mp_property_sub_forced_only(m_option_t * prop, int action,
- void *arg, MPContext * mpctx)
+static int mp_property_sub_forced_only(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
{
if (!vo_spudec)
return M_PROPERTY_UNAVAILABLE;
@@ -1796,8 +1830,8 @@ static int mp_property_sub_forced_only(m_option_t * prop, int action,
#ifdef CONFIG_FREETYPE
/// Subtitle scale (RW)
-static int mp_property_sub_scale(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
switch (action) {
@@ -1849,8 +1883,8 @@ static int mp_property_sub_scale(m_option_t * prop, int action, void *arg,
#ifdef CONFIG_TV
/// TV color settings (RW)
-static int mp_property_tv_color(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_tv_color(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
int r, val;
tvi_handle_t *tvh = mpctx->demuxer->priv;
@@ -1883,8 +1917,8 @@ static int mp_property_tv_color(m_option_t * prop, int action, void *arg,
#endif
#ifdef CONFIG_TV_TELETEXT
-static int mp_property_teletext_common(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_teletext_common(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
int val,result;
int base_ioctl=(int)prop->priv;
@@ -1924,8 +1958,8 @@ static int mp_property_teletext_common(m_option_t * prop, int action, void *arg,
return result == TVI_CONTROL_TRUE ? M_PROPERTY_OK : M_PROPERTY_ERROR;
}
-static int mp_property_teletext_mode(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_teletext_mode(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
tvi_handle_t *tvh = mpctx->demuxer->priv;
int result;
@@ -1937,14 +1971,14 @@ static int mp_property_teletext_mode(m_option_t * prop, int action, void *arg,
return result;
if(tvh->functions->control(tvh->priv, prop->priv, &val)==TVI_CONTROL_TRUE && val)
- mp_input_set_section("teletext");
+ mp_input_set_section(mpctx->input, "teletext");
else
- mp_input_set_section("tv");
+ mp_input_set_section(mpctx->input, "tv");
return M_PROPERTY_OK;
}
-static int mp_property_teletext_page(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_teletext_page(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
{
tvi_handle_t *tvh = mpctx->demuxer->priv;
int result;
@@ -2047,15 +2081,15 @@ static const m_option_t mp_properties[] = {
{ "framedropping", mp_property_framedropping, CONF_TYPE_INT,
M_OPT_RANGE, 0, 2, NULL },
{ "gamma", mp_property_gamma, CONF_TYPE_INT,
- M_OPT_RANGE, -100, 100, &vo_gamma_gamma },
+ M_OPT_RANGE, -100, 100, (void *)offsetof(struct MPOpts, vo_gamma_gamma)},
{ "brightness", mp_property_gamma, CONF_TYPE_INT,
- M_OPT_RANGE, -100, 100, &vo_gamma_brightness },
+ M_OPT_RANGE, -100, 100, (void *)offsetof(struct MPOpts, vo_gamma_brightness) },
{ "contrast", mp_property_gamma, CONF_TYPE_INT,
- M_OPT_RANGE, -100, 100, &vo_gamma_contrast },
+ M_OPT_RANGE, -100, 100, (void *)offsetof(struct MPOpts, vo_gamma_contrast) },
{ "saturation", mp_property_gamma, CONF_TYPE_INT,
- M_OPT_RANGE, -100, 100, &vo_gamma_saturation },
+ M_OPT_RANGE, -100, 100, (void *)offsetof(struct MPOpts, vo_gamma_saturation) },
{ "hue", mp_property_gamma, CONF_TYPE_INT,
- M_OPT_RANGE, -100, 100, &vo_gamma_hue },
+ M_OPT_RANGE, -100, 100, (void *)offsetof(struct MPOpts, vo_gamma_hue) },
{ "panscan", mp_property_panscan, CONF_TYPE_FLOAT,
M_OPT_RANGE, 0, 1, NULL },
{ "vsync", mp_property_vsync, CONF_TYPE_FLAG,
@@ -2150,7 +2184,7 @@ char* mp_property_print(const char *name, void* ctx)
return ret;
}
-char *property_expand_string(MPContext * mpctx, char *str)
+char *property_expand_string(MPContext *mpctx, char *str)
{
return m_properties_expand_string(mp_properties, str, mpctx);
}
@@ -2193,65 +2227,67 @@ static struct {
/// set/adjust or toggle command
int toggle;
/// progressbar type
- int osd_progbar;
+ int osd_progbar; // -1 is special value for seek indicators
/// osd msg id if it must be shared
int osd_id;
/// osd msg template
const char *osd_msg;
} set_prop_cmd[] = {
// general
- { "loop", MP_CMD_LOOP, 0, 0, -1, MSGTR_LoopStatus },
- { "chapter", MP_CMD_SEEK_CHAPTER, 0, 0, -1, NULL },
+ { "loop", MP_CMD_LOOP, 0, 0, -1, _("Loop: %s") },
+ { "chapter", MP_CMD_SEEK_CHAPTER, 0, -1, -1, NULL },
{ "angle", MP_CMD_SWITCH_ANGLE, 0, 0, -1, NULL },
+ { "pause", MP_CMD_PAUSE, 0, 0, -1, NULL },
// audio
- { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume },
- { "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus },
- { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus },
- { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, MSGTR_OSDAudio },
- { "balance", MP_CMD_BALANCE, 0, OSD_BALANCE, -1, MSGTR_Balance },
+ { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, _("Volume") },
+ { "mute", MP_CMD_MUTE, 1, 0, -1, _("Mute: %s") },
+ { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, _("A-V delay: %s") },
+ { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, _("Audio: %s") },
+ { "balance", MP_CMD_BALANCE, 0, OSD_BALANCE, -1, _("Balance") },
// video
{ "fullscreen", MP_CMD_VO_FULLSCREEN, 1, 0, -1, NULL },
- { "panscan", MP_CMD_PANSCAN, 0, OSD_PANSCAN, -1, MSGTR_Panscan },
- { "ontop", MP_CMD_VO_ONTOP, 1, 0, -1, MSGTR_OnTopStatus },
- { "rootwin", MP_CMD_VO_ROOTWIN, 1, 0, -1, MSGTR_RootwinStatus },
- { "border", MP_CMD_VO_BORDER, 1, 0, -1, MSGTR_BorderStatus },
- { "framedropping", MP_CMD_FRAMEDROPPING, 1, 0, -1, MSGTR_FramedroppingStatus },
- { "gamma", MP_CMD_GAMMA, 0, OSD_BRIGHTNESS, -1, MSGTR_Gamma },
- { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness },
- { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast },
- { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation },
- { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, MSGTR_Hue },
- { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, MSGTR_VSyncStatus },
+ { "panscan", MP_CMD_PANSCAN, 0, OSD_PANSCAN, -1, _("Panscan") },
+ { "ontop", MP_CMD_VO_ONTOP, 1, 0, -1, _("Stay on top: %s") },
+ { "rootwin", MP_CMD_VO_ROOTWIN, 1, 0, -1, _("Rootwin: %s") },
+ { "border", MP_CMD_VO_BORDER, 1, 0, -1, _("Border: %s") },
+ { "framedropping", MP_CMD_FRAMEDROPPING, 1, 0, -1, _("Framedropping: %s") },
+ { "gamma", MP_CMD_GAMMA, 0, OSD_BRIGHTNESS, -1, _("Gamma") },
+ { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, _("Brightness") },
+ { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, _("Contrast") },
+ { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, _("Saturation") },
+ { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, _("Hue") },
+ { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, _("VSync: %s") },
// subs
- { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, MSGTR_SubSelectStatus },
- { "sub_source", MP_CMD_SUB_SOURCE, 1, 0, -1, MSGTR_SubSourceStatus },
- { "sub_vob", MP_CMD_SUB_VOB, 1, 0, -1, MSGTR_SubSelectStatus },
- { "sub_demux", MP_CMD_SUB_DEMUX, 1, 0, -1, MSGTR_SubSelectStatus },
- { "sub_file", MP_CMD_SUB_FILE, 1, 0, -1, MSGTR_SubSelectStatus },
- { "sub_pos", MP_CMD_SUB_POS, 0, 0, -1, MSGTR_SubPosStatus },
- { "sub_alignment", MP_CMD_SUB_ALIGNMENT, 1, 0, -1, MSGTR_SubAlignStatus },
- { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, MSGTR_SubDelayStatus },
- { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, MSGTR_SubVisibleStatus },
- { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY, 1, 0, -1, MSGTR_SubForcedOnlyStatus },
+ { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, _("Subtitles: %s") },
+ { "sub_source", MP_CMD_SUB_SOURCE, 1, 0, -1, _("Sub source: %s") },
+ { "sub_vob", MP_CMD_SUB_VOB, 1, 0, -1, _("Subtitles: %s") },
+ { "sub_demux", MP_CMD_SUB_DEMUX, 1, 0, -1, _("Subtitles: %s") },
+ { "sub_file", MP_CMD_SUB_FILE, 1, 0, -1, _("Subtitles: %s") },
+ { "sub_pos", MP_CMD_SUB_POS, 0, 0, -1, _("Sub position: %s/100") },
+ { "sub_alignment", MP_CMD_SUB_ALIGNMENT, 1, 0, -1, _("Sub alignment: %s") },
+ { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, _("Sub delay: %s") },
+ { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, _("Subtitles: %s") },
+ { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY, 1, 0, -1, _("Forced sub only: %s") },
#ifdef CONFIG_FREETYPE
- { "sub_scale", MP_CMD_SUB_SCALE, 0, 0, -1, MSGTR_SubScale},
+ { "sub_scale", MP_CMD_SUB_SCALE, 0, 0, -1, _("Sub Scale: %s")},
#endif
#ifdef CONFIG_ASS
{ "ass_use_margins", MP_CMD_ASS_USE_MARGINS, 1, 0, -1, NULL },
#endif
#ifdef CONFIG_TV
- { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness },
- { "tv_hue", MP_CMD_TV_SET_HUE, 0, OSD_HUE, -1, MSGTR_Hue },
- { "tv_saturation", MP_CMD_TV_SET_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation },
- { "tv_contrast", MP_CMD_TV_SET_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast },
+ { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, _("Brightness") },
+ { "tv_hue", MP_CMD_TV_SET_HUE, 0, OSD_HUE, -1, _("Hue") },
+ { "tv_saturation", MP_CMD_TV_SET_SATURATION, 0, OSD_SATURATION, -1, _("Saturation") },
+ { "tv_contrast", MP_CMD_TV_SET_CONTRAST, 0, OSD_CONTRAST, -1, _("Contrast") },
#endif
{ NULL, 0, 0, 0, -1, NULL }
};
/// Handle commands that set a property.
-static int set_property_command(MPContext * mpctx, mp_cmd_t * cmd)
+static int set_property_command(MPContext *mpctx, mp_cmd_t *cmd)
{
+ struct MPOpts *opts = &mpctx->opts;
int i, r;
m_option_t* prop;
const char *pname;
@@ -2281,15 +2317,17 @@ static int set_property_command(MPContext * mpctx, mp_cmd_t * cmd)
if (r <= 0)
return 1;
- if (set_prop_cmd[i].osd_progbar) {
+ if (set_prop_cmd[i].osd_progbar == -1)
+ mpctx->add_osd_seek_info = true;
+ else if (set_prop_cmd[i].osd_progbar) {
if (prop->type == CONF_TYPE_INT) {
if (mp_property_do(pname, M_PROPERTY_GET, &r, mpctx) > 0)
- set_osd_bar(set_prop_cmd[i].osd_progbar,
+ set_osd_bar(mpctx, set_prop_cmd[i].osd_progbar,
set_prop_cmd[i].osd_msg, prop->min, prop->max, r);
} else if (prop->type == CONF_TYPE_FLOAT) {
float f;
if (mp_property_do(pname, M_PROPERTY_GET, &f, mpctx) > 0)
- set_osd_bar(set_prop_cmd[i].osd_progbar,
+ set_osd_bar(mpctx, set_prop_cmd[i].osd_progbar,
set_prop_cmd[i].osd_msg, prop->min, prop->max, f);
} else
mp_msg(MSGT_CPLAYER, MSGL_ERR,
@@ -2302,7 +2340,7 @@ static int set_property_command(MPContext * mpctx, mp_cmd_t * cmd)
if (val) {
set_osd_msg(set_prop_cmd[i].osd_id >=
0 ? set_prop_cmd[i].osd_id : OSD_MSG_PROPERTY + i,
- 1, osd_duration, set_prop_cmd[i].osd_msg, val);
+ 1, opts->osd_duration, set_prop_cmd[i].osd_msg, val);
free(val);
}
}
@@ -2339,36 +2377,35 @@ static const struct {
};
#endif
-int run_command(MPContext * mpctx, mp_cmd_t * cmd)
+void run_command(MPContext *mpctx, mp_cmd_t *cmd)
{
+ struct MPOpts *opts = &mpctx->opts;
sh_audio_t * const sh_audio = mpctx->sh_audio;
sh_video_t * const sh_video = mpctx->sh_video;
- int brk_cmd = 0;
+ int osd_duration = opts->osd_duration;
if (!set_property_command(mpctx, cmd))
switch (cmd->id) {
case MP_CMD_SEEK:{
float v;
int abs;
- if (sh_video)
- mpctx->osd_show_percentage = sh_video->fps;
+ mpctx->add_osd_seek_info = true;
v = cmd->args[0].v.f;
abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
if (abs == 2) { /* Absolute seek to a specific timestamp in seconds */
- abs_seek_pos = SEEK_ABSOLUTE;
+ mpctx->abs_seek_pos = SEEK_ABSOLUTE;
if (sh_video)
mpctx->osd_function =
(v > sh_video->pts) ? OSD_FFW : OSD_REW;
- rel_seek_secs = v;
+ mpctx->rel_seek_secs = v;
} else if (abs) { /* Absolute seek by percentage */
- abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR;
+ mpctx->abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR;
if (sh_video)
mpctx->osd_function = OSD_FFW; // Direction isn't set correctly
- rel_seek_secs = v / 100.0;
+ mpctx->rel_seek_secs = v / 100.0;
} else {
- rel_seek_secs += v;
+ mpctx->rel_seek_secs += v;
mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW;
}
- brk_cmd = 1;
}
break;
@@ -2444,18 +2481,16 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
case MP_CMD_EDL_MARK:
if (edl_fd) {
float v = sh_video ? sh_video->pts :
- playing_audio_pts(sh_audio, mpctx->d_audio,
- mpctx->audio_out);
-
+ playing_audio_pts(mpctx);
if (mpctx->begin_skip == MP_NOPTS_VALUE) {
mpctx->begin_skip = v;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutStartSkip);
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "EDL skip start, press 'i' again to end block.\n");
} else {
if (mpctx->begin_skip > v)
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdloutBadStop);
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "EDL skip canceled, last start > stop\n");
else {
fprintf(edl_fd, "%f %f %d\n", mpctx->begin_skip, v, 0);
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutEndSkip);
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "EDL skip end, line written.\n");
}
mpctx->begin_skip = MP_NOPTS_VALUE;
}
@@ -2466,40 +2501,38 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
if (!sh_video)
break;
if (cmd->nargs == 0 || cmd->args[0].v.f == -1)
- movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
+ opts->movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
else
- movie_aspect = cmd->args[0].v.f;
+ opts->movie_aspect = cmd->args[0].v.f;
mpcodecs_config_vo(sh_video, sh_video->disp_w, sh_video->disp_h, 0);
break;
case MP_CMD_SPEED_INCR:{
float v = cmd->args[0].v.f;
- playback_speed += v;
- build_afilter_chain(sh_audio, &ao_data);
- set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
- playback_speed);
+ opts->playback_speed += v;
+ build_afilter_chain(mpctx, sh_audio, &ao_data);
+ set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, _("Speed: x %6.2f"),
+ opts->playback_speed);
} break;
case MP_CMD_SPEED_MULT:{
float v = cmd->args[0].v.f;
- playback_speed *= v;
- build_afilter_chain(sh_audio, &ao_data);
- set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
- playback_speed);
+ opts->playback_speed *= v;
+ build_afilter_chain(mpctx, sh_audio, &ao_data);
+ set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, _("Speed: x %6.2f"),
+ opts->playback_speed);
} break;
case MP_CMD_SPEED_SET:{
float v = cmd->args[0].v.f;
- playback_speed = v;
- build_afilter_chain(sh_audio, &ao_data);
- set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
- playback_speed);
+ opts->playback_speed = v;
+ build_afilter_chain(mpctx, sh_audio, &ao_data);
+ set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, _("Speed: x %6.2f"),
+ opts->playback_speed);
} break;
case MP_CMD_FRAME_STEP:
- case MP_CMD_PAUSE:
- cmd->pausing = 1;
- brk_cmd = 1;
+ add_step_frame(mpctx);
break;
case MP_CMD_FILE_FILTER:
@@ -2507,7 +2540,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_QUIT:
- exit_player_with_rc(EXIT_QUIT,
+ exit_player_with_rc(mpctx, EXIT_QUIT,
(cmd->nargs > 0) ? cmd->args[0].v.i : 0);
case MP_CMD_PLAY_TREE_STEP:{
@@ -2531,14 +2564,13 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
play_tree_iter_new_copy(mpctx->playtree_iter);
if (play_tree_iter_step(i, n, 0) ==
PLAY_TREE_ITER_ENTRY)
- mpctx->eof =
+ mpctx->stop_play =
(n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
play_tree_iter_free(i);
} else
- mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
- if (mpctx->eof)
+ mpctx->stop_play = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
+ if (mpctx->stop_play)
mpctx->play_tree_step = n;
- brk_cmd = 1;
}
}
break;
@@ -2551,11 +2583,10 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
play_tree_iter_t *i =
play_tree_iter_new_copy(mpctx->playtree_iter);
if (play_tree_iter_up_step(i, n, 0) == PLAY_TREE_ITER_ENTRY)
- mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
+ mpctx->stop_play = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
play_tree_iter_free(i);
} else
- mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
- brk_cmd = 1;
+ mpctx->stop_play = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
}
break;
@@ -2565,11 +2596,10 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
if (v > 0
&& mpctx->playtree_iter->file <
mpctx->playtree_iter->num_files)
- mpctx->eof = PT_NEXT_SRC;
+ mpctx->stop_play = PT_NEXT_SRC;
else if (v < 0 && mpctx->playtree_iter->file > 1)
- mpctx->eof = PT_PREV_SRC;
+ mpctx->stop_play = PT_PREV_SRC;
}
- brk_cmd = 1;
break;
case MP_CMD_SUB_STEP:
@@ -2584,31 +2614,31 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
sub_delay) * 1000 + .5, movement) / 1000.;
#endif
set_osd_msg(OSD_MSG_SUB_DELAY, 1, osd_duration,
- MSGTR_OSDSubDelay, ROUND(sub_delay * 1000));
+ _("Sub delay: %d ms"), ROUND(sub_delay * 1000));
}
break;
case MP_CMD_SUB_LOG:
- log_sub();
+ log_sub(mpctx);
break;
case MP_CMD_OSD:{
int v = cmd->args[0].v.i;
int max = (term_osd
&& !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL;
- if (osd_level > max)
- osd_level = max;
+ if (opts->osd_level > max)
+ opts->osd_level = max;
if (v < 0)
- osd_level = (osd_level + 1) % (max + 1);
+ opts->osd_level = (opts->osd_level + 1) % (max + 1);
else
- osd_level = v > max ? max : v;
+ opts->osd_level = v > max ? max : v;
/* Show OSD state when disabled, but not when an explicit
argument is given to the OSD command, i.e. in slave mode. */
- if (v == -1 && osd_level <= 1)
+ if (v == -1 && opts->osd_level <= 1)
set_osd_msg(OSD_MSG_OSD_STATUS, 0, osd_duration,
- MSGTR_OSDosd,
- osd_level ? MSGTR_OSDenabled :
- MSGTR_OSDdisabled);
+ _("OSD: %s"),
+ opts->osd_level ? _("enabled") :
+ _("disabled"));
else
rm_osd_msg(OSD_MSG_OSD_STATUS);
}
@@ -2650,17 +2680,16 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
play_tree_free_list(mpctx->playtree->child, 1);
play_tree_set_child(mpctx->playtree, e);
pt_iter_goto_head(mpctx->playtree_iter);
- mpctx->eof = PT_NEXT_SRC;
+ mpctx->stop_play = PT_NEXT_SRC;
}
- brk_cmd = 1;
}
break;
case MP_CMD_LOADLIST:{
- play_tree_t *e = parse_playlist_file(cmd->args[0].v.s);
+ play_tree_t *e = parse_playlist_file(mpctx->mconfig, cmd->args[0].v.s);
if (!e)
- mp_msg(MSGT_CPLAYER, MSGL_ERR,
- MSGTR_PlaylistLoadUnable, cmd->args[0].v.s);
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR,
+ "\nUnable to load playlist %s.\n", cmd->args[0].v.s);
else {
if (cmd->args[1].v.i) // append
play_tree_append_entry(mpctx->playtree->child, e);
@@ -2673,10 +2702,9 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
play_tree_free_list(mpctx->playtree->child, 1);
play_tree_set_child(mpctx->playtree, e);
pt_iter_goto_head(mpctx->playtree_iter);
- mpctx->eof = PT_NEXT_SRC;
+ mpctx->stop_play = PT_NEXT_SRC;
}
}
- brk_cmd = 1;
}
break;
@@ -2685,8 +2713,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
while (play_tree_iter_up_step
(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
/* NOP */ ;
- mpctx->eof = PT_STOP;
- brk_cmd = 1;
+ mpctx->stop_play = PT_STOP;
break;
#ifdef CONFIG_RADIO
@@ -2701,7 +2728,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
RADIO_CHANNEL_LOWER);
if (radio_get_channel_name(mpctx->demuxer->stream)) {
set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration,
- MSGTR_OSDChannel,
+ _("Channel: %s"),
radio_get_channel_name(mpctx->demuxer->stream));
}
}
@@ -2712,7 +2739,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s);
if (radio_get_channel_name(mpctx->demuxer->stream)) {
set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration,
- MSGTR_OSDChannel,
+ _("Channel: %s"),
radio_get_channel_name(mpctx->demuxer->stream));
}
}
@@ -2782,7 +2809,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
}
if (tv_channel_list) {
set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
- MSGTR_OSDChannel, tv_channel_current->name);
+ _("Channel: %s"), tv_channel_current->name);
//vo_osd_changed(OSDTYPE_SUBTITLE);
}
}
@@ -2808,8 +2835,10 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
dir = DVB_CHANNEL_LOWER;
- if (dvb_step_channel(mpctx->stream, dir))
- mpctx->eof = mpctx->dvbin_reopen = 1;
+ if (dvb_step_channel(mpctx->stream, dir)) {
+ mpctx->stop_play = PT_NEXT_ENTRY;
+ mpctx->dvbin_reopen = 1;
+ }
}
#endif /* CONFIG_DVBIN */
break;
@@ -2820,7 +2849,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
cmd->args[0].v.s);
if (tv_channel_list) {
set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
- MSGTR_OSDChannel, tv_channel_current->name);
+ _("Channel: %s"), tv_channel_current->name);
//vo_osd_changed(OSDTYPE_SUBTITLE);
}
}
@@ -2839,9 +2868,11 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
if (mpctx->stream->type == STREAMTYPE_DVB) {
mpctx->last_dvb_step = 1;
- if (dvb_set_channel
- (mpctx->stream, cmd->args[1].v.i, cmd->args[0].v.i))
- mpctx->eof = mpctx->dvbin_reopen = 1;
+ if (dvb_set_channel(mpctx->stream, cmd->args[1].v.i,
+ cmd->args[0].v.i)) {
+ mpctx->stop_play = PT_NEXT_ENTRY;
+ mpctx->dvbin_reopen = 1;
+ }
}
break;
#endif /* CONFIG_DVBIN */
@@ -2851,7 +2882,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv));
if (tv_channel_list) {
set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
- MSGTR_OSDChannel, tv_channel_current->name);
+ _("Channel: %s"), tv_channel_current->name);
//vo_osd_changed(OSDTYPE_SUBTITLE);
}
}
@@ -2895,7 +2926,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
case MP_CMD_SUB_LOAD:
if (sh_video) {
int n = mpctx->set_of_sub_size;
- add_subtitles(cmd->args[0].v.s, sh_video->fps, 0);
+ add_subtitles(mpctx, cmd->args[0].v.s, sh_video->fps, 0);
if (n != mpctx->set_of_sub_size) {
if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] < 0)
mpctx->global_sub_indices[SUB_SOURCE_SUBS] =
@@ -2912,8 +2943,8 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
if (v < 0) {
for (v = 0; v < mpctx->set_of_sub_size; ++v) {
subd = mpctx->set_of_subtitles[v];
- mp_msg(MSGT_CPLAYER, MSGL_STATUS,
- MSGTR_RemovedSubtitleFile, v + 1,
+ mp_tmsg(MSGT_CPLAYER, MSGL_STATUS,
+ "SUB: Removed subtitle file (%d): %s\n", v + 1,
filename_recode(subd->filename));
sub_free(subd);
mpctx->set_of_subtitles[v] = NULL;
@@ -2924,18 +2955,20 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
if (mpctx->set_of_sub_pos >= 0) {
mpctx->global_sub_pos = -2;
subdata = NULL;
- mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
+ mp_input_queue_cmd(mpctx->input,
+ mp_input_parse_cmd("sub_select"));
}
} else if (v < mpctx->set_of_sub_size) {
subd = mpctx->set_of_subtitles[v];
mp_msg(MSGT_CPLAYER, MSGL_STATUS,
- MSGTR_RemovedSubtitleFile, v + 1,
+ "SUB: Removed subtitle file (%d): %s\n", v + 1,
filename_recode(subd->filename));
sub_free(subd);
if (mpctx->set_of_sub_pos == v) {
mpctx->global_sub_pos = -2;
subdata = NULL;
- mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
+ mp_input_queue_cmd(mpctx->input,
+ mp_input_parse_cmd("sub_select"));
} else if (mpctx->set_of_sub_pos > v) {
--mpctx->set_of_sub_pos;
--mpctx->global_sub_pos;
@@ -2960,7 +2993,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_SCREENSHOT:
- if (vo_config_count) {
+ if (mpctx->video_out && mpctx->video_out->config_ok) {
mp_msg(MSGT_CPLAYER, MSGL_INFO, "sending VFCTRL_SCREENSHOT!\n");
if (CONTROL_OK !=
((vf_instance_t *) sh_video->vfilter)->
@@ -2984,12 +3017,12 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
case MP_CMD_GET_FILENAME:{
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_FILENAME='%s'\n",
- get_metadata(META_NAME));
+ get_metadata(mpctx, META_NAME));
}
break;
case MP_CMD_GET_VIDEO_CODEC:{
- char *inf = get_metadata(META_VIDEO_CODEC);
+ char *inf = get_metadata(mpctx, META_VIDEO_CODEC);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf);
@@ -2998,7 +3031,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_VIDEO_BITRATE:{
- char *inf = get_metadata(META_VIDEO_BITRATE);
+ char *inf = get_metadata(mpctx, META_VIDEO_BITRATE);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf);
@@ -3007,7 +3040,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_VIDEO_RESOLUTION:{
- char *inf = get_metadata(META_VIDEO_RESOLUTION);
+ char *inf = get_metadata(mpctx, META_VIDEO_RESOLUTION);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO,
@@ -3017,7 +3050,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_AUDIO_CODEC:{
- char *inf = get_metadata(META_AUDIO_CODEC);
+ char *inf = get_metadata(mpctx, META_AUDIO_CODEC);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf);
@@ -3026,7 +3059,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_AUDIO_BITRATE:{
- char *inf = get_metadata(META_AUDIO_BITRATE);
+ char *inf = get_metadata(mpctx, META_AUDIO_BITRATE);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf);
@@ -3035,7 +3068,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_AUDIO_SAMPLES:{
- char *inf = get_metadata(META_AUDIO_SAMPLES);
+ char *inf = get_metadata(mpctx, META_AUDIO_SAMPLES);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf);
@@ -3044,7 +3077,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_META_TITLE:{
- char *inf = get_metadata(META_INFO_TITLE);
+ char *inf = get_metadata(mpctx, META_INFO_TITLE);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TITLE='%s'\n", inf);
@@ -3053,7 +3086,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_META_ARTIST:{
- char *inf = get_metadata(META_INFO_ARTIST);
+ char *inf = get_metadata(mpctx, META_INFO_ARTIST);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf);
@@ -3062,7 +3095,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_META_ALBUM:{
- char *inf = get_metadata(META_INFO_ALBUM);
+ char *inf = get_metadata(mpctx, META_INFO_ALBUM);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf);
@@ -3071,7 +3104,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_META_YEAR:{
- char *inf = get_metadata(META_INFO_YEAR);
+ char *inf = get_metadata(mpctx, META_INFO_YEAR);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_YEAR='%s'\n", inf);
@@ -3080,7 +3113,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_META_COMMENT:{
- char *inf = get_metadata(META_INFO_COMMENT);
+ char *inf = get_metadata(mpctx, META_INFO_COMMENT);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf);
@@ -3089,7 +3122,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_META_TRACK:{
- char *inf = get_metadata(META_INFO_TRACK);
+ char *inf = get_metadata(mpctx, META_INFO_TRACK);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TRACK='%s'\n", inf);
@@ -3098,7 +3131,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_META_GENRE:{
- char *inf = get_metadata(META_INFO_GENRE);
+ char *inf = get_metadata(mpctx, META_INFO_GENRE);
if (!inf)
inf = strdup("");
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_GENRE='%s'\n", inf);
@@ -3107,7 +3140,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_GET_VO_FULLSCREEN:
- if (mpctx->video_out && vo_config_count)
+ if (mpctx->video_out && mpctx->video_out->config_ok)
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs);
break;
@@ -3121,9 +3154,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
if (sh_video)
pos = sh_video->pts;
else if (sh_audio && mpctx->audio_out)
- pos =
- playing_audio_pts(sh_audio, mpctx->d_audio,
- mpctx->audio_out);
+ pos = playing_audio_pts(mpctx);
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos);
}
break;
@@ -3138,7 +3169,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
break;
case MP_CMD_KEYDOWN_EVENTS:
- mplayer_put_key(cmd->args[0].v.i);
+ mplayer_put_key(mpctx->key_fifo, cmd->args[0].v.i);
break;
case MP_CMD_SET_MOUSE_POS:{
@@ -3146,7 +3177,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
double dx, dy;
pointer_x = cmd->args[0].v.i;
pointer_y = cmd->args[1].v.i;
- rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy);
+ rescale_input_coordinates(mpctx, pointer_x, pointer_y, &dx, &dy);
#ifdef CONFIG_DVDNAV
if (mpctx->stream->type == STREAMTYPE_DVDNAV
&& dx > 0.0 && dy > 0.0) {
@@ -3155,7 +3186,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
pointer_y = (int) (dy * (double) sh_video->disp_h);
mp_dvdnav_update_mouse_pos(mpctx->stream,
pointer_x, pointer_y, &button);
- if (osd_level > 1 && button > 0)
+ if (opts->osd_level > 1 && button > 0)
set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
"Selected button number %d", button);
}
@@ -3182,7 +3213,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
command = mp_dvdnav_bindings[i].cmd;
mp_dvdnav_handle_input(mpctx->stream,command,&button);
- if (osd_level > 1 && button > 0)
+ if (opts->osd_level > 1 && button > 0)
set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
"Selected button number %d", button);
}
@@ -3207,18 +3238,13 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
switch (cmd->pausing) {
case 1: // "pausing"
- mpctx->osd_function = OSD_PAUSE;
+ pause_player(mpctx);
break;
case 3: // "pausing_toggle"
- mpctx->was_paused = !mpctx->was_paused;
- if (mpctx->was_paused)
- mpctx->osd_function = OSD_PAUSE;
- else if (mpctx->osd_function == OSD_PAUSE)
- mpctx->osd_function = OSD_PLAY;
+ if (mpctx->paused)
+ unpause_player(mpctx);
+ else
+ pause_player(mpctx);
break;
- case 2: // "pausing_keep"
- if (mpctx->was_paused)
- mpctx->osd_function = OSD_PAUSE;
}
- return brk_cmd;
}
diff --git a/command.h b/command.h
index f87c5a00ca..ee8c451a7c 100644
--- a/command.h
+++ b/command.h
@@ -4,7 +4,7 @@
struct MPContext;
struct mp_cmd;
-int run_command(struct MPContext *mpctx, struct mp_cmd *cmd);
+void run_command(struct MPContext *mpctx, struct mp_cmd *cmd);
char *property_expand_string(struct MPContext *mpctx, char *str);
void property_print_help(void);
diff --git a/common.mak b/common.mak
index 23907af9f2..35f7a0adef 100644
--- a/common.mak
+++ b/common.mak
@@ -18,28 +18,17 @@ endif
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
-CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
+CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) -I$(SRC_PATH)/ffmpeg $(OPTFLAGS)
%.o: %.c
- $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
+ $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ -MD -MP -MF $*.d $<
%.o: %.S
- $(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
+ $(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ -MD -MP -MF $*.d $<
%.ho: %.h
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
-%.d: %.c
- $(DEPEND_CMD) > $@
-
-%.d: %.S
- $(DEPEND_CMD) > $@
-
-%.d: %.cpp
- $(DEPEND_CMD) > $@
-
-%.o: %.d
-
%$(EXESUF): %.c
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
diff --git a/configure b/configure
index b459a0a1c9..c3381fd800 100755
--- a/configure
+++ b/configure
@@ -537,19 +537,19 @@ _libavutil_so=auto
_libavcodec_a=auto
_libamr_nb=auto
_libamr_wb=auto
-_libavdecoders_all=$(sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
+_libavdecoders_all=$(sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' ffmpeg/libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
_libavdecoders=$(echo $_libavdecoders_all | sed -e 's/ LIB[A-Z0-9_]*_DECODER//g' -e s/MPEG4AAC_DECODER//)
-_libavencoders_all=$(sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
+_libavencoders_all=$(sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' ffmpeg/libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
_libavencoders=$(echo $_libavencoders_all | sed 's/ LIB[A-Z0-9_]*_ENCODER//g')
-_libavparsers_all=$(sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
+_libavparsers_all=$(sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' ffmpeg/libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
_libavparsers=$_libavparsers_all
-_libavbsfs_all=$(sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
+_libavbsfs_all=$(sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' ffmpeg/libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
_libavbsfs=$_libavbsfs_all
-_libavdemuxers_all=$(sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]')
+_libavdemuxers_all=$(sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' ffmpeg/libavformat/allformats.c | tr '[a-z]' '[A-Z]')
_libavdemuxers=$(echo $_libavdemuxers_all | sed -e 's/ LIB[A-Z0-9_]*_DEMUXER//g' -e s/REDIR_DEMUXER// -e s/RTSP_DEMUXER// -e s/SDP_DEMUXER// -e s/AVISYNTH_DEMUXER//)
-_libavmuxers_all=$(sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]')
+_libavmuxers_all=$(sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' ffmpeg/libavformat/allformats.c | tr '[a-z]' '[A-Z]')
_libavmuxers=$(echo $_libavmuxers_all | sed -e 's/ LIB[A-Z0-9_]*_MUXER//g' -e s/RTP_MUXER//)
-_libavprotocols_all=$(sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]')
+_libavprotocols_all=$(sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' ffmpeg/libavformat/allformats.c | tr '[a-z]' '[A-Z]')
_libavcodec_so=auto
_libavformat_a=auto
_libavformat_so=auto
@@ -1334,6 +1334,11 @@ for ac_option do
esac
done
+if test "$_gui" = yes ; then
+ echo "Error: --enable-gui is no longer supported. Use an external frontend if you want a GUI." >&2
+ exit 1
+fi
+
# Atmos: moved this here, to be correct, if --prefix is specified
test -z "$_bindir" && _bindir="$_prefix/bin"
test -z "$_datadir" && _datadir="$_prefix/share/mplayer"
@@ -2218,6 +2223,7 @@ EOF
_arch='ALPHA'
_target_arch='ARCH_ALPHA = yes'
iproc='alpha'
+ def_fast_64bit='#define HAVE_FAST_64BIT 1'
echocheck "CPU type"
cat > $TMPC << EOF
@@ -2440,7 +2446,6 @@ int main(void) { return 0; }
EOF
if test "$cc_vendor" = "gnu" ; then
cc_check -std=gnu99 && CFLAGS="-std=gnu99 $CFLAGS"
- cc_check -Wdeclaration-after-statement && CFLAGS="-Wdeclaration-after-statement $CFLAGS"
cc_check -Wno-pointer-sign && CFLAGS="-Wno-pointer-sign $CFLAGS"
cc_check -Wdisabled-optimization && CFLAGS="-Wdisabled-optimization $CFLAGS"
cc_check -Wundef && CFLAGS="-Wundef $CFLAGS"
@@ -5366,6 +5371,15 @@ EOF
cc_check && _real_ossaudio=yes
if test "$_real_ossaudio" = yes; then
def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/dsp"'
+ # Check for OSS4 headers (override default headers)
+ # Does not apply to systems where OSS4 is native (e.g. FreeBSD)
+ if test -f /etc/oss.conf; then
+ . /etc/oss.conf
+ _ossinc="$OSSLIBDIR/include"
+ if test -f "$_ossinc/sys/soundcard.h"; then
+ extra_cflags="-I$_ossinc $extra_cflags"
+ fi
+ fi
elif netbsd || openbsd ; then
def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/sound"'
extra_ldflags="$extra_ldflags -lossaudio"
@@ -5814,6 +5828,9 @@ echores "$_vcd"
echocheck "dvdread"
+if test "$_dvdread_internal" = auto && test ! -f "libdvdread4/dvd_reader.c" ; then
+ _dvdread_internal=no
+fi
if test "$_dvdread_internal" = auto ; then
_dvdread_internal=no
_dvdread=no
@@ -6878,7 +6895,7 @@ echores "$_live"
echocheck "FFmpeg libavutil"
if test "$_libavutil_a" = auto ; then
- if test -d libavutil ; then
+ if test -d ffmpeg/libavutil ; then
_libavutil_a=yes
_res_comment="static"
else
@@ -6918,7 +6935,7 @@ echores "$_libavutil"
echocheck "FFmpeg libavcodec"
if test "$_libavcodec_a" = auto ; then
_libavcodec_a=no
- if test -d libavcodec && test -f libavcodec/utils.c ; then
+ if test -d ffmpeg/libavcodec && test -f ffmpeg/libavcodec/utils.c ; then
_libavcodec_a="yes"
_res_comment="static"
fi
@@ -6962,7 +6979,7 @@ echores "$_libavcodec"
echocheck "FFmpeg libavformat"
if test "$_libavformat_a" = auto ; then
_libavformat_a=no
- if test -d libavformat && test -f libavformat/utils.c ; then
+ if test -d ffmpeg/libavformat && test -f ffmpeg/libavformat/utils.c ; then
_libavformat_a=yes
_res_comment="static"
fi
@@ -6998,7 +7015,7 @@ echores "$_libavformat"
echocheck "FFmpeg libpostproc"
if test "$_libpostproc_a" = auto ; then
_libpostproc_a=no
- if test -d libpostproc && test -f libpostproc/postprocess.h ; then
+ if test -d ffmpeg/libpostproc && test -f ffmpeg/libpostproc/postprocess.h ; then
_libpostproc_a='yes'
_res_comment="static"
fi
@@ -8070,7 +8087,7 @@ if test "$_largefiles" = yes || freebsd ; then
fi
fi
-CXXFLAGS=" $CFLAGS -D__STDC_LIMIT_MACROS"
+CXXFLAGS=" $CFLAGS -Iffmpeg -D__STDC_LIMIT_MACROS"
# This must be the last test to be performed. Any other tests following it
# could fail due to linker errors. libdvdnavmini is intentionally not linked
@@ -8078,6 +8095,9 @@ CXXFLAGS=" $CFLAGS -D__STDC_LIMIT_MACROS"
# So any compilation using the flags added here but not linking against
# libdvdread can fail.
echocheck "DVD support (libdvdnav)"
+if test "$_dvdread_internal" = yes && test ! -f "libdvdnav/dvdnav.c" ; then
+ _dvdnav=no
+fi
dvdnav_internal=no
if test "$_dvdnav" = auto ; then
if test "$_dvdread_internal" = yes ; then
@@ -8119,6 +8139,9 @@ echores "$_dvdnav"
# DO NOT ADD ANY TESTS THAT USE LINKER FLAGS HERE (like cc_check).
# Read dvdnav comment above.
+CFLAGS_FFMPEG="-I../.. $CFLAGS"
+CFLAGS="-Iffmpeg $CFLAGS"
+
#############################################################################
echo "Creating config.mak"
cat > config.mak << EOF
@@ -8155,6 +8178,7 @@ WINDRES = $_windres
CFLAGS = $CFLAGS $extra_cflags
OPTFLAGS = $CFLAGS $extra_cflags
+FFMPEG_OFLAGS = $CFLAGS_FFMPEG $extra_cflags
CXXFLAGS = $CXXFLAGS $extra_cflags $extra_cxxflags
CFLAGS_DHAHELPER = $cflags_dhahelper
CFLAGS_FAAD_FIXED = $cflags_faad_fixed
@@ -8911,6 +8935,9 @@ EOF
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
cmp -s "$TMPH" config.h || mv -f "$TMPH" config.h
+cp -p config.h ffmpeg/config.h
+sed -e 's/OPTFLAGS/MPLAYER_OPTFLAGS/' -e 's/FFMPEG_OFLAGS/OPTFLAGS/' config.mak >ffmpeg/config.mak
+
#############################################################################
cat << EOF
diff --git a/defaultopts.c b/defaultopts.c
new file mode 100644
index 0000000000..d908eda347
--- /dev/null
+++ b/defaultopts.c
@@ -0,0 +1,61 @@
+#include <stddef.h>
+
+#include "config.h"
+#include "defaultopts.h"
+#include "options.h"
+
+void set_default_mplayer_options(struct MPOpts *opts)
+{
+ *opts = (const struct MPOpts){
+ .audio_driver_list = NULL,
+ .video_driver_list = NULL,
+ .fixed_vo = 1,
+ .monitor_pixel_aspect = 1.0,
+ .vo_panscanrange = 1.0,
+ .vo_gamma_gamma = 1000,
+ .vo_gamma_brightness = 1000,
+ .vo_gamma_contrast = 1000,
+ .vo_gamma_saturation = 1000,
+ .vo_gamma_hue = 1000,
+ .osd_level = 1,
+ .osd_duration = 1000,
+ .loop_times = -1,
+ .ordered_chapters = 1,
+ .user_correct_pts = -1,
+ .key_fifo_size = 7,
+ .doubleclick_time = 300,
+ .audio_id = -1,
+ .video_id = -1,
+ .sub_id = -2,
+ .playback_speed = 1.,
+ .movie_aspect = -1.,
+ .flip = -1,
+ .vd_use_slices = 1,
+ .lavc_param = {
+ .workaround_bugs = 1, // autodetect
+ .error_resilience = 2,
+ .error_concealment = 3,
+ .threads = 1,
+ },
+ .input = {
+ .config_file = "input.conf",
+ .ar_delay = 100,
+ .ar_rate = 8,
+ .use_joystick = 1,
+ .use_lirc = 1,
+ .use_lircc = 1,
+#ifdef CONFIG_APPLE_REMOTE
+ .use_ar = 1,
+#else
+ .use_ar = 0,
+#endif
+ .default_bindings = 1,
+ }
+ };
+}
+
+void set_default_mencoder_options(struct MPOpts *opts)
+{
+ set_default_mplayer_options(opts);
+ opts->user_correct_pts = 0;
+}
diff --git a/defaultopts.h b/defaultopts.h
new file mode 100644
index 0000000000..15067204a7
--- /dev/null
+++ b/defaultopts.h
@@ -0,0 +1,3 @@
+struct MPOpts;
+void set_default_mplayer_options(struct MPOpts *opts);
+void set_default_mencoder_options(struct MPOpts *opts);
diff --git a/drivers/radeon_vid.c b/drivers/radeon_vid.c
index 222f03b375..9367d4b36a 100644
--- a/drivers/radeon_vid.c
+++ b/drivers/radeon_vid.c
@@ -1547,4 +1547,3 @@ void __exit cleanup_module(void)
radeon_ram_size*0x100000);
#endif /* CONFIG_MTRR */
}
-
diff --git a/edl.c b/edl.c
index 5a38d9d59b..35950bdfde 100644
--- a/edl.c
+++ b/edl.c
@@ -19,7 +19,7 @@ static edl_record_ptr edl_alloc_new(edl_record_ptr next_edl_record)
{
edl_record_ptr new_record = calloc(1, sizeof(struct edl_record));
if (!new_record) {
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_EdlOutOfMem);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Can't allocate enough memory to hold EDL data.\n");
exit(1);
}
@@ -78,24 +78,26 @@ edl_record_ptr edl_parse_file(void)
if ((sscanf(line, "%f %f %d", &start, &stop, &action))
!= 3)
{
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadlyFormattedLine,
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Badly formatted EDL line [%d], discarding.\n",
lineCount);
continue;
}
if (next_edl_record && start <= next_edl_record->stop_sec)
{
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line);
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineOverlap,
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Invalid EDL line: %s\n", line);
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN,
+ "Last stop position was [%f]; next start is [%f].\n"\
+ "Entries must be in chronological order, cannot overlap. Discarding.\n",
next_edl_record->stop_sec, start);
continue;
}
if (stop <= start)
{
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine,
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Invalid EDL line: %s\n",
line);
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop);
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Stop time has to be after start time.\n");
continue;
}
@@ -131,9 +133,9 @@ edl_record_ptr edl_parse_file(void)
}
if (edl_records)
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, record_count);
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Read %d EDL actions.\n", record_count);
else
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty);
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "There are no EDL actions to take care of.\n");
return edl_records;
}
diff --git a/etc/menu.conf b/etc/menu.conf
index bb8177fa76..90a19923ce 100644
--- a/etc/menu.conf
+++ b/etc/menu.conf
@@ -149,5 +149,3 @@
<e name="Console" ok="set_menu console0"/>
<e name="Quit" ok="quit"/>
</cmdlist>
-
-
diff --git a/gui/cfg.c b/gui/cfg.c
index a57fa3db9d..adb365415f 100644
--- a/gui/cfg.c
+++ b/gui/cfg.c
@@ -369,4 +369,3 @@ int cfg_write( void )
return 0;
}
-
diff --git a/gui/mplayer/gtk/eq.c b/gui/mplayer/gtk/eq.c
index a344e741ab..d4ab6c1aea 100644
--- a/gui/mplayer/gtk/eq.c
+++ b/gui/mplayer/gtk/eq.c
@@ -688,4 +688,3 @@ GtkWidget * create_EquConfig( void )
return EquConfig;
}
-
diff --git a/gui/mplayer/gtk/gtk_url.c b/gui/mplayer/gtk/gtk_url.c
index 4899e801b1..da1d25aaa6 100644
--- a/gui/mplayer/gtk/gtk_url.c
+++ b/gui/mplayer/gtk/gtk_url.c
@@ -168,4 +168,3 @@ GtkWidget * create_URL( void )
return URL;
}
-
diff --git a/gui/mplayer/gtk/pl.c b/gui/mplayer/gtk/pl.c
index 2dade2bbc3..2750e233bc 100644
--- a/gui/mplayer/gtk/pl.c
+++ b/gui/mplayer/gtk/pl.c
@@ -543,4 +543,3 @@ GtkWidget * create_PlayList( void )
return PlayList;
}
-
diff --git a/gui/skin/cut.c b/gui/skin/cut.c
index b05f238984..f101b67f94 100644
--- a/gui/skin/cut.c
+++ b/gui/skin/cut.c
@@ -50,4 +50,3 @@ void cutChunk( char * in,char * s1 )
cutItem( in,s1,'=',0 );
memmove( in,strchr( in,'=' )+1,strlen( in ) - strlen( s1 ) );
}
-
diff --git a/help/help_mp-en.h b/help/help_mp-en.h
index 77d7bad685..384fee2c23 100644
--- a/help/help_mp-en.h
+++ b/help/help_mp-en.h
@@ -1151,7 +1151,6 @@ static const char help_text[]=
// ======================= audio output drivers ========================
// audio_out.c
-#define MSGTR_AO_ALSA9_1x_Removed "audio_out: alsa9 and alsa1x modules were removed, use -ao alsa instead.\n"
#define MSGTR_AO_TryingPreferredAudioDriver "Trying preferred audio driver '%.*s', options '%s'\n"
#define MSGTR_AO_NoSuchDriver "No such audio driver '%.*s'\n"
#define MSGTR_AO_FailedInit "Failed to initialize audio driver '%s'\n"
diff --git a/help/help_mp-es.h b/help/help_mp-es.h
index 9658cdda61..82af0a2745 100644
--- a/help/help_mp-es.h
+++ b/help/help_mp-es.h
@@ -2130,4 +2130,3 @@ static const char help_text[]=
#define MSGTR_LIBASS_ErrorOpeningMemoryFont "[ass] Error abriendo la fuente en memoria: %s\n"
#define MSGTR_LIBASS_NoCharmaps "[ass] Este font face no tiene charmaps\n"
#define MSGTR_LIBASS_NoCharmapAutodetected "[ass] No se detectó un charmap automaticamente, probando con el primero\n"
-
diff --git a/help/help_mp-hu.h b/help/help_mp-hu.h
index b437f9c218..920a6698a6 100644
--- a/help/help_mp-hu.h
+++ b/help/help_mp-hu.h
@@ -2117,4 +2117,3 @@ static const char help_text[]=
// url.c
#define MSGTR_MPDEMUX_URL_StringAlreadyEscaped "A karakterlánc már escape-ltnek tűnik az url_escape-ben %c%c1%c2\n"
-
diff --git a/help/help_mp-pl.h b/help/help_mp-pl.h
index d221886ac8..bddf87af40 100644
--- a/help/help_mp-pl.h
+++ b/help/help_mp-pl.h
@@ -1838,4 +1838,3 @@ static const char help_text[]=
#define MSGTR_RADIO_DriverUnknownStr "[radio] Nieznana nazwa sterownika: %s\n"
#define MSGTR_RADIO_DriverV4L2 "[radio] Używam interfejsu radiowego V4Lv2.\n"
#define MSGTR_RADIO_DriverV4L "[radio] Używam interfejsu radiowego V4Lv1.\n"
-
diff --git a/help/help_mp-sk.h b/help/help_mp-sk.h
index 81bd066155..776148de87 100644
--- a/help/help_mp-sk.h
+++ b/help/help_mp-sk.h
@@ -911,4 +911,3 @@ static const char help_text[]=
#define MSGTR_MSGBOX_LABEL_Warning "Upozornenie!"
#endif
-
diff --git a/help/help_mp-sv.h b/help/help_mp-sv.h
index 9b245447e6..aa4c45e130 100644
--- a/help/help_mp-sv.h
+++ b/help/help_mp-sv.h
@@ -953,4 +953,3 @@ static const char help_text[]=
// ao_plugin.c
#define MSGTR_AO_PLUGIN_InvalidPlugin "[AO PLUGIN] icke godkänd plugin: %s\n" // FIXME plugin - translate?
-
diff --git a/help/help_mp-uk.h b/help/help_mp-uk.h
index 2a4a99713e..f766628b6e 100644
--- a/help/help_mp-uk.h
+++ b/help/help_mp-uk.h
@@ -1183,4 +1183,3 @@ static const char help_text[]=
#define MSGTR_CouldNotFindColorspace "Ðе можу підібрати підходÑщу Ñхему кольорів - повтор з -vf scale...\n"
#define MSGTR_MovieAspectIsSet "Ð’Ñ–Ð´Ð½Ð¾ÑˆÐµÐ½Ð½Ñ Ñторін %.2f:1 - маÑштабую аби Ñкоректувати.\n"
#define MSGTR_MovieAspectUndefined "Ð’Ñ–Ð´Ð½Ð¾ÑˆÐµÐ½Ð½Ñ Ñторін не вказано - маÑÑˆÑ‚Ð°Ð±ÑƒÐ²Ð°Ð½Ð½Ñ Ð½Ðµ викориÑтовуєтьÑÑ.\n"
-
diff --git a/input/appleir.c b/input/appleir.c
index 07a9c5b797..5e4bc148c6 100644
--- a/input/appleir.c
+++ b/input/appleir.c
@@ -79,12 +79,12 @@ int mp_input_appleir_init (char *dev)
if (dev)
{
- mp_msg (MSGT_INPUT, MSGL_V, MSGTR_INPUT_APPLE_IR_Init, dev);
+ mp_tmsg (MSGT_INPUT, MSGL_V, "Initializing Apple IR on %s\n", dev);
fd = open (dev, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
- mp_msg (MSGT_INPUT, MSGL_ERR,
- MSGTR_INPUT_APPLE_IR_CantOpen, strerror (errno));
+ mp_tmsg (MSGT_INPUT, MSGL_ERR,
+ "Can't open Apple IR device: %s\n", strerror (errno));
return -1;
}
@@ -108,20 +108,20 @@ int mp_input_appleir_init (char *dev)
id.vendor == USB_VENDOR_APPLE &&
(id.product == USB_DEV_APPLE_IR ||id.product == USB_DEV_APPLE_IR_2))
{
- mp_msg (MSGT_INPUT, MSGL_V, MSGTR_INPUT_APPLE_IR_Detect, file);
+ mp_tmsg (MSGT_INPUT, MSGL_V, "Detected Apple IR on %s\n", file);
return fd;
}
close (fd);
}
- mp_msg (MSGT_INPUT, MSGL_ERR,
- MSGTR_INPUT_APPLE_IR_CantOpen, strerror (errno));
+ mp_tmsg (MSGT_INPUT, MSGL_ERR,
+ "Can't open Apple IR device: %s\n", strerror (errno));
}
return -1;
}
-int mp_input_appleir_read (int fd)
+int mp_input_appleir_read(void *ctx, int fd)
{
struct input_event ev;
int i, r;
diff --git a/input/ar.c b/input/ar.c
index e64c64d45b..0827b8be83 100644
--- a/input/ar.c
+++ b/input/ar.c
@@ -321,7 +321,7 @@ int is_mplayer_front(void)
return 0;
}
-int mp_input_ar_read(int fd)
+int mp_input_ar_read(void *ctx, int fd)
{
int i, down = 0;
int ret = MP_INPUT_NOTHING;
@@ -445,7 +445,7 @@ int main(void)
}
while (1) {
- switch ((ret = mp_input_ar_read(0)) & ~MP_KEY_DOWN) {
+ switch ((ret = mp_input_ar_read(NULL, 0)) & ~MP_KEY_DOWN) {
case AR_PLAY: printf(" - AR_PLAY."); break;
case AR_PLAY_HOLD: printf(" - AR_PLAY_HOLD."); break;
case AR_NEXT: printf(" - AR_NEXT."); break;
diff --git a/input/ar.h b/input/ar.h
index 31bbd0ade9..12944f84e1 100644
--- a/input/ar.h
+++ b/input/ar.h
@@ -37,11 +37,11 @@
/* MacOSX Driver */
int mp_input_ar_init(void);
-int mp_input_ar_read(int fd);
+int mp_input_ar_read(void *ctx, int fd);
void mp_input_ar_close(int fd);
/* Linux Driver */
int mp_input_appleir_init(char* dev);
-int mp_input_appleir_read(int fd);
+int mp_input_appleir_read(void *ctx, int fd);
#endif /* MPLAYER_AR_H */
diff --git a/input/input.c b/input/input.c
index 6df64307e8..71d378057e 100644
--- a/input/input.c
+++ b/input/input.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <stdbool.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
@@ -35,7 +36,6 @@
#include <assert.h>
#endif
#include "mp_fifo.h"
-#include "osdep/getch2.h"
#include "osdep/keycodes.h"
#include "osdep/timer.h"
#include "libavutil/avstring.h"
@@ -44,6 +44,8 @@
#include "m_config.h"
#include "m_option.h"
#include "get_path.h"
+#include "talloc.h"
+#include "options.h"
#include "joystick.h"
@@ -57,6 +59,16 @@
#include "ar.h"
+typedef struct mp_cmd_bind {
+ int input[MP_MAX_KEY_DOWN+1];
+ char* cmd;
+} mp_cmd_bind_t;
+
+typedef struct mp_key_name {
+ int key;
+ char* name;
+} mp_key_name_t;
+
/// This array defines all known commands.
/// The first field is an id used to recognize the command without too many strcmp.
/// The second is obviously the command name.
@@ -525,40 +537,72 @@ static const mp_cmd_bind_t gui_def_cmd_binds[] = {
typedef struct mp_input_fd {
int fd;
- void* read_func;
+ union {
+ mp_key_func_t key;
+ mp_cmd_func_t cmd;
+ } read_func;
mp_close_func_t close_func;
+ void *ctx;
unsigned eof : 1;
unsigned drop : 1;
unsigned dead : 1;
unsigned got_cmd : 1;
unsigned no_select : 1;
- unsigned no_readfunc_retval : 1;
// These fields are for the cmd fds.
char* buffer;
int pos,size;
} mp_input_fd_t;
-typedef struct mp_cmd_filter_st mp_cmd_filter_t;
+typedef struct mp_cmd_filter mp_cmd_filter_t;
-struct mp_cmd_filter_st {
+struct mp_cmd_filter {
mp_input_cmd_filter filter;
void* ctx;
mp_cmd_filter_t* next;
};
-typedef struct mp_cmd_bind_section_st mp_cmd_bind_section_t;
+typedef struct mp_cmd_bind_section mp_cmd_bind_section_t;
-struct mp_cmd_bind_section_st {
+struct mp_cmd_bind_section {
mp_cmd_bind_t* cmd_binds;
char* section;
mp_cmd_bind_section_t* next;
};
-// These are the user defined binds
-static mp_cmd_bind_section_t* cmd_binds_section = NULL;
-static char* section = NULL;
-static mp_cmd_bind_t* cmd_binds = NULL;
-static mp_cmd_bind_t* cmd_binds_default = NULL;
+struct input_ctx {
+ // Autorepeat stuff
+ short ar_state;
+ mp_cmd_t *ar_cmd;
+ unsigned int last_ar;
+ // Autorepeat config
+ unsigned int ar_delay;
+ unsigned int ar_rate;
+
+ // these are the keys currently down
+ int key_down[MP_MAX_KEY_DOWN];
+ unsigned int num_key_down;
+ unsigned int last_key_down;
+
+ bool default_bindings;
+ // List of command binding sections
+ mp_cmd_bind_section_t *cmd_bind_sections;
+ // Name of currently used command section
+ char *section;
+ // The command binds of current section
+ mp_cmd_bind_t *cmd_binds;
+ mp_cmd_bind_t *cmd_binds_default;
+
+ mp_input_fd_t key_fds[MP_MAX_KEY_FD];
+ unsigned int num_key_fd;
+
+ mp_input_fd_t cmd_fds[MP_MAX_CMD_FD];
+ unsigned int num_cmd_fd;
+
+ mp_cmd_t *cmd_queue[CMD_QUEUE_SIZE];
+ unsigned int cmd_queue_length, cmd_queue_start, cmd_queue_end;
+};
+
+
static mp_cmd_filter_t* cmd_filters = NULL;
// Callback to allow the menu filter to grab the incoming keys
@@ -566,81 +610,47 @@ int (*mp_input_key_cb)(int code) = NULL;
int async_quit_request;
-static mp_input_fd_t key_fds[MP_MAX_KEY_FD];
-static unsigned int num_key_fd = 0;
-static mp_input_fd_t cmd_fds[MP_MAX_CMD_FD];
-static unsigned int num_cmd_fd = 0;
-static mp_cmd_t* cmd_queue[CMD_QUEUE_SIZE];
-static unsigned int cmd_queue_length = 0,cmd_queue_start = 0, cmd_queue_end = 0;
-
-// this is the key currently down
-static int key_down[MP_MAX_KEY_DOWN];
-static unsigned int num_key_down = 0, last_key_down = 0;
-
-// Autorepeat stuff
-static short ar_state = -1;
-static mp_cmd_t* ar_cmd = NULL;
-static unsigned int ar_delay = 100, ar_rate = 8, last_ar = 0;
-
-static int use_joystick = 1, use_lirc = 1, use_lircc = 1;
-static int default_bindings = 1;
-static char* config_file = "input.conf";
-
-/* Apple Remote */
-#ifdef CONFIG_APPLE_REMOTE
-static int use_ar = 1;
-#else
-static int use_ar = 0;
-#endif
-
-static char* js_dev = NULL;
-static char* ar_dev = NULL;
-
-static char* in_file = NULL;
-static int in_file_fd = -1;
-
-static int mp_input_print_key_list(m_option_t* cfg);
-static int mp_input_print_cmd_list(m_option_t* cfg);
+static int print_key_list(m_option_t* cfg);
+static int print_cmd_list(m_option_t* cfg);
// Our command line options
-static m_option_t input_conf[] = {
- { "conf", &config_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL },
- { "ar-dev", &ar_dev, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL },
- { "ar-delay", &ar_delay, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL },
- { "ar-rate", &ar_rate, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL },
- { "keylist", mp_input_print_key_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, NULL },
- { "cmdlist", mp_input_print_cmd_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, NULL },
- { "js-dev", &js_dev, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL },
- { "file", &in_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL },
- { "default-bindings", &default_bindings, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL },
- { "nodefault-bindings", &default_bindings, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL },
+static const m_option_t input_conf[] = {
+ OPT_STRING("conf", input.config_file, CONF_GLOBAL),
+ OPT_INT("ar-delay",input.ar_delay, CONF_GLOBAL),
+ OPT_INT("ar-rate", input.ar_rate, CONF_GLOBAL),
+ { "keylist", print_key_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, NULL },
+ { "cmdlist", print_cmd_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, NULL },
+ OPT_STRING("js-dev", input.js_dev, CONF_GLOBAL),
+ OPT_STRING("ar-dev", input.ar_dev, CONF_GLOBAL),
+ OPT_STRING("file", input.in_file, CONF_GLOBAL),
+ OPT_FLAG_ON("default-bindings", input.default_bindings, CONF_GLOBAL),
+ OPT_FLAG_OFF("nodefault-bindings", input.default_bindings, CONF_GLOBAL),
{ NULL, NULL, 0, 0, 0, 0, NULL}
};
-static m_option_t mp_input_opts[] = {
+static const m_option_t mp_input_opts[] = {
{ "input", &input_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
- { "nojoystick", &use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL },
- { "joystick", &use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL },
- { "nolirc", &use_lirc, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL },
- { "lirc", &use_lirc, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL },
- { "nolircc", &use_lircc, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL },
- { "lircc", &use_lircc, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL },
- { "noar", &use_ar, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL },
- { "ar", &use_ar, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL },
+ OPT_FLAG_OFF("nojoystick", input.use_joystick, CONF_GLOBAL),
+ OPT_FLAG_ON("joystick", input.use_joystick, CONF_GLOBAL),
+ OPT_FLAG_OFF("nolirc", input.use_lirc, CONF_GLOBAL),
+ OPT_FLAG_ON("lirc", input.use_lirc, CONF_GLOBAL),
+ OPT_FLAG_OFF("nolircc", input.use_lircc, CONF_GLOBAL),
+ OPT_FLAG_ON("lircc", input.use_lircc, CONF_GLOBAL),
+ OPT_FLAG_OFF("noar", input.use_ar, CONF_GLOBAL),
+ OPT_FLAG_ON("ar", input.use_ar, CONF_GLOBAL),
{ NULL, NULL, 0, 0, 0, 0, NULL}
};
-static int
-mp_input_default_cmd_func(int fd,char* buf, int l);
+static int default_cmd_func(int fd,char* buf, int l);
-static char*
-mp_input_get_key_name(int key);
+static char *get_key_name(int key, char buffer[12]);
-int
-mp_input_add_cmd_fd(int fd, int select, mp_cmd_func_t read_func, mp_close_func_t close_func) {
- if(num_cmd_fd == MP_MAX_CMD_FD) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantRegister2ManyCmdFds,fd);
+int mp_input_add_cmd_fd(struct input_ctx *ictx, int fd, int select,
+ mp_cmd_func_t read_func, mp_close_func_t close_func)
+{
+ if (ictx->num_cmd_fd == MP_MAX_CMD_FD) {
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Too many command file descriptors, cannot register file descriptor %d.\n",fd);
return 0;
}
if (select && fd < 0) {
@@ -648,58 +658,65 @@ mp_input_add_cmd_fd(int fd, int select, mp_cmd_func_t read_func, mp_close_func_t
return 0;
}
- memset(&cmd_fds[num_cmd_fd],0,sizeof(mp_input_fd_t));
- cmd_fds[num_cmd_fd].fd = fd;
- cmd_fds[num_cmd_fd].read_func = read_func ? read_func : mp_input_default_cmd_func;
- cmd_fds[num_cmd_fd].close_func = close_func;
- cmd_fds[num_cmd_fd].no_select = !select;
- num_cmd_fd++;
+ ictx->cmd_fds[ictx->num_cmd_fd] = (struct mp_input_fd){
+ .fd = fd,
+ .read_func.cmd = read_func ? read_func : default_cmd_func,
+ .close_func = close_func,
+ .no_select = !select
+ };
+ ictx->num_cmd_fd++;
return 1;
}
-void
-mp_input_rm_cmd_fd(int fd) {
+void mp_input_rm_cmd_fd(struct input_ctx *ictx, int fd)
+{
+ struct mp_input_fd *cmd_fds = ictx->cmd_fds;
unsigned int i;
- for(i = 0; i < num_cmd_fd; i++) {
+ for (i = 0; i < ictx->num_cmd_fd; i++) {
if(cmd_fds[i].fd == fd)
break;
}
- if(i == num_cmd_fd)
+ if (i == ictx->num_cmd_fd)
return;
if(cmd_fds[i].close_func)
cmd_fds[i].close_func(cmd_fds[i].fd);
if(cmd_fds[i].buffer)
- free(cmd_fds[i].buffer);
+ talloc_free(cmd_fds[i].buffer);
- if(i + 1 < num_cmd_fd)
- memmove(&cmd_fds[i],&cmd_fds[i+1],(num_cmd_fd - i - 1)*sizeof(mp_input_fd_t));
- num_cmd_fd--;
+ if (i + 1 < ictx->num_cmd_fd)
+ memmove(&cmd_fds[i], &cmd_fds[i+1],
+ (ictx->num_cmd_fd - i - 1) * sizeof(mp_input_fd_t));
+ ictx->num_cmd_fd--;
}
-void
-mp_input_rm_key_fd(int fd) {
+void mp_input_rm_key_fd(struct input_ctx *ictx, int fd)
+{
+ struct mp_input_fd *key_fds = ictx->key_fds;
unsigned int i;
- for(i = 0; i < num_key_fd; i++) {
+ for (i = 0; i < ictx->num_key_fd; i++) {
if(key_fds[i].fd == fd)
break;
}
- if(i == num_key_fd)
+ if (i == ictx->num_key_fd)
return;
if(key_fds[i].close_func)
key_fds[i].close_func(key_fds[i].fd);
- if(i + 1 < num_key_fd)
- memmove(&key_fds[i],&key_fds[i+1],(num_key_fd - i - 1)*sizeof(mp_input_fd_t));
- num_key_fd--;
+ if(i + 1 < ictx->num_key_fd)
+ memmove(&key_fds[i], &key_fds[i+1],
+ (ictx->num_key_fd - i - 1) * sizeof(mp_input_fd_t));
+ ictx->num_key_fd--;
}
-int
-mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t close_func) {
- if(num_key_fd == MP_MAX_KEY_FD) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantRegister2ManyKeyFds,fd);
+int mp_input_add_key_fd(struct input_ctx *ictx, int fd, int select,
+ mp_key_func_t read_func, mp_close_func_t close_func,
+ void *ctx)
+{
+ if (ictx->num_key_fd == MP_MAX_KEY_FD) {
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Too many key file descriptors, cannot register file descriptor %d.\n",fd);
return 0;
}
if (select && fd < 0) {
@@ -707,44 +724,20 @@ mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t
return 0;
}
- memset(&key_fds[num_key_fd],0,sizeof(mp_input_fd_t));
- key_fds[num_key_fd].fd = fd;
- key_fds[num_key_fd].read_func = read_func;
- key_fds[num_key_fd].close_func = close_func;
- key_fds[num_key_fd].no_select = !select;
- num_key_fd++;
+ ictx->key_fds[ictx->num_key_fd] = (struct mp_input_fd){
+ .fd = fd,
+ .read_func.key = read_func,
+ .close_func = close_func,
+ .no_select = !select,
+ .ctx = ctx,
+ };
+ ictx->num_key_fd++;
return 1;
}
-int
-mp_input_add_event_fd(int fd, void (*read_func)(void))
+int mp_input_parse_and_queue_cmds(struct input_ctx *ictx, const char *str)
{
- if(num_key_fd == MP_MAX_KEY_FD) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantRegister2ManyKeyFds,fd);
- return 0;
- }
- if (fd < 0) {
- mp_msg(MSGT_INPUT, MSGL_ERR, "Invalid fd %i in mp_input_add_event_fd", fd);
- return 0;
- }
-
- memset(&key_fds[num_key_fd],0,sizeof(mp_input_fd_t));
- key_fds[num_key_fd].fd = fd;
- key_fds[num_key_fd].read_func = read_func;
- key_fds[num_key_fd].close_func = NULL;
- key_fds[num_key_fd].no_readfunc_retval = 1;
- num_key_fd++;
-
- return 1;
-}
-
-void mp_input_rm_event_fd(int fd)
-{
- mp_input_rm_key_fd(fd);
-}
-
-int mp_input_parse_and_queue_cmds(const char *str) {
int cmd_num = 0;
while (*str == '\n' || *str == '\r' || *str == ' ')
@@ -752,17 +745,17 @@ int mp_input_parse_and_queue_cmds(const char *str) {
while (*str) {
mp_cmd_t *cmd;
size_t len = strcspn(str, "\r\n");
- char *cmdbuf = malloc(len+1);
+ char *cmdbuf = talloc_size(NULL, len+1);
av_strlcpy(cmdbuf, str, len+1);
cmd = mp_input_parse_cmd(cmdbuf);
if (cmd) {
- mp_input_queue_cmd(cmd);
+ mp_input_queue_cmd(ictx, cmd);
++cmd_num;
}
str += len;
while (*str == '\n' || *str == '\r' || *str == ' ')
++str;
- free(cmdbuf);
+ talloc_free(cmdbuf);
}
return cmd_num;
}
@@ -770,9 +763,8 @@ int mp_input_parse_and_queue_cmds(const char *str) {
mp_cmd_t*
mp_input_parse_cmd(char* str) {
int i,l;
- int pausing = -1;
+ int pausing = 0;
char *ptr,*e;
- mp_cmd_t *cmd;
const mp_cmd_t *cmd_def;
#ifdef MP_DEBUG
@@ -817,19 +809,12 @@ mp_input_parse_cmd(char* str) {
cmd_def = &mp_cmds[i];
- cmd = calloc(1, sizeof(mp_cmd_t));
- cmd->id = cmd_def->id;
- cmd->name = strdup(cmd_def->name);
- if (pausing == -1) {
- switch (cmd->id) {
- case MP_CMD_KEYDOWN_EVENTS:
- case MP_CMD_SET_MOUSE_POS:
- pausing = 4; break;
- default:
- pausing = 0; break;
- }
- }
- cmd->pausing = pausing;
+ mp_cmd_t *cmd = talloc_ptrtype(NULL, cmd);
+ *cmd = (mp_cmd_t){
+ .id = cmd_def->id,
+ .name = talloc_strdup(cmd, cmd_def->name),
+ .pausing = pausing,
+ };
ptr = str;
@@ -844,7 +829,7 @@ mp_input_parse_cmd(char* str) {
errno = 0;
cmd->args[i].v.i = atoi(ptr);
if(errno != 0) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrArgMustBeInt,cmd_def->name,i+1);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Command %s: argument %d isn't an integer.\n",cmd_def->name,i+1);
ptr = NULL;
}
break;
@@ -852,7 +837,7 @@ mp_input_parse_cmd(char* str) {
errno = 0;
cmd->args[i].v.f = atof(ptr);
if(errno != 0) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrArgMustBeFloat,cmd_def->name,i+1);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Command %s: argument %d isn't a float.\n",cmd_def->name,i+1);
ptr = NULL;
}
break;
@@ -874,7 +859,7 @@ mp_input_parse_cmd(char* str) {
}
if(term != ' ' && (!e || e[0] == '\0')) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrUnterminatedArg,cmd_def->name,i+1);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Command %s: argument %d is unterminated.\n",cmd_def->name,i+1);
ptr = NULL;
break;
} else if(!e) e = ptr+strlen(ptr);
@@ -885,23 +870,21 @@ mp_input_parse_cmd(char* str) {
ptr2 = e + 1;
l--;
}
- cmd->args[i].v.s = malloc(l+1);
- strncpy(cmd->args[i].v.s,start,l);
- cmd->args[i].v.s[l] = '\0';
+ cmd->args[i].v.s = talloc_strndup(cmd, start, l);
if(term != ' ') ptr += l+2;
} break;
case -1:
ptr = NULL;
break;
default :
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrUnknownArg,i);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Unknown argument %d\n",i);
}
}
cmd->nargs = i;
if(cmd_def->nargs > cmd->nargs) {
/* mp_msg(MSGT_INPUT,MSGL_ERR,"Got command '%s' but\n",str); */
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_Err2FewArgs,cmd_def->name,cmd_def->nargs,cmd->nargs);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Command %s requires at least %d arguments, we found only %d so far.\n",cmd_def->name,cmd_def->nargs,cmd->nargs);
mp_cmd_free(cmd);
return NULL;
}
@@ -909,7 +892,7 @@ mp_input_parse_cmd(char* str) {
for( ; i < MP_CMD_MAX_ARGS && cmd_def->args[i].type != -1 ; i++) {
memcpy(&cmd->args[i],&cmd_def->args[i],sizeof(mp_cmd_arg_t));
if(cmd_def->args[i].type == MP_CMD_ARG_STRING && cmd_def->args[i].v.s != NULL)
- cmd->args[i].v.s = strdup(cmd_def->args[i].v.s);
+ cmd->args[i].v.s = talloc_strdup(cmd, cmd_def->args[i].v.s);
}
if(i < MP_CMD_MAX_ARGS)
@@ -920,27 +903,28 @@ mp_input_parse_cmd(char* str) {
#define MP_CMD_MAX_SIZE 4096
-static int
-mp_input_read_cmd(mp_input_fd_t* mp_fd, char** ret) {
+static int read_cmd(mp_input_fd_t* mp_fd, char** ret)
+{
char* end;
(*ret) = NULL;
// Allocate the buffer if it doesn't exist
if(!mp_fd->buffer) {
- mp_fd->buffer = malloc(MP_CMD_MAX_SIZE);
+ mp_fd->buffer = talloc_size(NULL, MP_CMD_MAX_SIZE);
mp_fd->pos = 0;
mp_fd->size = MP_CMD_MAX_SIZE;
}
// Get some data if needed/possible
while (!mp_fd->got_cmd && !mp_fd->eof && (mp_fd->size - mp_fd->pos > 1) ) {
- int r = ((mp_cmd_func_t)mp_fd->read_func)(mp_fd->fd,mp_fd->buffer+mp_fd->pos,mp_fd->size - 1 - mp_fd->pos);
+ int r = mp_fd->read_func.cmd(mp_fd->fd, mp_fd->buffer+mp_fd->pos,
+ mp_fd->size - 1 - mp_fd->pos);
// Error ?
if(r < 0) {
switch(r) {
case MP_INPUT_ERROR:
case MP_INPUT_DEAD:
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrReadingCmdFd,mp_fd->fd,strerror(errno));
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Error while reading command file descriptor %d: %s\n",mp_fd->fd,strerror(errno));
case MP_INPUT_NOTHING:
return r;
case MP_INPUT_RETRY:
@@ -966,7 +950,7 @@ mp_input_read_cmd(mp_input_fd_t* mp_fd, char** ret) {
if(!end) {
// If buffer is full we must drop all until the next \n
if(mp_fd->size - mp_fd->pos <= 1) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCmdBufferFullDroppingContent,mp_fd->fd);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Command buffer of file descriptor %d is full: dropping content.\n",mp_fd->fd);
mp_fd->pos = 0;
mp_fd->drop = 1;
}
@@ -981,16 +965,12 @@ mp_input_read_cmd(mp_input_fd_t* mp_fd, char** ret) {
l = end - mp_fd->buffer;
// Not dropping : put the cmd in ret
- if (!mp_fd->drop) {
- (*ret) = malloc(l+1);
- strncpy((*ret),mp_fd->buffer,l);
- (*ret)[l] = '\0';
- } else { // Remove the dropping flag
+ if (!mp_fd->drop)
+ *ret = talloc_strndup(NULL, mp_fd->buffer, l);
+ else
mp_fd->drop = 0;
- }
- if( mp_fd->pos - (l+1) > 0)
- memmove(mp_fd->buffer,end+1,mp_fd->pos-(l+1));
mp_fd->pos -= l+1;
+ memmove(mp_fd->buffer, end+1, mp_fd->pos);
}
if(*ret)
@@ -999,9 +979,8 @@ mp_input_read_cmd(mp_input_fd_t* mp_fd, char** ret) {
return MP_INPUT_NOTHING;
}
-static int
-mp_input_default_cmd_func(int fd,char* buf, int l) {
-
+static int default_cmd_func(int fd,char* buf, int l)
+{
while(1) {
int r = read(fd,buf,l);
// Error ?
@@ -1021,7 +1000,7 @@ mp_input_default_cmd_func(int fd,char* buf, int l) {
void
mp_input_add_cmd_filter(mp_input_cmd_filter func, void* ctx) {
- mp_cmd_filter_t* filter = malloc(sizeof(mp_cmd_filter_t))/*, *prev*/;
+ mp_cmd_filter_t *filter = talloc_ptrtype(NULL, filter);
filter->filter = func;
filter->ctx = ctx;
@@ -1030,8 +1009,8 @@ mp_input_add_cmd_filter(mp_input_cmd_filter func, void* ctx) {
}
-static char*
-mp_input_find_bind_for_key(const mp_cmd_bind_t* binds, int n,int* keys) {
+static char *find_bind_for_key(const mp_cmd_bind_t* binds, int n,int* keys)
+{
int j;
if (n <= 0) return NULL;
@@ -1049,9 +1028,10 @@ mp_input_find_bind_for_key(const mp_cmd_bind_t* binds, int n,int* keys) {
return binds[j].cmd;
}
-static mp_cmd_bind_section_t*
-mp_input_get_bind_section(char *section) {
- mp_cmd_bind_section_t* bind_section = cmd_binds_section;
+static mp_cmd_bind_section_t *get_bind_section(struct input_ctx *ictx,
+ char *section)
+{
+ mp_cmd_bind_section_t *bind_section = ictx->cmd_bind_sections;
if (section==NULL) section="default";
while (bind_section) {
@@ -1060,36 +1040,39 @@ mp_input_get_bind_section(char *section) {
bind_section=bind_section->next;
}
if(bind_section) {
- bind_section->next=malloc(sizeof(mp_cmd_bind_section_t));
+ bind_section->next = talloc_ptrtype(ictx, bind_section->next);
bind_section=bind_section->next;
} else {
- cmd_binds_section=malloc(sizeof(mp_cmd_bind_section_t));
- bind_section=cmd_binds_section;
+ ictx->cmd_bind_sections = talloc_ptrtype(ictx, ictx->cmd_bind_sections);
+ bind_section = ictx->cmd_bind_sections;
}
bind_section->cmd_binds=NULL;
- bind_section->section=strdup(section);
+ bind_section->section = talloc_strdup(bind_section, section);
bind_section->next=NULL;
return bind_section;
}
-static mp_cmd_t*
-mp_input_get_cmd_from_keys(int n,int* keys, int paused) {
+static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, int n, int *keys,
+ int paused)
+{
char* cmd = NULL;
mp_cmd_t* ret;
+ char key_buf[12];
- if(cmd_binds)
- cmd = mp_input_find_bind_for_key(cmd_binds,n,keys);
- if(cmd_binds_default && cmd == NULL)
- cmd = mp_input_find_bind_for_key(cmd_binds_default,n,keys);
- if(default_bindings && cmd == NULL)
- cmd = mp_input_find_bind_for_key(def_cmd_binds,n,keys);
+ if (ictx->cmd_binds)
+ cmd = find_bind_for_key(ictx->cmd_binds, n, keys);
+ if (ictx->cmd_binds_default && cmd == NULL)
+ cmd = find_bind_for_key(ictx->cmd_binds_default, n, keys);
+ if (ictx->default_bindings && cmd == NULL)
+ cmd = find_bind_for_key(def_cmd_binds,n,keys);
if(cmd == NULL) {
- mp_msg(MSGT_INPUT,MSGL_WARN,MSGTR_NoBindFound,mp_input_get_key_name(keys[0]));
+ mp_tmsg(MSGT_INPUT,MSGL_WARN,"No bind found for key '%s'.", get_key_name(keys[0],
+ key_buf));
if(n > 1) {
int s;
for(s=1; s < n; s++)
- mp_msg(MSGT_INPUT,MSGL_WARN,"-%s",mp_input_get_key_name(keys[s]));
+ mp_msg(MSGT_INPUT,MSGL_WARN,"-%s", get_key_name(keys[s], key_buf));
}
mp_msg(MSGT_INPUT,MSGL_WARN," \n");
return NULL;
@@ -1097,11 +1080,13 @@ mp_input_get_cmd_from_keys(int n,int* keys, int paused) {
if (strcmp(cmd, "ignore") == 0) return NULL;
ret = mp_input_parse_cmd(cmd);
if(!ret) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrInvalidCommandForKey,mp_input_get_key_name(key_down[0]));
- if( num_key_down > 1) {
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Invalid command for bound key %s",
+ get_key_name(ictx->key_down[0], key_buf));
+ if (ictx->num_key_down > 1) {
unsigned int s;
- for(s=1; s < num_key_down; s++)
- mp_msg(MSGT_INPUT,MSGL_ERR,"-%s",mp_input_get_key_name(key_down[s]));
+ for(s=1; s < ictx->num_key_down; s++)
+ mp_msg(MSGT_INPUT,MSGL_ERR,"-%s", get_key_name(ictx->key_down[s],
+ key_buf));
}
mp_msg(MSGT_INPUT,MSGL_ERR," : %s \n",cmd);
}
@@ -1109,8 +1094,7 @@ mp_input_get_cmd_from_keys(int n,int* keys, int paused) {
}
-static mp_cmd_t*
-interpret_key(int code, int paused)
+static mp_cmd_t* interpret_key(struct input_ctx *ictx, int code, int paused)
{
unsigned int j;
mp_cmd_t* ret;
@@ -1124,105 +1108,111 @@ interpret_key(int code, int paused)
}
if(code & MP_KEY_DOWN) {
- if(num_key_down > MP_MAX_KEY_DOWN) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_Err2ManyKeyDowns);
+ if (ictx->num_key_down > MP_MAX_KEY_DOWN) {
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Too many key down events at the same time\n");
return NULL;
}
code &= ~MP_KEY_DOWN;
// Check if we don't already have this key as pushed
- for(j = 0; j < num_key_down; j++) {
- if(key_down[j] == code)
+ for (j = 0; j < ictx->num_key_down; j++) {
+ if (ictx->key_down[j] == code)
break;
}
- if(j != num_key_down)
+ if (j != ictx->num_key_down)
return NULL;
- key_down[num_key_down] = code;
- num_key_down++;
- last_key_down = GetTimer();
- ar_state = 0;
+ ictx->key_down[ictx->num_key_down] = code;
+ ictx->num_key_down++;
+ ictx->last_key_down = GetTimer();
+ ictx->ar_state = 0;
return NULL;
}
// key released
// Check if the key is in the down key, driver which can't send push event
// send only release event
- for(j = 0; j < num_key_down; j++) {
- if(key_down[j] == code)
+ for (j = 0; j < ictx->num_key_down; j++) {
+ if (ictx->key_down[j] == code)
break;
}
- if(j == num_key_down) { // key was not in the down keys : add it
- if(num_key_down > MP_MAX_KEY_DOWN) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_Err2ManyKeyDowns);
+ if (j == ictx->num_key_down) { // key was not in the down keys : add it
+ if (ictx->num_key_down > MP_MAX_KEY_DOWN) {
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Too many key down events at the same time\n");
return NULL;
}
- key_down[num_key_down] = code;
- num_key_down++;
- last_key_down = 1;
+ ictx->key_down[ictx->num_key_down] = code;
+ ictx->num_key_down++;
+ ictx->last_key_down = 1;
}
// We ignore key from last combination
- ret = last_key_down ? mp_input_get_cmd_from_keys(num_key_down,key_down,paused) : NULL;
+ ret = ictx->last_key_down ?
+ get_cmd_from_keys(ictx, ictx->num_key_down, ictx->key_down, paused)
+ : NULL;
// Remove the key
- if(j+1 < num_key_down)
- memmove(&key_down[j],&key_down[j+1],(num_key_down-(j+1))*sizeof(int));
- num_key_down--;
- last_key_down = 0;
- ar_state = -1;
- if(ar_cmd) {
- mp_cmd_free(ar_cmd);
- ar_cmd = NULL;
+ if (j+1 < ictx->num_key_down)
+ memmove(&ictx->key_down[j], &ictx->key_down[j+1],
+ (ictx->num_key_down-(j+1))*sizeof(int));
+ ictx->num_key_down--;
+ ictx->last_key_down = 0;
+ ictx->ar_state = -1;
+ if (ictx->ar_cmd) {
+ mp_cmd_free(ictx->ar_cmd);
+ ictx->ar_cmd = NULL;
}
return ret;
}
-static mp_cmd_t *check_autorepeat(int paused)
+static mp_cmd_t *check_autorepeat(struct input_ctx *ictx, int paused)
{
// No input : autorepeat ?
- if(ar_rate > 0 && ar_state >=0 && num_key_down > 0 && ! (key_down[num_key_down-1] & MP_NO_REPEAT_KEY)) {
+ if (ictx->ar_rate > 0 && ictx->ar_state >=0 && ictx->num_key_down > 0
+ && !(ictx->key_down[ictx->num_key_down-1] & MP_NO_REPEAT_KEY)) {
unsigned int t = GetTimer();
// First time : wait delay
- if(ar_state == 0 && (t - last_key_down) >= ar_delay*1000) {
- ar_cmd = mp_input_get_cmd_from_keys(num_key_down,key_down,paused);
- if(!ar_cmd) {
- ar_state = -1;
+ if (ictx->ar_state == 0
+ && (t - ictx->last_key_down) >= ictx->ar_delay*1000) {
+ ictx->ar_cmd = get_cmd_from_keys(ictx, ictx->num_key_down,
+ ictx->key_down, paused);
+ if (!ictx->ar_cmd) {
+ ictx->ar_state = -1;
return NULL;
}
- ar_state = 1;
- last_ar = t;
- return mp_cmd_clone(ar_cmd);
+ ictx->ar_state = 1;
+ ictx->last_ar = t;
+ return mp_cmd_clone(ictx->ar_cmd);
// Then send rate / sec event
- } else if(ar_state == 1 && (t -last_ar) >= 1000000/ar_rate) {
- last_ar = t;
- return mp_cmd_clone(ar_cmd);
+ } else if (ictx->ar_state == 1
+ && (t -ictx->last_ar) >= 1000000 / ictx->ar_rate) {
+ ictx->last_ar = t;
+ return mp_cmd_clone(ictx->ar_cmd);
}
}
return NULL;
}
-static mp_cmd_t *read_events(int time, int paused)
+static mp_cmd_t *read_events(struct input_ctx *ictx, int time, int paused)
{
int i;
int got_cmd = 0;
- mp_cmd_t *autorepeat_cmd;
-#ifdef HAVE_POSIX_SELECT
- fd_set fds;
-#endif
- for (i = 0; i < num_key_fd; i++)
+ struct mp_input_fd *key_fds = ictx->key_fds;
+ struct mp_input_fd *cmd_fds = ictx->cmd_fds;
+ for (i = 0; i < ictx->num_key_fd; i++)
if (key_fds[i].dead) {
- mp_input_rm_key_fd(key_fds[i].fd);
+ mp_input_rm_key_fd(ictx, key_fds[i].fd);
i--;
}
- for (i = 0; i < num_cmd_fd; i++)
+ for (i = 0; i < ictx->num_cmd_fd; i++)
if (cmd_fds[i].dead || cmd_fds[i].eof) {
- mp_input_rm_cmd_fd(cmd_fds[i].fd);
+ mp_input_rm_cmd_fd(ictx, cmd_fds[i].fd);
i--;
}
else if (cmd_fds[i].got_cmd)
got_cmd = 1;
#ifdef HAVE_POSIX_SELECT
+ fd_set fds;
FD_ZERO(&fds);
if (!got_cmd) {
int max_fd = 0, num_fd = 0;
- for (i = 0; i < num_key_fd; i++) {
+ for (i = 0; i < ictx->num_key_fd; i++) {
if (key_fds[i].no_select)
continue;
if (key_fds[i].fd > max_fd)
@@ -1230,7 +1220,7 @@ static mp_cmd_t *read_events(int time, int paused)
FD_SET(key_fds[i].fd, &fds);
num_fd++;
}
- for (i = 0; i < num_cmd_fd; i++) {
+ for (i = 0; i < ictx->num_cmd_fd; i++) {
if (cmd_fds[i].no_select)
continue;
if (cmd_fds[i].fd > max_fd)
@@ -1249,7 +1239,7 @@ static mp_cmd_t *read_events(int time, int paused)
time_val = NULL;
if (select(max_fd + 1, &fds, NULL, NULL, time_val) < 0) {
if (errno != EINTR)
- mp_msg(MSGT_INPUT, MSGL_ERR, MSGTR_INPUT_INPUT_ErrSelect,
+ mp_tmsg(MSGT_INPUT, MSGL_ERR, "Select error: %s\n",
strerror(errno));
FD_ZERO(&fds);
}
@@ -1261,58 +1251,47 @@ static mp_cmd_t *read_events(int time, int paused)
#endif
- for (i = 0; i < num_key_fd; i++) {
- int code;
+ for (i = 0; i < ictx->num_key_fd; i++) {
#ifdef HAVE_POSIX_SELECT
if (!key_fds[i].no_select && !FD_ISSET(key_fds[i].fd, &fds))
continue;
#endif
- if (key_fds[i].no_readfunc_retval) { // getch2 handler special-cased for now
- ((void (*)(void))key_fds[i].read_func)();
- if (cmd_queue_length)
- return NULL;
- code = mplayer_get_key(0);
- if (code < 0)
- code = MP_INPUT_NOTHING;
- }
- else
- code = ((mp_key_func_t)key_fds[i].read_func)(key_fds[i].fd);
+ int code = key_fds[i].read_func.key(key_fds[i].ctx, key_fds[i].fd);
if (code >= 0) {
- mp_cmd_t *ret = interpret_key(code, paused);
+ mp_cmd_t *ret = interpret_key(ictx, code, paused);
if (ret)
return ret;
}
else if (code == MP_INPUT_ERROR)
- mp_msg(MSGT_INPUT, MSGL_ERR, MSGTR_INPUT_INPUT_ErrOnKeyInFd,
+ mp_tmsg(MSGT_INPUT, MSGL_ERR, "Error on key input file descriptor %d\n",
key_fds[i].fd);
else if (code == MP_INPUT_DEAD) {
- mp_msg(MSGT_INPUT, MSGL_ERR, MSGTR_INPUT_INPUT_ErrDeadKeyOnFd,
+ mp_tmsg(MSGT_INPUT, MSGL_ERR, "Dead key input on file descriptor %d\n",
key_fds[i].fd);
key_fds[i].dead = 1;
}
}
- autorepeat_cmd = check_autorepeat(paused);
+ mp_cmd_t *autorepeat_cmd = check_autorepeat(ictx, paused);
if (autorepeat_cmd)
return autorepeat_cmd;
- for (i = 0; i < num_cmd_fd; i++) {
- char *cmd;
- int r;
+ for (i = 0; i < ictx->num_cmd_fd; i++) {
#ifdef HAVE_POSIX_SELECT
if (!cmd_fds[i].no_select && !FD_ISSET(cmd_fds[i].fd, &fds) &&
!cmd_fds[i].got_cmd)
continue;
#endif
- r = mp_input_read_cmd(&cmd_fds[i], &cmd);
+ char *cmd;
+ int r = read_cmd(&cmd_fds[i], &cmd);
if (r >= 0) {
mp_cmd_t *ret = mp_input_parse_cmd(cmd);
- free(cmd);
+ talloc_free(cmd);
if (ret)
return ret;
}
else if (r == MP_INPUT_ERROR)
- mp_msg(MSGT_INPUT, MSGL_ERR, MSGTR_INPUT_INPUT_ErrOnCmdFd,
+ mp_tmsg(MSGT_INPUT, MSGL_ERR, "Error on command file descriptor %d\n",
cmd_fds[i].fd);
else if (r == MP_INPUT_DEAD)
cmd_fds[i].dead = 1;
@@ -1322,28 +1301,28 @@ static mp_cmd_t *read_events(int time, int paused)
}
-int
-mp_input_queue_cmd(mp_cmd_t* cmd) {
- if(!cmd || cmd_queue_length >= CMD_QUEUE_SIZE)
+int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t* cmd)
+{
+ if (!cmd || ictx->cmd_queue_length >= CMD_QUEUE_SIZE)
return 0;
- cmd_queue[cmd_queue_end] = cmd;
- cmd_queue_end = (cmd_queue_end + 1) % CMD_QUEUE_SIZE;
- cmd_queue_length++;
+ ictx->cmd_queue[ictx->cmd_queue_end] = cmd;
+ ictx->cmd_queue_end = (ictx->cmd_queue_end + 1) % CMD_QUEUE_SIZE;
+ ictx->cmd_queue_length++;
return 1;
}
-static mp_cmd_t*
-mp_input_get_queued_cmd(int peek_only) {
+static mp_cmd_t *get_queued_cmd(struct input_ctx *ictx, int peek_only)
+{
mp_cmd_t* ret;
- if(cmd_queue_length == 0)
+ if (ictx->cmd_queue_length == 0)
return NULL;
- ret = cmd_queue[cmd_queue_start];
+ ret = ictx->cmd_queue[ictx->cmd_queue_start];
if (!peek_only) {
- cmd_queue_length--;
- cmd_queue_start = (cmd_queue_start + 1) % CMD_QUEUE_SIZE;
+ ictx->cmd_queue_length--;
+ ictx->cmd_queue_start = (ictx->cmd_queue_start + 1) % CMD_QUEUE_SIZE;
}
return ret;
@@ -1353,8 +1332,9 @@ mp_input_get_queued_cmd(int peek_only) {
* \param peek_only when set, the returned command stays in the queue.
* Do not free the returned cmd whe you set this!
*/
-mp_cmd_t*
-mp_input_get_cmd(int time, int paused, int peek_only) {
+mp_cmd_t *mp_input_get_cmd(struct input_ctx *ictx, int time, int paused,
+ int peek_only)
+{
mp_cmd_t* ret = NULL;
mp_cmd_filter_t* cf;
int from_queue;
@@ -1363,13 +1343,13 @@ mp_input_get_cmd(int time, int paused, int peek_only) {
return mp_input_parse_cmd("quit 1");
while(1) {
from_queue = 1;
- ret = mp_input_get_queued_cmd(peek_only);
+ ret = get_queued_cmd(ictx, peek_only);
if(ret) break;
from_queue = 0;
- ret = read_events(time, paused);
+ ret = read_events(ictx, time, paused);
if (!ret) {
from_queue = 1;
- ret = mp_input_get_queued_cmd(peek_only);
+ ret = get_queued_cmd(ictx, peek_only);
}
break;
}
@@ -1379,34 +1359,21 @@ mp_input_get_cmd(int time, int paused, int peek_only) {
if(cf->filter(ret,paused,cf->ctx)) {
if (peek_only && from_queue)
// The filter ate the cmd, so we remove it from queue
- ret = mp_input_get_queued_cmd(0);
+ ret = get_queued_cmd(ictx, 0);
mp_cmd_free(ret);
return NULL;
}
}
if (!from_queue && peek_only)
- mp_input_queue_cmd(ret);
+ mp_input_queue_cmd(ictx, ret);
return ret;
}
void
mp_cmd_free(mp_cmd_t* cmd) {
- int i;
-//#ifdef MP_DEBUG
-// assert(cmd != NULL);
-//#endif
- if ( !cmd ) return;
-
- if(cmd->name)
- free(cmd->name);
-
- for(i=0; i < MP_CMD_MAX_ARGS && cmd->args[i].type != -1; i++) {
- if(cmd->args[i].type == MP_CMD_ARG_STRING && cmd->args[i].v.s != NULL)
- free(cmd->args[i].v.s);
- }
- free(cmd);
+ talloc_free(cmd);
}
mp_cmd_t*
@@ -1417,22 +1384,18 @@ mp_cmd_clone(mp_cmd_t* cmd) {
assert(cmd != NULL);
#endif
- ret = malloc(sizeof(mp_cmd_t));
- memcpy(ret,cmd,sizeof(mp_cmd_t));
- if(cmd->name)
- ret->name = strdup(cmd->name);
+ ret = talloc_memdup(NULL, cmd, sizeof(mp_cmd_t));
+ ret->name = talloc_strdup(ret, cmd->name);
for(i = 0; i < MP_CMD_MAX_ARGS && cmd->args[i].type != -1; i++) {
if(cmd->args[i].type == MP_CMD_ARG_STRING && cmd->args[i].v.s != NULL)
- ret->args[i].v.s = strdup(cmd->args[i].v.s);
+ ret->args[i].v.s = talloc_strdup(ret, cmd->args[i].v.s);
}
return ret;
}
-static char key_str[12];
-
-static char*
-mp_input_get_key_name(int key) {
+static char *get_key_name(int key, char buffer[12])
+{
int i;
for(i = 0; key_names[i].name != NULL; i++) {
@@ -1441,13 +1404,13 @@ mp_input_get_key_name(int key) {
}
if(isascii(key)) {
- snprintf(key_str,12,"%c",(char)key);
- return key_str;
+ snprintf(buffer, 12, "%c",(char)key);
+ return buffer;
}
// Print the hex key code
- snprintf(key_str,12,"%#-8x",key);
- return key_str;
+ snprintf(buffer, 12, "%#-8x",key);
+ return buffer;
}
@@ -1468,8 +1431,7 @@ mp_input_get_key_from_name(const char *name) {
return -1;
}
-static int
-mp_input_get_input_from_name(char* name,int* keys) {
+static int get_input_from_name(char* name,int* keys) {
char *end,*ptr;
int n=0;
@@ -1498,8 +1460,9 @@ mp_input_get_input_from_name(char* name,int* keys) {
#define BS_MAX 256
#define SPACE_CHAR " \n\r\t"
-void
-mp_input_bind_keys(const int keys[MP_MAX_KEY_DOWN+1], char* cmd) {
+static void bind_keys(struct input_ctx *ictx,
+ const int keys[MP_MAX_KEY_DOWN+1], char *cmd)
+{
int i = 0,j;
mp_cmd_bind_t* bind = NULL;
mp_cmd_bind_section_t* bind_section = NULL;
@@ -1518,7 +1481,7 @@ mp_input_bind_keys(const int keys[MP_MAX_KEY_DOWN+1], char* cmd) {
for( ; cmd[0] != '\0' && strchr(SPACE_CHAR,cmd[0]) != NULL ; cmd++)
/* NOTHING */;
}
- bind_section=mp_input_get_bind_section(section);
+ bind_section = get_bind_section(ictx, section);
if(bind_section->cmd_binds) {
for(i = 0; bind_section->cmd_binds[i].cmd != NULL ; i++) {
@@ -1532,39 +1495,27 @@ mp_input_bind_keys(const int keys[MP_MAX_KEY_DOWN+1], char* cmd) {
}
if(!bind) {
- bind_section->cmd_binds = realloc(bind_section->cmd_binds,(i+2)*sizeof(mp_cmd_bind_t));
+ bind_section->cmd_binds = talloc_realloc(bind_section,
+ bind_section->cmd_binds,
+ mp_cmd_bind_t, i + 2);
memset(&bind_section->cmd_binds[i],0,2*sizeof(mp_cmd_bind_t));
bind = &bind_section->cmd_binds[i];
}
if(bind->cmd)
- free(bind->cmd);
- bind->cmd = strdup(cmd);
+ talloc_free(bind->cmd);
+ bind->cmd = talloc_strdup(bind_section->cmd_binds, cmd);
memcpy(bind->input,keys,(MP_MAX_KEY_DOWN+1)*sizeof(int));
}
-void
-mp_input_add_binds(const mp_cmd_bind_t* list) {
+static void add_binds(struct input_ctx *ictx, const mp_cmd_bind_t* list)
+{
int i;
for(i = 0 ; list[i].cmd ; i++)
- mp_input_bind_keys(list[i].input,list[i].cmd);
+ bind_keys(ictx, list[i].input,list[i].cmd);
}
-static void
-mp_input_free_binds(mp_cmd_bind_t* binds) {
- int i;
-
- if(!binds)
- return;
-
- for(i = 0; binds[i].cmd != NULL; i++)
- free(binds[i].cmd);
-
- free(binds);
-
-}
-
-static int
-mp_input_parse_config(char *file) {
+static int parse_config(struct input_ctx *ictx, char *file)
+{
int fd;
int bs = 0,r,eof = 0,comments = 0;
char *iter,*end;
@@ -1587,7 +1538,7 @@ mp_input_parse_config(char *file) {
if(r < 0) {
if(errno == EINTR)
continue;
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrReadingInputConfig,file,strerror(errno));
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Error while reading input config file %s: %s\n",file,strerror(errno));
close(fd);
return 0;
} else if(r == 0) {
@@ -1640,9 +1591,9 @@ mp_input_parse_config(char *file) {
if(end[0] == '\0') { // Key name doesn't fit in the buffer
if(buffer == iter) {
if(eof && (buffer-iter) == bs)
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrUnfinishedBinding,iter);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Unfinished binding %s\n",iter);
else
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrBuffer2SmallForKeyName,iter);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Buffer is too small for this key name: %s\n",iter);
return 0;
}
memmove(buffer,iter,end-iter);
@@ -1653,8 +1604,8 @@ mp_input_parse_config(char *file) {
char name[end-iter+1];
strncpy(name,iter,end-iter);
name[end-iter] = '\0';
- if(! mp_input_get_input_from_name(name,keys)) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrUnknownKey,name);
+ if (!get_input_from_name(name,keys)) {
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Unknown key '%s'\n",name);
close(fd);
return 0;
}
@@ -1668,10 +1619,11 @@ mp_input_parse_config(char *file) {
// Found new line
if(iter[0] == '\n' || iter[0] == '\r') {
int i;
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrNoCmdForKey,mp_input_get_key_name(keys[0]));
+ char key_buf[12];
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"No command found for key %s", get_key_name(keys[0], key_buf));
for(i = 1; keys[i] != 0 ; i++)
- mp_msg(MSGT_INPUT,MSGL_ERR,"-%s",mp_input_get_key_name(keys[i]));
- mp_msg(MSGT_INPUT,MSGL_ERR,"\n");
+ mp_msg(MSGT_INPUT,MSGL_ERR,"-%s", get_key_name(keys[i], key_buf));
+ mp_msg(MSGT_INPUT,MSGL_ERR,"\n");
keys[0] = 0;
if(iter > buffer) {
memmove(buffer,iter,bs- (iter-buffer));
@@ -1683,7 +1635,7 @@ mp_input_parse_config(char *file) {
/* NOTHING */;
if(end[0] == '\0' && ! (eof && ((end+1) - buffer) == bs)) {
if(iter == buffer) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrBuffer2SmallForCmd,buffer);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Buffer is too small for command %s\n",buffer);
close(fd);
return 0;
}
@@ -1696,7 +1648,7 @@ mp_input_parse_config(char *file) {
strncpy(cmd,iter,end-iter);
cmd[end-iter] = '\0';
//printf("Set bind %d => %s\n",keys[0],cmd);
- mp_input_bind_keys(keys,cmd);
+ bind_keys(ictx, keys,cmd);
n_binds++;
}
keys[0] = 0;
@@ -1708,46 +1660,60 @@ mp_input_parse_config(char *file) {
continue;
}
}
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrWhyHere);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"What are we doing here?\n");
close(fd);
- mp_input_set_section(NULL);
+ mp_input_set_section(ictx, NULL);
return 0;
}
-void
-mp_input_set_section(char *name) {
- mp_cmd_bind_section_t* bind_section = NULL;
-
- cmd_binds=NULL;
- cmd_binds_default=NULL;
- if(section) free(section);
- if(name) section=strdup(name); else section=strdup("default");
- if((bind_section=mp_input_get_bind_section(section)))
- cmd_binds=bind_section->cmd_binds;
- if(strcmp(section,"default")==0) return;
- if((bind_section=mp_input_get_bind_section(NULL)))
- cmd_binds_default=bind_section->cmd_binds;
+void mp_input_set_section(struct input_ctx *ictx, char *name)
+{
+ mp_cmd_bind_section_t* bind_section = NULL;
+
+ ictx->cmd_binds = NULL;
+ ictx->cmd_binds_default = NULL;
+ if (ictx->section)
+ talloc_free(ictx->section);
+ if (name)
+ ictx->section = talloc_strdup(ictx, name);
+ else
+ ictx->section = talloc_strdup(ictx, "default");
+ if ((bind_section = get_bind_section(ictx, ictx->section)))
+ ictx->cmd_binds = bind_section->cmd_binds;
+ if (strcmp(ictx->section, "default") == 0)
+ return;
+ if ((bind_section = get_bind_section(ictx, NULL)))
+ ictx->cmd_binds_default = bind_section->cmd_binds;
}
-char*
-mp_input_get_section(void) {
- return section;
+char *mp_input_get_section(struct input_ctx *ictx)
+{
+ return ictx->section;
}
-void
-mp_input_init(int use_gui) {
+struct input_ctx *mp_input_init(struct input_conf *input_conf, int use_gui)
+{
+ struct input_ctx *ictx = talloc_ptrtype(NULL, ictx);
+ *ictx = (struct input_ctx){
+ .ar_state = -1,
+ .ar_delay = input_conf->ar_delay,
+ .ar_rate = input_conf->ar_rate,
+ .default_bindings = input_conf->default_bindings,
+ };
+
char* file;
#ifdef CONFIG_GUI
if(use_gui)
- mp_input_add_binds(gui_def_cmd_binds);
+ add_binds(ictx, gui_def_cmd_binds);
#endif
+ char *config_file = input_conf->config_file;
file = config_file[0] != '/' ? get_path(config_file) : config_file;
if(!file)
- return;
+ return ictx;
- if( !mp_input_parse_config(file)) {
+ if (!parse_config(ictx, file)) {
// free file if it was allocated by get_path(),
// before it gets overwritten
if( file != config_file)
@@ -1756,7 +1722,7 @@ mp_input_init(int use_gui) {
}
// Try global conf dir
file = MPLAYER_CONFDIR "/input.conf";
- if(! mp_input_parse_config(file))
+ if (!parse_config(ictx, file))
mp_msg(MSGT_INPUT,MSGL_V,"Falling back on default (hardcoded) input config\n");
}
else
@@ -1767,87 +1733,89 @@ mp_input_init(int use_gui) {
}
#ifdef CONFIG_JOYSTICK
- if(use_joystick) {
- int fd = mp_input_joystick_init(js_dev);
+ if (input_conf->use_joystick) {
+ int fd = mp_input_joystick_init(input_conf->js_dev);
if(fd < 0)
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantInitJoystick);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Can't init input joystick\n");
else
- mp_input_add_key_fd(fd,1,mp_input_joystick_read,(mp_close_func_t)close);
+ mp_input_add_key_fd(ictx, fd, 1, mp_input_joystick_read,
+ (mp_close_func_t)close,NULL);
}
#endif
#ifdef CONFIG_LIRC
- if(use_lirc) {
+ if (input_conf->use_lirc) {
int fd = mp_input_lirc_init();
if(fd > 0)
- mp_input_add_cmd_fd(fd,0,mp_input_lirc_read,mp_input_lirc_close);
+ mp_input_add_cmd_fd(ictx, fd, 0, mp_input_lirc_read,
+ mp_input_lirc_close);
}
#endif
#ifdef CONFIG_LIRCC
- if(use_lircc) {
+ if (input_conf->use_lircc) {
int fd = lircc_init("mplayer", NULL);
if(fd >= 0)
- mp_input_add_cmd_fd(fd,1,NULL,(mp_close_func_t)lircc_cleanup);
+ mp_input_add_cmd_fd(ictx, fd, 1, NULL, (mp_close_func_t)lircc_cleanup);
}
#endif
#ifdef CONFIG_APPLE_REMOTE
- if(use_ar) {
+ if (input_conf->use_ar) {
if(mp_input_ar_init() < 0)
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantInitAppleRemote);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Can't init Apple Remote.\n");
else
- mp_input_add_key_fd(-1,0,mp_input_ar_read,mp_input_ar_close);
+ mp_input_add_key_fd(ictx, -1, 0, mp_input_ar_read, mp_input_ar_close,
+ NULL);
}
#endif
#ifdef CONFIG_APPLE_IR
- if(use_ar) {
- int fd = mp_input_appleir_init(ar_dev);
+ if (input_conf->use_ar) {
+ int fd = mp_input_appleir_init(input_conf->ar_dev);
if(fd < 0)
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantInitAppleRemote);
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Can't init Apple Remote.\n");
else
- mp_input_add_key_fd(fd,1,mp_input_appleir_read,(mp_close_func_t)close);
+ mp_input_add_key_fd(ictx, fd, 1, mp_input_appleir_read,
+ (mp_close_func_t)close, NULL);
}
#endif
- if(in_file) {
+ if (input_conf->in_file) {
struct stat st;
- if(stat(in_file,&st))
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantStatFile,in_file,strerror(errno));
+ if (stat(input_conf->in_file, &st))
+ mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't stat %s: %s\n", input_conf->in_file, strerror(errno));
else {
- in_file_fd = open(in_file,S_ISFIFO(st.st_mode) ? O_RDWR : O_RDONLY);
+ int in_file_fd = open(input_conf->in_file,
+ S_ISFIFO(st.st_mode) ? O_RDWR : O_RDONLY);
if(in_file_fd >= 0)
- mp_input_add_cmd_fd(in_file_fd,1,NULL,(mp_close_func_t)close);
+ mp_input_add_cmd_fd(ictx, in_file_fd, 1, NULL,
+ (mp_close_func_t)close);
else
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantOpenFile,in_file,strerror(errno));
+ mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't open %s: %s\n",
+ input_conf->in_file, strerror(errno));
}
}
-
+ return ictx;
}
-void
-mp_input_uninit(void) {
+void mp_input_uninit(struct input_ctx *ictx)
+{
+ if (!ictx)
+ return;
+
unsigned int i;
- mp_cmd_bind_section_t* bind_section;
- for(i=0; i < num_key_fd; i++) {
- if(key_fds[i].close_func)
- key_fds[i].close_func(key_fds[i].fd);
+ for (i=0; i < ictx->num_key_fd; i++) {
+ if (ictx->key_fds[i].close_func)
+ ictx->key_fds[i].close_func(ictx->key_fds[i].fd);
}
- for(i=0; i < num_cmd_fd; i++) {
- if(cmd_fds[i].close_func)
- cmd_fds[i].close_func(cmd_fds[i].fd);
- }
- while (cmd_binds_section) {
- mp_input_free_binds(cmd_binds_section->cmd_binds);
- free(cmd_binds_section->section);
- bind_section=cmd_binds_section->next;
- free(cmd_binds_section);
- cmd_binds_section=bind_section;
+ for (i = 0; i < ictx->num_cmd_fd; i++) {
+ if (ictx->cmd_fds[i].close_func)
+ ictx->cmd_fds[i].close_func(ictx->cmd_fds[i].fd);
}
- cmd_binds_section=NULL;
+ talloc_free(ictx);
}
void
@@ -1855,7 +1823,8 @@ mp_input_register_options(m_config_t* cfg) {
m_config_register_options(cfg,mp_input_opts);
}
-static int mp_input_print_key_list(m_option_t* cfg) {
+static int print_key_list(m_option_t* cfg)
+{
int i;
printf("\n");
for(i= 0; key_names[i].name != NULL ; i++)
@@ -1863,7 +1832,8 @@ static int mp_input_print_key_list(m_option_t* cfg) {
exit(0);
}
-static int mp_input_print_cmd_list(m_option_t* cfg) {
+static int print_cmd_list(m_option_t* cfg)
+{
const mp_cmd_t *cmd;
int i,j;
const char* type;
@@ -1894,10 +1864,10 @@ static int mp_input_print_cmd_list(m_option_t* cfg) {
exit(0);
}
-int
-mp_input_check_interrupt(int time) {
+int mp_input_check_interrupt(struct input_ctx *ictx, int time)
+{
mp_cmd_t* cmd;
- if((cmd = mp_input_get_cmd(time,0,1)) == NULL)
+ if ((cmd = mp_input_get_cmd(ictx, time, 0, 1)) == NULL)
return 0;
switch(cmd->id) {
case MP_CMD_QUIT:
@@ -1908,7 +1878,7 @@ mp_input_check_interrupt(int time) {
return 1;
}
// remove the cmd from the queue
- cmd = mp_input_get_cmd(time,0,0);
+ cmd = mp_input_get_cmd(ictx, time, 0, 0);
mp_cmd_free(cmd);
return 0;
}
diff --git a/input/input.h b/input/input.h
index 12a56c8509..69ed394ff2 100644
--- a/input/input.h
+++ b/input/input.h
@@ -193,6 +193,8 @@ typedef enum {
#define MP_MAX_KEY_DOWN 32
#endif
+struct input_ctx;
+
typedef union mp_cmd_arg_value {
int i;
float f;
@@ -214,21 +216,11 @@ typedef struct mp_cmd {
} mp_cmd_t;
-typedef struct mp_cmd_bind {
- int input[MP_MAX_KEY_DOWN+1];
- char* cmd;
-} mp_cmd_bind_t;
-
-typedef struct mp_key_name {
- int key;
- char* name;
-} mp_key_name_t;
-
// These typedefs are for the drivers. They are the functions used to retrieve
// the next key code or command.
// These functions should return the key code or one of the error codes
-typedef int (*mp_key_func_t)(int fd);
+typedef int (*mp_key_func_t)(void *ctx, int fd);
// These functions should act like read but they must use our error code (if needed ;-)
typedef int (*mp_cmd_func_t)(int fd,char* dest,int size);
// These are used to close the driver
@@ -246,25 +238,20 @@ typedef int (*mp_input_cmd_filter)(mp_cmd_t* cmd, int paused, void* ctx);
// fd will be used.
// The last arg can be NULL if nothing is needed to close the driver. The close
// function can be used
-int
-mp_input_add_cmd_fd(int fd, int select, mp_cmd_func_t read_func, mp_close_func_t close_func);
+int mp_input_add_cmd_fd(struct input_ctx *ictx, int fd, int select,
+ mp_cmd_func_t read_func, mp_close_func_t close_func);
// This removes a cmd driver, you usually don't need to use it.
-void
-mp_input_rm_cmd_fd(int fd);
+void mp_input_rm_cmd_fd(struct input_ctx *ictx, int fd);
// The args are the same as for the key's drivers. If you don't use any valid fd you MUST
// give a read_func.
-int
-mp_input_add_key_fd(int fd, int select, mp_key_func_t read_func, mp_close_func_t close_func);
+int mp_input_add_key_fd(struct input_ctx *ictx, int fd, int select,
+ mp_key_func_t read_func, mp_close_func_t close_func,
+ void *ctx);
// As for the cmd one you usually don't need this function.
-void
-mp_input_rm_key_fd(int fd);
-
-int mp_input_add_event_fd(int fd, void (*read_func)(void));
-
-void mp_input_rm_event_fd(int fd);
+void mp_input_rm_key_fd(struct input_ctx *ictx, int fd);
/// Get input key from its name.
int mp_input_get_key_from_name(const char *name);
@@ -272,13 +259,12 @@ int mp_input_get_key_from_name(const char *name);
// This function can be used to put a command in the system again. It's used by libmpdemux
// when it performs a blocking operation to resend the command it received to the main
// loop.
-int
-mp_input_queue_cmd(mp_cmd_t* cmd);
+int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t* cmd);
// This function retrieves the next available command waiting no more than time msec.
// If pause is true, the next input will always return a pause command.
mp_cmd_t*
-mp_input_get_cmd(int time, int paused, int peek_only);
+mp_input_get_cmd(struct input_ctx *ictx, int time, int paused, int peek_only);
mp_cmd_t*
mp_input_parse_cmd(char* str);
@@ -287,7 +273,7 @@ mp_input_parse_cmd(char* str);
* Parse and queue commands separated by '\n'.
* @return count of commands new queued.
*/
-int mp_input_parse_and_queue_cmds(const char *str);
+int mp_input_parse_and_queue_cmds(struct input_ctx *ictx, const char *str);
/// These filters allow you to process the command before MPlayer.
/// If a filter returns a true value mp_input_get_cmd will return NULL.
@@ -304,23 +290,23 @@ mp_cmd_t*
mp_cmd_clone(mp_cmd_t* cmd);
// Set current input section
-void
-mp_input_set_section(char *name);
+void mp_input_set_section(struct input_ctx *ictx, char *name);
// Get current input section
-char*
-mp_input_get_section(void);
+char *mp_input_get_section(struct input_ctx *ictx);
// When you create a new driver you should add it in these 2 functions.
-void
-mp_input_init(int use_gui);
+struct input_conf;
+struct input_ctx *mp_input_init(struct input_conf *input_conf, int use_gui);
-void
-mp_input_uninit(void);
+void mp_input_uninit(struct input_ctx *ictx);
+
+struct m_config;
+void mp_input_register_options(struct m_config *cfg);
// Interruptible usleep: (used by libmpdemux)
int
-mp_input_check_interrupt(int time);
+mp_input_check_interrupt(struct input_ctx *ictx, int time);
extern int async_quit_request;
diff --git a/input/joystick.c b/input/joystick.c
index 4549a1bd9c..4a63c14fae 100644
--- a/input/joystick.c
+++ b/input/joystick.c
@@ -51,11 +51,11 @@ int mp_input_joystick_init(char* dev) {
int initialized = 0;
struct js_event ev;
- mp_msg(MSGT_INPUT,MSGL_V,MSGTR_INPUT_JOYSTICK_Opening,dev ? dev : JS_DEV);
+ mp_tmsg(MSGT_INPUT,MSGL_V,"Opening joystick device %s\n",dev ? dev : JS_DEV);
fd = open( dev ? dev : JS_DEV , O_RDONLY | O_NONBLOCK );
if(fd < 0) {
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_JOYSTICK_CantOpen,dev ? dev : JS_DEV,strerror(errno));
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Can't open joystick device %s: %s\n",dev ? dev : JS_DEV,strerror(errno));
return -1;
}
@@ -70,7 +70,7 @@ int mp_input_joystick_init(char* dev) {
initialized = 1;
break;
}
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_JOYSTICK_ErrReading,strerror(errno));
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Error while reading joystick device: %s\n",strerror(errno));
close(fd);
return -1;
}
@@ -78,7 +78,7 @@ int mp_input_joystick_init(char* dev) {
}
if((unsigned int)l < sizeof(struct js_event)) {
if(l > 0)
- mp_msg(MSGT_INPUT,MSGL_WARN,MSGTR_INPUT_JOYSTICK_LoosingBytes,l);
+ mp_tmsg(MSGT_INPUT,MSGL_WARN,"Joystick: We lose %d bytes of data\n",l);
break;
}
if(ev.type == JS_EVENT_BUTTON)
@@ -90,7 +90,7 @@ int mp_input_joystick_init(char* dev) {
return fd;
}
-int mp_input_joystick_read(int fd) {
+int mp_input_joystick_read(void *ctx, int fd) {
struct js_event ev;
int l=0;
@@ -102,9 +102,9 @@ int mp_input_joystick_read(int fd) {
else if(errno == EAGAIN)
return MP_INPUT_NOTHING;
if( r < 0)
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_JOYSTICK_ErrReading,strerror(errno));
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Error while reading joystick device: %s\n",strerror(errno));
else
- mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_JOYSTICK_ErrReading,"EOF");
+ mp_tmsg(MSGT_INPUT,MSGL_ERR,"Error while reading joystick device: %s\n","EOF");
return MP_INPUT_DEAD;
}
l += r;
@@ -112,12 +112,12 @@ int mp_input_joystick_read(int fd) {
if((unsigned int)l < sizeof(struct js_event)) {
if(l > 0)
- mp_msg(MSGT_INPUT,MSGL_WARN,MSGTR_INPUT_JOYSTICK_LoosingBytes,l);
+ mp_tmsg(MSGT_INPUT,MSGL_WARN,"Joystick: We lose %d bytes of data\n",l);
return MP_INPUT_NOTHING;
}
if(ev.type & JS_EVENT_INIT) {
- mp_msg(MSGT_INPUT,MSGL_WARN,MSGTR_INPUT_JOYSTICK_WarnLostSync);
+ mp_tmsg(MSGT_INPUT,MSGL_WARN,"Joystick: warning init event, we have lost sync with driver.\n");
ev.type &= ~JS_EVENT_INIT;
if(ev.type == JS_EVENT_BUTTON) {
int s = (btns >> ev.number) & 1;
@@ -154,7 +154,7 @@ int mp_input_joystick_read(int fd) {
} else
return MP_INPUT_NOTHING;
} else {
- mp_msg(MSGT_INPUT,MSGL_WARN,MSGTR_INPUT_JOYSTICK_WarnUnknownEvent,ev.type);
+ mp_tmsg(MSGT_INPUT,MSGL_WARN,"Joystick warning unknown event type %d\n",ev.type);
return MP_INPUT_ERROR;
}
diff --git a/input/joystick.h b/input/joystick.h
index dbb269035f..996f0fed21 100644
--- a/input/joystick.h
+++ b/input/joystick.h
@@ -55,6 +55,6 @@
int mp_input_joystick_init(char* dev);
-int mp_input_joystick_read(int fd);
+int mp_input_joystick_read(void *ctx, int fd);
#endif /* MPLAYER_JOYSTICK_H */
diff --git a/input/lirc.c b/input/lirc.c
index d7fb95d7f8..1e3708a3f4 100644
--- a/input/lirc.c
+++ b/input/lirc.c
@@ -40,9 +40,9 @@ mp_input_lirc_init(void) {
int lirc_sock;
int mode;
- mp_msg(MSGT_LIRC,MSGL_V,MSGTR_SettingUpLIRC);
+ mp_tmsg(MSGT_LIRC,MSGL_V,"Setting up LIRC support...\n");
if((lirc_sock=lirc_init("mplayer",1))==-1){
- mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCopenfailed);
+ mp_tmsg(MSGT_LIRC,MSGL_ERR,"Failed to open LIRC support. You will not be able to use your remote control.\n");
return -1;
}
@@ -55,7 +55,7 @@ mp_input_lirc_init(void) {
}
if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){
- mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCcfgerr,
+ mp_tmsg(MSGT_LIRC,MSGL_ERR,"Failed to read LIRC config file %s.\n",
lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile);
lirc_deinit();
return -1;
diff --git a/libaf/af.h b/libaf/af.h
index aaf9b730e8..de70fcf77c 100644
--- a/libaf/af.h
+++ b/libaf/af.h
@@ -117,7 +117,7 @@ typedef struct af_cfg_s{
}af_cfg_t;
// Current audio stream
-typedef struct af_stream_s
+typedef struct af_stream
{
// The first and last filter in the list
af_instance_t* first;
diff --git a/libaf/af_delay.c b/libaf/af_delay.c
index 02327d0c53..84a76c470e 100644
--- a/libaf/af_delay.c
+++ b/libaf/af_delay.c
@@ -202,5 +202,3 @@ af_info_t af_info_delay = {
AF_FLAGS_REENTRANT,
af_open
};
-
-
diff --git a/libaf/af_equalizer.c b/libaf/af_equalizer.c
index cdc0011cb7..bd69fdec9d 100644
--- a/libaf/af_equalizer.c
+++ b/libaf/af_equalizer.c
@@ -248,10 +248,3 @@ af_info_t af_info_equalizer = {
AF_FLAGS_NOT_REENTRANT,
af_open
};
-
-
-
-
-
-
-
diff --git a/libaf/af_ladspa.c b/libaf/af_ladspa.c
index e343d1ded7..78a9be26d1 100644
--- a/libaf/af_ladspa.c
+++ b/libaf/af_ladspa.c
@@ -213,7 +213,7 @@ static int af_ladspa_parse_plugin(af_ladspa_t *setup) {
if (setup->ninputs == 0) {
mp_msg(MSGT_AFILTER, MSGL_WARN, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_WarnNoInputs);
+ _("WARNING! This LADSPA plugin has no audio inputs.\n The incoming audio signal will be lost."));
} else if (setup->ninputs == 1) {
mp_msg(MSGT_AFILTER, MSGL_V, "%s: this is a mono effect\n", setup->myname);
} else if (setup->ninputs == 2) {
@@ -225,13 +225,13 @@ static int af_ladspa_parse_plugin(af_ladspa_t *setup) {
if (setup->noutputs == 0) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrNoOutputs);
+ _("This LADSPA plugin has no audio outputs."));
return AF_ERROR;
}
if (setup->noutputs != setup->ninputs ) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrInOutDiff);
+ _("The number of audio inputs and audio outputs of the LADSPA plugin differ."));
return AF_ERROR;
}
@@ -391,7 +391,7 @@ static int af_ladspa_load_plugin(af_ladspa_t *setup) {
if (!setup->libhandle) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s %s\n\t%s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrFailedToLoad, setup->file, dlerror() );
+ _("failed to load"), setup->file, dlerror() );
return AF_ERROR;
}
@@ -404,7 +404,7 @@ static int af_ladspa_load_plugin(af_ladspa_t *setup) {
if (!descriptor_function) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n\t%s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrNoDescriptor, dlerror());
+ _("Couldn't find ladspa_descriptor() function in the specified library file."), dlerror());
return AF_ERROR;
}
@@ -412,7 +412,7 @@ static int af_ladspa_load_plugin(af_ladspa_t *setup) {
if (strcmp(setup->label, "help") == 0) {
mp_msg(MSGT_AFILTER, MSGL_INFO, "%s: %s %s:\n", setup->myname,
- MSGTR_AF_LADSPA_AvailableLabels, setup->file);
+ _("available labels in"), setup->file);
for (i=0; ; i++) {
ladspa_descriptor = descriptor_function(i);
if (ladspa_descriptor == NULL) {
@@ -432,7 +432,7 @@ static int af_ladspa_load_plugin(af_ladspa_t *setup) {
ladspa_descriptor = descriptor_function(i);
if (ladspa_descriptor == NULL) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrLabelNotFound);
+ _("Couldn't find label in plugin library."));
return AF_ERROR;
}
if (strcmp(ladspa_descriptor->Label, setup->label) == 0) {
@@ -458,7 +458,7 @@ static int af_ladspa_load_plugin(af_ladspa_t *setup) {
*/
static int af_ladspa_malloc_failed(char *myname) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s", myname, MSGTR_MemAllocFailed);
+ mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s", myname, "Memory allocation failed.\n");
return AF_ERROR;
}
@@ -520,7 +520,7 @@ static int control(struct af_instance_s *af, int cmd, void *arg) {
if (!arg) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrNoSuboptions);
+ _("No suboptions specified."));
return AF_ERROR;
}
@@ -532,7 +532,7 @@ static int control(struct af_instance_s *af, int cmd, void *arg) {
sscanf(arg, "%[^:]", buf);
if (buf[0] == '\0') {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrNoLibFile);
+ _("No library file specified."));
free(buf);
return AF_ERROR;
}
@@ -548,7 +548,7 @@ static int control(struct af_instance_s *af, int cmd, void *arg) {
sscanf(arg, "%[^:]", buf);
if (buf[0] == '\0') {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrNoLabel);
+ _("No filter label specified."));
free(buf);
return AF_ERROR;
}
@@ -584,14 +584,14 @@ static int control(struct af_instance_s *af, int cmd, void *arg) {
for(i=0; i<setup->ninputcontrols; i++) {
if (!arg || (*(char*)arg != ':') ) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrNotEnoughControls);
+ _("Not enough controls specified on the command line."));
return AF_ERROR;
}
arg++;
r = sscanf(arg, "%f", &val);
if (r!=1) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
- MSGTR_AF_LADSPA_ErrNotEnoughControls);
+ _("Not enough controls specified on the command line."));
return AF_ERROR;
}
setup->inputcontrols[setup->inputcontrolsmap[i]] = val;
@@ -617,13 +617,13 @@ static int control(struct af_instance_s *af, int cmd, void *arg) {
if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) &&
val < hint.LowerBound) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_AF_LADSPA_ErrControlBelow,
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "%s: Input control #%d is below lower boundary of %0.4f.\n",
setup->myname, i, hint.LowerBound);
return AF_ERROR;
}
if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) &&
val > hint.UpperBound) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_AF_LADSPA_ErrControlAbove,
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "%s: Input control #%d is above upper boundary of %0.4f.\n",
setup->myname, i, hint.UpperBound);
return AF_ERROR;
}
diff --git a/libaf/af_lavcac3enc.c b/libaf/af_lavcac3enc.c
index 36a19dad60..761debec01 100644
--- a/libaf/af_lavcac3enc.c
+++ b/libaf/af_lavcac3enc.c
@@ -98,7 +98,7 @@ static int control(struct af_instance_s *af, int cmd, void *arg)
s->lavc_actx->bit_rate = bit_rate;
if(avcodec_open(s->lavc_actx, s->lavc_acodec) < 0) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_CouldntOpenCodec, "ac3", bit_rate);
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Couldn't open codec %s, br=%d.\n", "ac3", bit_rate);
return AF_ERROR;
}
}
@@ -295,13 +295,13 @@ static int af_open(af_instance_t* af){
s->lavc_acodec = avcodec_find_encoder_by_name("ac3");
if (!s->lavc_acodec) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_LavcAudioCodecNotFound, "ac3");
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Audio LAVC, couldn't find encoder for codec %s.\n", "ac3");
return AF_ERROR;
}
s->lavc_actx = avcodec_alloc_context();
if (!s->lavc_actx) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_CouldntAllocateLavcContext);
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Audio LAVC, couldn't allocate context!\n");
return AF_ERROR;
}
diff --git a/libaf/af_resample.c b/libaf/af_resample.c
index ac39f36faf..5dd0e70329 100644
--- a/libaf/af_resample.c
+++ b/libaf/af_resample.c
@@ -393,4 +393,3 @@ af_info_t af_info_resample = {
AF_FLAGS_REENTRANT,
af_open
};
-
diff --git a/libaf/af_scaletempo.c b/libaf/af_scaletempo.c
index 8b39290efa..a7926712cb 100644
--- a/libaf/af_scaletempo.c
+++ b/libaf/af_scaletempo.c
@@ -470,26 +470,26 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
return AF_ERROR;
}
if (s->scale_nominal <= 0) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
- MSGTR_ErrorParsingCommandLine ": " MSGTR_AF_ValueOutOfRange
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
+ _("error parsing command line") ": " _("value out of range")
": scale > 0\n");
return AF_ERROR;
}
if (s->ms_stride <= 0) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
- MSGTR_ErrorParsingCommandLine ": " MSGTR_AF_ValueOutOfRange
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
+ _("error parsing command line") ": " _("value out of range")
": stride > 0\n");
return AF_ERROR;
}
if (s->percent_overlap < 0 || s->percent_overlap > 1) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
- MSGTR_ErrorParsingCommandLine ": " MSGTR_AF_ValueOutOfRange
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
+ _("error parsing command line") ": " _("value out of range")
": 0 <= overlap <= 1\n");
return AF_ERROR;
}
if (s->ms_search < 0) {
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
- MSGTR_ErrorParsingCommandLine ": " MSGTR_AF_ValueOutOfRange
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
+ _("error parsing command line") ": " _("value out of range")
": search >= 0\n");
return AF_ERROR;
}
@@ -507,8 +507,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
s->speed_tempo = 1;
s->speed_pitch = 1;
} else {
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
- MSGTR_ErrorParsingCommandLine ": " MSGTR_AF_ValueOutOfRange
+ mp_tmsg(MSGT_AFILTER, MSGL_ERR, "[scaletempo] "
+ _("error parsing command line") ": " _("value out of range")
": speed=[pitch|tempo|none|both]\n");
return AF_ERROR;
}
diff --git a/libaf/af_sweep.c b/libaf/af_sweep.c
index 782bf7ec46..e1890c6b3b 100644
--- a/libaf/af_sweep.c
+++ b/libaf/af_sweep.c
@@ -105,4 +105,3 @@ af_info_t af_info_sweep = {
AF_FLAGS_REENTRANT,
af_open
};
-
diff --git a/libaf/filter.c b/libaf/filter.c
index 9ea4359a32..c5ab039130 100644
--- a/libaf/filter.c
+++ b/libaf/filter.c
@@ -448,4 +448,3 @@ int af_filter_szxform(const FLOAT_TYPE* a, const FLOAT_TYPE* b, FLOAT_TYPE Q, FL
return 0;
}
-
diff --git a/libaf/format.c b/libaf/format.c
index 1427f232f1..93dfdbbc31 100644
--- a/libaf/format.c
+++ b/libaf/format.c
@@ -123,7 +123,7 @@ char* af_fmt2str(int format, char* str, int size)
case(AF_FORMAT_IMA_ADPCM):
i+=snprintf(&str[i],size-i,"IMA-ADPCM "); break;
default:
- i+=snprintf(&str[i],size-i,MSGTR_AF_FORMAT_UnknownFormat);
+ i+=snprintf(&str[i],size-i,mp_gtext("unknown format "));
}
}
else{
diff --git a/libaf/reorder_ch.c b/libaf/reorder_ch.c
index 1ef05f4838..2cbedb8146 100644
--- a/libaf/reorder_ch.c
+++ b/libaf/reorder_ch.c
@@ -1198,4 +1198,3 @@ int main(int argc, char *argv[]) {
}
#endif
-
diff --git a/libaf/window.c b/libaf/window.c
index 2b2923afc9..a970bdcbea 100644
--- a/libaf/window.c
+++ b/libaf/window.c
@@ -211,4 +211,3 @@ void af_window_kaiser(int n, FLOAT_TYPE* w, FLOAT_TYPE b)
w[end-(1&(!k2))+i] = w[end-1-i] = k1 * besselizero(b*sqrt(1.0 - tmp*tmp));
}
}
-
diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c
index 5e848446f2..4c3629b8c9 100644
--- a/libao2/ao_alsa.c
+++ b/libao2/ao_alsa.c
@@ -84,6 +84,7 @@ static int ao_noblock = 0;
static int open_mode;
static int alsa_can_pause = 0;
+static snd_pcm_sframes_t prepause_frames;
#define ALSA_DEVICE_SIZE 256
@@ -146,8 +147,8 @@ static int control(int cmd, void *arg)
mix_index = strtol(test_mix_index, &test_mix_index, 0);
if (*test_mix_index){
- mp_msg(MSGT_AO,MSGL_ERR,
- MSGTR_AO_ALSA_InvalidMixerIndexDefaultingToZero);
+ mp_tmsg(MSGT_AO,MSGL_ERR,
+ "[AO_ALSA] Invalid mixer index. Defaulting to 0.\n");
mix_index = 0 ;
}
}
@@ -167,32 +168,32 @@ static int control(int cmd, void *arg)
}
if ((err = snd_mixer_open(&handle, 0)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_MixerOpenError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Mixer open error: %s\n", snd_strerror(err));
return CONTROL_ERROR;
}
if ((err = snd_mixer_attach(handle, card)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_MixerAttachError,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Mixer attach %s error: %s\n",
card, snd_strerror(err));
snd_mixer_close(handle);
return CONTROL_ERROR;
}
if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_MixerRegisterError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Mixer register error: %s\n", snd_strerror(err));
snd_mixer_close(handle);
return CONTROL_ERROR;
}
err = snd_mixer_load(handle);
if (err < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_MixerLoadError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Mixer load error: %s\n", snd_strerror(err));
snd_mixer_close(handle);
return CONTROL_ERROR;
}
elem = snd_mixer_find_selem(handle, sid);
if (!elem) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToFindSimpleControl,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to find simple control '%s',%i.\n",
snd_mixer_selem_id_get_name(sid), snd_mixer_selem_id_get_index(sid));
snd_mixer_close(handle);
return CONTROL_ERROR;
@@ -207,7 +208,7 @@ static int control(int cmd, void *arg)
//setting channels
if ((err = snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, set_vol)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_ErrorSettingLeftChannel,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Error setting left channel, %s\n",
snd_strerror(err));
return CONTROL_ERROR;
}
@@ -216,7 +217,7 @@ static int control(int cmd, void *arg)
set_vol = vol->right / f_multi + pmin + 0.5;
if ((err = snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, set_vol)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_ErrorSettingRightChannel,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Error setting right channel, %s\n",
snd_strerror(err));
return CONTROL_ERROR;
}
@@ -263,8 +264,15 @@ static void parse_device (char *dest, const char *src, int len)
static void print_help (void)
{
- mp_msg (MSGT_AO, MSGL_FATAL,
- MSGTR_AO_ALSA_CommandlineHelp);
+ mp_tmsg (MSGT_AO, MSGL_FATAL,
+ "\n[AO_ALSA] -ao alsa commandline help:\n"\
+ "[AO_ALSA] Example: mplayer -ao alsa:device=hw=0.3\n"\
+ "[AO_ALSA] Sets first card fourth hardware device.\n\n"\
+ "[AO_ALSA] Options:\n"\
+ "[AO_ALSA] noblock\n"\
+ "[AO_ALSA] Opens device in non-blocking mode.\n"\
+ "[AO_ALSA] device=<device-name>\n"\
+ "[AO_ALSA] Sets device (change , to . and : to =)\n");
}
static int str_maxlen(strarg_t *str) {
@@ -348,6 +356,8 @@ static int init(int rate_hz, int channels, int format, int flags)
mp_msg(MSGT_AO,MSGL_V,"alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR);
#endif
+ prepause_frames = 0;
+
snd_lib_error_set_handler(alsa_error_handler);
ao_data.samplerate = rate_hz;
@@ -450,7 +460,7 @@ static int init(int rate_hz, int channels, int format, int flags)
break;
default:
device.str = "default";
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_ChannelsNotSupported,channels);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] %d channels are not supported.\n",channels);
}
device.len = strlen(device.str);
if (subopt_parse(ao_subdevice, subopts) != 0) {
@@ -510,19 +520,19 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = try_open_device(alsa_device, open_mode, format == AF_FORMAT_AC3)) < 0)
{
if (err != -EBUSY && ao_noblock) {
- mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_ALSA_OpenInNonblockModeFailed);
+ mp_tmsg(MSGT_AO,MSGL_INFO,"[AO_ALSA] Open in nonblock-mode failed, trying to open in block-mode.\n");
if ((err = try_open_device(alsa_device, 0, format == AF_FORMAT_AC3)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PlaybackOpenError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Playback open error: %s\n", snd_strerror(err));
return 0;
}
} else {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PlaybackOpenError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Playback open error: %s\n", snd_strerror(err));
return 0;
}
}
if ((err = snd_pcm_nonblock(alsa_handler, 0)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_ErrorSetBlockMode, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AL_ALSA] Error setting block-mode %s.\n", snd_strerror(err));
} else {
mp_msg(MSGT_AO,MSGL_V,"alsa-init: pcm opened in blocking mode\n");
}
@@ -533,7 +543,7 @@ static int init(int rate_hz, int channels, int format, int flags)
// setting hw-parameters
if ((err = snd_pcm_hw_params_any(alsa_handler, alsa_hwparams)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToGetInitialParameters,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get initial parameters: %s\n",
snd_strerror(err));
return 0;
}
@@ -541,7 +551,7 @@ static int init(int rate_hz, int channels, int format, int flags)
err = snd_pcm_hw_params_set_access(alsa_handler, alsa_hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetAccessType,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set access type: %s\n",
snd_strerror(err));
return 0;
}
@@ -551,8 +561,8 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_hw_params_test_format(alsa_handler, alsa_hwparams,
alsa_format)) < 0)
{
- mp_msg(MSGT_AO,MSGL_INFO,
- MSGTR_AO_ALSA_FormatNotSupportedByHardware, af_fmt2str_short(format));
+ mp_tmsg(MSGT_AO,MSGL_INFO,
+ "[AO_ALSA] Format %s is not supported by hardware, trying default.\n", af_fmt2str_short(format));
alsa_format = SND_PCM_FORMAT_S16_LE;
ao_data.format = AF_FORMAT_S16_LE;
}
@@ -560,7 +570,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_hw_params_set_format(alsa_handler, alsa_hwparams,
alsa_format)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetFormat,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set format: %s\n",
snd_strerror(err));
return 0;
}
@@ -568,7 +578,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_hw_params_set_channels_near(alsa_handler, alsa_hwparams,
&ao_data.channels)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetChannels,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set channels: %s\n",
snd_strerror(err));
return 0;
}
@@ -579,7 +589,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_hw_params_set_rate_resample(alsa_handler, alsa_hwparams,
0)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToDisableResampling,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to disable resampling: %s\n",
snd_strerror(err));
return 0;
}
@@ -588,7 +598,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams,
&ao_data.samplerate, NULL)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetSamplerate2,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set samplerate-2: %s\n",
snd_strerror(err));
return 0;
}
@@ -605,7 +615,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams,
&alsa_buffer_time, NULL)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetBufferTimeNear,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set buffer time near: %s\n",
snd_strerror(err));
return 0;
} else
@@ -615,11 +625,11 @@ static int init(int rate_hz, int channels, int format, int flags)
&alsa_period_time, NULL)) < 0)
/* original: alsa_buffer_time/ao_data.bps */
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetPeriodTime,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set period time: %s\n",
snd_strerror(err));
return 0;
}
- mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_ALSA_BufferTimePeriodTime,
+ mp_tmsg(MSGT_AO,MSGL_INFO,"[AO_ALSA] buffer_time: %d, period_time :%d\n",
alsa_buffer_time, err);
}
#endif//end SET_BUFFERTIME
@@ -630,7 +640,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_hw_params_set_period_size_near(alsa_handler, alsa_hwparams,
&chunk_size, NULL)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetPeriodSize,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO ALSA] Unable to set period size(%ld): %s\n",
chunk_size, snd_strerror(err));
return 0;
}
@@ -639,7 +649,7 @@ static int init(int rate_hz, int channels, int format, int flags)
}
if ((err = snd_pcm_hw_params_set_periods_near(alsa_handler, alsa_hwparams,
&alsa_fragcount, NULL)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetPeriods,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set periods: %s\n",
snd_strerror(err));
return 0;
}
@@ -652,7 +662,7 @@ static int init(int rate_hz, int channels, int format, int flags)
/* finally install hardware parameters */
if ((err = snd_pcm_hw_params(alsa_handler, alsa_hwparams)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetHwParameters,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set hw-parameters: %s\n",
snd_strerror(err));
return 0;
}
@@ -662,7 +672,7 @@ static int init(int rate_hz, int channels, int format, int flags)
// gets buffersize for control
if ((err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &bufsize)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToGetBufferSize, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get buffersize: %s\n", snd_strerror(err));
return 0;
}
else {
@@ -671,7 +681,7 @@ static int init(int rate_hz, int channels, int format, int flags)
}
if ((err = snd_pcm_hw_params_get_period_size(alsa_hwparams, &chunk_size, NULL)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToGetPeriodSize, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO ALSA] Unable to get period size: %s\n", snd_strerror(err));
return 0;
} else {
mp_msg(MSGT_AO,MSGL_V,"alsa-init: got period size %li\n", chunk_size);
@@ -680,13 +690,13 @@ static int init(int rate_hz, int channels, int format, int flags)
/* setting software parameters */
if ((err = snd_pcm_sw_params_current(alsa_handler, alsa_swparams)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToGetSwParameters,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get sw-parameters: %s\n",
snd_strerror(err));
return 0;
}
#if SND_LIB_VERSION >= 0x000901
if ((err = snd_pcm_sw_params_get_boundary(alsa_swparams, &boundary)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToGetBoundary,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get boundary: %s\n",
snd_strerror(err));
return 0;
}
@@ -695,26 +705,26 @@ static int init(int rate_hz, int channels, int format, int flags)
#endif
/* start playing when one period has been written */
if ((err = snd_pcm_sw_params_set_start_threshold(alsa_handler, alsa_swparams, chunk_size)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetStartThreshold,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set start threshold: %s\n",
snd_strerror(err));
return 0;
}
/* disable underrun reporting */
if ((err = snd_pcm_sw_params_set_stop_threshold(alsa_handler, alsa_swparams, boundary)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetStopThreshold,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set stop threshold: %s\n",
snd_strerror(err));
return 0;
}
#if SND_LIB_VERSION >= 0x000901
/* play silence when there is an underrun */
if ((err = snd_pcm_sw_params_set_silence_size(alsa_handler, alsa_swparams, boundary)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetSilenceSize,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set silence size: %s\n",
snd_strerror(err));
return 0;
}
#endif
if ((err = snd_pcm_sw_params(alsa_handler, alsa_swparams)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToGetSwParameters,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get sw-parameters: %s\n",
snd_strerror(err));
return 0;
}
@@ -742,7 +752,7 @@ static void uninit(int immed)
if ((err = snd_pcm_close(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmCloseError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm close error: %s\n", snd_strerror(err));
return;
}
else {
@@ -751,7 +761,7 @@ static void uninit(int immed)
}
}
else {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_NoHandlerDefined);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] No handler defined!\n");
}
}
@@ -762,14 +772,18 @@ static void audio_pause(void)
if (alsa_can_pause) {
if ((err = snd_pcm_pause(alsa_handler, 1)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPauseError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm pause error: %s\n", snd_strerror(err));
return;
}
mp_msg(MSGT_AO,MSGL_V,"alsa-pause: pause supported by hardware\n");
} else {
+ if (snd_pcm_delay(alsa_handler, &prepause_frames) < 0
+ || prepause_frames < 0)
+ prepause_frames = 0;
+
if ((err = snd_pcm_drop(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmDropError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm drop error: %s\n", snd_strerror(err));
return;
}
}
@@ -780,22 +794,27 @@ static void audio_resume(void)
int err;
if (snd_pcm_state(alsa_handler) == SND_PCM_STATE_SUSPENDED) {
- mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_ALSA_PcmInSuspendModeTryingResume);
+ mp_tmsg(MSGT_AO,MSGL_INFO,"[AO_ALSA] Pcm in suspend mode, trying to resume.\n");
while ((err = snd_pcm_resume(alsa_handler)) == -EAGAIN) sleep(1);
}
if (alsa_can_pause) {
if ((err = snd_pcm_pause(alsa_handler, 0)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmResumeError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm resume error: %s\n", snd_strerror(err));
return;
}
mp_msg(MSGT_AO,MSGL_V,"alsa-resume: resume supported by hardware\n");
} else {
if ((err = snd_pcm_prepare(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm prepare error: %s\n", snd_strerror(err));
return;
}
+ if (prepause_frames) {
+ void *silence = calloc(prepause_frames, bytes_per_sample);
+ play(silence, prepause_frames * bytes_per_sample, 0);
+ free(silence);
+ }
}
}
@@ -804,14 +823,15 @@ static void reset(void)
{
int err;
+ prepause_frames = 0;
if ((err = snd_pcm_drop(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm prepare error: %s\n", snd_strerror(err));
return;
}
if ((err = snd_pcm_prepare(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError, snd_strerror(err));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm prepare error: %s\n", snd_strerror(err));
return;
}
return;
@@ -832,7 +852,7 @@ static int play(void* data, int len, int flags)
//mp_msg(MSGT_AO,MSGL_ERR,"alsa-play: frames=%i, len=%i\n",num_frames,len);
if (!alsa_handler) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_DeviceConfigurationError);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Device configuration error.");
return 0;
}
@@ -847,15 +867,15 @@ static int play(void* data, int len, int flags)
res = 0;
}
else if (res == -ESTRPIPE) { /* suspend */
- mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_ALSA_PcmInSuspendModeTryingResume);
+ mp_tmsg(MSGT_AO,MSGL_INFO,"[AO_ALSA] Pcm in suspend mode, trying to resume.\n");
while ((res = snd_pcm_resume(alsa_handler)) == -EAGAIN)
sleep(1);
}
if (res < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_WriteError, snd_strerror(res));
- mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_ALSA_TryingToResetSoundcard);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Write error: %s\n", snd_strerror(res));
+ mp_tmsg(MSGT_AO,MSGL_INFO,"[AO_ALSA] Trying to reset soundcard.\n");
if ((res = snd_pcm_prepare(alsa_handler)) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError, snd_strerror(res));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] pcm prepare error: %s\n", snd_strerror(res));
return 0;
break;
}
@@ -875,14 +895,14 @@ static int get_space(void)
if ((ret = snd_pcm_status(alsa_handler, status)) < 0)
{
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_CannotGetPcmStatus, snd_strerror(ret));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Cannot get pcm status: %s\n", snd_strerror(ret));
return 0;
}
- ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
- if (ret > ao_data.buffersize) // Buffer underrun?
- ret = ao_data.buffersize;
- return ret;
+ unsigned space = snd_pcm_status_get_avail(status) * bytes_per_sample;
+ if (space > ao_data.buffersize) // Buffer underrun?
+ space = ao_data.buffersize;
+ return space;
}
/* delay in seconds between first and last sample in buffer */
diff --git a/libao2/ao_alsa5.c b/libao2/ao_alsa5.c
index feb2919f1d..b2dc1efd3a 100644
--- a/libao2/ao_alsa5.c
+++ b/libao2/ao_alsa5.c
@@ -65,7 +65,7 @@ static int init(int rate_hz, int channels, int format, int flags)
snd_pcm_info_t info;
snd_pcm_channel_info_t chninfo;
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_ALSA5_InitInfo, rate_hz,
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ALSA5] alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz,
channels, af_fmt2str_short(format));
alsa_handler = NULL;
@@ -75,7 +75,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((cards = snd_cards()) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_SoundCardNotFound);
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: no soundcards found.\n");
return 0;
}
@@ -125,7 +125,7 @@ static int init(int rate_hz, int channels, int format, int flags)
ao_data.bps *= 2;
break;
case -1:
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_InvalidFormatReq,af_fmt2str_short(format));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: invalid format (%s) requested - output disabled.\n",af_fmt2str_short(format));
return 0;
default:
break;
@@ -177,17 +177,17 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_open(&alsa_handler, 0, 0, SND_PCM_OPEN_PLAYBACK)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PlayBackError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: playback open error: %s\n", snd_strerror(err));
return 0;
}
if ((err = snd_pcm_info(alsa_handler, &info)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PcmInfoError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: PCM info error: %s\n", snd_strerror(err));
return 0;
}
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_ALSA5_SoundcardsFound,
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ALSA5] alsa-init: %d soundcard(s) found, using: %s\n",
cards, info.name);
if (info.flags & SND_PCM_INFO_PLAYBACK)
@@ -196,7 +196,7 @@ static int init(int rate_hz, int channels, int format, int flags)
chninfo.channel = SND_PCM_CHANNEL_PLAYBACK;
if ((err = snd_pcm_channel_info(alsa_handler, &chninfo)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PcmChanInfoError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: PCM channel info error: %s\n", snd_strerror(err));
return 0;
}
@@ -220,7 +220,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_channel_params(alsa_handler, &params)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_CantSetParms, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: error setting parameters: %s\n", snd_strerror(err));
return 0;
}
@@ -233,13 +233,13 @@ static int init(int rate_hz, int channels, int format, int flags)
if ((err = snd_pcm_channel_setup(alsa_handler, &setup)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_CantSetChan, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: error setting up channel: %s\n", snd_strerror(err));
return 0;
}
if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ChanPrepareError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: channel prepare error: %s\n", snd_strerror(err));
return 0;
}
@@ -256,19 +256,19 @@ static void uninit(int immed)
if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_DrainError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: playback drain error: %s\n", snd_strerror(err));
return;
}
if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_FlushError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: playback flush error: %s\n", snd_strerror(err));
return;
}
if ((err = snd_pcm_close(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PcmCloseError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: PCM close error: %s\n", snd_strerror(err));
return;
}
}
@@ -280,19 +280,19 @@ static void reset(void)
if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetDrainError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: playback drain error: %s\n", snd_strerror(err));
return;
}
if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetFlushError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: playback flush error: %s\n", snd_strerror(err));
return;
}
if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetChanPrepareError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: channel prepare error: %s\n", snd_strerror(err));
return;
}
}
@@ -304,13 +304,13 @@ static void audio_pause(void)
if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PauseDrainError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-pause: playback drain error: %s\n", snd_strerror(err));
return;
}
if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PauseFlushError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-pause: playback flush error: %s\n", snd_strerror(err));
return;
}
}
@@ -321,7 +321,7 @@ static void audio_resume(void)
int err;
if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResumePrepareError, snd_strerror(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-resume: channel prepare error: %s\n", snd_strerror(err));
return;
}
}
@@ -341,21 +341,21 @@ static int play(void* data, int len, int flags)
{
if (got_len == -EPIPE) /* underrun? */
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_Underrun);
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: alsa underrun, resetting stream.\n");
if ((got_len = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PlaybackPrepareError, snd_strerror(got_len));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: playback prepare error: %s\n", snd_strerror(got_len));
return 0;
}
if ((got_len = snd_pcm_write(alsa_handler, data, len)) < 0)
{
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_WriteErrorAfterReset,
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: write error after reset: %s - giving up.\n",
snd_strerror(got_len));
return 0;
}
return got_len; /* 2nd write was ok */
}
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_OutPutError, snd_strerror(got_len));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: output error: %s\n", snd_strerror(got_len));
return 0;
}
return got_len;
diff --git a/libao2/ao_arts.c b/libao2/ao_arts.c
index df44db4f02..5e55d6f6b7 100644
--- a/libao2/ao_arts.c
+++ b/libao2/ao_arts.c
@@ -59,10 +59,10 @@ static int init(int rate_hz, int channels, int format, int flags)
int frag_spec;
if( (err=arts_init()) ) {
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ARTS_CantInit, arts_error_text(err));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ARTS] %s\n", arts_error_text(err));
return 0;
}
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_ARTS_ServerConnect);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ARTS] Connected to sound server.\n");
/*
* arts supports 8bit unsigned and 16bit signed sample formats
@@ -93,7 +93,7 @@ static int init(int rate_hz, int channels, int format, int flags)
stream=arts_play_stream(rate_hz, OBTAIN_BITRATE(format), channels, "MPlayer");
if(stream == NULL) {
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ARTS_CantOpenStream);
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ARTS] Unable to open a stream.\n");
arts_free();
return 0;
}
@@ -104,11 +104,11 @@ static int init(int rate_hz, int channels, int format, int flags)
frag_spec = ARTS_PACKET_SIZE_LOG2 | ARTS_PACKETS << 16;
arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec);
ao_data.buffersize = arts_stream_get(stream, ARTS_P_BUFFER_SIZE);
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_ARTS_StreamOpen);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ARTS] Stream opened.\n");
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_ARTS_BufferSize,
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ARTS] buffer size: %d\n",
ao_data.buffersize);
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_ARTS_BufferSize,
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ARTS] buffer size: %d\n",
arts_stream_get(stream, ARTS_P_PACKET_SIZE));
return 1;
@@ -147,4 +147,3 @@ static float get_delay(void)
return ((float) (ao_data.buffersize - arts_stream_get(stream,
ARTS_P_BUFFER_SPACE))) / ((float) ao_data.bps);
}
-
diff --git a/libao2/ao_dxr2.c b/libao2/ao_dxr2.c
index 136efd1a9e..e8aa65aab5 100644
--- a/libao2/ao_dxr2.c
+++ b/libao2/ao_dxr2.c
@@ -73,7 +73,7 @@ static int control(int cmd,void *arg){
if(v.arg != volume) {
volume = v.arg;
if( ioctl(dxr2_fd,DXR2_IOC_SET_AUDIO_VOLUME,&v) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_DXR2_SetVolFailed,volume);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO DXR2] Setting volume to %d failed.\n",volume);
return CONTROL_ERROR;
}
}
@@ -135,7 +135,7 @@ static int init(int rate,int channels,int format,int flags){
break;
#endif
default:
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_DXR2_UnsupSamplerate,rate);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO DXR2] %d Hz not supported, try to resample.\n",rate);
return 0;
}
@@ -220,4 +220,3 @@ static float get_delay(void){
return 0.0;
}
-
diff --git a/libao2/ao_esd.c b/libao2/ao_esd.c
index 593d5a934a..28a0009b80 100644
--- a/libao2/ao_esd.c
+++ b/libao2/ao_esd.c
@@ -168,7 +168,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if (esd_fd < 0) {
esd_fd = esd_open_sound(server);
if (esd_fd < 0) {
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ESD_CantOpenSound,
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ESD] esd_open_sound failed: %s\n",
strerror(errno));
return 0;
}
@@ -245,14 +245,14 @@ static int init(int rate_hz, int channels, int format, int flags)
lag_serv = (esd_latency * 4.0f) / (bytes_per_sample * rate_hz);
lag_seconds = lag_net + lag_serv;
audio_delay += lag_seconds;
- mp_msg(MSGT_AO, MSGL_INFO,MSGTR_AO_ESD_LatencyInfo,
+ mp_tmsg(MSGT_AO, MSGL_INFO,"[AO ESD] latency: [server: %0.2fs, net: %0.2fs] (adjust %0.2fs)\n",
lag_serv, lag_net, lag_seconds);
}
esd_play_fd = esd_play_stream_fallback(esd_fmt, rate_hz,
server, ESD_CLIENT_NAME);
if (esd_play_fd < 0) {
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ESD_CantOpenPBStream, strerror(errno));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ESD] failed to open ESD playback stream: %s\n", strerror(errno));
return 0;
}
diff --git a/libao2/ao_ivtv.c b/libao2/ao_ivtv.c
index b09e5308bb..6b6bb8816c 100644
--- a/libao2/ao_ivtv.c
+++ b/libao2/ao_ivtv.c
@@ -86,7 +86,7 @@ init (int rate, int channels, int format, int flags)
/* check for supported audio rate */
if (rate != 32000 || rate != 41000 || rate != 48000)
{
- mp_msg (MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_UnsupSamplerate, rate);
+ mp_tmsg (MSGT_AO, MSGL_ERR, "[AO MPEGPES] %d Hz not supported, try to resample.\n", rate);
rate = 48000;
}
@@ -147,7 +147,7 @@ get_space (void)
static int
play (void *data, int len, int flags)
{
- int ivtv_write (unsigned char *data, int len);
+ int ivtv_write (const unsigned char *data, int len);
if (ao_data.format != AF_FORMAT_MPEG2)
return 0;
diff --git a/libao2/ao_jack.c b/libao2/ao_jack.c
index e92786c28d..14bb1c90dd 100644
--- a/libao2/ao_jack.c
+++ b/libao2/ao_jack.c
@@ -360,4 +360,3 @@ static float get_delay(void) {
}
return (float)buffered / (float)ao_data.bps + in_jack;
}
-
diff --git a/libao2/ao_mpegpes.c b/libao2/ao_mpegpes.c
index 64cb05fa03..096f7bade5 100644
--- a/libao2/ao_mpegpes.c
+++ b/libao2/ao_mpegpes.c
@@ -97,7 +97,7 @@ static int control(int cmd,void *arg){
if(dvb_mixer.volume_right>255) dvb_mixer.volume_right=255;
// printf("Setting DVB volume: %d ; %d \n",dvb_mixer.volume_left,dvb_mixer.volume_right);
if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_MIXER, &dvb_mixer) < 0)){
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_CantSetMixer,
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO MPEGPES] DVB audio set mixer failed: %s.\n",
strerror(errno));
return CONTROL_ERROR;
}
@@ -208,7 +208,7 @@ static int preinit(const char *arg)
return vo_mpegpes_fd2;
}
-static int my_ao_write(unsigned char* data,int len){
+static int my_ao_write(const unsigned char* data,int len){
int orig_len = len;
#ifdef CONFIG_DVB
#define NFD 1
@@ -263,7 +263,7 @@ static int init(int rate,int channels,int format,int flags){
case 44100: freq_id=2;break;
case 32000: freq_id=3;break;
default:
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_UnsupSamplerate, rate);
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO MPEGPES] %d Hz not supported, try to resample.\n", rate);
#if 0
if(rate>48000) rate=96000; else
if(rate>44100) rate=48000; else
@@ -303,8 +303,6 @@ static void audio_resume(void)
{
}
-void send_pes_packet(unsigned char* data,int len,int id,int timestamp);
-void send_lpcm_packet(unsigned char* data,int len,int id,int timestamp,int freq_id);
extern int vo_pts;
// return: how many bytes can be played without blocking
diff --git a/libao2/ao_openal.c b/libao2/ao_openal.c
index 829eb7ae58..b00a77364a 100644
--- a/libao2/ao_openal.c
+++ b/libao2/ao_openal.c
@@ -251,4 +251,3 @@ static float get_delay(void) {
alGetSourcei(sources[0], AL_BUFFERS_QUEUED, &queued);
return queued * CHUNK_SIZE / 2 / (float)ao_data.samplerate;
}
-
diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c
index 4666c400e9..c16d55c8df 100644
--- a/libao2/ao_oss.c
+++ b/libao2/ao_oss.c
@@ -160,7 +160,7 @@ static int oss2format(int format)
case AFMT_AC3: return AF_FORMAT_AC3;
#endif
}
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_AO_OSS_UnknownUnsupportedFormat, format);
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[AO OSS] Unknown/Unsupported OSS format: %x.\n", format);
return -1;
}
@@ -172,6 +172,29 @@ static int prepause_space;
static const char *oss_mixer_device = PATH_DEV_MIXER;
static int oss_mixer_channel = SOUND_MIXER_PCM;
+#ifdef SNDCTL_DSP_GETPLAYVOL
+static int volume_oss4(ao_control_vol_t *vol, int cmd) {
+ int v;
+
+ if (audio_fd < 0)
+ return CONTROL_ERROR;
+
+ if (cmd == AOCONTROL_GET_VOLUME) {
+ if (ioctl(audio_fd, SNDCTL_DSP_GETPLAYVOL, &v) == -1)
+ return CONTROL_ERROR;
+ vol->right = (v & 0xff00) >> 8;
+ vol->left = v & 0x00ff;
+ return CONTROL_OK;
+ } else if (cmd == AOCONTROL_SET_VOLUME) {
+ v = ((int) vol->right << 8) | (int) vol->left;
+ if (ioctl(audio_fd, SNDCTL_DSP_SETPLAYVOL, &v) == -1)
+ return CONTROL_ERROR;
+ return CONTROL_OK;
+ } else
+ return CONTROL_UNKNOWN;
+}
+#endif
+
// to set/get/query special features/parameters
static int control(int cmd,void *arg){
switch(cmd){
@@ -197,6 +220,12 @@ static int control(int cmd,void *arg){
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
int fd, v, devs;
+#ifdef SNDCTL_DSP_GETPLAYVOL
+ // Try OSS4 first
+ if (volume_oss4(vol, cmd) == CONTROL_OK)
+ return CONTROL_OK;
+#endif
+
if(ao_data.format == AF_FORMAT_AC3)
return CONTROL_TRUE;
@@ -265,7 +294,7 @@ static int init(int rate,int channels,int format,int flags){
int fd, devs, i;
if ((fd = open(oss_mixer_device, O_RDONLY)) == -1){
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_CantOpenMixer,
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS] audio_setup: Can't open mixer device %s: %s\n",
oss_mixer_device, strerror(errno));
}else{
ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs);
@@ -274,7 +303,7 @@ static int init(int rate,int channels,int format,int flags){
for (i=0; i<SOUND_MIXER_NRDEVICES; i++){
if(!strcasecmp(mixer_channels[i], mchan)){
if(!(devs & (1 << i))){
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_ChanNotFound,mchan);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS] audio_setup: Audio card mixer does not have channel '%s', using default.\n",mchan);
i = SOUND_MIXER_NRDEVICES+1;
break;
}
@@ -283,7 +312,7 @@ static int init(int rate,int channels,int format,int flags){
}
}
if(i==SOUND_MIXER_NRDEVICES){
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_ChanNotFound,mchan);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS] audio_setup: Audio card mixer does not have channel '%s', using default.\n",mchan);
}
}
} else
@@ -299,14 +328,14 @@ static int init(int rate,int channels,int format,int flags){
audio_fd=open(dsp, O_WRONLY);
#endif
if(audio_fd<0){
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_CantOpenDev, dsp, strerror(errno));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS] audio_setup: Can't open audio device %s: %s\n", dsp, strerror(errno));
return 0;
}
#ifdef __linux__
/* Remove the non-blocking flag */
if(fcntl(audio_fd, F_SETFL, 0) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_CantMakeFd, strerror(errno));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS] audio_setup: Can't make file descriptor blocking: %s\n", strerror(errno));
return 0;
}
#endif
@@ -333,7 +362,7 @@ ac3_retry:
}
if( ioctl(audio_fd, SNDCTL_DSP_SETFMT, &oss_format)<0 ||
oss_format != format2oss(format)) {
- mp_msg(MSGT_AO,MSGL_WARN, MSGTR_AO_OSS_CantSet, dsp,
+ mp_tmsg(MSGT_AO,MSGL_WARN, "[AO OSS] Can't set audio device %s to %s output, trying %s...\n", dsp,
af_fmt2str_short(format), af_fmt2str_short(AF_FORMAT_S16_NE) );
format=AF_FORMAT_S16_NE;
goto ac3_retry;
@@ -355,14 +384,14 @@ ac3_retry:
if (ao_data.channels > 2) {
if ( ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels) == -1 ||
ao_data.channels != channels ) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_CantSetChans, channels);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS] audio_setup: Failed to set audio device to %d channels.\n", channels);
return 0;
}
}
else {
int c = ao_data.channels-1;
if (ioctl (audio_fd, SNDCTL_DSP_STEREO, &c) == -1) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_CantSetChans, ao_data.channels);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS] audio_setup: Failed to set audio device to %d channels.\n", ao_data.channels);
return 0;
}
ao_data.channels=c+1;
@@ -376,7 +405,7 @@ ac3_retry:
if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)==-1){
int r=0;
- mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_OSS_CantUseGetospace);
+ mp_tmsg(MSGT_AO,MSGL_WARN,"[AO OSS] audio_setup: driver doesn't support SNDCTL_DSP_GETOSPACE :-(\n");
if(ioctl(audio_fd, SNDCTL_DSP_GETBLKSIZE, &r)==-1){
mp_msg(MSGT_AO,MSGL_V,"audio_setup: %d bytes/frag (config.h)\n",ao_data.outburst);
} else {
@@ -407,7 +436,7 @@ ac3_retry:
}
free(data);
if(ao_data.buffersize==0){
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_CantUseSelect);
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS]\n *** Your audio driver DOES NOT support select() ***\n Recompile MPlayer with #undef HAVE_AUDIO_SELECT in config.h !\n\n");
return 0;
}
#endif
@@ -445,7 +474,7 @@ static void reset(void){
uninit(1);
audio_fd=open(dsp, O_WRONLY);
if(audio_fd < 0){
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_OSS_CantReopen, strerror(errno));
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS]\nFatal error: *** CANNOT RE-OPEN / RESET AUDIO DEVICE *** %s\n", strerror(errno));
return;
}
diff --git a/libao2/ao_pcm.c b/libao2/ao_pcm.c
index a49a963a30..78652c7cdc 100644
--- a/libao2/ao_pcm.c
+++ b/libao2/ao_pcm.c
@@ -158,10 +158,10 @@ static int init(int rate,int channels,int format,int flags){
wavhdr.data_length=le2me_32(0x7ffff000);
wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8;
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_FileInfo, ao_outputfilename,
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO PCM] File: %s (%s)\nPCM: Samplerate: %iHz Channels: %s Format %s\n", ao_outputfilename,
(ao_pcm_waveheader?"WAVE":"RAW PCM"), rate,
(channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_HintInfo);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast\n[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).\n");
fp = fopen(ao_outputfilename, "wb");
if(fp) {
@@ -170,7 +170,7 @@ static int init(int rate,int channels,int format,int flags){
}
return 1;
}
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_PCM_CantOpenOutputFile,
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO PCM] Failed to open %s for writing!\n",
ao_outputfilename);
return 0;
}
@@ -267,9 +267,3 @@ static float get_delay(void){
return 0.0;
}
-
-
-
-
-
-
diff --git a/libao2/ao_sdl.c b/libao2/ao_sdl.c
index aae6e3fc7d..b5c56d9f33 100644
--- a/libao2/ao_sdl.c
+++ b/libao2/ao_sdl.c
@@ -115,7 +115,7 @@ static int control(int cmd,void *arg){
}
// SDL Callback function
-void outputaudio(void *unused, Uint8 *stream, int len) {
+static void outputaudio(void *unused, Uint8 *stream, int len) {
//SDL_MixAudio(stream, read_buffer(buffers, len), len, SDL_MIX_MAXVOLUME);
//if(!full_buffers) printf("SDL: Buffer underrun!\n");
@@ -133,11 +133,11 @@ static int init(int rate,int channels,int format,int flags){
/* Allocate ring-buffer memory */
buffer = av_fifo_alloc(BUFFSIZE);
- mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
+ mp_tmsg(MSGT_AO,MSGL_INFO,"[AO SDL] Samplerate: %iHz Channels: %s Format %s\n", rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
if(ao_subdevice) {
setenv("SDL_AUDIODRIVER", ao_subdevice, 1);
- mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_DriverInfo, ao_subdevice);
+ mp_tmsg(MSGT_AO,MSGL_INFO,"[AO SDL] using %s audio driver.\n", ao_subdevice);
}
ao_data.channels=channels;
@@ -171,7 +171,7 @@ static int init(int rate,int channels,int format,int flags){
default:
aspec.format = AUDIO_S16LSB;
ao_data.format = AF_FORMAT_S16_LE;
- mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, format);
+ mp_tmsg(MSGT_AO,MSGL_WARN,"[AO SDL] Unsupported audio format: 0x%x.\n", format);
}
/* The desired audio frequency in samples-per-second. */
@@ -192,13 +192,13 @@ void callback(void *userdata, Uint8 *stream, int len); userdata is the pointer s
/* initialize the SDL Audio system */
if (SDL_Init (SDL_INIT_AUDIO/*|SDL_INIT_NOPARACHUTE*/)) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_SDL_CantInit, SDL_GetError());
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO SDL] SDL Audio initialization failed: %s\n", SDL_GetError());
return 0;
}
/* Open the audio device and start playing sound! */
if(SDL_OpenAudio(&aspec, &obtained) < 0) {
- mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_SDL_CantOpenAudio, SDL_GetError());
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO SDL] Unable to open audio: %s\n", SDL_GetError());
return 0;
}
@@ -226,7 +226,7 @@ void callback(void *userdata, Uint8 *stream, int len); userdata is the pointer s
ao_data.format = AF_FORMAT_U16_BE;
break;
default:
- mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, obtained.format);
+ mp_tmsg(MSGT_AO,MSGL_WARN,"[AO SDL] Unsupported audio format: 0x%x.\n", obtained.format);
return 0;
}
@@ -310,9 +310,3 @@ static float get_delay(void){
int buffered = av_fifo_size(buffer); // could be less
return (float)(buffered + ao_data.buffersize)/(float)ao_data.bps;
}
-
-
-
-
-
-
diff --git a/libao2/ao_sgi.c b/libao2/ao_sgi.c
index 9853b7e12d..71ce784657 100644
--- a/libao2/ao_sgi.c
+++ b/libao2/ao_sgi.c
@@ -117,7 +117,7 @@ static int fmt2sgial(int *format, int *width) {
// to set/get/query special features/parameters
static int control(int cmd, void *arg){
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_INFO);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] control.\n");
switch(cmd) {
case AOCONTROL_QUERY_FORMAT:
@@ -138,7 +138,7 @@ static int init(int rate, int channels, int format, int flags) {
smpfmt = fmt2sgial(&format, &smpwidth);
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_InitInfo, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] init: Samplerate: %iHz Channels: %s Format %s\n", rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
{ /* from /usr/share/src/dmedia/audio/setrate.c */
@@ -148,7 +148,7 @@ static int init(int rate, int channels, int format, int flags) {
if(ao_subdevice) {
rv = alGetResourceByName(AL_SYSTEM, ao_subdevice, AL_OUTPUT_DEVICE_TYPE);
if (!rv) {
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InvalidDevice);
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SGI] play: invalid device.\n");
return 0;
}
}
@@ -161,20 +161,20 @@ static int init(int rate, int channels, int format, int flags) {
x[1].value.i = AL_CRYSTAL_MCLK_TYPE;
if (alSetParams(rv,x, 2)<0) {
- mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetParms_Samplerate, alGetErrorString(oserror()));
+ mp_tmsg(MSGT_AO, MSGL_WARN, "[AO SGI] init: setparams failed: %s\nCould not set desired samplerate.\n", alGetErrorString(oserror()));
}
if (x[0].sizeOut < 0) {
- mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetAlRate);
+ mp_tmsg(MSGT_AO, MSGL_WARN, "[AO SGI] init: AL_RATE was not accepted on the given resource.\n");
}
if (alGetParams(rv,x, 1)<0) {
- mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantGetParms, alGetErrorString(oserror()));
+ mp_tmsg(MSGT_AO, MSGL_WARN, "[AO SGI] init: getparams failed: %s\n", alGetErrorString(oserror()));
}
realrate = alFixedToDouble(x[0].value.ll);
if (frate != realrate) {
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_SampleRateInfo, realrate, frate);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] init: samplerate is now %lf (desired rate is %lf)\n", realrate, frate);
}
sample_rate = (int)realrate;
}
@@ -191,7 +191,7 @@ static int init(int rate, int channels, int format, int flags) {
ao_config = alNewConfig();
if (!ao_config) {
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror()));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SGI] init: %s\n", alGetErrorString(oserror()));
return 0;
}
@@ -200,14 +200,14 @@ static int init(int rate, int channels, int format, int flags) {
alSetSampFmt(ao_config, smpfmt) < 0 ||
alSetQueueSize(ao_config, sample_rate) < 0 ||
alSetDevice(ao_config, rv) < 0) {
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror()));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SGI] init: %s\n", alGetErrorString(oserror()));
return 0;
}
ao_port = alOpenPort("mplayer", "w", ao_config);
if (!ao_port) {
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitOpenAudioFailed, alGetErrorString(oserror()));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SGI] init: Unable to open audio channel: %s\n", alGetErrorString(oserror()));
return 0;
}
@@ -222,7 +222,7 @@ static void uninit(int immed) {
/* TODO: samplerate should be set back to the value before mplayer was started! */
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Uninit);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] uninit: ...\n");
if (ao_config) {
alFreeConfig(ao_config);
@@ -241,7 +241,7 @@ static void uninit(int immed) {
// stop playing and empty buffers (for seeking/pause)
static void reset(void) {
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Reset);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] reset: ...\n");
alDiscardFrames(ao_port, queue_size);
}
@@ -249,14 +249,14 @@ static void reset(void) {
// stop playing, keep buffers (for pause)
static void audio_pause(void) {
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_PauseInfo);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] audio_pause: ...\n");
}
// resume playing, after audio_pause()
static void audio_resume(void) {
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_ResumeInfo);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] audio_resume: ...\n");
}
@@ -307,9 +307,3 @@ static float get_delay(void){
return (float)((outstanding < 0) ? queue_size : outstanding) /
((float)sample_rate);
}
-
-
-
-
-
-
diff --git a/libao2/ao_sun.c b/libao2/ao_sun.c
index 7cea31d529..72353bc736 100644
--- a/libao2/ao_sun.c
+++ b/libao2/ao_sun.c
@@ -154,13 +154,13 @@ static int realtime_samplecounter_available(char *dev)
info.play.samples = 0;
if (ioctl(fd, AUDIO_SETINFO, &info)) {
if ( mp_msg_test(MSGT_AO,MSGL_V) )
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_RtscSetinfoFailed);
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SUN] rtsc: SETINFO failed.\n");
goto error;
}
if (write(fd, silence, len) != len) {
if ( mp_msg_test(MSGT_AO,MSGL_V) )
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_RtscWriteFailed);
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SUN] rtsc: write failed.\n");
goto error;
}
@@ -494,7 +494,7 @@ static int init(int rate,int channels,int format,int flags){
audio_fd=open(audio_dev, O_WRONLY);
if(audio_fd<0){
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_CantOpenAudioDev, audio_dev, strerror(errno));
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SUN] Can't open audio device %s, %s -> nosound.\n", audio_dev, strerror(errno));
return 0;
}
@@ -572,7 +572,7 @@ static int init(int rate,int channels,int format,int flags){
if (!ok) {
char buf[128];
- mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_UnsupSampleRate,
+ mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SUN] audio_setup: your card doesn't support %d channel, %s, %d Hz samplerate.\n",
channels, af_fmt2str(format, buf, 128), rate);
return 0;
}
@@ -694,4 +694,3 @@ static float get_delay(void){
return (float)((queued_bursts - info.play.eof) * ao_data.outburst) / (float)byte_per_sec;
#endif
}
-
diff --git a/libao2/ao_v4l2.c b/libao2/ao_v4l2.c
index a9e386a448..82c53a226a 100644
--- a/libao2/ao_v4l2.c
+++ b/libao2/ao_v4l2.c
@@ -83,7 +83,7 @@ init (int rate, int channels, int format, int flags)
/* check for supported audio rate */
if (rate != 32000 || rate != 41000 || rate != 48000)
{
- mp_msg (MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_UnsupSamplerate, rate);
+ mp_tmsg (MSGT_AO, MSGL_ERR, "[AO MPEGPES] %d Hz not supported, try to resample.\n", rate);
rate = 48000;
}
@@ -144,7 +144,7 @@ get_space (void)
static int
play (void *data, int len, int flags)
{
- int v4l2_write (unsigned char *data, int len);
+ int v4l2_write (const unsigned char *data, int len);
if (ao_data.format != AF_FORMAT_MPEG2)
return 0;
diff --git a/libao2/audio_out.c b/libao2/audio_out.c
index fc41a73e57..5ceafff73f 100644
--- a/libao2/audio_out.c
+++ b/libao2/audio_out.c
@@ -25,7 +25,6 @@
#include "mp_msg.h"
#include "help_mp.h"
-#include "mplayer.h" /* for exit_player() */
// there are some globals:
ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0};
@@ -125,7 +124,7 @@ const ao_functions_t* const audio_out_drivers[] =
void list_audio_out(void){
int i=0;
- mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
+ mp_tmsg(MSGT_AO, MSGL_INFO, "Available audio output drivers:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n");
while (audio_out_drivers[i]) {
const ao_info_t *info = audio_out_drivers[i++]->info;
@@ -141,10 +140,6 @@ const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate
while(ao_list[0][0]){
char* ao=ao_list[0];
int ao_len;
- if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) {
- mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed);
- exit_player(NULL);
- }
if (ao_subdevice) {
free(ao_subdevice);
ao_subdevice = NULL;
@@ -157,7 +152,7 @@ const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate
else
ao_len = strlen(ao);
- mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingPreferredAudioDriver,
+ mp_tmsg(MSGT_AO, MSGL_V, "Trying preferred audio driver '%.*s', options '%s'\n",
ao_len, ao, ao_subdevice ? ao_subdevice : "[none]");
for(i=0;audio_out_drivers[i];i++){
@@ -167,12 +162,12 @@ const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate
if(audio_out->init(rate,channels,format,flags))
return audio_out; // success!
else
- mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_FailedInit, ao);
+ mp_tmsg(MSGT_AO, MSGL_WARN, "Failed to initialize audio driver '%s'\n", ao);
break;
}
}
if (!audio_out_drivers[i]) // we searched through the entire list
- mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao);
+ mp_tmsg(MSGT_AO, MSGL_WARN, "No such audio driver '%.*s'\n", ao_len, ao);
// continue...
++ao_list;
if(!(ao_list[0])) return NULL; // do NOT fallback to others
@@ -182,7 +177,7 @@ const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate
ao_subdevice = NULL;
}
- mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown);
+ mp_tmsg(MSGT_AO, MSGL_V, "Trying every known audio driver...\n");
// now try the rest...
for(i=0;audio_out_drivers[i];i++){
@@ -193,4 +188,3 @@ const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate
}
return NULL;
}
-
diff --git a/libao2/audio_out.h b/libao2/audio_out.h
index 049cfc5f21..e483a88422 100644
--- a/libao2/audio_out.h
+++ b/libao2/audio_out.h
@@ -47,8 +47,7 @@ typedef struct ao_functions_s
} ao_functions_t;
/* global data used by mplayer and plugins */
-typedef struct ao_data_s
-{
+typedef struct ao_data {
int samplerate;
int channels;
int format;
diff --git a/libass/ass.c b/libass/ass.c
index 822f1e03f8..5e9e82c2c4 100644
--- a/libass/ass.c
+++ b/libass/ass.c
@@ -1132,4 +1132,3 @@ ass_track_t* ass_new_track(ass_library_t* library) {
track->parser_priv = calloc(1, sizeof(parser_priv_t));
return track;
}
-
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c
index 15d583ac48..302827af10 100644
--- a/libass/ass_bitmap.c
+++ b/libass/ass_bitmap.c
@@ -334,4 +334,3 @@ int glyph_to_bitmap(ass_synth_priv_t* priv_blur,
assert(bm_s);
return 0;
}
-
diff --git a/libass/ass_cache.c b/libass/ass_cache.c
index dc217bd75e..2150d27ec2 100644
--- a/libass/ass_cache.c
+++ b/libass/ass_cache.c
@@ -230,6 +230,13 @@ void ass_font_cache_done(void)
hashmap_done(font_cache);
}
+
+// Create hash/compare functions for bitmap and glyph
+#define CREATE_HASH_FUNCTIONS
+#include "ass_cache_template.c"
+#define CREATE_COMPARISON_FUNCTIONS
+#include "ass_cache_template.c"
+
//---------------------------------
// bitmap cache
@@ -265,7 +272,8 @@ void ass_bitmap_cache_init(void)
bitmap_cache = hashmap_init(sizeof(bitmap_hash_key_t),
sizeof(bitmap_hash_val_t),
0xFFFF + 13,
- bitmap_hash_dtor, NULL, NULL);
+ bitmap_hash_dtor, bitmap_compare,
+ bitmap_hash);
}
void ass_bitmap_cache_done(void)
@@ -313,7 +321,7 @@ void ass_glyph_cache_init(void)
glyph_cache = hashmap_init(sizeof(glyph_hash_key_t),
sizeof(glyph_hash_val_t),
0xFFFF + 13,
- glyph_hash_dtor, NULL, NULL);
+ glyph_hash_dtor, glyph_compare, glyph_hash);
}
void ass_glyph_cache_done(void)
@@ -375,4 +383,3 @@ void ass_composite_cache_reset(void)
ass_composite_cache_done();
ass_composite_cache_init();
}
-
diff --git a/libass/ass_cache.h b/libass/ass_cache.h
index 59ac8cee2a..863ba6fdf6 100644
--- a/libass/ass_cache.h
+++ b/libass/ass_cache.h
@@ -33,25 +33,9 @@ void* ass_font_cache_add(ass_font_t* font);
void ass_font_cache_done(void);
-// describes a bitmap; bitmaps with equivalents structs are considered identical
-typedef struct bitmap_hash_key_s {
- char bitmap; // bool : true = bitmap, false = outline
- ass_font_t* font;
- double size; // font size
- uint32_t ch; // character code
- unsigned outline; // border width, 16.16 fixed point value
- int bold, italic;
- char be; // blur edges
- double blur; // gaussian blur
-
- unsigned scale_x, scale_y; // 16.16
- int frx, fry, frz; // signed 16.16
- int shift_x, shift_y; // shift vector that was added to glyph before applying rotation
- // = 0, if frx = fry = frx = 0
- // = (glyph base point) - (rotation origin), otherwise
-
- FT_Vector advance; // subpixel shift vector
-} bitmap_hash_key_t;
+// Create definitions for bitmap_hash_key and glyph_hash_key
+#define CREATE_STRUCT_DEFINITIONS
+#include "ass_cache_template.c"
typedef struct bitmap_hash_val_s {
bitmap_t* bm; // the actual bitmaps
@@ -86,17 +70,6 @@ void ass_composite_cache_reset(void);
void ass_composite_cache_done(void);
-// describes an outline glyph
-typedef struct glyph_hash_key_s {
- ass_font_t* font;
- double size; // font size
- uint32_t ch; // character code
- int bold, italic;
- unsigned scale_x, scale_y; // 16.16
- FT_Vector advance; // subpixel shift vector
- unsigned outline; // border width, 16.16
-} glyph_hash_key_t;
-
typedef struct glyph_hash_val_s {
FT_Glyph glyph;
FT_Glyph outline_glyph;
diff --git a/libass/ass_cache_template.c b/libass/ass_cache_template.c
new file mode 100644
index 0000000000..7f9ec95f57
--- /dev/null
+++ b/libass/ass_cache_template.c
@@ -0,0 +1,88 @@
+#ifdef CREATE_STRUCT_DEFINITIONS
+#undef CREATE_STRUCT_DEFINITIONS
+#define START(funcname, structname) \
+ typedef struct structname {
+#define GENERIC(type, member) \
+ type member;
+#define FTVECTOR(member) \
+ FT_Vector member;
+#define END(typedefnamename) \
+ } typedefnamename;
+
+#elif defined(CREATE_COMPARISON_FUNCTIONS)
+#undef CREATE_COMPARISON_FUNCTIONS
+#define START(funcname, structname) \
+ static int funcname##_compare(void *key1, void *key2, size_t key_size) \
+ { \
+ struct structname *a = key1; \
+ struct structname *b = key2; \
+ return // conditions follow
+#define GENERIC(type, member) \
+ a->member == b->member &&
+#define FTVECTOR(member) \
+ a->member.x == b->member.x && a->member.y == b->member.y &&
+#define END(typedefname) \
+ 1; \
+ }
+
+#elif defined(CREATE_HASH_FUNCTIONS)
+#undef CREATE_HASH_FUNCTIONS
+#define START(funcname, structname) \
+ static unsigned funcname##_hash(void *buf, size_t len) \
+ { \
+ struct structname *p = buf; \
+ unsigned hval = FNV1_32A_INIT;
+#define GENERIC(type, member) \
+ hval = fnv_32a_buf(&p->member, sizeof(p->member), hval);
+#define FTVECTOR(member) GENERIC(, member.x); GENERIC(, member.y);
+#define END(typedefname) \
+ return hval; \
+ }
+
+#else
+#error missing defines
+#endif
+
+
+
+// describes a bitmap; bitmaps with equivalents structs are considered identical
+START(bitmap, bipmap_hash_key_s)
+ GENERIC(char, bitmap) // bool : true = bitmap, false = outline
+ GENERIC(ass_font_t *, font)
+ GENERIC(double, size) // font size
+ GENERIC(uint32_t, ch) // character code
+ GENERIC(unsigned, outline) // border width, 16.16 fixed point value
+ GENERIC(int, bold)
+ GENERIC(int, italic)
+ GENERIC(char, be) // blur edges
+ GENERIC(double, blur) // gaussian blur
+ GENERIC(unsigned, scale_x) // 16.16
+ GENERIC(unsigned, scale_y) // 16.16
+ GENERIC(int, frx) // signed 16.16
+ GENERIC(int, fry) // signed 16.16
+ GENERIC(int, frz) // signed 16.16
+ // shift vector that was added to glyph before applying rotation
+ // = 0, if frx = fry = frx = 0
+ // = (glyph base point) - (rotation origin), otherwise
+ GENERIC(int, shift_x)
+ GENERIC(int, shift_y)
+ FTVECTOR(advance) // subpixel shift vector
+END(bitmap_hash_key_t)
+
+// describes an outline glyph
+START(glyph, glyph_hash_key_s)
+ GENERIC(ass_font_t *, font)
+ GENERIC(double, size) // font size
+ GENERIC(uint32_t, ch) // character code
+ GENERIC(int, bold)
+ GENERIC(int, italic)
+ GENERIC(unsigned, scale_x) // 16.16
+ GENERIC(unsigned, scale_y) // 16.16
+ FTVECTOR(advance) // subpixel shift vector
+ GENERIC(unsigned, outline) // border width, 16.16
+END(glyph_hash_key_t)
+
+#undef START
+#undef GENERIC
+#undef FTVECTOR
+#undef END
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c
index 2e7b5f0f64..0b030bdf85 100644
--- a/libass/ass_fontconfig.c
+++ b/libass/ass_fontconfig.c
@@ -514,5 +514,3 @@ void fontconfig_done(fc_instance_t* priv)
if (priv && priv->family_default) free(priv->family_default);
if (priv) free(priv);
}
-
-
diff --git a/libass/ass_render.c b/libass/ass_render.c
index f13f76661e..e3896e89a4 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -1018,7 +1018,10 @@ static char* parse_tag(char* p, double pwr) {
mystrtod(&p, &v2);
skip(')');
mp_msg(MSGT_ASS, MSGL_DBG2, "pos(%f, %f)\n", v1, v2);
- if (render_context.evt_type != EVENT_POSITIONED) {
+ if (render_context.evt_type == EVENT_POSITIONED) {
+ mp_msg(MSGT_ASS, MSGL_V, "Subtitle has a new \\pos "
+ "after \\move or \\pos, ignoring\n");
+ } else {
render_context.evt_type = EVENT_POSITIONED;
render_context.detect_collisions = 0;
render_context.pos_x = v1;
@@ -2186,7 +2189,7 @@ static int ass_render_event(ass_event_t* event, event_images_t* event_images)
* \brief deallocate image list
* \param img list pointer
*/
-void ass_free_images(ass_image_t* img)
+static void ass_free_images(ass_image_t* img)
{
while (img) {
ass_image_t* next = img->next;
@@ -2495,7 +2498,7 @@ static void fix_collisions(event_images_t* imgs, int cnt)
* \param i2 second image
* \return 0 if identical, 1 if different positions, 2 if different content
*/
-int ass_image_compare(ass_image_t *i1, ass_image_t *i2)
+static int ass_image_compare(ass_image_t *i1, ass_image_t *i2)
{
if (i1->w != i2->w) return 2;
if (i1->h != i2->h) return 2;
@@ -2513,7 +2516,7 @@ int ass_image_compare(ass_image_t *i1, ass_image_t *i2)
* \param priv library handle
* \return 0 if identical, 1 if different positions, 2 if different content
*/
-int ass_detect_change(ass_renderer_t *priv)
+static int ass_detect_change(ass_renderer_t *priv)
{
ass_image_t* img, *img2;
int diff;
@@ -2611,4 +2614,3 @@ ass_image_t* ass_render_frame(ass_renderer_t *priv, ass_track_t* track, long lon
return ass_renderer->images_root;
}
-
diff --git a/libmenu/menu.c b/libmenu/menu.c
index c8cf349c94..3ba54be45c 100644
--- a/libmenu/menu.c
+++ b/libmenu/menu.c
@@ -88,13 +88,15 @@ double menu_mouse_y = -1.0;
int menu_mouse_pos_updated = 0;
static struct MPContext *menu_ctx = NULL;
+static struct m_config *menu_mconfig = NULL;
+static struct input_ctx *menu_input = NULL;
static menu_def_t* menu_list = NULL;
static int menu_count = 0;
static menu_cmd_bindings_t *cmd_bindings = NULL;
static int cmd_bindings_num = 0;
-menu_cmd_bindings_t *get_cmd_bindings(const char *name) {
+static menu_cmd_bindings_t *get_cmd_bindings(const char *name) {
int i;
for (i = 0; i < cmd_bindings_num; ++i)
if (!strcasecmp(cmd_bindings[i].name, name))
@@ -102,16 +104,17 @@ menu_cmd_bindings_t *get_cmd_bindings(const char *name) {
return NULL;
}
-static int menu_parse_config(char* buffer) {
+static int menu_parse_config(char* buffer, struct m_config *mconfig)
+{
char *element,*body, **attribs, *name;
menu_info_t* minfo = NULL;
int r,i;
- ASX_Parser_t* parser = asx_parser_new();
+ ASX_Parser_t* parser = asx_parser_new(mconfig);
while(1) {
r = asx_get_element(parser,&buffer,&element,&body,&attribs);
if(r < 0) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] syntax error at line: %d\n",parser->line);
asx_parser_free(parser);
return 0;
} else if(r == 0) {
@@ -121,7 +124,7 @@ static int menu_parse_config(char* buffer) {
// Has it a name ?
name = asx_get_attrib("name",attribs);
if(!name) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuDefinitionsNeedANameAttrib,parser->line);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Menu definitions need a name attribute (line %d).\n",parser->line);
free(element);
if(body) free(body);
asx_free_attribs(attribs);
@@ -153,7 +156,7 @@ static int menu_parse_config(char* buffer) {
for(;;) {
r = asx_get_element(parser,&bd,&element,&b,&attribs);
if(r < 0) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_SyntaxErrorAtLine,
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] syntax error at line: %d\n",
parser->line);
free(body);
asx_parser_free(parser);
@@ -206,13 +209,13 @@ static int menu_parse_config(char* buffer) {
for(i = 0 ; attribs[2*i] ; i++) {
if(strcasecmp(attribs[2*i],"name") == 0) continue;
if(!m_struct_set(&minfo->priv_st,menu_list[menu_count].cfg,attribs[2*i], attribs[2*i+1]))
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_BadAttrib,attribs[2*i],attribs[2*i+1],
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] bad attribute %s=%s in menu '%s' at line %d\n",attribs[2*i],attribs[2*i+1],
name,parser->line);
}
menu_count++;
memset(&menu_list[menu_count],0,sizeof(menu_def_t));
} else {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnknownMenuType,element,parser->line);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] unknown menu type '%s' at line %d\n",element,parser->line);
free(name);
if(body) free(body);
}
@@ -228,7 +231,9 @@ static int menu_parse_config(char* buffer) {
#define BUF_STEP 1024
#define BUF_MIN 128
#define BUF_MAX BUF_STEP*1024
-int menu_init(struct MPContext *mpctx, char* cfg_file) {
+int menu_init(struct MPContext *mpctx, struct m_config *mconfig,
+ struct input_ctx *input_ctx, char* cfg_file)
+{
char* buffer = NULL;
int bl = BUF_STEP, br = 0;
int f, fd;
@@ -238,7 +243,7 @@ int menu_init(struct MPContext *mpctx, char* cfg_file) {
#endif
fd = open(cfg_file, O_RDONLY);
if(fd < 0) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantOpenConfigFile,cfg_file);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Can't open menu config file: %s\n",cfg_file);
return 0;
}
buffer = malloc(bl);
@@ -246,7 +251,7 @@ int menu_init(struct MPContext *mpctx, char* cfg_file) {
int r;
if(bl - br < BUF_MIN) {
if(bl >= BUF_MAX) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ConfigFileIsTooBig,BUF_MAX/1024);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Config file is too big (> %d KB)\n",BUF_MAX/1024);
close(fd);
free(buffer);
return 0;
@@ -259,7 +264,7 @@ int menu_init(struct MPContext *mpctx, char* cfg_file) {
br += r;
}
if(!br) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ConfigFileIsEmpty);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Config file is empty.\n");
return 0;
}
buffer[br-1] = '\0';
@@ -267,7 +272,9 @@ int menu_init(struct MPContext *mpctx, char* cfg_file) {
close(fd);
menu_ctx = mpctx;
- f = menu_parse_config(buffer);
+ menu_mconfig = mconfig;
+ menu_input = input_ctx;
+ f = menu_parse_config(buffer, mconfig);
free(buffer);
return f;
}
@@ -303,7 +310,8 @@ int menu_dflt_read_key(menu_t* menu,int cmd) {
for (i = 0; i < bindings->binding_num; ++i) {
if (bindings->bindings[i].key == cmd) {
if (bindings->bindings[i].cmd)
- mp_input_parse_and_queue_cmds(bindings->bindings[i].cmd);
+ mp_input_parse_and_queue_cmds(menu->input_ctx,
+ bindings->bindings[i].cmd);
return 1;
}
}
@@ -321,20 +329,22 @@ menu_t* menu_open(char *name) {
break;
}
if(menu_list[i].name == NULL) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuNotFound,name);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Menu %s not found.\n",name);
return NULL;
}
m = calloc(1,sizeof(menu_t));
m->priv_st = &(menu_list[i].type->priv_st);
m->priv = m_struct_copy(m->priv_st,menu_list[i].cfg);
m->ctx = menu_ctx;
+ m->mconfig = menu_mconfig;
+ m->input_ctx = menu_input;
m->type = &menu_list[i];
if(menu_list[i].type->open(m,menu_list[i].args))
return m;
if(m->priv)
m_struct_free(m->priv_st,m->priv);
free(m);
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuInitFailed,name);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Menu '%s': Init failed.\n",name);
return NULL;
}
@@ -472,7 +482,7 @@ void menu_draw_text(mp_image_t* mpi,char* txt, int x, int y) {
int font;
if(!draw_alpha) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnsupportedOutformat);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Unsupported output format!!!!\n");
return;
}
@@ -506,7 +516,7 @@ void menu_draw_text_full(mp_image_t* mpi,char* txt,
draw_alpha_f draw_alpha = get_draw_alpha(mpi->imgfmt);
if(!draw_alpha) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnsupportedOutformat);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Unsupported output format!!!!\n");
return;
}
@@ -725,7 +735,7 @@ int menu_text_num_lines(char* txt, int max_width) {
return l;
}
-char* menu_text_get_next_line(char* txt, int max_width) {
+static char* menu_text_get_next_line(char* txt, int max_width) {
int i = 0;
render_txt(txt);
while (*txt) {
@@ -748,7 +758,7 @@ void menu_draw_box(mp_image_t* mpi,unsigned char grey,unsigned char alpha, int x
int g;
if(!draw_alpha) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnsupportedOutformat);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Unsupported output format!!!!\n");
return;
}
diff --git a/libmenu/menu.h b/libmenu/menu.h
index d29091a4ae..cc76b5b7a3 100644
--- a/libmenu/menu.h
+++ b/libmenu/menu.h
@@ -31,6 +31,8 @@ struct m_struct_st;
struct menu_s {
struct MPContext *ctx;
+ struct m_config *mconfig;
+ struct input_ctx *input_ctx;
void (*draw)(menu_t* menu,mp_image_t* mpi);
void (*read_cmd)(menu_t* menu,int cmd);
int (*read_key)(menu_t* menu,int cmd);
@@ -70,7 +72,8 @@ typedef struct menu_info_s {
#define MENU_CMD_CLICK 11
/// Global init/uninit
-int menu_init(struct MPContext *mpctx, char* cfg_file);
+int menu_init(struct MPContext *mpctx, struct m_config *mconfig,
+ struct input_ctx *input_ctx, char* cfg_file);
void menu_uninit(void);
/// Open a menu defined in the config file
diff --git a/libmenu/menu_chapsel.c b/libmenu/menu_chapsel.c
index 01fcd25550..f350655311 100644
--- a/libmenu/menu_chapsel.c
+++ b/libmenu/menu_chapsel.c
@@ -141,9 +141,9 @@ static void read_cmd (menu_t* menu, int cmd)
case MENU_CMD_OK: {
char cmdbuf[26];
sprintf(cmdbuf, "seek_chapter %d 1", menu->priv->p.current->cid);
- mp_input_queue_cmd(mp_input_parse_cmd(cmdbuf));
+ mp_input_queue_cmd(menu->input_ctx, mp_input_parse_cmd(cmdbuf));
if (menu->priv->auto_close)
- mp_input_queue_cmd(mp_input_parse_cmd("menu hide"));
+ mp_input_queue_cmd(menu->input_ctx, mp_input_parse_cmd("menu hide"));
break;
}
default:
diff --git a/libmenu/menu_cmdlist.c b/libmenu/menu_cmdlist.c
index e146a4e9db..60146e31f1 100644
--- a/libmenu/menu_cmdlist.c
+++ b/libmenu/menu_cmdlist.c
@@ -71,21 +71,21 @@ static void read_cmd(menu_t* menu,int cmd) {
switch(cmd) {
case MENU_CMD_RIGHT:
if(mpriv->p.current->right) {
- mp_input_parse_and_queue_cmds(mpriv->p.current->right);
+ mp_input_parse_and_queue_cmds(menu->input_ctx, mpriv->p.current->right);
break;
} // fallback on ok if right is not defined
case MENU_CMD_OK:
if (mpriv->p.current->ok)
- mp_input_parse_and_queue_cmds(mpriv->p.current->ok);
+ mp_input_parse_and_queue_cmds(menu->input_ctx, mpriv->p.current->ok);
break;
case MENU_CMD_LEFT:
if(mpriv->p.current->left) {
- mp_input_parse_and_queue_cmds(mpriv->p.current->left);
+ mp_input_parse_and_queue_cmds(menu->input_ctx, mpriv->p.current->left);
break;
} // fallback on cancel if left is not defined
case MENU_CMD_CANCEL:
if(mpriv->p.current->cancel) {
- mp_input_parse_and_queue_cmds(mpriv->p.current->cancel);
+ mp_input_parse_and_queue_cmds(menu->input_ctx, mpriv->p.current->cancel);
break;
}
default:
@@ -114,24 +114,24 @@ static int parse_args(menu_t* menu,char* args) {
char *element,*body, **attribs, *name;
list_entry_t* m = NULL;
int r;
- ASX_Parser_t* parser = asx_parser_new();
+ ASX_Parser_t* parser = asx_parser_new(menu->mconfig);
while(1) {
r = asx_get_element(parser,&args,&element,&body,&attribs);
if(r < 0) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] syntax error at line: %d\n",parser->line);
asx_parser_free(parser);
return -1;
} else if(r == 0) {
asx_parser_free(parser);
if(!m)
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_NoEntryFoundInTheMenuDefinition);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] No entry found in the menu definition.\n");
return m ? 1 : 0;
}
// Has it a name ?
name = asx_get_attrib("name",attribs);
if(!name) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ListMenuEntryDefinitionsNeedAName,parser->line);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] List menu entry definitions need a name (line %d).\n",parser->line);
free(element);
if(body) free(body);
asx_free_attribs(attribs);
@@ -157,7 +157,7 @@ static int open_cmdlist(menu_t* menu, char* args) {
menu->close = close_menu;
if(!args) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ListMenuNeedsAnArgument);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] List menu needs an argument.\n");
return 0;
}
diff --git a/libmenu/menu_console.c b/libmenu/menu_console.c
index db0ab2d7db..8070ff63a3 100644
--- a/libmenu/menu_console.c
+++ b/libmenu/menu_console.c
@@ -265,10 +265,10 @@ static void check_child(menu_t* menu) {
mpriv->prompt = mpriv->mp_prompt;
//add_line(mpriv,"Child process exited");
}
- else mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WaitPidError,strerror(errno));
+ else mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] Waitpid error: %s.\n",strerror(errno));
}
} else if(r < 0) {
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_SelectError);
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] Select error.\n");
return;
}
@@ -278,7 +278,7 @@ static void check_child(menu_t* menu) {
if(w) mpriv->add_line = 1;
r = read(mpriv->child_fd[i],buffer,255);
if(r < 0)
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReadErrorOnChildFD, i == 1 ? "stdout":"stderr");
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] Read error on child's file descriptor: %s.\n", i == 1 ? "stdout":"stderr");
else if(r>0) {
buffer[r] = '\0';
add_string(mpriv,buffer);
@@ -296,9 +296,9 @@ static int run_shell_cmd(menu_t* menu, char* cmd) {
#ifndef __MINGW32__
int in[2],out[2],err[2];
- mp_msg(MSGT_GLOBAL,MSGL_INFO,MSGTR_LIBMENU_ConsoleRun,cmd);
+ mp_tmsg(MSGT_GLOBAL,MSGL_INFO,"[MENU] Console run: %s ...\n",cmd);
if(mpriv->child) {
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_AChildIsAlreadyRunning);
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] A child is already running.\n");
return 0;
}
@@ -308,7 +308,7 @@ static int run_shell_cmd(menu_t* menu, char* cmd) {
mpriv->child = fork();
if(mpriv->child < 0) {
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ForkFailed);
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] Fork failed !!!\n");
close_pipe(in);
close_pipe(out);
close_pipe(err);
@@ -382,14 +382,14 @@ static void read_cmd(menu_t* menu,int cmd) {
while(l > 0) {
int w = write(mpriv->child_fd[0],str,l);
if(w < 0) {
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError);
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] write error\n");
break;
}
l -= w;
str += w;
}
if(write(mpriv->child_fd[0],"\n",1) < 0)
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError);
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] write error\n");
enter_cmd(menu);
return;
}
@@ -420,7 +420,7 @@ static void read_cmd(menu_t* menu,int cmd) {
run_shell_cmd(menu,c->args[0].v.s);
break;
default: // Send the other commands to mplayer
- mp_input_queue_cmd(c);
+ mp_input_queue_cmd(menu->input_ctx, c);
}
}
return;
diff --git a/libmenu/menu_dvbin.c b/libmenu/menu_dvbin.c
index 0f84386f8c..e2b99a0f07 100644
--- a/libmenu/menu_dvbin.c
+++ b/libmenu/menu_dvbin.c
@@ -232,8 +232,8 @@ static void read_cmd(menu_t* menu, int cmd)
if(c)
{
if(mpriv->auto_close)
- mp_input_queue_cmd (mp_input_parse_cmd ("menu hide"));
- mp_input_queue_cmd(c);
+ mp_input_queue_cmd(menu->input_ctx, mp_input_parse_cmd ("menu hide"));
+ mp_input_queue_cmd(menu->input_ctx, c);
}
}
}
diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c
index 1321702945..08507bec20 100644
--- a/libmenu/menu_filesel.c
+++ b/libmenu/menu_filesel.c
@@ -48,7 +48,6 @@
int menu_keepdir = 0;
char *menu_chroot = NULL;
-extern char *filename;
struct list_entry_s {
struct list_entry p;
@@ -250,7 +249,7 @@ static int open_dir(menu_t* menu,char* args) {
mpriv->p.title = replace_path(mpriv->title,mpriv->dir,0);
if ((dirp = opendir (mpriv->dir)) == NULL){
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_OpendirError, strerror(errno));
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] opendir error: %s\n", strerror(errno));
return 0;
}
@@ -292,7 +291,7 @@ static int open_dir(menu_t* menu,char* args) {
if(n%20 == 0){ // Get some more mem
if((tp = (char **) realloc(namelist, (n+20) * sizeof (char *)))
== NULL) {
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReallocError, strerror(errno));
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] realloc error: %s\n", strerror(errno));
n--;
goto bailout;
}
@@ -301,7 +300,7 @@ static int open_dir(menu_t* menu,char* args) {
namelist[n] = (char *) malloc(strlen(dp->d_name) + 2);
if(namelist[n] == NULL){
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_MallocError, strerror(errno));
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] memory allocation error: %s\n", strerror(errno));
n--;
goto bailout;
}
@@ -319,7 +318,7 @@ bailout:
qsort(namelist, n, sizeof(char *), (kill_warn)compare);
if (n < 0) {
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReaddirError,strerror(errno));
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] readdir error: %s\n",strerror(errno));
return 0;
}
while(n--) {
@@ -330,7 +329,7 @@ bailout:
e->d = 1;
menu_list_add_entry(menu,e);
}else{
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_MallocError, strerror(errno));
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] memory allocation error: %s\n", strerror(errno));
}
free(namelist[n]);
}
@@ -369,7 +368,7 @@ static void read_cmd(menu_t* menu,int cmd) {
}
menu_list_uninit(menu,free_entry);
if(!open_dir(menu,p)) {
- mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_CantOpenDirectory,p);
+ mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[MENU] Can't open directory %s.\n",p);
menu->cl = 1;
}
free(p);
@@ -380,7 +379,7 @@ static void read_cmd(menu_t* menu,int cmd) {
char *action = mpriv->p.current->d ? mpriv->dir_action:mpriv->file_action;
sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt);
str = replace_path(action, filename,1);
- mp_input_parse_and_queue_cmds(str);
+ mp_input_parse_and_queue_cmds(menu->input_ctx, str);
if (str != action)
free(str);
}
@@ -391,7 +390,7 @@ static void read_cmd(menu_t* menu,int cmd) {
char *str;
sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt);
str = replace_path(action, filename,1);
- mp_input_parse_and_queue_cmds(str);
+ mp_input_parse_and_queue_cmds(menu->input_ctx, str);
if(str != action)
free(str);
} break;
diff --git a/libmenu/menu_list.c b/libmenu/menu_list.c
index 9264490b81..0fd6ffb2cf 100644
--- a/libmenu/menu_list.c
+++ b/libmenu/menu_list.c
@@ -332,4 +332,3 @@ void menu_list_uninit(menu_t* menu,free_entry_t free_func) {
mpriv->menu = mpriv->current = NULL;
}
-
diff --git a/libmenu/menu_param.c b/libmenu/menu_param.c
index 529cd49e2f..5052a26954 100644
--- a/libmenu/menu_param.c
+++ b/libmenu/menu_param.c
@@ -111,19 +111,19 @@ static int parse_args(menu_t* menu,char* args) {
list_entry_t* m = NULL;
int r;
m_option_t* opt;
- ASX_Parser_t* parser = asx_parser_new();
+ ASX_Parser_t* parser = asx_parser_new(menu->mconfig);
while(1) {
r = asx_get_element(parser,&args,&element,&body,&attribs);
if(r < 0) {
- mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line);
+ mp_tmsg(MSGT_OSD_MENU,MSGL_ERR,"[MENU] syntax error at line: %d\n",parser->line);
asx_parser_free(parser);
return -1;
} else if(r == 0) {
asx_parser_free(parser);
if(!m)
- mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_NoEntryFoundInTheMenuDefinition);
+ mp_tmsg(MSGT_OSD_MENU,MSGL_WARN,"[MENU] No entry found in the menu definition.\n");
m = calloc(1,sizeof(struct list_entry_s));
m->p.txt = strdup("Back");
menu_list_add_entry(menu,m);
@@ -132,7 +132,7 @@ static int parse_args(menu_t* menu,char* args) {
if(!strcmp(element,"menu")) {
name = asx_get_attrib("menu",attribs);
if(!name) {
- mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_SubmenuDefinitionNeedAMenuAttribut);
+ mp_tmsg(MSGT_OSD_MENU,MSGL_WARN,"[MENU] Submenu definition needs a 'menu' attribute.\n");
goto next_element;
}
m = calloc(1,sizeof(struct list_entry_s));
@@ -147,13 +147,13 @@ static int parse_args(menu_t* menu,char* args) {
name = asx_get_attrib("property",attribs);
opt = NULL;
if(name && mp_property_do(name,M_PROPERTY_GET_TYPE,&opt,menu->ctx) <= 0) {
- mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_InvalidProperty,
+ mp_tmsg(MSGT_OSD_MENU,MSGL_WARN,"[MENU] Invalid property '%s' in pref menu entry. (line %d).\n",
name,parser->line);
goto next_element;
}
txt = asx_get_attrib("txt",attribs);
if(!(name || txt)) {
- mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_PrefMenuEntryDefinitionsNeed,parser->line);
+ mp_tmsg(MSGT_OSD_MENU,MSGL_WARN,"[MENU] Pref menu entry definitions need a valid 'property' or 'txt' attribute (line %d).\n",parser->line);
if(txt) free(txt), txt = NULL;
goto next_element;
}
@@ -236,7 +236,7 @@ static void read_cmd(menu_t* menu,int cmd) {
char* txt = malloc(10 + strlen(e->menu) + 1);
sprintf(txt,"set_menu %s",e->menu);
c = mp_input_parse_cmd(txt);
- if(c) mp_input_queue_cmd(c);
+ if(c) mp_input_queue_cmd(menu->input_ctx, c);
return;
}
}
@@ -278,7 +278,7 @@ static int openMenu(menu_t* menu, char* args) {
if(!args) {
- mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_PrefMenuNeedsAnArgument);
+ mp_tmsg(MSGT_OSD_MENU,MSGL_ERR,"[MENU] Pref menu needs an argument.\n");
return 0;
}
diff --git a/libmenu/menu_pt.c b/libmenu/menu_pt.c
index f5f9999492..a985b63176 100644
--- a/libmenu/menu_pt.c
+++ b/libmenu/menu_pt.c
@@ -98,7 +98,7 @@ static void read_cmd(menu_t* menu,int cmd) {
d--;
}
if(i == NULL) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Can't find the target item ????\n");
break;
}
}
@@ -107,11 +107,11 @@ static void read_cmd(menu_t* menu,int cmd) {
c = mp_input_parse_cmd(str);
if(c) {
if(mpriv->auto_close)
- mp_input_queue_cmd(mp_input_parse_cmd("menu hide"));
- mp_input_queue_cmd(c);
+ mp_input_queue_cmd(menu->input_ctx, mp_input_parse_cmd("menu hide"));
+ mp_input_queue_cmd(menu->input_ctx, c);
}
else
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Failed to build command: %s.\n",str);
} break;
default:
menu_list_read_cmd(menu,cmd);
diff --git a/libmenu/menu_txt.c b/libmenu/menu_txt.c
index 30d0fcc98f..d7d2c874c5 100644
--- a/libmenu/menu_txt.c
+++ b/libmenu/menu_txt.c
@@ -141,13 +141,13 @@ static int open_txt(menu_t* menu, char* args) {
menu->read_cmd = read_cmd;
if(!mpriv->file) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuTxtNeedATxtFileName);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Text menu needs a textfile name (parameter file).\n");
return 0;
}
fd = fopen(mpriv->file,"r");
if(!fd) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuTxtCantOpen,mpriv->file);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Can't open %s.\n",mpriv->file);
return 0;
}
@@ -178,7 +178,7 @@ static int open_txt(menu_t* menu, char* args) {
mpriv->num_lines++;
}
if(pos >= BUF_SIZE-1) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_WarningTooLongLineSplitting);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Warning, line too long. Splitting it.\n");
mpriv->lines = realloc(mpriv->lines,(mpriv->num_lines + 1)*sizeof(char*));
mpriv->lines[mpriv->num_lines] = strdup(buf);
mpriv->num_lines++;
@@ -186,7 +186,7 @@ static int open_txt(menu_t* menu, char* args) {
}
}
- mp_msg(MSGT_GLOBAL,MSGL_INFO,MSGTR_LIBMENU_ParsedLines,mpriv->num_lines);
+ mp_tmsg(MSGT_GLOBAL,MSGL_INFO,"[MENU] Parsed %d lines.\n",mpriv->num_lines);
return 1;
}
diff --git a/libmenu/vf_menu.c b/libmenu/vf_menu.c
index 50c9ebfe1a..f8ceecc9ca 100644
--- a/libmenu/vf_menu.c
+++ b/libmenu/vf_menu.c
@@ -54,15 +54,15 @@ struct vf_priv_s {
int passthrough;
};
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts);
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts);
-void vf_menu_pause_update(struct vf_instance_s* vf) {
- const vo_functions_t *video_out = mpctx_get_video_out(vf->priv->current->ctx);
+void vf_menu_pause_update(struct vf_instance* vf) {
+ const struct vo *video_out = mpctx_get_video_out(vf->priv->current->ctx);
if(pause_mpi) {
put_image(vf,pause_mpi, MP_NOPTS_VALUE);
// Don't draw the osd atm
//vf->control(vf,VFCTRL_DRAW_OSD,NULL);
- video_out->flip_page();
+ vo_flip_page(video_out);
}
}
@@ -99,7 +99,7 @@ static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) {
else if(strcmp(arg,"hide") == 0 || strcmp(arg,"toggle") == 0)
priv->current->show = 0;
else
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnknownMenuCommand,arg);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Unknown command: '%s'.\n",arg);
return 1;
}
case MP_CMD_SET_MENU : {
@@ -107,7 +107,7 @@ static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) {
menu_t* l = priv->current;
priv->current = menu_open(menu);
if(!priv->current) {
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToOpenMenu,menu);
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Failed to open menu: '%s'.\n",menu);
priv->current = l;
priv->current->show = 0;
} else {
@@ -120,7 +120,7 @@ static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) {
return 0;
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
mp_image_t *dmpi;
if(mpi->type == MP_IMGTYPE_TEMP && (!(mpi->flags&MP_IMGFLAG_PRESERVE)) ) {
@@ -137,7 +137,7 @@ static int key_cb(int code) {
return menu_read_key(st_priv->current,code);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi = NULL;
if (vf->priv->passthrough) {
@@ -213,7 +213,7 @@ static void uninit(vf_instance_t *vf) {
}
}
-static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height,
+static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt) {
#ifdef CONFIG_FREETYPE
// here is the right place to get screen dimensions
@@ -227,8 +227,8 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
- return vf_next_query_format(vf,fmt);
+static int query_format(struct vf_instance* vf, unsigned int fmt){
+ return vf_next_query_format(vf, fmt);
}
static int open_vf(vf_instance_t *vf, char* args){
@@ -264,6 +264,3 @@ vf_info_t vf_info_menu = {
open_vf,
NULL
};
-
-
-
diff --git a/libmpcodecs/ad.c b/libmpcodecs/ad.c
index 01b9b26d9f..c7e87cd92e 100644
--- a/libmpcodecs/ad.c
+++ b/libmpcodecs/ad.c
@@ -14,34 +14,34 @@
/* Missed vorbis, mad, dshow */
//extern ad_functions_t mpcodecs_ad_null;
-extern ad_functions_t mpcodecs_ad_mp3lib;
-extern ad_functions_t mpcodecs_ad_ffmpeg;
-extern ad_functions_t mpcodecs_ad_liba52;
-extern ad_functions_t mpcodecs_ad_hwac3;
-extern ad_functions_t mpcodecs_ad_hwmpa;
-extern ad_functions_t mpcodecs_ad_pcm;
-extern ad_functions_t mpcodecs_ad_dvdpcm;
-extern ad_functions_t mpcodecs_ad_alaw;
-extern ad_functions_t mpcodecs_ad_imaadpcm;
-extern ad_functions_t mpcodecs_ad_msadpcm;
-extern ad_functions_t mpcodecs_ad_dk3adpcm;
-extern ad_functions_t mpcodecs_ad_dk4adpcm;
-extern ad_functions_t mpcodecs_ad_dshow;
-extern ad_functions_t mpcodecs_ad_dmo;
-extern ad_functions_t mpcodecs_ad_acm;
-extern ad_functions_t mpcodecs_ad_msgsm;
-extern ad_functions_t mpcodecs_ad_faad;
-extern ad_functions_t mpcodecs_ad_libvorbis;
-extern ad_functions_t mpcodecs_ad_speex;
-extern ad_functions_t mpcodecs_ad_libmad;
-extern ad_functions_t mpcodecs_ad_realaud;
-extern ad_functions_t mpcodecs_ad_libdv;
-extern ad_functions_t mpcodecs_ad_qtaudio;
-extern ad_functions_t mpcodecs_ad_twin;
-extern ad_functions_t mpcodecs_ad_libmusepack;
-extern ad_functions_t mpcodecs_ad_libdca;
+extern const ad_functions_t mpcodecs_ad_mp3lib;
+extern const ad_functions_t mpcodecs_ad_ffmpeg;
+extern const ad_functions_t mpcodecs_ad_liba52;
+extern const ad_functions_t mpcodecs_ad_hwac3;
+extern const ad_functions_t mpcodecs_ad_hwmpa;
+extern const ad_functions_t mpcodecs_ad_pcm;
+extern const ad_functions_t mpcodecs_ad_dvdpcm;
+extern const ad_functions_t mpcodecs_ad_alaw;
+extern const ad_functions_t mpcodecs_ad_imaadpcm;
+extern const ad_functions_t mpcodecs_ad_msadpcm;
+extern const ad_functions_t mpcodecs_ad_dk3adpcm;
+extern const ad_functions_t mpcodecs_ad_dk4adpcm;
+extern const ad_functions_t mpcodecs_ad_dshow;
+extern const ad_functions_t mpcodecs_ad_dmo;
+extern const ad_functions_t mpcodecs_ad_acm;
+extern const ad_functions_t mpcodecs_ad_msgsm;
+extern const ad_functions_t mpcodecs_ad_faad;
+extern const ad_functions_t mpcodecs_ad_libvorbis;
+extern const ad_functions_t mpcodecs_ad_speex;
+extern const ad_functions_t mpcodecs_ad_libmad;
+extern const ad_functions_t mpcodecs_ad_realaud;
+extern const ad_functions_t mpcodecs_ad_libdv;
+extern const ad_functions_t mpcodecs_ad_qtaudio;
+extern const ad_functions_t mpcodecs_ad_twin;
+extern const ad_functions_t mpcodecs_ad_libmusepack;
+extern const ad_functions_t mpcodecs_ad_libdca;
-ad_functions_t* mpcodecs_ad_drivers[] =
+const ad_functions_t * const mpcodecs_ad_drivers[] =
{
// &mpcodecs_ad_null,
#ifdef CONFIG_MP3LIB
diff --git a/libmpcodecs/ad.h b/libmpcodecs/ad.h
index 6f1d5e7566..a23faa24e7 100644
--- a/libmpcodecs/ad.h
+++ b/libmpcodecs/ad.h
@@ -7,9 +7,9 @@
typedef mp_codec_info_t ad_info_t;
/* interface of video decoder drivers */
-typedef struct ad_functions_s
+typedef struct ad_functions
{
- ad_info_t *info;
+ const ad_info_t *info;
int (*preinit)(sh_audio_t *sh);
int (*init)(sh_audio_t *sh);
void (*uninit)(sh_audio_t *sh);
@@ -18,7 +18,7 @@ typedef struct ad_functions_s
} ad_functions_t;
// NULL terminated array of all drivers
-extern ad_functions_t* mpcodecs_ad_drivers[];
+extern const ad_functions_t * const mpcodecs_ad_drivers[];
// fallback if ADCTRL_RESYNC not implemented: sh_audio->a_in_buffer_len=0;
#define ADCTRL_RESYNC_STREAM 1 /* resync, called after seeking! */
diff --git a/libmpcodecs/ad_acm.c b/libmpcodecs/ad_acm.c
index 33efe8f223..b5a416b145 100644
--- a/libmpcodecs/ad_acm.c
+++ b/libmpcodecs/ad_acm.c
@@ -11,7 +11,7 @@
#include "ad_internal.h"
#include "osdep/timer.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Win32/ACM decoders",
"acm",
@@ -59,7 +59,7 @@ static int preinit(sh_audio_t *sh_audio)
priv->o_wf = malloc(sizeof(WAVEFORMATEX));
if (!priv->o_wf)
{
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ACMiniterror);
+ mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n");
return 0;
}
@@ -90,7 +90,7 @@ static int preinit(sh_audio_t *sh_audio)
else
mp_msg(MSGT_WIN32, MSGL_ERR, "ACM_Decoder: acmStreamOpen error: %d\n",
(int)ret);
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ACMiniterror);
+ mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n");
return 0;
}
mp_msg(MSGT_WIN32, MSGL_V, "Audio codec opened OK! ;-)\n");
diff --git a/libmpcodecs/ad_alaw.c b/libmpcodecs/ad_alaw.c
index ae5f7605f1..61bb7e39ec 100644
--- a/libmpcodecs/ad_alaw.c
+++ b/libmpcodecs/ad_alaw.c
@@ -5,7 +5,7 @@
#include "config.h"
#include "ad_internal.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"aLaw/uLaw audio decoder",
"alaw",
diff --git a/libmpcodecs/ad_dk3adpcm.c b/libmpcodecs/ad_dk3adpcm.c
index 8e7c4bc93c..0db12138d6 100644
--- a/libmpcodecs/ad_dk3adpcm.c
+++ b/libmpcodecs/ad_dk3adpcm.c
@@ -19,7 +19,7 @@
#include "mpbswap.h"
#include "ad_internal.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Duck Corp. DK3 ADPCM decoder",
"dk3adpcm",
diff --git a/libmpcodecs/ad_dmo.c b/libmpcodecs/ad_dmo.c
index a810aecd72..d329caadaf 100644
--- a/libmpcodecs/ad_dmo.c
+++ b/libmpcodecs/ad_dmo.c
@@ -9,7 +9,7 @@
#include "ad_internal.h"
#include "libaf/reorder_ch.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Win32/DMO decoders",
"dmo",
@@ -34,7 +34,7 @@ static int preinit(sh_audio_t *sh_audio)
audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1);
if(!(ds_adec=DMO_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf,chans)))
{
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll);
+ mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll);
return 0;
}
sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
diff --git a/libmpcodecs/ad_dshow.c b/libmpcodecs/ad_dshow.c
index b4f0a742c5..db6a98cbee 100644
--- a/libmpcodecs/ad_dshow.c
+++ b/libmpcodecs/ad_dshow.c
@@ -8,7 +8,7 @@
#include "ad_internal.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Win32/DirectShow decoders",
"dshow",
@@ -31,7 +31,7 @@ static int preinit(sh_audio_t *sh_audio)
DS_AudioDecoder* ds_adec;
if(!(ds_adec=DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf)))
{
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll);
+ mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll);
return 0;
}
sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
diff --git a/libmpcodecs/ad_dvdpcm.c b/libmpcodecs/ad_dvdpcm.c
index 3b89cdac7f..ca56eeea1e 100644
--- a/libmpcodecs/ad_dvdpcm.c
+++ b/libmpcodecs/ad_dvdpcm.c
@@ -7,7 +7,7 @@
#include "help_mp.h"
#include "ad_internal.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Uncompressed DVD/VOB LPCM audio decoder",
"dvdpcm",
@@ -38,7 +38,7 @@ static int init(sh_audio_t *sh)
sh->samplesize = 2;
break;
case 1:
- mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_SamplesWanted);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Samples of this format are needed to improve support. Please contact the developers.\n");
sh->i_bps = sh->channels * sh->samplerate * 5 / 2;
case 2:
sh->sample_format = AF_FORMAT_S24_BE;
diff --git a/libmpcodecs/ad_faad.c b/libmpcodecs/ad_faad.c
index 1e973119c2..905decd977 100644
--- a/libmpcodecs/ad_faad.c
+++ b/libmpcodecs/ad_faad.c
@@ -28,7 +28,7 @@
#include "ad_internal.h"
#include "libaf/reorder_ch.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"AAC (MPEG2/4 Advanced Audio Coding)",
"faad",
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
index 770ff946e7..0a4db6c600 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -11,7 +11,7 @@
#include "mpbswap.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"FFmpeg/libavcodec audio decoders",
"ffmpeg",
@@ -49,7 +49,7 @@ static int init(sh_audio_t *sh_audio)
lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll);
if(!lavc_codec){
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_audio->codec->dll);
+ mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Cannot find codec '%s' in libavcodec...\n",sh_audio->codec->dll);
return 0;
}
@@ -88,7 +88,7 @@ static int init(sh_audio_t *sh_audio)
/* open it */
if (avcodec_open(lavc_context, lavc_codec) < 0) {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec);
+ mp_tmsg(MSGT_DECAUDIO,MSGL_ERR, "Could not open codec.\n");
return 0;
}
mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec init OK!\n");
@@ -138,7 +138,7 @@ static void uninit(sh_audio_t *sh)
AVCodecContext *lavc_context = sh->context;
if (avcodec_close(lavc_context) < 0)
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n");
av_freep(&lavc_context->extradata);
av_freep(&lavc_context);
}
diff --git a/libmpcodecs/ad_hwac3.c b/libmpcodecs/ad_hwac3.c
index 19a77baca6..14f884be54 100644
--- a/libmpcodecs/ad_hwac3.c
+++ b/libmpcodecs/ad_hwac3.c
@@ -27,7 +27,7 @@
static int isdts = -1;
-static ad_info_t info =
+static const ad_info_t info =
{
"AC3/DTS pass-through S/PDIF",
"hwac3",
diff --git a/libmpcodecs/ad_hwmpa.c b/libmpcodecs/ad_hwmpa.c
index ca60fcf69f..7cb25afab2 100644
--- a/libmpcodecs/ad_hwmpa.c
+++ b/libmpcodecs/ad_hwmpa.c
@@ -15,7 +15,7 @@
//based on ad_hwac3.c and ad_libmad.c
-static ad_info_t info =
+static const ad_info_t info =
{
"MPEG audio pass-through (fake decoder)",
"hwmpa",
diff --git a/libmpcodecs/ad_imaadpcm.c b/libmpcodecs/ad_imaadpcm.c
index 7b2b653bb6..9007e7695c 100644
--- a/libmpcodecs/ad_imaadpcm.c
+++ b/libmpcodecs/ad_imaadpcm.c
@@ -62,7 +62,7 @@ static const int8_t adpcm_index[8] =
// clamp a number above 16
#define CLAMP_ABOVE_16(x) if (x < 16) x = 16;
-static ad_info_t info =
+static const ad_info_t info =
{
"IMA ADPCM audio decoder",
"imaadpcm",
diff --git a/libmpcodecs/ad_internal.h b/libmpcodecs/ad_internal.h
index 0bd01bcd6c..4018b57657 100644
--- a/libmpcodecs/ad_internal.h
+++ b/libmpcodecs/ad_internal.h
@@ -17,7 +17,7 @@ static void uninit(sh_audio_t *sh);
static int control(sh_audio_t *sh,int cmd,void* arg, ...);
static int decode_audio(sh_audio_t *sh,unsigned char *buffer,int minlen,int maxlen);
-#define LIBAD_EXTERN(x) ad_functions_t mpcodecs_ad_##x = {\
+#define LIBAD_EXTERN(x) const ad_functions_t mpcodecs_ad_##x = {\
&info,\
preinit,\
init,\
diff --git a/libmpcodecs/ad_liba52.c b/libmpcodecs/ad_liba52.c
index e725c82da0..315ac1d4c9 100644
--- a/libmpcodecs/ad_liba52.c
+++ b/libmpcodecs/ad_liba52.c
@@ -45,7 +45,7 @@ static sample_t a52_level = 1;
float a52_drc_level = 1.0;
static int a52_drc_action = DRC_NO_ACTION;
-static ad_info_t info =
+static const ad_info_t info =
{
"AC3 decoding with liba52",
"liba52",
@@ -56,7 +56,7 @@ static ad_info_t info =
LIBAD_EXTERN(liba52)
-int a52_fillbuff(sh_audio_t *sh_audio){
+static int a52_fillbuff(sh_audio_t *sh_audio){
int length=0;
int flags=0;
int sample_rate=0;
@@ -120,7 +120,7 @@ int channels=0;
return (flags&A52_LFE) ? (channels+1) : channels;
}
-sample_t dynrng_call (sample_t c, void *data) {
+static sample_t dynrng_call (sample_t c, void *data) {
// fprintf(stderr, "(%lf, %lf): %lf\n", (double)c, (double)a52_drc_level, (double)pow((double)c, a52_drc_level));
return pow((double)c, a52_drc_level);
}
diff --git a/libmpcodecs/ad_libdca.c b/libmpcodecs/ad_libdca.c
index 1514a9953a..c167c92490 100644
--- a/libmpcodecs/ad_libdca.c
+++ b/libmpcodecs/ad_libdca.c
@@ -32,7 +32,7 @@
#include <dts.h>
-static ad_info_t info =
+static const ad_info_t info =
{
"DTS decoding with libdca",
"libdca",
diff --git a/libmpcodecs/ad_libdv.c b/libmpcodecs/ad_libdv.c
index 2fe7071b20..868d67303f 100644
--- a/libmpcodecs/ad_libdv.c
+++ b/libmpcodecs/ad_libdv.c
@@ -20,7 +20,7 @@
#include "ad_internal.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Raw DV Audio Decoder",
"libdv",
@@ -86,7 +86,7 @@ static int decode_audio(sh_audio_t *audio, unsigned char *buf, int minlen, int m
dv_parse_header(decoder, dv_audio_frame);
if(xx!=decoder->frame_size)
- mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_MPCODECS_AudioFramesizeDiffers,
+ mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[AD_LIBDV] Warning! Audio framesize differs! read=%d hdr=%d.\n",
xx, decoder->frame_size);
if (dv_decode_full_audio(decoder, dv_audio_frame,(int16_t**) audioBuffers))
diff --git a/libmpcodecs/ad_libmad.c b/libmpcodecs/ad_libmad.c
index fa544b3183..ffc8faf94b 100644
--- a/libmpcodecs/ad_libmad.c
+++ b/libmpcodecs/ad_libmad.c
@@ -8,7 +8,7 @@
#include "ad_internal.h"
-static ad_info_t info = {
+static const ad_info_t info = {
"libmad mpeg audio decoder",
"libmad",
"A'rpi",
diff --git a/libmpcodecs/ad_libvorbis.c b/libmpcodecs/ad_libvorbis.c
index b189542c77..a10d101126 100644
--- a/libmpcodecs/ad_libvorbis.c
+++ b/libmpcodecs/ad_libvorbis.c
@@ -9,7 +9,7 @@
#include "ad_internal.h"
#include "libaf/reorder_ch.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Ogg/Vorbis audio decoder",
#ifdef CONFIG_TREMOR
diff --git a/libmpcodecs/ad_mp3lib.c b/libmpcodecs/ad_mp3lib.c
index 8cab15bbdb..f10a718b09 100644
--- a/libmpcodecs/ad_mp3lib.c
+++ b/libmpcodecs/ad_mp3lib.c
@@ -6,7 +6,7 @@
#include "ad_internal.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"MPEG layer-2, layer-3",
"mp3lib",
diff --git a/libmpcodecs/ad_mpc.c b/libmpcodecs/ad_mpc.c
index 65dec395d4..0a7b08a618 100644
--- a/libmpcodecs/ad_mpc.c
+++ b/libmpcodecs/ad_mpc.c
@@ -16,7 +16,7 @@
#include "libaf/af_format.h"
#include "libvo/fastmemcpy.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Musepack audio decoder",
"mpcdec",
@@ -215,4 +215,3 @@ static int control(sh_audio_t *sh, int cmd, void* arg, ...) {
}
return CONTROL_UNKNOWN;
}
-
diff --git a/libmpcodecs/ad_msadpcm.c b/libmpcodecs/ad_msadpcm.c
index fa2bcbec2d..57beb9a84c 100644
--- a/libmpcodecs/ad_msadpcm.c
+++ b/libmpcodecs/ad_msadpcm.c
@@ -17,7 +17,7 @@
#include "mpbswap.h"
#include "ad_internal.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"MS ADPCM audio decoder",
"msadpcm",
diff --git a/libmpcodecs/ad_msgsm.c b/libmpcodecs/ad_msgsm.c
index ab21a99e9a..de1ea52aa2 100644
--- a/libmpcodecs/ad_msgsm.c
+++ b/libmpcodecs/ad_msgsm.c
@@ -5,7 +5,7 @@
#include "config.h"
#include "ad_internal.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"native GSM/MSGSM audio decoder",
"msgsm",
diff --git a/libmpcodecs/ad_pcm.c b/libmpcodecs/ad_pcm.c
index 20f33e14dc..058f6c25cb 100644
--- a/libmpcodecs/ad_pcm.c
+++ b/libmpcodecs/ad_pcm.c
@@ -2,12 +2,13 @@
#include <stdlib.h>
#include <unistd.h>
+#include "talloc.h"
#include "config.h"
#include "ad_internal.h"
#include "libaf/af_format.h"
#include "libaf/reorder_ch.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"Uncompressed PCM audio decoder",
"pcm",
@@ -16,6 +17,11 @@ static ad_info_t info =
""
};
+struct ad_pcm_context {
+ unsigned char *packet_ptr;
+ int packet_len;
+};
+
LIBAD_EXTERN(pcm)
static int init(sh_audio_t *sh_audio)
@@ -91,6 +97,7 @@ static int init(sh_audio_t *sh_audio)
}
if (!sh_audio->samplesize) // this would cause MPlayer to hang later
sh_audio->samplesize = 2;
+ sh_audio->context = talloc_zero(NULL, struct ad_pcm_context);
return 1;
}
@@ -102,6 +109,7 @@ static int preinit(sh_audio_t *sh)
static void uninit(sh_audio_t *sh)
{
+ talloc_free(sh->context);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
@@ -121,12 +129,37 @@ static int control(sh_audio_t *sh,int cmd,void* arg, ...)
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
unsigned len = sh_audio->channels*sh_audio->samplesize;
- len = (minlen + len - 1) / len * len;
- if (len > maxlen)
+ minlen = (minlen + len - 1) / len * len;
+ if (minlen > maxlen)
// if someone needs hundreds of channels adjust audio_out_minsize
// based on channels in preinit()
return -1;
- len=demux_read_data(sh_audio->ds,buf,len);
+
+ len = 0;
+ struct ad_pcm_context *ctx = sh_audio->context;
+ while (len < minlen) {
+ if (ctx->packet_len == 0) {
+ double pts;
+ int plen = ds_get_packet_pts(sh_audio->ds, &ctx->packet_ptr, &pts);
+ if (plen < 0)
+ break;
+ ctx->packet_len = plen;
+ if (pts != MP_NOPTS_VALUE) {
+ sh_audio->pts = pts;
+ sh_audio->pts_bytes = 0;
+ }
+ }
+ int from_stored = ctx->packet_len;
+ if (from_stored > minlen - len)
+ from_stored = minlen - len;
+ memcpy(buf + len, ctx->packet_ptr, from_stored);
+ ctx->packet_len -= from_stored;
+ ctx->packet_ptr += from_stored;
+ sh_audio->pts_bytes += from_stored;
+ len += from_stored;
+ }
+ if (len == 0)
+ len = -1; // The loop above only exits at error/EOF
if (len > 0 && sh_audio->channels >= 5) {
reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT,
AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
diff --git a/libmpcodecs/ad_qtaudio.c b/libmpcodecs/ad_qtaudio.c
index 4b2c876fb7..f3386957b5 100644
--- a/libmpcodecs/ad_qtaudio.c
+++ b/libmpcodecs/ad_qtaudio.c
@@ -15,7 +15,7 @@
#include "loader/wine/windef.h"
#endif
-static ad_info_t info = {
+static const ad_info_t info = {
"QuickTime Audio Decoder",
"qtaudio",
"A'rpi",
diff --git a/libmpcodecs/ad_realaud.c b/libmpcodecs/ad_realaud.c
index afc7e568bd..28ce717a5c 100644
--- a/libmpcodecs/ad_realaud.c
+++ b/libmpcodecs/ad_realaud.c
@@ -14,7 +14,7 @@
#include "ad_internal.h"
#include "loader/wine/windef.h"
-static ad_info_t info = {
+static const ad_info_t info = {
"RealAudio decoder",
"realaud",
"Alex Beregszaszi",
@@ -218,7 +218,7 @@ static int preinit(sh_audio_t *sh){
if (!load_syms_windows(sh->codec->dll))
#endif
{
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_MissingDLLcodec, sh->codec->dll);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "ERROR: Could not open required DirectShow codec %s.\n", sh->codec->dll);
mp_msg(MSGT_DECVIDEO, MSGL_HINT, "Read the RealAudio section of the DOCS!\n");
free(path);
return 0;
diff --git a/libmpcodecs/ad_sample.c b/libmpcodecs/ad_sample.c
index 5ddf4ef77b..74e2a19f18 100644
--- a/libmpcodecs/ad_sample.c
+++ b/libmpcodecs/ad_sample.c
@@ -7,7 +7,7 @@
#include "config.h"
#include "ad_internal.h"
-static ad_info_t info = {
+static const ad_info_t info = {
"Sample audio decoder", // name of the driver
"sample", // driver name. should be the same as filename without ad_
"A'rpi", // writer/maintainer of _this_ file
diff --git a/libmpcodecs/ad_speex.c b/libmpcodecs/ad_speex.c
index c41dfe8e3e..430d10a61d 100644
--- a/libmpcodecs/ad_speex.c
+++ b/libmpcodecs/ad_speex.c
@@ -11,7 +11,7 @@
#include <speex/speex_header.h>
#include "ad_internal.h"
-static ad_info_t info = {
+static const ad_info_t info ={
"Speex audio decoder",
"speex",
"Reimar Döffinger",
@@ -118,4 +118,3 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf,
static int control(sh_audio_t *sh, int cmd, void *arg, ...) {
return CONTROL_UNKNOWN;
}
-
diff --git a/libmpcodecs/ad_twin.c b/libmpcodecs/ad_twin.c
index 5f38dd0c4b..395567128a 100644
--- a/libmpcodecs/ad_twin.c
+++ b/libmpcodecs/ad_twin.c
@@ -11,7 +11,7 @@
#include "help_mp.h"
-static ad_info_t info =
+static const ad_info_t info =
{
"TWinVQ decoder",
"vqf",
diff --git a/libmpcodecs/ae.c b/libmpcodecs/ae.c
index 8640b87579..425c6c5ff9 100644
--- a/libmpcodecs/ae.c
+++ b/libmpcodecs/ae.c
@@ -96,5 +96,3 @@ audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params
encoder->codec = stream->codec;
return encoder;
}
-
-
diff --git a/libmpcodecs/ae_lame.c b/libmpcodecs/ae_lame.c
index 68143b860f..b719ce3865 100644
--- a/libmpcodecs/ae_lame.c
+++ b/libmpcodecs/ae_lame.c
@@ -39,6 +39,55 @@ static char* lame_param_preset=NULL; // unset
static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_name );
#endif
+#define MEncoderMP3LameHelp _("\n\n"\
+" vbr=<0-4> variable bitrate method\n"\
+" 0: cbr (constant bitrate)\n"\
+" 1: mt (Mark Taylor VBR algorithm)\n"\
+" 2: rh (Robert Hegemann VBR algorithm - default)\n"\
+" 3: abr (average bitrate)\n"\
+" 4: mtrh (Mark Taylor Robert Hegemann VBR algorithm)\n"\
+"\n"\
+" abr average bitrate\n"\
+"\n"\
+" cbr constant bitrate\n"\
+" Also forces CBR mode encoding on subsequent ABR presets modes.\n"\
+"\n"\
+" br=<0-1024> specify bitrate in kBit (CBR and ABR only)\n"\
+"\n"\
+" q=<0-9> quality (0-highest, 9-lowest) (only for VBR)\n"\
+"\n"\
+" aq=<0-9> algorithmic quality (0-best/slowest, 9-worst/fastest)\n"\
+"\n"\
+" ratio=<1-100> compression ratio\n"\
+"\n"\
+" vol=<0-10> set audio input gain\n"\
+"\n"\
+" mode=<0-3> (default: auto)\n"\
+" 0: stereo\n"\
+" 1: joint-stereo\n"\
+" 2: dualchannel\n"\
+" 3: mono\n"\
+"\n"\
+" padding=<0-2>\n"\
+" 0: no\n"\
+" 1: all\n"\
+" 2: adjust\n"\
+"\n"\
+" fast Switch on faster encoding on subsequent VBR presets modes,\n"\
+" slightly lower quality and higher bitrates.\n"\
+"\n"\
+" preset=<value> Provide the highest possible quality settings.\n"\
+" medium: VBR encoding, good quality\n"\
+" (150-180 kbps bitrate range)\n"\
+" standard: VBR encoding, high quality\n"\
+" (170-210 kbps bitrate range)\n"\
+" extreme: VBR encoding, very high quality\n"\
+" (200-240 kbps bitrate range)\n"\
+" insane: CBR encoding, highest preset quality\n"\
+" (320 kbps bitrate)\n"\
+" <8-320>: ABR encoding at average given kbps bitrate.\n\n")
+
+
m_option_t lameopts_conf[]={
{"q", &lame_param_quality, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
@@ -64,18 +113,18 @@ m_option_t lameopts_conf[]={
{"fast", "MPlayer was built without -lameopts fast support (requires libmp3lame >=3.92).\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
{"preset", "MPlayer was built without -lameopts preset support (requires libmp3lame >=3.92).\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
#endif
- {"help", MSGTR_MEncoderMP3LameHelp, CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+ {"help", MEncoderMP3LameHelp, CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
static int bind_lame(audio_encoder_t *encoder, muxer_stream_t *mux_a)
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MP3AudioSelected);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "MP3 audio selected.\n");
mux_a->h.dwSampleSize=0; // VBR
mux_a->h.dwRate=encoder->params.sample_rate;
mux_a->h.dwScale=encoder->params.samples_per_frame; // samples/frame
- if(sizeof(MPEGLAYER3WAVEFORMAT)!=30) mp_msg(MSGT_MENCODER,MSGL_WARN,MSGTR_MP3WaveFormatSizeNot30,sizeof(MPEGLAYER3WAVEFORMAT));
+ if(sizeof(MPEGLAYER3WAVEFORMAT)!=30) mp_tmsg(MSGT_MENCODER,MSGL_WARN,"sizeof(MPEGLAYER3WAVEFORMAT)==%d!=30, maybe broken C compiler?\n",sizeof(MPEGLAYER3WAVEFORMAT));
mux_a->wf=malloc(sizeof(MPEGLAYER3WAVEFORMAT)); // should be 30
mux_a->wf->wFormatTag=0x55; // MP3
mux_a->wf->nChannels= (lame_param_mode<0) ? encoder->params.channels : ((lame_param_mode==3) ? 1 : 2);
@@ -143,7 +192,7 @@ static void fixup(audio_encoder_t *encoder)
encoder->stream->h.dwRate=encoder->stream->wf->nAvgBytesPerSec;
encoder->stream->h.dwScale=1;
encoder->stream->wf->nBlockAlign=1;
- mp_msg(MSGT_MENCODER, MSGL_V, MSGTR_CBRAudioByterate,
+ mp_tmsg(MSGT_MENCODER, MSGL_V, "\n\nCBR audio: %d bytes/sec, %d bytes/block\n",
encoder->stream->h.dwRate,((MPEGLAYER3WAVEFORMAT*)(encoder->stream->wf))->nBlockSize);
}
}
@@ -174,20 +223,23 @@ int mpae_init_lame(audio_encoder_t *encoder)
if(lame_param_mode>=0) lame_set_mode(lame,lame_param_mode); // j-st
if(lame_param_ratio>0) lame_set_compression_ratio(lame,lame_param_ratio);
if(lame_param_scale>0) {
- mp_msg(MSGT_MENCODER, MSGL_V, MSGTR_SettingAudioInputGain, lame_param_scale);
+ mp_tmsg(MSGT_MENCODER, MSGL_V, "Setting audio input gain to %f.\n", lame_param_scale);
lame_set_scale(lame,lame_param_scale);
}
if(lame_param_lowpassfreq>=-1) lame_set_lowpassfreq(lame,lame_param_lowpassfreq);
if(lame_param_highpassfreq>=-1) lame_set_highpassfreq(lame,lame_param_highpassfreq);
#ifdef CONFIG_MP3LAME_PRESET
if(lame_param_preset != NULL) {
- mp_msg(MSGT_MENCODER, MSGL_V, MSGTR_LamePresetEquals,lame_param_preset);
+ mp_tmsg(MSGT_MENCODER, MSGL_V, "\npreset=%s\n\n",lame_param_preset);
if(lame_presets_set(lame,lame_param_fast, (lame_param_vbr==0), lame_param_preset) < 0)
return 0;
}
#endif
if(lame_init_params(lame) == -1) {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LameCantInit);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL,
+ "Cannot set LAME options, check bitrate/samplerate, some very low bitrates\n"\
+ "(<32) need lower samplerates (i.e. -srate 8000).\n"\
+ "If everything else fails, try a preset.");
return 0;
}
if( mp_msg_test(MSGT_MENCODER,MSGL_V) ) {
@@ -211,8 +263,87 @@ static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_
int mono = 0;
if (strcmp(preset_name, "help") == 0) {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LameVersion, get_lame_version(), get_lame_url());
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LamePresetsLongInfo);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url());
+
+#define LamePresetsLongInfo _("\n"\
+"The preset switches are designed to provide the highest possible quality.\n"\
+"\n"\
+"They have for the most part been subjected to and tuned via rigorous double\n"\
+"blind listening tests to verify and achieve this objective.\n"\
+"\n"\
+"These are continually updated to coincide with the latest developments that\n"\
+"occur and as a result should provide you with nearly the best quality\n"\
+"currently possible from LAME.\n"\
+"\n"\
+"To activate these presets:\n"\
+"\n"\
+" For VBR modes (generally highest quality):\n"\
+"\n"\
+" \"preset=standard\" This preset should generally be transparent\n"\
+" to most people on most music and is already\n"\
+" quite high in quality.\n"\
+"\n"\
+" \"preset=extreme\" If you have extremely good hearing and similar\n"\
+" equipment, this preset will generally provide\n"\
+" slightly higher quality than the \"standard\"\n"\
+" mode.\n"\
+"\n"\
+" For CBR 320kbps (highest quality possible from the preset switches):\n"\
+"\n"\
+" \"preset=insane\" This preset will usually be overkill for most\n"\
+" people and most situations, but if you must\n"\
+" have the absolute highest quality with no\n"\
+" regard to filesize, this is the way to go.\n"\
+"\n"\
+" For ABR modes (high quality per given bitrate but not as high as VBR):\n"\
+"\n"\
+" \"preset=<kbps>\" Using this preset will usually give you good\n"\
+" quality at a specified bitrate. Depending on the\n"\
+" bitrate entered, this preset will determine the\n"\
+" optimal settings for that particular situation.\n"\
+" While this approach works, it is not nearly as\n"\
+" flexible as VBR, and usually will not attain the\n"\
+" same level of quality as VBR at higher bitrates.\n"\
+"\n"\
+"The following options are also available for the corresponding profiles:\n"\
+"\n"\
+" <fast> standard\n"\
+" <fast> extreme\n"\
+" insane\n"\
+" <cbr> (ABR Mode) - The ABR Mode is implied. To use it,\n"\
+" simply specify a bitrate. For example:\n"\
+" \"preset=185\" activates this\n"\
+" preset and uses 185 as an average kbps.\n"\
+"\n"\
+" \"fast\" - Enables the new fast VBR for a particular profile. The\n"\
+" disadvantage to the speed switch is that often times the\n"\
+" bitrate will be slightly higher than with the normal mode\n"\
+" and quality may be slightly lower also.\n"\
+" Warning: with the current version fast presets might result in too\n"\
+" high bitrate compared to regular presets.\n"\
+"\n"\
+" \"cbr\" - If you use the ABR mode (read above) with a significant\n"\
+" bitrate such as 80, 96, 112, 128, 160, 192, 224, 256, 320,\n"\
+" you can use the \"cbr\" option to force CBR mode encoding\n"\
+" instead of the standard abr mode. ABR does provide higher\n"\
+" quality but CBR may be useful in situations such as when\n"\
+" streaming an MP3 over the internet may be important.\n"\
+"\n"\
+" For example:\n"\
+"\n"\
+" \"-lameopts fast:preset=standard \"\n"\
+" or \"-lameopts cbr:preset=192 \"\n"\
+" or \"-lameopts preset=172 \"\n"\
+" or \"-lameopts preset=extreme \"\n"\
+"\n"\
+"\n"\
+"A few aliases are available for ABR mode:\n"\
+"phone => 16kbps/mono phon+/lw/mw-eu/sw => 24kbps/mono\n"\
+"mw-us => 40kbps/mono voice => 56kbps/mono\n"\
+"fm/radio/tape => 112kbps hifi => 160kbps\n"\
+"cd => 192kbps studio => 256kbps")
+
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, LamePresetsLongInfo);
return -1;
}
@@ -307,14 +438,39 @@ static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_
}
else {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LameVersion, get_lame_version(), get_lame_url());
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_InvalidBitrateForLamePreset);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url());
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL,
+ "Error: The bitrate specified is out of the valid range for this preset.\n"\
+ "\n"\
+ "When using this mode you must enter a value between \"8\" and \"320\".\n"\
+ "\n"\
+ "For further information try: \"-lameopts preset=help\"\n");
return -1;
}
}
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LameVersion, get_lame_version(), get_lame_url());
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_InvalidLamePresetOptions);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url());
+#define InvalidLamePresetOptions _("Error: You did not enter a valid profile and/or options with preset.\n"\
+"\n"\
+"Available profiles are:\n"\
+"\n"\
+" <fast> standard\n"\
+" <fast> extreme\n"\
+" insane\n"\
+" <cbr> (ABR Mode) - The ABR Mode is implied. To use it,\n"\
+" simply specify a bitrate. For example:\n"\
+" \"preset=185\" activates this\n"\
+" preset and uses 185 as an average kbps.\n"\
+"\n"\
+" Some examples:\n"\
+"\n"\
+" \"-lameopts fast:preset=standard \"\n"\
+" or \"-lameopts cbr:preset=192 \"\n"\
+" or \"-lameopts preset=172 \"\n"\
+" or \"-lameopts preset=extreme \"\n"\
+"\n"\
+"For further information try: \"-lameopts preset=help\"\n")
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, InvalidLamePresetOptions);
return -1;
}
#endif
diff --git a/libmpcodecs/ae_lavc.c b/libmpcodecs/ae_lavc.c
index 781a100ff5..6806287e57 100644
--- a/libmpcodecs/ae_lavc.c
+++ b/libmpcodecs/ae_lavc.c
@@ -166,7 +166,7 @@ int mpae_init_lavc(audio_encoder_t *encoder)
if(!lavc_param_acodec)
{
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_NoLavcAudioCodecName);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, Missing codec name!\n");
return 0;
}
@@ -179,7 +179,7 @@ int mpae_init_lavc(audio_encoder_t *encoder)
lavc_acodec = avcodec_find_encoder_by_name(lavc_param_acodec);
if (!lavc_acodec)
{
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LavcAudioCodecNotFound, lavc_param_acodec);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, couldn't find encoder for codec %s.\n", lavc_param_acodec);
return 0;
}
if(lavc_param_atag == 0)
@@ -199,7 +199,7 @@ int mpae_init_lavc(audio_encoder_t *encoder)
lavc_actx = avcodec_alloc_context();
if(lavc_actx == NULL)
{
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CouldntAllocateLavcContext);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, couldn't allocate context!\n");
return 0;
}
@@ -238,7 +238,7 @@ int mpae_init_lavc(audio_encoder_t *encoder)
if(avcodec_open(lavc_actx, lavc_acodec) < 0)
{
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CouldntOpenCodec, lavc_param_acodec, lavc_param_abitrate);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Couldn't open codec %s, br=%d.\n", lavc_param_acodec, lavc_param_abitrate);
return 0;
}
@@ -256,4 +256,3 @@ int mpae_init_lavc(audio_encoder_t *encoder)
return 1;
}
-
diff --git a/libmpcodecs/ae_pcm.c b/libmpcodecs/ae_pcm.c
index c3aaeee724..d18381bf46 100644
--- a/libmpcodecs/ae_pcm.c
+++ b/libmpcodecs/ae_pcm.c
@@ -80,4 +80,3 @@ int mpae_init_pcm(audio_encoder_t *encoder)
return 1;
}
-
diff --git a/libmpcodecs/ae_toolame.c b/libmpcodecs/ae_toolame.c
index 49c186694e..04adc1e479 100644
--- a/libmpcodecs/ae_toolame.c
+++ b/libmpcodecs/ae_toolame.c
@@ -216,4 +216,3 @@ int mpae_init_toolame(audio_encoder_t *encoder)
return 1;
}
-
diff --git a/libmpcodecs/ae_twolame.c b/libmpcodecs/ae_twolame.c
index d557f9398b..37122933ea 100644
--- a/libmpcodecs/ae_twolame.c
+++ b/libmpcodecs/ae_twolame.c
@@ -215,4 +215,3 @@ int mpae_init_twolame(audio_encoder_t *encoder)
return 1;
}
-
diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c
index d73b381906..78dddbf05f 100644
--- a/libmpcodecs/dec_audio.c
+++ b/libmpcodecs/dec_audio.c
@@ -34,7 +34,7 @@ af_cfg_t af_cfg = { 1, NULL }; // Configuration for audio filters
void afm_help(void)
{
int i;
- mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_AvailableAudioFm);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Available (compiled-in) audio codec families/drivers:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_DRIVERS\n");
mp_msg(MSGT_DECAUDIO, MSGL_INFO, " afm: info: (comment)\n");
for (i = 0; mpcodecs_ad_drivers[i] != NULL; i++)
@@ -61,14 +61,14 @@ static int init_audio_codec(sh_audio_t *sh_audio)
}
}
if (!sh_audio->ad_driver->preinit(sh_audio)) {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_ADecoderPreinitFailed);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "ADecoder preinit failed :(\n");
return 0;
}
/* allocate audio in buffer: */
if (sh_audio->audio_in_minsize > 0) {
sh_audio->a_in_buffer_size = sh_audio->audio_in_minsize;
- mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_AllocatingBytesForInputBuffer,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_V, "dec_audio: Allocating %d bytes for input buffer.\n",
sh_audio->a_in_buffer_size);
sh_audio->a_in_buffer = av_mallocz(sh_audio->a_in_buffer_size);
sh_audio->a_in_buffer_len = 0;
@@ -76,18 +76,18 @@ static int init_audio_codec(sh_audio_t *sh_audio)
sh_audio->a_buffer_size = sh_audio->audio_out_minsize + MAX_OUTBURST;
- mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_AllocatingBytesForOutputBuffer,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_V, "dec_audio: Allocating %d + %d = %d bytes for output buffer.\n",
sh_audio->audio_out_minsize, MAX_OUTBURST, sh_audio->a_buffer_size);
sh_audio->a_buffer = av_mallocz(sh_audio->a_buffer_size);
if (!sh_audio->a_buffer) {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_CantAllocAudioBuf);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Cannot allocate audio out buffer.\n");
return 0;
}
sh_audio->a_buffer_len = 0;
if (!sh_audio->ad_driver->init(sh_audio)) {
- mp_msg(MSGT_DECAUDIO, MSGL_WARN, MSGTR_ADecoderInitFailed);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "ADecoder init failed :(\n");
uninit_audio(sh_audio); // free buffers
return 0;
}
@@ -95,7 +95,7 @@ static int init_audio_codec(sh_audio_t *sh_audio)
sh_audio->initialized = 1;
if (!sh_audio->channels || !sh_audio->samplerate) {
- mp_msg(MSGT_DECAUDIO, MSGL_WARN, MSGTR_UnknownAudio);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "Unknown/missing audio format -> no sound\n");
uninit_audio(sh_audio); // free buffers
return 0;
}
@@ -198,18 +198,18 @@ static int init_audio(sh_audio_t *sh_audio, char *codecname, char *afm,
}
#endif
if (!mpadec) { // driver not available (==compiled in)
- mp_msg(MSGT_DECAUDIO, MSGL_ERR,
- MSGTR_AudioCodecFamilyNotAvailableStr,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_ERR,
+ "Requested audio codec family [%s] (afm=%s) not available.\nEnable it at compilation.\n",
sh_audio->codec->name, sh_audio->codec->drv);
continue;
}
// it's available, let's try to init!
// init()
- mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_OpeningAudioDecoder,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Opening audio decoder: [%s] %s\n",
mpadec->info->short_name, mpadec->info->name);
sh_audio->ad_driver = mpadec;
if (!init_audio_codec(sh_audio)) {
- mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_ADecoderInitFailed);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "ADecoder init failed :(\n");
continue; // try next...
}
// Yeah! We got it!
@@ -237,7 +237,7 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list,
stringset_add(&selected, audio_codec + 1);
} else {
// forced codec by name:
- mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_ForcedAudioCodec,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Forced audio codec: %s\n",
audio_codec);
init_audio(sh_audio, audio_codec, NULL, -1, &selected);
}
@@ -250,7 +250,7 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list,
// try first the preferred codec families:
while (!sh_audio->initialized && *fmlist) {
char *audio_fm = *(fmlist++);
- mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_TryForceAudioFmtStr,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Trying to force audio codec driver family %s...\n",
audio_fm);
for (status = CODECS_STATUS__MAX;
status >= CODECS_STATUS__MIN; --status)
@@ -268,12 +268,12 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list,
stringset_free(&selected);
if (!sh_audio->initialized) {
- mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_CantFindAudioCodec,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Cannot find codec for audio format 0x%X.\n",
sh_audio->format);
return 0; // failed
}
- mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_SelectedAudioCodec,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Selected audio codec: [%s] afm: %s (%s)\n",
sh_audio->codec->name, sh_audio->codec->drv, sh_audio->codec->info);
return 1; // success
}
@@ -287,7 +287,7 @@ void uninit_audio(sh_audio_t *sh_audio)
sh_audio->afilter = NULL;
}
if (sh_audio->initialized) {
- mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_UninitAudioStr,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_V, "Uninit audio: %s\n",
sh_audio->codec->drv);
sh_audio->ad_driver->uninit(sh_audio);
#ifdef CONFIG_DYNAMIC_PLUGINS
@@ -327,7 +327,7 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate,
// filter config:
memcpy(&afs->cfg, &af_cfg, sizeof(af_cfg_t));
- mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_BuildingAudioFilterChain,
+ mp_tmsg(MSGT_DECAUDIO, MSGL_V, "Building audio filter chain for %dHz/%dch/%s -> %dHz/%dch/%s...\n",
afs->input.rate, afs->input.nch,
af_fmt2str_short(afs->input.format), afs->output.rate,
afs->output.nch, af_fmt2str_short(afs->output.format));
diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c
index 6d9eb97074..0a258fabcb 100644
--- a/libmpcodecs/dec_video.c
+++ b/libmpcodecs/dec_video.c
@@ -1,8 +1,9 @@
-
#include "config.h"
+#include "options.h"
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <unistd.h>
#include "mp_msg.h"
@@ -36,333 +37,381 @@ extern double vout_time_usage;
#include "cpudetect.h"
-int field_dominance=-1;
-
-int divx_quality=0;
+int field_dominance = -1;
-vd_functions_t* mpvdec=NULL;
+int divx_quality = 0;
-int get_video_quality_max(sh_video_t *sh_video){
- vf_instance_t* vf=sh_video->vfilter;
- if(vf){
- int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL);
- if(ret>0){
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingExternalPP,ret);
- return ret;
+int get_video_quality_max(sh_video_t *sh_video)
+{
+ vf_instance_t *vf = sh_video->vfilter;
+ if (vf) {
+ int ret = vf->control(vf, VFCTRL_QUERY_MAX_PP_LEVEL, NULL);
+ if (ret > 0) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[PP] Using external postprocessing filter, max q = %d.\n", ret);
+ return ret;
+ }
}
- }
- if(mpvdec){
- int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL);
- if(ret>0){
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingCodecPP,ret);
- return ret;
+ const struct vd_functions *vd = sh_video->vd_driver;
+ if (vd) {
+ int ret = vd->control(sh_video, VDCTRL_QUERY_MAX_PP_LEVEL, NULL);
+ if (ret > 0) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[PP] Using codec's postprocessing, max q = %d.\n", ret);
+ return ret;
+ }
}
- }
-// mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Sorry, postprocessing is not available\n");
- return 0;
+ return 0;
}
-void set_video_quality(sh_video_t *sh_video,int quality){
- vf_instance_t* vf=sh_video->vfilter;
- if(vf){
- int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality));
- if(ret==CONTROL_TRUE) return; // success
- }
- if(mpvdec)
- mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality));
+void set_video_quality(sh_video_t *sh_video, int quality)
+{
+ vf_instance_t *vf = sh_video->vfilter;
+ if (vf) {
+ int ret = vf->control(vf, VFCTRL_SET_PP_LEVEL, (void *) (&quality));
+ if (ret == CONTROL_TRUE)
+ return; // success
+ }
+ const struct vd_functions *vd = sh_video->vd_driver;
+ if (vd)
+ vd->control(sh_video, VDCTRL_SET_PP_LEVEL, (void *) (&quality));
}
-int set_video_colors(sh_video_t *sh_video,const char *item,int value)
+int set_video_colors(sh_video_t *sh_video, const char *item, int value)
{
- vf_instance_t* vf=sh_video->vfilter;
+ vf_instance_t *vf = sh_video->vfilter;
vf_equalizer_t data;
data.item = item;
data.value = value;
- mp_dbg(MSGT_DECVIDEO,MSGL_V,"set video colors %s=%d \n", item, value);
- if (vf)
- {
- int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data);
- if (ret == CONTROL_TRUE)
- return 1;
+ mp_dbg(MSGT_DECVIDEO, MSGL_V, "set video colors %s=%d \n", item, value);
+ if (vf) {
+ int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data);
+ if (ret == CONTROL_TRUE)
+ return 1;
}
/* try software control */
- if(mpvdec)
- if( mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER, item, (int *)value)
- == CONTROL_OK) return 1;
- mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_VideoAttributeNotSupportedByVO_VD,item);
+ const struct vd_functions *vd = sh_video->vd_driver;
+ if (vd &&
+ vd->control(sh_video, VDCTRL_SET_EQUALIZER, item, (int *) value)
+ == CONTROL_OK)
+ return 1;
+ mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Video attribute '%s' is not supported by selected vo & vd.\n",
+ item);
return 0;
}
-int get_video_colors(sh_video_t *sh_video,const char *item,int *value)
+int get_video_colors(sh_video_t *sh_video, const char *item, int *value)
{
- vf_instance_t* vf=sh_video->vfilter;
+ vf_instance_t *vf = sh_video->vfilter;
vf_equalizer_t data;
data.item = item;
- mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item);
- if (vf)
- {
+ mp_dbg(MSGT_DECVIDEO, MSGL_V, "get video colors %s \n", item);
+ if (vf) {
int ret = vf->control(vf, VFCTRL_GET_EQUALIZER, &data);
- if (ret == CONTROL_TRUE){
- *value = data.value;
- return 1;
- }
+ if (ret == CONTROL_TRUE) {
+ *value = data.value;
+ return 1;
+ }
}
/* try software control */
- if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value);
+ const struct vd_functions *vd = sh_video->vd_driver;
+ if (vd)
+ return vd->control(sh_video, VDCTRL_GET_EQUALIZER, item, value);
return 0;
}
-int set_rectangle(sh_video_t *sh_video,int param,int value)
+int set_rectangle(sh_video_t *sh_video, int param, int value)
{
- vf_instance_t* vf=sh_video->vfilter;
- int data[] = {param, value};
+ vf_instance_t *vf = sh_video->vfilter;
+ int data[] = { param, value };
- mp_dbg(MSGT_DECVIDEO,MSGL_V,"set rectangle \n");
- if (vf)
- {
+ mp_dbg(MSGT_DECVIDEO, MSGL_V, "set rectangle \n");
+ if (vf) {
int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data);
- if (ret)
- return 1;
+ if (ret)
+ return 1;
}
return 0;
}
+int redraw_osd(struct sh_video *sh_video, struct osd_state *osd)
+{
+ struct vf_instance *vf = sh_video->vfilter;
+ if (vf->control(vf, VFCTRL_REDRAW_OSD, osd) == true)
+ return 0;
+ return -1;
+}
+
void resync_video_stream(sh_video_t *sh_video)
{
- if(mpvdec) mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL);
+ const struct vd_functions *vd = sh_video->vd_driver;
+ if (vd)
+ vd->control(sh_video, VDCTRL_RESYNC_STREAM, NULL);
}
int get_current_video_decoder_lag(sh_video_t *sh_video)
{
- int ret;
-
- if (!mpvdec)
- return -1;
- ret = mpvdec->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL);
+ const struct vd_functions *vd = sh_video->vd_driver;
+ if (!vd)
+ return -1;
+ int ret = vd->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL);
if (ret >= 10)
- return ret-10;
+ return ret - 10;
return -1;
}
-void uninit_video(sh_video_t *sh_video){
- if(!sh_video->initialized) return;
- mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_UninitVideoStr,sh_video->codec->drv);
- mpvdec->uninit(sh_video);
+void uninit_video(sh_video_t *sh_video)
+{
+ if (!sh_video->initialized)
+ return;
+ mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Uninit video: %s\n", sh_video->codec->drv);
+ sh_video->vd_driver->uninit(sh_video);
#ifdef CONFIG_DYNAMIC_PLUGINS
if (sh_video->dec_handle)
- dlclose(sh_video->dec_handle);
+ dlclose(sh_video->dec_handle);
#endif
vf_uninit_filter_chain(sh_video->vfilter);
- sh_video->initialized=0;
+ sh_video->initialized = 0;
}
-void vfm_help(void){
+void vfm_help(void)
+{
int i;
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_AvailableVideoFm);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Available (compiled-in) video codec families/drivers:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_DRIVERS\n");
- mp_msg(MSGT_DECVIDEO,MSGL_INFO," vfm: info: (comment)\n");
- for (i=0; mpcodecs_vd_drivers[i] != NULL; i++)
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,"%8s %s (%s)\n",
- mpcodecs_vd_drivers[i]->info->short_name,
- mpcodecs_vd_drivers[i]->info->name,
- mpcodecs_vd_drivers[i]->info->comment);
+ mp_msg(MSGT_DECVIDEO, MSGL_INFO, " vfm: info: (comment)\n");
+ for (i = 0; mpcodecs_vd_drivers[i] != NULL; i++)
+ mp_msg(MSGT_DECVIDEO, MSGL_INFO, "%8s %s (%s)\n",
+ mpcodecs_vd_drivers[i]->info->short_name,
+ mpcodecs_vd_drivers[i]->info->name,
+ mpcodecs_vd_drivers[i]->info->comment);
}
-static int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status,
- stringset_t *selected){
+static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
+ int status, stringset_t *selected)
+{
int force = 0;
- unsigned int orig_fourcc=sh_video->bih?sh_video->bih->biCompression:0;
- sh_video->codec=NULL;
- sh_video->vf_initialized=0;
+ unsigned int orig_fourcc =
+ sh_video->bih ? sh_video->bih->biCompression : 0;
+ sh_video->codec = NULL;
+ sh_video->vf_initialized = 0;
if (codecname && codecname[0] == '+') {
- codecname = &codecname[1];
- force = 1;
+ codecname = &codecname[1];
+ force = 1;
}
- while(1){
- int i;
- int orig_w, orig_h;
- // restore original fourcc:
- if(sh_video->bih) sh_video->bih->biCompression=orig_fourcc;
- if(!(sh_video->codec=find_video_codec(sh_video->format,
- sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,
- sh_video->codec,force) )) break;
- // ok we found one codec
- if(stringset_test(selected, sh_video->codec->name)) continue; // already tried & failed
- if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc
- if(vfm && strcmp(sh_video->codec->drv,vfm)) continue; // vfm doesn't match
- if(!force && sh_video->codec->status<status) continue; // too unstable
- stringset_add(selected, sh_video->codec->name); // tagging it
- // ok, it matches all rules, let's find the driver!
- for (i=0; mpcodecs_vd_drivers[i] != NULL; i++)
-// if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break;
- if(!strcmp(mpcodecs_vd_drivers[i]->info->short_name,sh_video->codec->drv)) break;
- mpvdec=mpcodecs_vd_drivers[i];
+ while (1) {
+ int i;
+ int orig_w, orig_h;
+ // restore original fourcc:
+ if (sh_video->bih)
+ sh_video->bih->biCompression = orig_fourcc;
+ if (!
+ (sh_video->codec =
+ find_video_codec(sh_video->format,
+ sh_video->bih ? ((unsigned int *) &sh_video->
+ bih->biCompression) : NULL,
+ sh_video->codec, force)))
+ break;
+ // ok we found one codec
+ if (stringset_test(selected, sh_video->codec->name))
+ continue; // already tried & failed
+ if (codecname && strcmp(sh_video->codec->name, codecname))
+ continue; // -vc
+ if (vfm && strcmp(sh_video->codec->drv, vfm))
+ continue; // vfm doesn't match
+ if (!force && sh_video->codec->status < status)
+ continue; // too unstable
+ stringset_add(selected, sh_video->codec->name); // tagging it
+ // ok, it matches all rules, let's find the driver!
+ for (i = 0; mpcodecs_vd_drivers[i] != NULL; i++)
+ if (!strcmp(mpcodecs_vd_drivers[i]->info->short_name,
+ sh_video->codec->drv))
+ break;
+ sh_video->vd_driver = mpcodecs_vd_drivers[i];
#ifdef CONFIG_DYNAMIC_PLUGINS
- if (!mpvdec)
- {
- /* try to open shared decoder plugin */
- int buf_len;
- char *buf;
- vd_functions_t *funcs_sym;
- vd_info_t *info_sym;
-
- buf_len = strlen(MPLAYER_LIBDIR)+strlen(sh_video->codec->drv)+16;
- buf = malloc(buf_len);
- if (!buf)
- break;
- snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", MPLAYER_LIBDIR, sh_video->codec->drv);
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf);
- sh_video->dec_handle = dlopen(buf, RTLD_LAZY);
- if (!sh_video->dec_handle)
- break;
- snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv);
- funcs_sym = dlsym(sh_video->dec_handle, buf);
- if (!funcs_sym || !funcs_sym->info || !funcs_sym->init ||
- !funcs_sym->uninit || !funcs_sym->control || !funcs_sym->decode)
- break;
- info_sym = funcs_sym->info;
- if (strcmp(info_sym->short_name, sh_video->codec->drv))
- break;
- free(buf);
- mpvdec = funcs_sym;
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n",
- MPLAYER_LIBDIR, sh_video->codec->drv);
- }
+ if (!sh_video->vd_driver) {
+ /* try to open shared decoder plugin */
+ int buf_len;
+ char *buf;
+ vd_functions_t *funcs_sym;
+ vd_info_t *info_sym;
+
+ buf_len =
+ strlen(MPLAYER_LIBDIR) + strlen(sh_video->codec->drv) + 16;
+ buf = malloc(buf_len);
+ if (!buf)
+ break;
+ snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", MPLAYER_LIBDIR,
+ sh_video->codec->drv);
+ mp_msg(MSGT_DECVIDEO, MSGL_DBG2,
+ "Trying to open external plugin: %s\n", buf);
+ sh_video->dec_handle = dlopen(buf, RTLD_LAZY);
+ if (!sh_video->dec_handle)
+ break;
+ snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv);
+ funcs_sym = dlsym(sh_video->dec_handle, buf);
+ if (!funcs_sym || !funcs_sym->info || !funcs_sym->init
+ || !funcs_sym->uninit || !funcs_sym->control
+ || !funcs_sym->decode)
+ break;
+ info_sym = funcs_sym->info;
+ if (strcmp(info_sym->short_name, sh_video->codec->drv))
+ break;
+ free(buf);
+ sh_video->vd_driver = funcs_sym;
+ mp_msg(MSGT_DECVIDEO, MSGL_V,
+ "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n",
+ MPLAYER_LIBDIR, sh_video->codec->drv);
+ }
#endif
- if(!mpvdec){ // driver not available (==compiled in)
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_VideoCodecFamilyNotAvailableStr,
- sh_video->codec->name, sh_video->codec->drv);
- continue;
- }
- orig_w = sh_video->bih ? sh_video->bih->biWidth : sh_video->disp_w;
- orig_h = sh_video->bih ? sh_video->bih->biHeight : sh_video->disp_h;
- sh_video->disp_w = orig_w;
- sh_video->disp_h = orig_h;
- // it's available, let's try to init!
- if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){
- // align width/height to n*16
- sh_video->disp_w=(sh_video->disp_w+15)&(~15);
- sh_video->disp_h=(sh_video->disp_h+15)&(~15);
- }
- if (sh_video->bih) {
- sh_video->bih->biWidth = sh_video->disp_w;
- sh_video->bih->biHeight = sh_video->disp_h;
- }
- // init()
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_OpeningVideoDecoder,mpvdec->info->short_name,mpvdec->info->name);
- // clear vf init error, it is no longer relevant
- if (sh_video->vf_initialized < 0)
- sh_video->vf_initialized = 0;
- if(!mpvdec->init(sh_video)){
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_VDecoderInitFailed);
- sh_video->disp_w=orig_w;
- sh_video->disp_h=orig_h;
- if (sh_video->bih) {
- sh_video->bih->biWidth = sh_video->disp_w;
- sh_video->bih->biHeight = sh_video->disp_h;
- }
- continue; // try next...
- }
- // Yeah! We got it!
- sh_video->initialized=1;
- return 1;
+ if (!sh_video->vd_driver) { // driver not available (==compiled in)
+ mp_tmsg(MSGT_DECVIDEO, MSGL_WARN,
+ _("Requested video codec family [%s] (vfm=%s) not available.\nEnable it at compilation.\n"),
+ sh_video->codec->name, sh_video->codec->drv);
+ continue;
+ }
+ orig_w = sh_video->bih ? sh_video->bih->biWidth : sh_video->disp_w;
+ orig_h = sh_video->bih ? sh_video->bih->biHeight : sh_video->disp_h;
+ sh_video->disp_w = orig_w;
+ sh_video->disp_h = orig_h;
+ // it's available, let's try to init!
+ if (sh_video->codec->flags & CODECS_FLAG_ALIGN16) {
+ // align width/height to n*16
+ sh_video->disp_w = (sh_video->disp_w + 15) & (~15);
+ sh_video->disp_h = (sh_video->disp_h + 15) & (~15);
+ }
+ if (sh_video->bih) {
+ sh_video->bih->biWidth = sh_video->disp_w;
+ sh_video->bih->biHeight = sh_video->disp_h;
+ }
+
+ // init()
+ const struct vd_functions *vd = sh_video->vd_driver;
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Opening video decoder: [%s] %s\n",
+ vd->info->short_name, vd->info->name);
+ // clear vf init error, it is no longer relevant
+ if (sh_video->vf_initialized < 0)
+ sh_video->vf_initialized = 0;
+ if (!vd->init(sh_video)) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "VDecoder init failed :(\n");
+ sh_video->disp_w = orig_w;
+ sh_video->disp_h = orig_h;
+ if (sh_video->bih) {
+ sh_video->bih->biWidth = sh_video->disp_w;
+ sh_video->bih->biHeight = sh_video->disp_h;
+ }
+ continue; // try next...
+ }
+ // Yeah! We got it!
+ sh_video->initialized = 1;
+ return 1;
}
return 0;
}
-int init_best_video_codec(sh_video_t *sh_video,char** video_codec_list,char** video_fm_list){
-char* vc_l_default[2]={"",(char*)NULL};
-stringset_t selected;
-// hack:
-if(!video_codec_list) video_codec_list=vc_l_default;
-// Go through the codec.conf and find the best codec...
-sh_video->initialized=0;
-stringset_init(&selected);
-while(!sh_video->initialized && *video_codec_list){
- char* video_codec=*(video_codec_list++);
- if(video_codec[0]){
- if(video_codec[0]=='-'){
- // disable this codec:
- stringset_add(&selected, video_codec+1);
- } else {
- // forced codec by name:
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_ForcedVideoCodec,video_codec);
- init_video(sh_video,video_codec,NULL,-1, &selected);
- }
- } else {
- int status;
- // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING.
- if(video_fm_list){
- char** fmlist=video_fm_list;
- // try first the preferred codec families:
- while(!sh_video->initialized && *fmlist){
- char* video_fm=*(fmlist++);
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_TryForceVideoFmtStr,video_fm);
- for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status)
- if(init_video(sh_video,NULL,video_fm,status, &selected)) break;
- }
+int init_best_video_codec(sh_video_t *sh_video, char **video_codec_list,
+ char **video_fm_list)
+{
+ char *vc_l_default[2] = { "", (char *) NULL };
+ stringset_t selected;
+ // hack:
+ if (!video_codec_list)
+ video_codec_list = vc_l_default;
+ // Go through the codec.conf and find the best codec...
+ sh_video->initialized = 0;
+ stringset_init(&selected);
+ while (!sh_video->initialized && *video_codec_list) {
+ char *video_codec = *(video_codec_list++);
+ if (video_codec[0]) {
+ if (video_codec[0] == '-') {
+ // disable this codec:
+ stringset_add(&selected, video_codec + 1);
+ } else {
+ // forced codec by name:
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Forced video codec: %s\n",
+ video_codec);
+ init_video(sh_video, video_codec, NULL, -1, &selected);
+ }
+ } else {
+ int status;
+ // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING.
+ if (video_fm_list) {
+ char **fmlist = video_fm_list;
+ // try first the preferred codec families:
+ while (!sh_video->initialized && *fmlist) {
+ char *video_fm = *(fmlist++);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Trying to force video codec driver family %s...\n",
+ video_fm);
+ for (status = CODECS_STATUS__MAX;
+ status >= CODECS_STATUS__MIN; --status)
+ if (init_video
+ (sh_video, NULL, video_fm, status, &selected))
+ break;
+ }
+ }
+ if (!sh_video->initialized)
+ for (status = CODECS_STATUS__MAX; status >= CODECS_STATUS__MIN;
+ --status)
+ if (init_video(sh_video, NULL, NULL, status, &selected))
+ break;
+ }
}
- if(!sh_video->initialized)
- for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status)
- if(init_video(sh_video,NULL,NULL,status, &selected)) break;
- }
-}
-stringset_free(&selected);
+ stringset_free(&selected);
-if(!sh_video->initialized){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format);
- return 0; // failed
-}
+ if (!sh_video->initialized) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Cannot find codec matching selected -vo and video format 0x%X.\n",
+ sh_video->format);
+ return 0; // failed
+ }
-mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_SelectedVideoCodec,
- sh_video->codec->name,sh_video->codec->drv,sh_video->codec->info);
-return 1; // success
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Selected video codec: [%s] vfm: %s (%s)\n",
+ sh_video->codec->name, sh_video->codec->drv, sh_video->codec->info);
+ return 1; // success
}
void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
- int drop_frame, double pts)
+ int drop_frame, double pts)
{
mp_image_t *mpi = NULL;
unsigned int t = GetTimer();
unsigned int t2;
double tt;
+ struct MPOpts *opts = sh_video->opts;
- if (correct_pts && pts != MP_NOPTS_VALUE) {
- int delay = get_current_video_decoder_lag(sh_video);
- if (delay >= 0) {
- if (delay > sh_video->num_buffered_pts)
+ if (opts->correct_pts && pts != MP_NOPTS_VALUE) {
+ int delay = get_current_video_decoder_lag(sh_video);
+ if (delay >= 0) {
+ if (delay > sh_video->num_buffered_pts)
#if 0
- // this is disabled because vd_ffmpeg reports the same lag
- // after seek even when there are no buffered frames,
- // leading to incorrect error messages
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n");
+ // this is disabled because vd_ffmpeg reports the same lag
+ // after seek even when there are no buffered frames,
+ // leading to incorrect error messages
+ mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n");
#else
- ;
+ ;
#endif
- else
- sh_video->num_buffered_pts = delay;
- }
- if (sh_video->num_buffered_pts ==
- sizeof(sh_video->buffered_pts)/sizeof(double))
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n");
- else {
- int i, j;
- for (i = 0; i < sh_video->num_buffered_pts; i++)
- if (sh_video->buffered_pts[i] < pts)
- break;
- for (j = sh_video->num_buffered_pts; j > i; j--)
- sh_video->buffered_pts[j] = sh_video->buffered_pts[j-1];
- sh_video->buffered_pts[i] = pts;
- sh_video->num_buffered_pts++;
- }
+ else
+ sh_video->num_buffered_pts = delay;
+ }
+ if (sh_video->num_buffered_pts ==
+ sizeof(sh_video->buffered_pts) / sizeof(double))
+ mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n");
+ else {
+ int i, j;
+ for (i = 0; i < sh_video->num_buffered_pts; i++)
+ if (sh_video->buffered_pts[i] < pts)
+ break;
+ for (j = sh_video->num_buffered_pts; j > i; j--)
+ sh_video->buffered_pts[j] = sh_video->buffered_pts[j - 1];
+ sh_video->buffered_pts[i] = pts;
+ sh_video->num_buffered_pts++;
+ }
}
- mpi = mpvdec->decode(sh_video, start, in_size, drop_frame);
+ mpi = sh_video->vd_driver->decode(sh_video, start, in_size, drop_frame);
//------------------------ frame decoded. --------------------
@@ -370,35 +419,34 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
// some codecs are broken, and doesn't restore MMX state :(
// it happens usually with broken/damaged files.
if (gCpuCaps.has3DNow) {
- __asm__ volatile ("femms\n\t":::"memory");
- }
- else if (gCpuCaps.hasMMX) {
- __asm__ volatile ("emms\n\t":::"memory");
+ __asm__ volatile("femms\n\t":::"memory");
+ } else if (gCpuCaps.hasMMX) {
+ __asm__ volatile("emms\n\t":::"memory");
}
#endif
- t2 = GetTimer(); t = t2-t;
- tt = t*0.000001f;
+ t2 = GetTimer();
+ t = t2 - t;
+ tt = t * 0.000001f;
video_time_usage += tt;
if (!mpi || drop_frame)
- return NULL; // error / skipped frame
+ return NULL; // error / skipped frame
if (field_dominance == 0)
- mpi->fields |= MP_IMGFIELD_TOP_FIRST;
+ mpi->fields |= MP_IMGFIELD_TOP_FIRST;
else if (field_dominance == 1)
- mpi->fields &= ~MP_IMGFIELD_TOP_FIRST;
-
- if (correct_pts) {
- if (sh_video->num_buffered_pts) {
- sh_video->num_buffered_pts--;
- sh_video->pts = sh_video->buffered_pts[sh_video->num_buffered_pts];
- }
- else {
- mp_msg(MSGT_CPLAYER, MSGL_ERR, "No pts value from demuxer to "
- "use for frame!\n");
- sh_video->pts = MP_NOPTS_VALUE;
- }
+ mpi->fields &= ~MP_IMGFIELD_TOP_FIRST;
+
+ if (opts->correct_pts) {
+ if (sh_video->num_buffered_pts) {
+ sh_video->num_buffered_pts--;
+ sh_video->pts = sh_video->buffered_pts[sh_video->num_buffered_pts];
+ } else {
+ mp_msg(MSGT_CPLAYER, MSGL_ERR,
+ "No pts value from demuxer to " "use for frame!\n");
+ sh_video->pts = MP_NOPTS_VALUE;
+ }
}
return mpi;
}
@@ -410,18 +458,9 @@ int filter_video(sh_video_t *sh_video, void *frame, double pts)
vf_instance_t *vf = sh_video->vfilter;
// apply video filters and call the leaf vo/ve
int ret = vf->put_image(vf, mpi, pts);
- if (ret > 0) {
- // draw EOSD first so it ends up below the OSD.
- // Note that changing this is will not work right with vf_ass and the
- // vos currently always draw the EOSD first in paused mode.
-#ifdef CONFIG_ASS
- vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
-#endif
- vf->control(vf, VFCTRL_DRAW_OSD, NULL);
- }
- t2 = GetTimer()-t2;
- vout_time_usage += t2*0.000001;
+ t2 = GetTimer() - t2;
+ vout_time_usage += t2 * 0.000001;
return ret;
}
diff --git a/libmpcodecs/dec_video.h b/libmpcodecs/dec_video.h
index 7a08a0410e..606fbe946e 100644
--- a/libmpcodecs/dec_video.h
+++ b/libmpcodecs/dec_video.h
@@ -3,6 +3,8 @@
#include "libmpdemux/stheader.h"
+struct osd_state;
+
// dec_video.c:
void vfm_help(void);
@@ -18,6 +20,7 @@ void set_video_quality(sh_video_t *sh_video, int quality);
int get_video_colors(sh_video_t *sh_video, const char *item, int *value);
int set_video_colors(sh_video_t *sh_video, const char *item, int value);
int set_rectangle(sh_video_t *sh_video, int param, int value);
+int redraw_osd(struct sh_video *sh_video, struct osd_state *osd);
void resync_video_stream(sh_video_t *sh_video);
int get_current_video_decoder_lag(sh_video_t *sh_video);
diff --git a/libmpcodecs/mp_image.h b/libmpcodecs/mp_image.h
index ddf52c71c5..77ce04102a 100644
--- a/libmpcodecs/mp_image.h
+++ b/libmpcodecs/mp_image.h
@@ -78,7 +78,7 @@
#define MP_IMGFIELD_BOTTOM 0x10
#define MP_IMGFIELD_INTERLACED 0x20
-typedef struct mp_image_s {
+typedef struct mp_image {
unsigned int flags;
unsigned char type;
int number;
diff --git a/libmpcodecs/native/xa_gsm.c b/libmpcodecs/native/xa_gsm.c
index 73bf31c3d8..2fc2357c13 100644
--- a/libmpcodecs/native/xa_gsm.c
+++ b/libmpcodecs/native/xa_gsm.c
@@ -258,7 +258,7 @@ register word * s;
}
/**** 4.3.2 */
-void Gsm_Long_Term_Synthesis_Filtering (S,Ncr,bcr,erp,drp)
+static void Gsm_Long_Term_Synthesis_Filtering (S,Ncr,bcr,erp,drp)
XA_GSM_STATE * S;
word Ncr;
word bcr;
diff --git a/libmpcodecs/pullup.c b/libmpcodecs/pullup.c
index a74cb83b20..90aa2b87b7 100644
--- a/libmpcodecs/pullup.c
+++ b/libmpcodecs/pullup.c
@@ -804,12 +804,3 @@ void pullup_free_context(struct pullup_context *c)
free(c->frame);
free(c);
}
-
-
-
-
-
-
-
-
-
diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c
index 3bf99190fd..62a3fcbdda 100644
--- a/libmpcodecs/vd.c
+++ b/libmpcodecs/vd.c
@@ -5,9 +5,9 @@
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "options.h"
#include "codec-cfg.h"
-//#include "mp_image.h"
#include "img_format.h"
@@ -19,312 +19,310 @@
#include "vd.h"
#include "vf.h"
-//#include "vd_internal.h"
-
-extern vd_functions_t mpcodecs_vd_null;
-extern vd_functions_t mpcodecs_vd_ffmpeg;
-extern vd_functions_t mpcodecs_vd_theora;
-extern vd_functions_t mpcodecs_vd_dshow;
-extern vd_functions_t mpcodecs_vd_dmo;
-extern vd_functions_t mpcodecs_vd_vfw;
-extern vd_functions_t mpcodecs_vd_vfwex;
-extern vd_functions_t mpcodecs_vd_raw;
-extern vd_functions_t mpcodecs_vd_hmblck;
-extern vd_functions_t mpcodecs_vd_xanim;
-extern vd_functions_t mpcodecs_vd_mpng;
-extern vd_functions_t mpcodecs_vd_ijpg;
-extern vd_functions_t mpcodecs_vd_mtga;
-extern vd_functions_t mpcodecs_vd_sgi;
-extern vd_functions_t mpcodecs_vd_libmpeg2;
-extern vd_functions_t mpcodecs_vd_mpegpes;
-extern vd_functions_t mpcodecs_vd_zrmjpeg;
-extern vd_functions_t mpcodecs_vd_realvid;
-extern vd_functions_t mpcodecs_vd_xvid;
-extern vd_functions_t mpcodecs_vd_libdv;
-extern vd_functions_t mpcodecs_vd_lzo;
-extern vd_functions_t mpcodecs_vd_qtvideo;
+extern const vd_functions_t mpcodecs_vd_null;
+extern const vd_functions_t mpcodecs_vd_ffmpeg;
+extern const vd_functions_t mpcodecs_vd_theora;
+extern const vd_functions_t mpcodecs_vd_dshow;
+extern const vd_functions_t mpcodecs_vd_dmo;
+extern const vd_functions_t mpcodecs_vd_vfw;
+extern const vd_functions_t mpcodecs_vd_vfwex;
+extern const vd_functions_t mpcodecs_vd_raw;
+extern const vd_functions_t mpcodecs_vd_hmblck;
+extern const vd_functions_t mpcodecs_vd_xanim;
+extern const vd_functions_t mpcodecs_vd_mpng;
+extern const vd_functions_t mpcodecs_vd_ijpg;
+extern const vd_functions_t mpcodecs_vd_mtga;
+extern const vd_functions_t mpcodecs_vd_sgi;
+extern const vd_functions_t mpcodecs_vd_libmpeg2;
+extern const vd_functions_t mpcodecs_vd_mpegpes;
+extern const vd_functions_t mpcodecs_vd_zrmjpeg;
+extern const vd_functions_t mpcodecs_vd_realvid;
+extern const vd_functions_t mpcodecs_vd_xvid;
+extern const vd_functions_t mpcodecs_vd_libdv;
+extern const vd_functions_t mpcodecs_vd_lzo;
+extern const vd_functions_t mpcodecs_vd_qtvideo;
/* Please do not add any new decoders here. If you want to implement a new
* decoder, add it to libavcodec, except for wrappers around external
* libraries and decoders requiring binary support. */
const vd_functions_t * const mpcodecs_vd_drivers[] = {
- &mpcodecs_vd_null,
+ &mpcodecs_vd_null,
#ifdef CONFIG_LIBAVCODEC
- &mpcodecs_vd_ffmpeg,
+ &mpcodecs_vd_ffmpeg,
#endif
#ifdef CONFIG_OGGTHEORA
- &mpcodecs_vd_theora,
+ &mpcodecs_vd_theora,
#endif
#ifdef CONFIG_WIN32DLL
- &mpcodecs_vd_dshow,
- &mpcodecs_vd_dmo,
- &mpcodecs_vd_vfw,
- &mpcodecs_vd_vfwex,
+ &mpcodecs_vd_dshow,
+ &mpcodecs_vd_dmo,
+ &mpcodecs_vd_vfw,
+ &mpcodecs_vd_vfwex,
#endif
- &mpcodecs_vd_lzo,
- &mpcodecs_vd_raw,
- &mpcodecs_vd_hmblck,
+ &mpcodecs_vd_lzo,
+ &mpcodecs_vd_raw,
+ &mpcodecs_vd_hmblck,
#ifdef CONFIG_XANIM
- &mpcodecs_vd_xanim,
+ &mpcodecs_vd_xanim,
#endif
#ifdef CONFIG_PNG
- &mpcodecs_vd_mpng,
+ &mpcodecs_vd_mpng,
#endif
#ifdef CONFIG_JPEG
- &mpcodecs_vd_ijpg,
+ &mpcodecs_vd_ijpg,
#endif
- &mpcodecs_vd_mtga,
- &mpcodecs_vd_sgi,
+ &mpcodecs_vd_mtga,
+ &mpcodecs_vd_sgi,
#ifdef CONFIG_LIBMPEG2
- &mpcodecs_vd_libmpeg2,
+ &mpcodecs_vd_libmpeg2,
#endif
- &mpcodecs_vd_mpegpes,
+ &mpcodecs_vd_mpegpes,
#ifdef CONFIG_ZR
- &mpcodecs_vd_zrmjpeg,
+ &mpcodecs_vd_zrmjpeg,
#endif
#ifdef CONFIG_REALCODECS
- &mpcodecs_vd_realvid,
+ &mpcodecs_vd_realvid,
#endif
#ifdef CONFIG_XVID4
- &mpcodecs_vd_xvid,
+ &mpcodecs_vd_xvid,
#endif
#ifdef CONFIG_LIBDV095
- &mpcodecs_vd_libdv,
+ &mpcodecs_vd_libdv,
#endif
#ifdef CONFIG_QTX_CODECS
- &mpcodecs_vd_qtvideo,
+ &mpcodecs_vd_qtvideo,
#endif
/* Please do not add any new decoders here. If you want to implement a new
* decoder, add it to libavcodec, except for wrappers around external
* libraries and decoders requiring binary support. */
- NULL
+ NULL
};
#include "libvo/video_out.h"
-// libvo opts:
-int fullscreen=0;
-int vidmode=0;
-int softzoom=0;
-int flip=-1;
-int opt_screen_size_x=0;
-int opt_screen_size_y=0;
-float screen_size_xy=0;
-float movie_aspect=-1.0;
-int vo_flags=0;
-int vd_use_slices=1;
-
-/** global variables for gamma, brightness, contrast, saturation and hue
- modified by mplayer.c and gui/mplayer/gtk/eq.c:
- ranges -100 - 100
- 1000 if the vo default should be used
-*/
-int vo_gamma_gamma = 1000;
-int vo_gamma_brightness = 1000;
-int vo_gamma_contrast = 1000;
-int vo_gamma_saturation = 1000;
-int vo_gamma_hue = 1000;
-
-extern vd_functions_t* mpvdec; // FIXME!
-
-#define SCREEN_SIZE_X 1
-#define SCREEN_SIZE_Y 1
-
-int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){
- int i,j;
- unsigned int out_fmt=0;
- int screen_size_x=0;//SCREEN_SIZE_X;
- int screen_size_y=0;//SCREEN_SIZE_Y;
- vf_instance_t* vf=sh->vfilter,*sc=NULL;
- int palette=0;
- int vocfg_flags=0;
-
- if(w)
- sh->disp_w=w;
- if(h)
- sh->disp_h=h;
-
- if(!sh->disp_w || !sh->disp_h)
- return 0;
-
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_VoConfigRequest,w,h,vo_format_name(preferred_outfmt));
-
-// if(!vf) return 1; // temp hack
-
- if(get_video_quality_max(sh)<=0 && divx_quality){
- // user wants postprocess but no pp filter yet:
- sh->vfilter=vf=vf_open_filter(vf,"pp",NULL);
+int mpcodecs_config_vo(sh_video_t *sh, int w, int h,
+ unsigned int preferred_outfmt)
+{
+ struct MPOpts *opts = sh->opts;
+ int i, j;
+ unsigned int out_fmt = 0;
+ int screen_size_x = 0;
+ int screen_size_y = 0;
+ vf_instance_t *vf = sh->vfilter, *sc = NULL;
+ int palette = 0;
+ int vocfg_flags = 0;
+
+ if (w)
+ sh->disp_w = w;
+ if (h)
+ sh->disp_h = h;
+
+ if (!sh->disp_w || !sh->disp_h)
+ return 0;
+
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "VDec: vo config request - %d x %d (preferred colorspace: %s)\n", w, h,
+ vo_format_name(preferred_outfmt));
+
+ if (get_video_quality_max(sh) <= 0 && divx_quality) {
+ // user wants postprocess but no pp filter yet:
+ sh->vfilter = vf = vf_open_filter(opts, vf, "pp", NULL);
}
-
// check if libvo and codec has common outfmt (no conversion):
-csp_again:
-
- if( mp_msg_test(MSGT_DECVIDEO,MSGL_V) ){
- vf_instance_t* f=vf;
- mp_msg(MSGT_DECVIDEO,MSGL_V,"Trying filter chain:");
- for(f = vf ; f ; f = f->next)
- mp_msg(MSGT_DECVIDEO,MSGL_V," %s",f->info->name);
- mp_msg(MSGT_DECVIDEO,MSGL_V,"\n");
+ csp_again:
+
+ if (mp_msg_test(MSGT_DECVIDEO, MSGL_V)) {
+ vf_instance_t *f = vf;
+ mp_msg(MSGT_DECVIDEO, MSGL_V, "Trying filter chain:");
+ for (f = vf; f; f = f->next)
+ mp_msg(MSGT_DECVIDEO, MSGL_V, " %s", f->info->name);
+ mp_msg(MSGT_DECVIDEO, MSGL_V, "\n");
}
- j=-1;
- for(i=0;i<CODECS_MAX_OUTFMT;i++){
- int flags;
- out_fmt=sh->codec->outfmt[i];
- if(out_fmt==(unsigned int)0xFFFFFFFF) continue;
- flags=vf->query_format(vf,out_fmt);
- mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: query(%s) returned 0x%X (i=%d) \n",vo_format_name(out_fmt),flags,i);
- if((flags&VFCAP_CSP_SUPPORTED_BY_HW) || (flags&VFCAP_CSP_SUPPORTED && j<0)){
- // check (query) if codec really support this outfmt...
- sh->outfmtidx=j; // pass index to the control() function this way
- if(mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)==CONTROL_FALSE){
- mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: codec query_format(%s) returned FALSE\n",vo_format_name(out_fmt));
- continue;
- }
- j=i; vo_flags=flags; if(flags&VFCAP_CSP_SUPPORTED_BY_HW) break;
- } else
- if(!palette && !(flags&(VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_CSP_SUPPORTED)) && (out_fmt==IMGFMT_RGB8||out_fmt==IMGFMT_BGR8)){
- sh->outfmtidx=j; // pass index to the control() function this way
- if(mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)!=CONTROL_FALSE)
- palette=1;
- }
+ j = -1;
+ for (i = 0; i < CODECS_MAX_OUTFMT; i++) {
+ int flags;
+ out_fmt = sh->codec->outfmt[i];
+ if (out_fmt == (unsigned int) 0xFFFFFFFF)
+ continue;
+ flags = vf->query_format(vf, out_fmt);
+ mp_msg(MSGT_CPLAYER, MSGL_DBG2,
+ "vo_debug: query(%s) returned 0x%X (i=%d) \n",
+ vo_format_name(out_fmt), flags, i);
+ if ((flags & VFCAP_CSP_SUPPORTED_BY_HW)
+ || (flags & VFCAP_CSP_SUPPORTED && j < 0)) {
+ // check (query) if codec really support this outfmt...
+ sh->outfmtidx = j; // pass index to the control() function this way
+ if (sh->vd_driver->control(sh, VDCTRL_QUERY_FORMAT, &out_fmt) ==
+ CONTROL_FALSE) {
+ mp_msg(MSGT_CPLAYER, MSGL_DBG2,
+ "vo_debug: codec query_format(%s) returned FALSE\n",
+ vo_format_name(out_fmt));
+ continue;
+ }
+ j = i;
+ sh->output_flags = flags;
+ if (flags & VFCAP_CSP_SUPPORTED_BY_HW)
+ break;
+ } else if (!palette
+ && !(flags &
+ (VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_CSP_SUPPORTED))
+ && (out_fmt == IMGFMT_RGB8 || out_fmt == IMGFMT_BGR8)) {
+ sh->outfmtidx = j; // pass index to the control() function this way
+ if (sh->vd_driver->control(sh, VDCTRL_QUERY_FORMAT, &out_fmt) !=
+ CONTROL_FALSE)
+ palette = 1;
+ }
}
- if(j<0){
- // TODO: no match - we should use conversion...
- if(strcmp(vf->info->name,"scale") && palette!=-1){
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_CouldNotFindColorspace);
- sc=vf=vf_open_filter(vf,"scale",NULL);
- goto csp_again;
- } else
- if(palette==1){
- mp_msg(MSGT_DECVIDEO,MSGL_V,"vd: Trying -vf palette...\n");
- palette=-1;
- vf=vf_open_filter(vf,"palette",NULL);
- goto csp_again;
- } else
- { // sws failed, if the last filter (vf_vo) support MPEGPES try to append vf_lavc
- vf_instance_t* vo, *vp = NULL, *ve;
- // Remove the scale filter if we added it ourself
- if(vf == sc) {
- ve = vf;
- vf = vf->next;
- vf_uninit_filter(ve);
- }
- // Find the last filter (vf_vo)
- for(vo = vf ; vo->next ; vo = vo->next)
- vp = vo;
- if(vo->query_format(vo,IMGFMT_MPEGPES) && (!vp || (vp && strcmp(vp->info->name,"lavc")))) {
- ve = vf_open_filter(vo,"lavc",NULL);
- if(vp) vp->next = ve;
- else vf = ve;
- goto csp_again;
- }
- }
- mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_VOincompCodec);
- sh->vf_initialized=-1;
- return 0; // failed
+ if (j < 0) {
+ // TODO: no match - we should use conversion...
+ if (strcmp(vf->info->name, "scale") && palette != -1) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Could not find matching colorspace - retrying with -vf scale...\n");
+ sc = vf = vf_open_filter(opts, vf, "scale", NULL);
+ goto csp_again;
+ } else if (palette == 1) {
+ mp_msg(MSGT_DECVIDEO, MSGL_V, "vd: Trying -vf palette...\n");
+ palette = -1;
+ vf = vf_open_filter(opts, vf, "palette", NULL);
+ goto csp_again;
+ } else {
+ // sws failed, if the last filter (vf_vo) support MPEGPES try
+ // to append vf_lavc
+ vf_instance_t *vo, *vp = NULL, *ve;
+ // Remove the scale filter if we added it ourselves
+ if (vf == sc) {
+ ve = vf;
+ vf = vf->next;
+ vf_uninit_filter(ve);
+ }
+ // Find the last filter (vf_vo)
+ for (vo = vf; vo->next; vo = vo->next)
+ vp = vo;
+ if (vo->query_format(vo, IMGFMT_MPEGPES)
+ && (!vp || (vp && strcmp(vp->info->name, "lavc")))) {
+ ve = vf_open_filter(opts, vo, "lavc", NULL);
+ if (vp)
+ vp->next = ve;
+ else
+ vf = ve;
+ goto csp_again;
+ }
+ }
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN,
+ "The selected video_out device is incompatible with this codec.\n"\
+ "Try appending the scale filter to your filter list,\n"\
+ "e.g. -vf spp,scale instead of -vf spp.\n");
+ sh->vf_initialized = -1;
+ return 0; // failed
}
- out_fmt=sh->codec->outfmt[j];
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_UsingXAsOutputCspNoY,vo_format_name(out_fmt),j);
- sh->outfmtidx=j;
- sh->vfilter=vf;
+ out_fmt = sh->codec->outfmt[j];
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "VDec: using %s as output csp (no %d)\n",
+ vo_format_name(out_fmt), j);
+ sh->outfmtidx = j;
+ sh->vfilter = vf;
// autodetect flipping
- if(flip==-1){
- flip=0;
- if(sh->codec->outflags[j]&CODECS_FLAG_FLIP)
- if(!(sh->codec->outflags[j]&CODECS_FLAG_NOFLIP))
- flip=1;
+ if (opts->flip == -1) {
+ opts->flip = 0;
+ if (sh->codec->outflags[j] & CODECS_FLAG_FLIP)
+ if (!(sh->codec->outflags[j] & CODECS_FLAG_NOFLIP))
+ opts->flip = 1;
}
- if(vo_flags&VFCAP_FLIPPED) flip^=1;
- if(flip && !(vo_flags&VFCAP_FLIP)){
- // we need to flip, but no flipping filter avail.
- vf_add_before_vo(&vf, "flip", NULL);
- sh->vfilter = vf;
+ if (sh->output_flags & VFCAP_FLIPPED)
+ opts->flip ^= 1;
+ if (opts->flip && !(sh->output_flags & VFCAP_FLIP)) {
+ // we need to flip, but no flipping filter avail.
+ vf_add_before_vo(&vf, "flip", NULL);
+ sh->vfilter = vf;
}
-
// time to do aspect ratio corrections...
- if(movie_aspect>-1.0) sh->aspect = movie_aspect; // cmdline overrides autodetect
- else if(sh->stream_aspect!=0.0) sh->aspect = sh->stream_aspect;
-// if(!sh->aspect) sh->aspect=1.0;
-
- if(opt_screen_size_x||opt_screen_size_y){
- screen_size_x = opt_screen_size_x;
- screen_size_y = opt_screen_size_y;
- if(!vidmode){
- if(!screen_size_x) screen_size_x=SCREEN_SIZE_X;
- if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y;
- if(screen_size_x<=8) screen_size_x*=sh->disp_w;
- if(screen_size_y<=8) screen_size_y*=sh->disp_h;
- }
- } else {
- // check source format aspect, calculate prescale ::atmos
- screen_size_x=sh->disp_w;
- screen_size_y=sh->disp_h;
- if(screen_size_xy>=0.001){
- if(screen_size_xy<=8){
- // -xy means x+y scale
- screen_size_x*=screen_size_xy;
- screen_size_y*=screen_size_xy;
- } else {
- // -xy means forced width while keeping correct aspect
- screen_size_x=screen_size_xy;
- screen_size_y=screen_size_xy*sh->disp_h/sh->disp_w;
- }
- }
- if(sh->aspect>0.01){
- int w;
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MovieAspectIsSet,sh->aspect);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", sh->aspect);
- w=(int)((float)screen_size_y*sh->aspect); w+=w%2; // round
- // we don't like horizontal downscale || user forced width:
- if(w<screen_size_x || screen_size_xy>8){
- screen_size_y=(int)((float)screen_size_x*(1.0/sh->aspect));
- screen_size_y+=screen_size_y%2; // round
- } else screen_size_x=w; // keep new width
+ if (opts->movie_aspect > -1.0)
+ sh->aspect = opts->movie_aspect; // cmdline overrides autodetect
+ else if (sh->stream_aspect != 0.0)
+ sh->aspect = sh->stream_aspect;
+
+ if (opts->screen_size_x || opts->screen_size_y) {
+ screen_size_x = opts->screen_size_x;
+ screen_size_y = opts->screen_size_y;
+ if (!opts->vidmode) {
+ if (!screen_size_x)
+ screen_size_x = 1;
+ if (!screen_size_y)
+ screen_size_y = 1;
+ if (screen_size_x <= 8)
+ screen_size_x *= sh->disp_w;
+ if (screen_size_y <= 8)
+ screen_size_y *= sh->disp_h;
+ }
} else {
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MovieAspectUndefined);
+ // check source format aspect, calculate prescale ::atmos
+ screen_size_x = sh->disp_w;
+ screen_size_y = sh->disp_h;
+ if (opts->screen_size_xy >= 0.001) {
+ if (opts->screen_size_xy <= 8) {
+ // -xy means x+y scale
+ screen_size_x *= opts->screen_size_xy;
+ screen_size_y *= opts->screen_size_xy;
+ } else {
+ // -xy means forced width while keeping correct aspect
+ screen_size_x = opts->screen_size_xy;
+ screen_size_y = opts->screen_size_xy * sh->disp_h / sh->disp_w;
+ }
+ }
+ if (sh->aspect > 0.01) {
+ int w;
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Movie-Aspect is %.2f:1 - prescaling to correct movie aspect.\n",
+ sh->aspect);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n",
+ sh->aspect);
+ w = (int) ((float) screen_size_y * sh->aspect);
+ w += w % 2; // round
+ // we don't like horizontal downscale || user forced width:
+ if (w < screen_size_x || opts->screen_size_xy > 8) {
+ screen_size_y =
+ (int) ((float) screen_size_x * (1.0 / sh->aspect));
+ screen_size_y += screen_size_y % 2; // round
+ } else
+ screen_size_x = w; // keep new width
+ } else {
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Movie-Aspect is undefined - no prescaling applied.\n");
+ }
}
- }
- vocfg_flags = (fullscreen ? VOFLAG_FULLSCREEN:0)
- | (vidmode ? VOFLAG_MODESWITCHING:0)
- | (softzoom ? VOFLAG_SWSCALE:0)
- | (flip ? VOFLAG_FLIPPING:0);
+ vocfg_flags = (opts->fullscreen ? VOFLAG_FULLSCREEN : 0)
+ | (opts->vidmode ? VOFLAG_MODESWITCHING : 0)
+ | (opts->softzoom ? VOFLAG_SWSCALE : 0)
+ | (opts->flip ? VOFLAG_FLIPPING : 0);
// Time to config libvo!
- mp_msg(MSGT_CPLAYER,MSGL_V,"VO Config (%dx%d->%dx%d,flags=%d,'%s',0x%X)\n",
- sh->disp_w,sh->disp_h,
- screen_size_x,screen_size_y,
- vocfg_flags,
- "MPlayer",out_fmt);
+ mp_msg(MSGT_CPLAYER, MSGL_V,
+ "VO Config (%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", sh->disp_w,
+ sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, "MPlayer",
+ out_fmt);
vf->w = sh->disp_w;
vf->h = sh->disp_h;
- if(vf_config_wrapper(vf,sh->disp_w,sh->disp_h,
- screen_size_x,screen_size_y,
- vocfg_flags,
- out_fmt)==0){
-// "MPlayer",out_fmt)){
- mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_CannotInitVO);
- sh->vf_initialized=-1;
- return 0;
+ if (vf_config_wrapper
+ (vf, sh->disp_w, sh->disp_h, screen_size_x, screen_size_y, vocfg_flags,
+ out_fmt) == 0) {
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "FATAL: Cannot initialize video driver.\n");
+ sh->vf_initialized = -1;
+ return 0;
}
- sh->vf_initialized=1;
+ sh->vf_initialized = 1;
- if (vo_gamma_gamma != 1000)
- set_video_colors(sh, "gamma", vo_gamma_gamma);
- if (vo_gamma_brightness != 1000)
- set_video_colors(sh, "brightness", vo_gamma_brightness);
- if (vo_gamma_contrast != 1000)
- set_video_colors(sh, "contrast", vo_gamma_contrast);
- if (vo_gamma_saturation != 1000)
- set_video_colors(sh, "saturation", vo_gamma_saturation);
- if (vo_gamma_hue != 1000)
- set_video_colors(sh, "hue", vo_gamma_hue);
+ if (opts->vo_gamma_gamma != 1000)
+ set_video_colors(sh, "gamma", opts->vo_gamma_gamma);
+ if (opts->vo_gamma_brightness != 1000)
+ set_video_colors(sh, "brightness", opts->vo_gamma_brightness);
+ if (opts->vo_gamma_contrast != 1000)
+ set_video_colors(sh, "contrast", opts->vo_gamma_contrast);
+ if (opts->vo_gamma_saturation != 1000)
+ set_video_colors(sh, "saturation", opts->vo_gamma_saturation);
+ if (opts->vo_gamma_hue != 1000)
+ set_video_colors(sh, "hue", opts->vo_gamma_hue);
return 1;
}
@@ -333,15 +331,22 @@ csp_again:
// mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h
// returns NULL or allocated mp_image_t*
// Note: buffer allocation may be moved to mpcodecs_config_vo() later...
-mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h){
- mp_image_t* mpi=vf_get_image(sh->vfilter,sh->codec->outfmt[sh->outfmtidx],mp_imgtype,mp_imgflag,w,h);
- if (mpi) mpi->x=mpi->y=0;
- return mpi;
+mp_image_t *mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag,
+ int w, int h)
+{
+ mp_image_t *mpi =
+ vf_get_image(sh->vfilter, sh->codec->outfmt[sh->outfmtidx], mp_imgtype,
+ mp_imgflag, w, h);
+ if (mpi)
+ mpi->x = mpi->y = 0;
+ return mpi;
}
-void mpcodecs_draw_slice(sh_video_t *sh, unsigned char** src, int* stride, int w,int h, int x, int y) {
- struct vf_instance_s* vf = sh->vfilter;
+void mpcodecs_draw_slice(sh_video_t *sh, unsigned char **src, int *stride,
+ int w, int h, int x, int y)
+{
+ struct vf_instance *vf = sh->vfilter;
- if(vf->draw_slice)
- vf->draw_slice(vf,src,stride,w,h,x,y);
+ if (vf->draw_slice)
+ vf->draw_slice(vf, src, stride, w, h, x, y);
}
diff --git a/libmpcodecs/vd.h b/libmpcodecs/vd.h
index f05241b49e..df71970f7d 100644
--- a/libmpcodecs/vd.h
+++ b/libmpcodecs/vd.h
@@ -8,9 +8,9 @@
typedef mp_codec_info_t vd_info_t;
/* interface of video decoder drivers */
-typedef struct vd_functions_s
+typedef struct vd_functions
{
- vd_info_t *info;
+ const vd_info_t *info;
int (*init)(sh_video_t *sh);
void (*uninit)(sh_video_t *sh);
int (*control)(sh_video_t *sh,int cmd,void* arg, ...);
@@ -20,8 +20,6 @@ typedef struct vd_functions_s
// NULL terminated array of all drivers
extern const vd_functions_t * const mpcodecs_vd_drivers[];
-extern int vd_use_slices;
-
#define VDCTRL_QUERY_FORMAT 3 /* test for availabilty of a format */
#define VDCTRL_QUERY_MAX_PP_LEVEL 4 /* test for postprocessing support (max level) */
#define VDCTRL_SET_PP_LEVEL 5 /* set postprocessing level */
diff --git a/libmpcodecs/vd_dmo.c b/libmpcodecs/vd_dmo.c
index 88b6a1ce5c..4bc3570607 100644
--- a/libmpcodecs/vd_dmo.c
+++ b/libmpcodecs/vd_dmo.c
@@ -11,7 +11,7 @@
#include "loader/dmo/DMO_VideoDecoder.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"DMO video codecs",
"dmo",
"A'rpi",
@@ -30,8 +30,8 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){
static int init(sh_video_t *sh){
unsigned int out_fmt;
if(!(sh->context=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
- mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_HINT,"You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n");
return 0;
}
if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
@@ -50,7 +50,7 @@ static int init(sh_video_t *sh){
DMO_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
}
DMO_VideoDecoder_StartInternal(sh->context);
- mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DMOInitOK);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO video codec init OK.\n");
return 1;
}
@@ -76,7 +76,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
sh->disp_w, sh->disp_h);
if(!mpi){ // temporary!
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n");
return NULL;
}
diff --git a/libmpcodecs/vd_dshow.c b/libmpcodecs/vd_dshow.c
index 3a247fd4db..00f9ab4332 100644
--- a/libmpcodecs/vd_dshow.c
+++ b/libmpcodecs/vd_dshow.c
@@ -11,7 +11,7 @@
#include "loader/dshow/DS_VideoDecoder.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"DirectShow video codecs",
"dshow",
"A'rpi",
@@ -58,8 +58,8 @@ static int init(sh_video_t *sh){
return 0;
if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
- mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_HINT,"You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n");
return 0;
}
if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
@@ -79,7 +79,7 @@ static int init(sh_video_t *sh){
}
DS_SetAttr_DivX("Quality",divx_quality);
DS_VideoDecoder_StartInternal(sh->context);
- mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DShowInitOK);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK.\n");
return 1;
}
@@ -105,7 +105,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
sh->disp_w, sh->disp_h);
if(!mpi){ // temporary!
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n");
return NULL;
}
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 244e6495b3..4cf20037e9 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -6,6 +6,7 @@
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "options.h"
#include "av_opts.h"
#include "libavutil/common.h"
@@ -15,7 +16,7 @@
#include "vd_internal.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"FFmpeg's libavcodec codec family",
"ffmpeg",
"A'rpi",
@@ -49,57 +50,38 @@ typedef struct {
int ip_count;
int b_count;
AVRational last_sample_aspect_ratio;
+ int lowres;
} vd_ffmpeg_ctx;
#include "m_option.h"
static int get_buffer(AVCodecContext *avctx, AVFrame *pic);
static void release_buffer(AVCodecContext *avctx, AVFrame *pic);
-static void draw_slice(struct AVCodecContext *s, AVFrame *src, int offset[4],
- int y, int type, int height);
+static void draw_slice(struct AVCodecContext *s, const AVFrame *src,
+ int offset[4], int y, int type, int height);
static enum PixelFormat get_format(struct AVCodecContext *avctx,
const enum PixelFormat *pix_fmt);
-static int lavc_param_workaround_bugs= FF_BUG_AUTODETECT;
-static int lavc_param_error_resilience=2;
-static int lavc_param_error_concealment=3;
-static int lavc_param_gray=0;
-static int lavc_param_vstats=0;
-static int lavc_param_idct_algo=0;
-static int lavc_param_debug=0;
-static int lavc_param_vismv=0;
-static int lavc_param_skip_top=0;
-static int lavc_param_skip_bottom=0;
-static int lavc_param_fast=0;
-static int lavc_param_lowres=0;
-static char *lavc_param_lowres_str=NULL;
-static char *lavc_param_skip_loop_filter_str = NULL;
-static char *lavc_param_skip_idct_str = NULL;
-static char *lavc_param_skip_frame_str = NULL;
-static int lavc_param_threads=1;
-static int lavc_param_bitexact=0;
-static char *lavc_avopt = NULL;
-
const m_option_t lavc_decode_opts_conf[]={
- {"bug", &lavc_param_workaround_bugs, CONF_TYPE_INT, CONF_RANGE, -1, 999999, NULL},
- {"er", &lavc_param_error_resilience, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL},
- {"gray", &lavc_param_gray, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART, NULL},
- {"idct", &lavc_param_idct_algo, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL},
- {"ec", &lavc_param_error_concealment, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL},
- {"vstats", &lavc_param_vstats, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"debug", &lavc_param_debug, CONF_TYPE_INT, CONF_RANGE, 0, 9999999, NULL},
- {"vismv", &lavc_param_vismv, CONF_TYPE_INT, CONF_RANGE, 0, 9999999, NULL},
- {"st", &lavc_param_skip_top, CONF_TYPE_INT, CONF_RANGE, 0, 999, NULL},
- {"sb", &lavc_param_skip_bottom, CONF_TYPE_INT, CONF_RANGE, 0, 999, NULL},
- {"fast", &lavc_param_fast, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG2_FAST, NULL},
- {"lowres", &lavc_param_lowres_str, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"skiploopfilter", &lavc_param_skip_loop_filter_str, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"skipidct", &lavc_param_skip_idct_str, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"skipframe", &lavc_param_skip_frame_str, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"threads", &lavc_param_threads, CONF_TYPE_INT, CONF_RANGE, 1, 8, NULL},
- {"bitexact", &lavc_param_bitexact, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_BITEXACT, NULL},
- {"o", &lavc_avopt, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ OPT_INTRANGE("bug", lavc_param.workaround_bugs, 0, -1, 999999),
+ OPT_INTRANGE("er", lavc_param.error_resilience, 0, 0, 99),
+ OPT_FLAG_ON("gray", lavc_param.gray, 0),
+ OPT_INTRANGE("idct", lavc_param.idct_algo, 0, 0, 99),
+ OPT_INTRANGE("ec", lavc_param.error_concealment, 0, 0, 99),
+ OPT_FLAG_ON("vstats", lavc_param.vstats, 0),
+ OPT_INTRANGE("debug", lavc_param.debug, 0, 0, 9999999),
+ OPT_INTRANGE("vismv", lavc_param.vismv, 0, 0, 9999999),
+ OPT_INTRANGE("st", lavc_param.skip_top, 0, 0, 999),
+ OPT_INTRANGE("sb", lavc_param.skip_bottom, 0, 0, 999),
+ OPT_FLAG_CONSTANTS("fast", lavc_param.fast, 0, 0, CODEC_FLAG2_FAST),
+ OPT_STRING("lowres", lavc_param.lowres_str, 0),
+ OPT_STRING("skiploopfilter", lavc_param.skip_loop_filter_str, 0),
+ OPT_STRING("skipidct", lavc_param.skip_idct_str, 0),
+ OPT_STRING("skipframe", lavc_param.skip_frame_str, 0),
+ OPT_INTRANGE("threads", lavc_param.threads, 0, 1, 8),
+ OPT_FLAG_CONSTANTS("bitexact", lavc_param.bitexact, 0, 0, CODEC_FLAG_BITEXACT),
+ OPT_STRING("o", lavc_param.avopt, 0),
{NULL, NULL, 0, 0, 0, 0, NULL}
};
@@ -144,13 +126,19 @@ static int control(sh_video_t *sh, int cmd, void *arg, ...){
case VDCTRL_RESYNC_STREAM:
avcodec_flush_buffers(avctx);
return CONTROL_TRUE;
- case VDCTRL_QUERY_UNSEEN_FRAMES:
- return avctx->has_b_frames + 10;
+ case VDCTRL_QUERY_UNSEEN_FRAMES:;
+ int delay = avctx->has_b_frames;
+#ifdef FF_THREAD_FRAME
+ // FFmpeg-mt has extra delay when using frame threading
+ if (avctx->thread_type & FF_THREAD_FRAME)
+ delay += avctx->thread_count - 1;
+#endif
+ return delay + 10;
}
return CONTROL_UNKNOWN;
}
-void mp_msp_av_log_callback(void *ptr, int level, const char *fmt, va_list vl)
+static void mp_msp_av_log_callback(void *ptr, int level, const char *fmt, va_list vl)
{
static int print_prefix=1;
AVClass *avc= ptr ? *(AVClass **)ptr : NULL;
@@ -213,18 +201,19 @@ static void set_format_params(struct AVCodecContext *avctx, enum PixelFormat fmt
avctx->release_buffer = release_buffer;
avctx->reget_buffer = get_buffer;
avctx->draw_horiz_band = draw_slice;
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedMPEG2);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[VD_FFMPEG] XVMC-accelerated MPEG-2.\n");
avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
}
}
// init driver
static int init(sh_video_t *sh){
+ struct lavc_param *lavc_param = &sh->opts->lavc_param;
AVCodecContext *avctx;
vd_ffmpeg_ctx *ctx;
AVCodec *lavc_codec;
int lowres_w=0;
- int do_vis_debug= lavc_param_vismv || (lavc_param_debug&(FF_DEBUG_VIS_MB_TYPE|FF_DEBUG_VIS_QP));
+ int do_vis_debug= lavc_param->vismv || (lavc_param->debug&(FF_DEBUG_VIS_MB_TYPE|FF_DEBUG_VIS_QP));
if(!avcodec_initialized){
avcodec_init();
@@ -240,12 +229,12 @@ static int init(sh_video_t *sh){
lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll);
if(!lavc_codec){
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_MissingLAVCcodec, sh->codec->dll);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Cannot find codec '%s' in libavcodec...\n", sh->codec->dll);
uninit(sh);
return 0;
}
- if(vd_use_slices && (lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) && !do_vis_debug)
+ if(sh->opts->vd_use_slices && (lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) && !do_vis_debug)
ctx->do_slices=1;
if(lavc_codec->capabilities&CODEC_CAP_DR1 && !do_vis_debug && lavc_codec->id != CODEC_ID_H264 && lavc_codec->id != CODEC_ID_INTERPLAY_VIDEO && lavc_codec->id != CODEC_ID_ROQ)
@@ -265,7 +254,7 @@ static int init(sh_video_t *sh){
#endif /* CONFIG_VDPAU */
#if CONFIG_XVMC
if(lavc_codec->capabilities & CODEC_CAP_HWACCEL){
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedCodec);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[VD_FFMPEG] XVMC accelerated codec.\n");
avctx->get_format= get_format;//for now only this decoder will use it
// HACK around badly placed checks in mpeg_mc_decode_init
set_format_params(avctx, PIX_FMT_XVMC_MPEG2_IDCT);
@@ -278,38 +267,38 @@ static int init(sh_video_t *sh){
avctx->reget_buffer= get_buffer;
}
- avctx->flags|= lavc_param_bitexact;
+ avctx->flags|= lavc_param->bitexact;
avctx->width = sh->disp_w;
avctx->height= sh->disp_h;
- avctx->workaround_bugs= lavc_param_workaround_bugs;
- avctx->error_recognition= lavc_param_error_resilience;
- if(lavc_param_gray) avctx->flags|= CODEC_FLAG_GRAY;
- avctx->flags2|= lavc_param_fast;
+ avctx->workaround_bugs= lavc_param->workaround_bugs;
+ avctx->error_recognition= lavc_param->error_resilience;
+ if(lavc_param->gray) avctx->flags|= CODEC_FLAG_GRAY;
+ avctx->flags2|= lavc_param->fast;
avctx->codec_tag= sh->format;
avctx->stream_codec_tag= sh->video.fccHandler;
- avctx->idct_algo= lavc_param_idct_algo;
- avctx->error_concealment= lavc_param_error_concealment;
- avctx->debug= lavc_param_debug;
- if (lavc_param_debug)
+ avctx->idct_algo= lavc_param->idct_algo;
+ avctx->error_concealment= lavc_param->error_concealment;
+ avctx->debug= lavc_param->debug;
+ if (lavc_param->debug)
av_log_set_level(AV_LOG_DEBUG);
- avctx->debug_mv= lavc_param_vismv;
- avctx->skip_top = lavc_param_skip_top;
- avctx->skip_bottom= lavc_param_skip_bottom;
- if(lavc_param_lowres_str != NULL)
+ avctx->debug_mv= lavc_param->vismv;
+ avctx->skip_top = lavc_param->skip_top;
+ avctx->skip_bottom= lavc_param->skip_bottom;
+ if(lavc_param->lowres_str != NULL)
{
- sscanf(lavc_param_lowres_str, "%d,%d", &lavc_param_lowres, &lowres_w);
- if(lavc_param_lowres < 1 || lavc_param_lowres > 16 || (lowres_w > 0 && avctx->width < lowres_w))
- lavc_param_lowres = 0;
- avctx->lowres = lavc_param_lowres;
- }
- avctx->skip_loop_filter = str2AVDiscard(lavc_param_skip_loop_filter_str);
- avctx->skip_idct = str2AVDiscard(lavc_param_skip_idct_str);
- avctx->skip_frame = str2AVDiscard(lavc_param_skip_frame_str);
-
- if(lavc_avopt){
- if(parse_avopts(avctx, lavc_avopt) < 0){
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", lavc_avopt);
+ sscanf(lavc_param->lowres_str, "%d,%d", &ctx->lowres, &lowres_w);
+ if(ctx->lowres < 1 || ctx->lowres > 16 || (lowres_w > 0 && avctx->width < lowres_w))
+ ctx->lowres = 0;
+ avctx->lowres = ctx->lowres;
+ }
+ avctx->skip_loop_filter = str2AVDiscard(lavc_param->skip_loop_filter_str);
+ avctx->skip_idct = str2AVDiscard(lavc_param->skip_idct_str);
+ avctx->skip_frame = str2AVDiscard(lavc_param->skip_frame_str);
+
+ if(lavc_param->avopt){
+ if(parse_avopts(avctx, lavc_param->avopt) < 0){
+ mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", lavc_param->avopt);
uninit(sh);
return 0;
}
@@ -401,11 +390,11 @@ static int init(sh_video_t *sh){
if(sh->bih)
avctx->bits_per_coded_sample= sh->bih->biBitCount;
- if(lavc_param_threads > 1)
- avcodec_thread_init(avctx, lavc_param_threads);
+ if(lavc_param->threads > 1)
+ avcodec_thread_init(avctx, lavc_param->threads);
/* open it */
if (avcodec_open(avctx, lavc_codec) < 0) {
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantOpenCodec);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n");
uninit(sh);
return 0;
}
@@ -421,12 +410,12 @@ static void uninit(sh_video_t *sh){
vd_ffmpeg_ctx *ctx = sh->context;
AVCodecContext *avctx = ctx->avctx;
- if(lavc_param_vstats){
+ if(sh->opts->lavc_param.vstats){
int i;
for(i=1; i<32; i++){
mp_msg(MSGT_DECVIDEO, MSGL_INFO, "QP: %d, count: %d\n", i, ctx->qp_stat[i]);
}
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_ArithmeticMeanOfQP,
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[VD_FFMPEG] Arithmetic mean of QP: %2.4f, Harmonic mean of QP: %2.4f\n",
ctx->qp_sum / avctx->coded_frame->coded_picture_number,
1.0/(ctx->inv_qp_sum / avctx->coded_frame->coded_picture_number)
);
@@ -434,7 +423,7 @@ static void uninit(sh_video_t *sh){
if (avctx) {
if (avctx->codec && avcodec_close(avctx) < 0)
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n");
av_freep(&avctx->extradata);
av_freep(&avctx->palctrl);
@@ -448,14 +437,15 @@ static void uninit(sh_video_t *sh){
}
static void draw_slice(struct AVCodecContext *s,
- AVFrame *src, int offset[4],
- int y, int type, int height){
+ const AVFrame *src, int offset[4],
+ int y, int type, int height){
sh_video_t *sh = s->opaque;
uint8_t *source[MP_MAX_PLANES]= {src->data[0] + offset[0], src->data[1] + offset[1], src->data[2] + offset[2]};
#if 0
int start=0, i;
int width= s->width;
- int skip_stride= ((width<<lavc_param_lowres)+15)>>4;
+ vd_ffmpeg_ctx *ctx = sh->context;
+ int skip_stride= ((width << ctx->lowres)+15)>>4;
uint8_t *skip= &s->coded_frame->mbskip_table[(y>>4)*skip_stride];
int threshold= s->coded_frame->age;
if(s->pict_type!=B_TYPE){
@@ -493,8 +483,8 @@ static int init_vo(sh_video_t *sh, enum PixelFormat pix_fmt){
// if sh->ImageDesc is non-NULL, it means we decode QuickTime(tm) video.
// use dimensions from BIH to avoid black borders at the right and bottom.
if (sh->bih && sh->ImageDesc) {
- width = sh->bih->biWidth>>lavc_param_lowres;
- height = sh->bih->biHeight>>lavc_param_lowres;
+ width = sh->bih->biWidth >> ctx->lowres;
+ height = sh->bih->biHeight >> ctx->lowres;
}
// it is possible another vo buffers to be used after vo config()
@@ -577,7 +567,7 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){
} else
if (!pic->buffer_hints) {
if(ctx->b_count>1 || ctx->ip_count>2){
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_DRIFailure);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_WARN, "[VD_FFMPEG] DRI failure.\n");
ctx->do_dr1=0; //FIXME
avctx->get_buffer= avcodec_default_get_buffer;
@@ -611,13 +601,13 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){
struct xvmc_pix_fmt *render = mpi->priv; //same as data[2]
avctx->draw_horiz_band= draw_slice;
if(!avctx->xvmc_acceleration) {
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_McGetBufferShouldWorkOnlyWithXVMC);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[VD_FFMPEG] The mc_get_buffer should work only with XVMC acceleration!!");
assert(0);
exit(1);
// return -1;//!!fixme check error conditions in ffmpeg
}
if(!(mpi->flags & MP_IMGFLAG_DIRECT)) {
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_MPCODECS_OnlyBuffersAllocatedByVoXvmcAllowed);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "[VD_FFMPEG] Only buffers allocated by vo_xvmc allowed.\n");
assert(0);
exit(1);
// return -1;//!!fixme check error conditions in ffmpeg
@@ -742,7 +732,7 @@ typedef struct dp_hdr_s {
uint32_t chunktab; // offset to chunk offset array
} dp_hdr_t;
-void swap_palette(void *pal) {
+static void swap_palette(void *pal) {
int i;
uint32_t *p = pal;
for (i = 0; i < AVPALETTE_COUNT; i++)
@@ -756,6 +746,7 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){
vd_ffmpeg_ctx *ctx = sh->context;
AVFrame *pic= ctx->pic;
AVCodecContext *avctx = ctx->avctx;
+ struct lavc_param *lavc_param = &sh->opts->lavc_param;
mp_image_t *mpi=NULL;
int dr1= ctx->do_dr1;
AVPacket pkt;
@@ -790,7 +781,7 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){
if(ret<0) mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error while decoding frame!\n");
//printf("repeat: %d\n", pic->repeat_pict);
//-- vstats generation
- while(lavc_param_vstats){ // always one time loop
+ while(lavc_param->vstats){ // always one time loop
static FILE *fvstats=NULL;
char filename[20];
static long long int all_len=0;
@@ -809,7 +800,7 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){
fvstats = fopen(filename, "w");
if(!fvstats) {
perror("fopen");
- lavc_param_vstats=0; // disable block
+ lavc_param->vstats=0; // disable block
break;
/*exit(1);*/
}
@@ -818,8 +809,8 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){
// average MB quantizer
{
int x, y;
- int w = ((avctx->width << lavc_param_lowres)+15) >> 4;
- int h = ((avctx->height << lavc_param_lowres)+15) >> 4;
+ int w = ((avctx->width << ctx->lowres)+15) >> 4;
+ int h = ((avctx->height << ctx->lowres)+15) >> 4;
int8_t *q = pic->qscale_table;
for(y = 0; y < h; y++) {
for(x = 0; x < w; x++)
@@ -874,7 +865,7 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){
mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE,
avctx->width, avctx->height);
if(!mpi){ // temporary!
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_CouldntAllocateImageForCodec);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_WARN, "[VD_FFMPEG] Couldn't allocate image for codec.\n");
return NULL;
}
@@ -925,7 +916,7 @@ static enum PixelFormat get_format(struct AVCodecContext *avctx,
for(i=0;fmt[i]!=PIX_FMT_NONE;i++){
imgfmt = pixfmt2imgfmt(fmt[i]);
if(!IMGFMT_IS_XVMC(imgfmt) && !IMGFMT_IS_VDPAU(imgfmt)) continue;
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_TryingPixfmt, i);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[VD_FFMPEG] Trying pixfmt=%d.\n", i);
if(init_vo(sh, fmt[i]) >= 0) {
break;
}
diff --git a/libmpcodecs/vd_hmblck.c b/libmpcodecs/vd_hmblck.c
index 9d12402a4f..f3b7a71026 100644
--- a/libmpcodecs/vd_hmblck.c
+++ b/libmpcodecs/vd_hmblck.c
@@ -8,7 +8,7 @@
#define TEMP_BUF_SIZE (720*576)
-static vd_info_t info = {
+static const vd_info_t info = {
"Hauppauge Macroblock/NV12/NV21 Decoder",
"hmblck",
"Alex <d18c7db@hotmail.com>, A'rpi, Alex Beregszaszi",
diff --git a/libmpcodecs/vd_ijpg.c b/libmpcodecs/vd_ijpg.c
index a54b339c8f..3338067872 100644
--- a/libmpcodecs/vd_ijpg.c
+++ b/libmpcodecs/vd_ijpg.c
@@ -16,7 +16,7 @@
#include "vd_internal.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"JPEG Images decoder",
"ijpg",
"Pontscho",
@@ -93,7 +93,7 @@ METHODDEF(void) skip_input_data (j_decompress_ptr cinfo, long num_bytes)
METHODDEF(void) term_source (j_decompress_ptr cinfo) { }
-GLOBAL(void) jpeg_buf_src ( j_decompress_ptr cinfo, char * inbuf,int bufsize )
+static void jpeg_buf_src ( j_decompress_ptr cinfo, char * inbuf,int bufsize )
{
my_src_ptr src;
if (cinfo->src == NULL) cinfo->src=malloc( sizeof( my_source_mgr ) );
diff --git a/libmpcodecs/vd_internal.h b/libmpcodecs/vd_internal.h
index d04903e26a..dee8448cb1 100644
--- a/libmpcodecs/vd_internal.h
+++ b/libmpcodecs/vd_internal.h
@@ -19,7 +19,7 @@ static int init(sh_video_t *sh);
static void uninit(sh_video_t *sh);
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags);
-#define LIBVD_EXTERN(x) vd_functions_t mpcodecs_vd_##x = {\
+#define LIBVD_EXTERN(x) const vd_functions_t mpcodecs_vd_##x = {\
&info,\
init,\
uninit,\
diff --git a/libmpcodecs/vd_libdv.c b/libmpcodecs/vd_libdv.c
index 4856cbc907..7332629325 100644
--- a/libmpcodecs/vd_libdv.c
+++ b/libmpcodecs/vd_libdv.c
@@ -18,7 +18,7 @@
#include "vd_internal.h"
-static vd_info_t info =
+static const vd_info_t info =
{
"Raw DV Video Decoder",
"libdv",
diff --git a/libmpcodecs/vd_libmpeg2.c b/libmpcodecs/vd_libmpeg2.c
index 626aca09db..cc170c5034 100644
--- a/libmpcodecs/vd_libmpeg2.c
+++ b/libmpcodecs/vd_libmpeg2.c
@@ -2,14 +2,14 @@
#include <stdlib.h>
#include "config.h"
-
+#include "options.h"
#include "mp_msg.h"
#include "vd_internal.h"
//#undef MPEG12_POSTPROC
-static vd_info_t info =
+static const vd_info_t info =
{
"libmpeg2 MPEG 1/2 Video decoder",
"libmpeg2",
@@ -219,7 +219,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
}
mpeg2_skip(mpeg2dec, 0); //mpeg2skip skips frames until set again to 0
- use_callback = (!framedrop && vd_use_slices &&
+ use_callback = (!framedrop && sh->opts->vd_use_slices &&
(info->current_picture->flags&PIC_FLAG_PROGRESSIVE_FRAME)) ?
MP_IMGFLAG_DRAW_CALLBACK:0;
diff --git a/libmpcodecs/vd_lzo.c b/libmpcodecs/vd_lzo.c
index d80fa8817a..ac291cf446 100644
--- a/libmpcodecs/vd_lzo.c
+++ b/libmpcodecs/vd_lzo.c
@@ -9,7 +9,7 @@
#define MOD_NAME "DecLZO"
-static vd_info_t info = {
+static const vd_info_t info = {
"LZO compressed Video",
"lzo",
"Tilmann Bitterberg",
diff --git a/libmpcodecs/vd_mpegpes.c b/libmpcodecs/vd_mpegpes.c
index 1879f6418d..7d2a206564 100644
--- a/libmpcodecs/vd_mpegpes.c
+++ b/libmpcodecs/vd_mpegpes.c
@@ -7,7 +7,7 @@
#include "vd_internal.h"
-static vd_info_t info =
+static const vd_info_t info =
{
"MPEG 1/2 Video passthrough",
"mpegpes",
diff --git a/libmpcodecs/vd_mpng.c b/libmpcodecs/vd_mpng.c
index 3d870300f0..487e33d2de 100644
--- a/libmpcodecs/vd_mpng.c
+++ b/libmpcodecs/vd_mpng.c
@@ -12,7 +12,7 @@
#include "vd_internal.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"PNG Images decoder",
"mpng",
"A'rpi",
diff --git a/libmpcodecs/vd_mtga.c b/libmpcodecs/vd_mtga.c
index 72612d8d5d..fb5fa6e807 100644
--- a/libmpcodecs/vd_mtga.c
+++ b/libmpcodecs/vd_mtga.c
@@ -16,7 +16,7 @@
#include "vd_internal.h"
-static vd_info_t info =
+static const vd_info_t info =
{
"TGA Images decoder",
"mtga",
@@ -231,4 +231,3 @@ static mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags)
return mpi;
}
-
diff --git a/libmpcodecs/vd_null.c b/libmpcodecs/vd_null.c
index 61c2b821a9..b842967323 100644
--- a/libmpcodecs/vd_null.c
+++ b/libmpcodecs/vd_null.c
@@ -6,7 +6,7 @@
#include "vd_internal.h"
-static vd_info_t info =
+static const vd_info_t info =
{
"Null video decoder",
"null",
@@ -36,4 +36,3 @@ static void uninit(sh_video_t *sh){
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
return NULL;
}
-
diff --git a/libmpcodecs/vd_qtvideo.c b/libmpcodecs/vd_qtvideo.c
index 468dbb1832..f97c85571b 100644
--- a/libmpcodecs/vd_qtvideo.c
+++ b/libmpcodecs/vd_qtvideo.c
@@ -16,7 +16,7 @@
#include "loader/wine/windef.h"
#endif
-static vd_info_t info = {
+static const vd_info_t info = {
"Quicktime Video decoder",
"qtvideo",
"A'rpi",
diff --git a/libmpcodecs/vd_raw.c b/libmpcodecs/vd_raw.c
index f194e82759..53a736b29b 100644
--- a/libmpcodecs/vd_raw.c
+++ b/libmpcodecs/vd_raw.c
@@ -6,7 +6,7 @@
#include "vd_internal.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"RAW Uncompressed Video",
"raw",
"A'rpi",
diff --git a/libmpcodecs/vd_realvid.c b/libmpcodecs/vd_realvid.c
index c13b178900..575728388f 100644
--- a/libmpcodecs/vd_realvid.c
+++ b/libmpcodecs/vd_realvid.c
@@ -14,7 +14,7 @@
#include "vd_internal.h"
#include "loader/wine/windef.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"RealVideo decoder",
"realvid",
"Alex Beregszaszi",
@@ -288,7 +288,7 @@ static int init(sh_video_t *sh){
if (!load_syms_windows(sh->codec->dll))
#endif
{
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll);
mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Read the RealVideo section of the DOCS!\n");
free(path);
return 0;
diff --git a/libmpcodecs/vd_sgi.c b/libmpcodecs/vd_sgi.c
index 5aa4625ab9..3ab1ed18fa 100644
--- a/libmpcodecs/vd_sgi.c
+++ b/libmpcodecs/vd_sgi.c
@@ -21,7 +21,7 @@
#define OUT_PIXEL_STRIDE 3 /* RGB */
-static vd_info_t info =
+static const vd_info_t info =
{
"SGI Image decoder",
"sgi",
@@ -325,4 +325,3 @@ mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags)
return mpi;
}
-
diff --git a/libmpcodecs/vd_theora.c b/libmpcodecs/vd_theora.c
index eb37b97cf8..83123c89cb 100644
--- a/libmpcodecs/vd_theora.c
+++ b/libmpcodecs/vd_theora.c
@@ -9,7 +9,7 @@
#include "vd_internal.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"Theora/VP3",
"theora",
"David Kuehling",
diff --git a/libmpcodecs/vd_vfw.c b/libmpcodecs/vd_vfw.c
index 7ad6a98f30..197ead6bae 100644
--- a/libmpcodecs/vd_vfw.c
+++ b/libmpcodecs/vd_vfw.c
@@ -10,7 +10,7 @@
#include "loader/wine/driver.h"
#include "loader/wine/vfw.h"
-static vd_info_t info = {
+static const vd_info_t info = {
#ifdef BUILD_VFWEX
"Win32/VfWex video codecs",
"vfwex",
@@ -304,7 +304,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
MP_IMGTYPE_STATIC : MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH,
sh->disp_w, sh->disp_h);
if(!mpi){ // temporary!
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n");
return NULL;
}
diff --git a/libmpcodecs/vd_xanim.c b/libmpcodecs/vd_xanim.c
index 72301c865b..4922d9d590 100644
--- a/libmpcodecs/vd_xanim.c
+++ b/libmpcodecs/vd_xanim.c
@@ -18,7 +18,7 @@
#include "vd_internal.h"
-static vd_info_t info = {
+static const vd_info_t info = {
"XAnim codecs",
"xanim",
"A'rpi & Alex",
diff --git a/libmpcodecs/vd_xvid4.c b/libmpcodecs/vd_xvid4.c
index bf12ab12f0..62eab8c3ed 100644
--- a/libmpcodecs/vd_xvid4.c
+++ b/libmpcodecs/vd_xvid4.c
@@ -378,7 +378,7 @@ static float stats2aspect(xvid_dec_stats_t *stats)
* Module structure definition
****************************************************************************/
-static vd_info_t info =
+static const vd_info_t info =
{
"XviD 1.0 decoder",
"xvid",
diff --git a/libmpcodecs/vd_zrmjpeg.c b/libmpcodecs/vd_zrmjpeg.c
index ab5bc59053..8dd460ab5b 100644
--- a/libmpcodecs/vd_zrmjpeg.c
+++ b/libmpcodecs/vd_zrmjpeg.c
@@ -36,7 +36,7 @@
#include "vd_internal.h"
-static vd_info_t info =
+static const vd_info_t info =
{
"Zoran MJPEG Video passthrough",
"zrmjpeg",
diff --git a/libmpcodecs/ve.c b/libmpcodecs/ve.c
index dd7f650ba8..9781bfc0d8 100644
--- a/libmpcodecs/ve.c
+++ b/libmpcodecs/ve.c
@@ -51,8 +51,7 @@ static vf_info_t* encoder_list[]={
NULL
};
-vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args){
+vf_instance_t* vf_open_encoder(struct MPOpts *opts, vf_instance_t* next, const char *name, char *args){
char* vf_args[] = { "_oldargs_", args, NULL };
- return vf_open_plugin(encoder_list,next,name,vf_args);
+ return vf_open_plugin(opts, encoder_list,next,name,vf_args);
}
-
diff --git a/libmpcodecs/ve_lavc.c b/libmpcodecs/ve_lavc.c
index 50368858c3..c9d60a202a 100644
--- a/libmpcodecs/ve_lavc.c
+++ b/libmpcodecs/ve_lavc.c
@@ -325,9 +325,9 @@ struct vf_priv_s {
#define mux_v (vf->priv->mux)
#define lavc_venc_context (vf->priv->context)
-static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts);
+static int encode_frame(struct vf_instance* vf, AVFrame *pic, double pts);
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int size, i;
@@ -531,7 +531,7 @@ static int config(struct vf_instance_s* vf,
lavc_venc_context->flags = 0;
if (lavc_param_mb_decision)
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MPCODECS_HighQualityEncodingSelected);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "[VE_LAVC] High quality encoding selected (non-realtime)!\n");
lavc_venc_context->mb_decision= lavc_param_mb_decision;
}
@@ -683,7 +683,7 @@ static int config(struct vf_instance_s* vf,
/* fixed qscale :p */
if (lavc_param_vqscale >= 0.0)
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MPCODECS_UsingConstantQscale, lavc_param_vqscale);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "[VE_LAVC] Using constant qscale = %f (VBR).\n", lavc_param_vqscale);
lavc_venc_context->flags |= CODEC_FLAG_QSCALE;
lavc_venc_context->global_quality=
vf->priv->pic->quality = (int)(FF_QP2LAMBDA * lavc_param_vqscale + 0.5);
@@ -693,7 +693,7 @@ static int config(struct vf_instance_s* vf,
avcodec_thread_init(lavc_venc_context, lavc_param_threads);
if (avcodec_open(lavc_venc_context, vf->priv->codec) != 0) {
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec);
+ mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Could not open codec.\n");
return 0;
}
@@ -717,7 +717,7 @@ static int config(struct vf_instance_s* vf,
return 1;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
switch(request){
case VFCTRL_FLUSH_FRAMES:
@@ -729,7 +729,7 @@ static int control(struct vf_instance_s* vf, int request, void* data){
}
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_IYUV:
@@ -766,7 +766,7 @@ static double psnr(double d){
return -10.0*log(d)/log(10);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
AVFrame *pic= vf->priv->pic;
pic->data[0]=mpi->planes[0];
@@ -789,7 +789,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return encode_frame(vf, pic, pts) >= 0;
}
-static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts){
+static int encode_frame(struct vf_instance* vf, AVFrame *pic, double pts){
const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'};
int out_size;
double dts;
@@ -894,7 +894,7 @@ static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts){
return out_size;
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(lavc_param_psnr){
double f= lavc_venc_context->width*lavc_venc_context->height*255.0*255.0;
@@ -1041,7 +1041,7 @@ static int vf_open(vf_instance_t *vf, char* args){
vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name(lavc_param_vcodec);
if (!vf->priv->codec) {
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_MissingLAVCcodec, lavc_param_vcodec);
+ mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Cannot find codec '%s' in libavcodec...\n", lavc_param_vcodec);
return 0;
}
diff --git a/libmpcodecs/ve_libdv.c b/libmpcodecs/ve_libdv.c
index 948bc1e525..23733e70e7 100644
--- a/libmpcodecs/ve_libdv.c
+++ b/libmpcodecs/ve_libdv.c
@@ -37,7 +37,7 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -59,18 +59,18 @@ static int config(struct vf_instance_s* vf,
return 1;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
return CONTROL_UNKNOWN;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
if(fmt==IMGFMT_YUY2) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
if(fmt==IMGFMT_RGB24) return VFCAP_CSP_SUPPORTED;
return 0;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
dv_encode_full_frame(vf->priv->enc, mpi->planes,
(mpi->flags&MP_IMGFLAG_YUV) ? e_dv_color_yuv : e_dv_color_rgb,
diff --git a/libmpcodecs/ve_nuv.c b/libmpcodecs/ve_nuv.c
index 58606d661a..67cc8b532d 100644
--- a/libmpcodecs/ve_nuv.c
+++ b/libmpcodecs/ve_nuv.c
@@ -70,7 +70,7 @@ m_option_t nuvopts_conf[]={
#define COMPDATASIZE (128*4)
#define FRAMEHEADERSIZE 12
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -92,17 +92,17 @@ static int config(struct vf_instance_s* vf,
return 1;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
return CONTROL_UNKNOWN;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
if(fmt==IMGFMT_I420) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
return 0;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
uint8_t *header = vf->priv->buffer;
uint8_t* data = vf->priv->buffer + FRAMEHEADERSIZE;
uint8_t* zdata = vf->priv->zbuffer + FRAMEHEADERSIZE;
@@ -183,7 +183,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return 1;
}
-static void uninit(struct vf_instance_s* vf) {
+static void uninit(struct vf_instance* vf) {
if(vf->priv->buffer)
free(vf->priv->buffer);
diff --git a/libmpcodecs/ve_qtvideo.c b/libmpcodecs/ve_qtvideo.c
index 88ceb45a64..92b76fb252 100644
--- a/libmpcodecs/ve_qtvideo.c
+++ b/libmpcodecs/ve_qtvideo.c
@@ -139,7 +139,7 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
// OSErr cres;
@@ -177,19 +177,19 @@ static int config(struct vf_instance_s* vf,
return 1;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
return CONTROL_UNKNOWN;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
if(fmt==IMGFMT_YUY2) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
return 0;
}
static int codec_initialized = 0;
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
OSErr cres;
long framesizemax;
diff --git a/libmpcodecs/ve_raw.c b/libmpcodecs/ve_raw.c
index 228bfdee07..5e438f727d 100644
--- a/libmpcodecs/ve_raw.c
+++ b/libmpcodecs/ve_raw.c
@@ -26,7 +26,7 @@ struct vf_priv_s {
};
#define mux_v (vf->priv->mux)
-static int set_format(struct vf_instance_s *vf, unsigned int fmt) {
+static int set_format(struct vf_instance *vf, unsigned int fmt) {
if (!force_fourcc)
mux_v->bih->biCompression = fmt;
@@ -74,7 +74,7 @@ static int set_format(struct vf_instance_s *vf, unsigned int fmt) {
mux_v->bih->biBitCount = 8;
break;
default:
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MPCODECS_OutputWithFourccNotSupported, fmt);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "[VE_RAW] Raw output with FourCC [%x] not supported!\n", fmt);
mux_v->bih->biCompression = 0;
return 0;
}
@@ -82,7 +82,7 @@ static int set_format(struct vf_instance_s *vf, unsigned int fmt) {
}
-static int config(struct vf_instance_s *vf,
+static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -97,11 +97,11 @@ static int config(struct vf_instance_s *vf,
return 1;
}
-static int control(struct vf_instance_s *vf, int request, void *data) {
+static int control(struct vf_instance *vf, int request, void *data) {
return CONTROL_UNKNOWN;
}
-static int query_format(struct vf_instance_s *vf, unsigned int fmt) {
+static int query_format(struct vf_instance *vf, unsigned int fmt) {
if (IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt))
return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
switch (fmt) {
@@ -122,7 +122,7 @@ static int query_format(struct vf_instance_s *vf, unsigned int fmt) {
return 0;
}
-static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts) {
+static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) {
mux_v->buffer = mpi->planes[0];
muxer_write_chunk(mux_v, mpi->width*mpi->height*mux_v->bih->biBitCount/8, 0x10, pts, pts);
return 1;
diff --git a/libmpcodecs/ve_vfw.c b/libmpcodecs/ve_vfw.c
index efdac241b6..bc116df2bc 100644
--- a/libmpcodecs/ve_vfw.c
+++ b/libmpcodecs/ve_vfw.c
@@ -84,16 +84,16 @@ static BITMAPINFOHEADER* vfw_open_encoder(char *dll_name, char *compdatafile, BI
ret = ICGetInfo(encoder_hic, &icinfo, sizeof(ICINFO));
mp_msg(MSGT_WIN32,MSGL_INFO,"%ld - %ld - %d\n", ret, icinfo.dwSize, sizeof(ICINFO));
- mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorType, icinfo.fccType);
- mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorSubtype, icinfo.fccHandler);
- mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorFlags,
+ mp_tmsg(MSGT_WIN32,MSGL_INFO,"Compressor type: %.4lx\n", icinfo.fccType);
+ mp_tmsg(MSGT_WIN32,MSGL_INFO,"Compressor subtype: %.4lx\n", icinfo.fccHandler);
+ mp_tmsg(MSGT_WIN32,MSGL_INFO,"Compressor flags: %lu, version %lu, ICM version: %lu\n",
icinfo.dwFlags, icinfo.dwVersion, icinfo.dwVersionICM);
//printf("Compressor name: %s\n", icinfo.szName);
//printf("Compressor description: %s\n", icinfo.szDescription);
-mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_Flags);
+mp_tmsg(MSGT_WIN32,MSGL_INFO,"Flags:");
if (icinfo.dwFlags & VIDCF_QUALITY)
- mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_Quality);
+ mp_tmsg(MSGT_WIN32,MSGL_INFO," quality");
if (icinfo.dwFlags & VIDCF_FASTTEMPORALD)
mp_msg(MSGT_WIN32,MSGL_INFO," fast-decompr");
if (icinfo.dwFlags & VIDCF_QUALITYTIME)
@@ -259,7 +259,7 @@ static int vfw_encode_frame(BITMAPINFOHEADER* biOutput,void* OutBuf,
#define mux_v (vf->priv->mux)
#define vfw_bih (vf->priv->bih)
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -277,17 +277,17 @@ static int config(struct vf_instance_s* vf,
return 1;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
return CONTROL_UNKNOWN;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
if(fmt==IMGFMT_BGR24) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIPPED;
return 0;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
long flags=0;
int ret;
// flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack
@@ -298,7 +298,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return 1;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
HRESULT ret;
@@ -340,7 +340,7 @@ static int vf_open(vf_instance_t *vf, char* args){
if (!vfw_param_codec)
{
- mp_msg(MSGT_WIN32,MSGL_WARN, MSGTR_MPCODECS_NoVfwCodecSpecified);
+ mp_tmsg(MSGT_WIN32,MSGL_WARN, "[VE_RAW] Required VfW codec not specified!!\n");
return 0;
}
// mux_v->bih=vfw_open_encoder("divxc32.dll",vfw_bih,mmioFOURCC('D', 'I', 'V', '3'));
diff --git a/libmpcodecs/ve_x264.c b/libmpcodecs/ve_x264.c
index 56bb5868df..51da237169 100644
--- a/libmpcodecs/ve_x264.c
+++ b/libmpcodecs/ve_x264.c
@@ -73,8 +73,8 @@ static int encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal){
return p - buf;
}
-static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts);
-static int encode_frame(struct vf_instance_s *vf, x264_picture_t *pic_in);
+static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts);
+static int encode_frame(struct vf_instance *vf, x264_picture_t *pic_in);
void x264enc_set_param(const m_option_t* opt, char* arg)
{
@@ -148,7 +148,7 @@ void x264enc_set_param(const m_option_t* opt, char* arg)
}
}
-static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) {
+static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) {
h264_module_t *mod=(h264_module_t*)vf->priv;
if(parse_error)
@@ -215,7 +215,7 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width,
return 1;
}
-static int control(struct vf_instance_s* vf, int request, void *data)
+static int control(struct vf_instance* vf, int request, void *data)
{
h264_module_t *mod=(h264_module_t*)vf->priv;
switch(request){
@@ -228,7 +228,7 @@ static int control(struct vf_instance_s* vf, int request, void *data)
}
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch(fmt) {
case IMGFMT_I420:
@@ -247,7 +247,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
h264_module_t *mod=(h264_module_t*)vf->priv;
int i;
@@ -265,7 +265,7 @@ static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts)
return encode_frame(vf, &mod->pic) >= 0;
}
-static int encode_frame(struct vf_instance_s *vf, x264_picture_t *pic_in)
+static int encode_frame(struct vf_instance *vf, x264_picture_t *pic_in)
{
h264_module_t *mod=(h264_module_t*)vf->priv;
x264_picture_t pic_out;
@@ -296,7 +296,7 @@ static int encode_frame(struct vf_instance_s *vf, x264_picture_t *pic_in)
return i_size;
}
-static void uninit(struct vf_instance_s *vf)
+static void uninit(struct vf_instance *vf)
{
h264_module_t *mod=(h264_module_t*)vf->priv;
if (mod->x264)
diff --git a/libmpcodecs/ve_xvid4.c b/libmpcodecs/ve_xvid4.c
index c812e4c20a..858ca903f4 100644
--- a/libmpcodecs/ve_xvid4.c
+++ b/libmpcodecs/ve_xvid4.c
@@ -374,7 +374,7 @@ static const char *errorstring(int err);
*==========================================================================*/
static int
-config(struct vf_instance_s* vf,
+config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -439,7 +439,7 @@ config(struct vf_instance_s* vf,
*==========================================================================*/
static void
-uninit(struct vf_instance_s* vf)
+uninit(struct vf_instance* vf)
{
xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv;
@@ -477,7 +477,7 @@ uninit(struct vf_instance_s* vf)
*==========================================================================*/
static int
-control(struct vf_instance_s* vf, int request, void* data)
+control(struct vf_instance* vf, int request, void* data)
{
xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv;
@@ -495,7 +495,7 @@ xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv;
*==========================================================================*/
static int
-query_format(struct vf_instance_s* vf, unsigned int fmt)
+query_format(struct vf_instance* vf, unsigned int fmt)
{
switch(fmt){
case IMGFMT_YV12:
@@ -514,7 +514,7 @@ query_format(struct vf_instance_s* vf, unsigned int fmt)
*==========================================================================*/
static int
-put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
int size;
xvid_enc_stats_t stats;
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 46e41c3716..72d2bfe488 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -195,7 +195,6 @@ static const vf_info_t* const filter_list[]={
};
// For the vf option
-m_obj_settings_t* vf_settings = NULL;
const m_obj_list_t vf_obj_list = {
(void**)filter_list,
M_ST_OFF(vf_info_t,name),
@@ -441,23 +440,23 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
//============================================================================
// By default vf doesn't accept MPEGPES
-static int vf_default_query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int vf_default_query_format(struct vf_instance* vf, unsigned int fmt){
if(fmt == IMGFMT_MPEGPES) return 0;
return vf_next_query_format(vf,fmt);
}
-vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){
+vf_instance_t* vf_open_plugin(struct MPOpts *opts, const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){
vf_instance_t* vf;
int i;
for(i=0;;i++){
if(!filter_list[i]){
- mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotFindVideoFilter,name);
+ mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Couldn't find video filter '%s'.\n",name);
return NULL; // no such filter!
}
if(!strcmp(filter_list[i]->name,name)) break;
}
- vf=malloc(sizeof(vf_instance_t));
- memset(vf,0,sizeof(vf_instance_t));
+ vf = calloc(1, sizeof *vf);
+ vf->opts = opts;
vf->info=filter_list[i];
vf->next=next;
vf->config=vf_next_config;
@@ -481,11 +480,11 @@ vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t
args = NULL;
if(vf->info->open(vf,(char*)args)>0) return vf; // Success!
free(vf);
- mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name);
+ mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Couldn't open video filter '%s'.\n",name);
return NULL;
}
-vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args){
+vf_instance_t* vf_open_filter(struct MPOpts *opts, vf_instance_t* next, const char *name, char **args){
if(args && strcmp(args[0],"_oldargs_")) {
int i,l = 0;
for(i = 0 ; args && args[2*i] ; i++)
@@ -497,17 +496,17 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args
p += sprintf(str,"%s",name);
for(i = 0 ; args && args[2*i] ; i++)
p += sprintf(p," %s=%s",args[2*i],args[2*i+1]);
- mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter "[%s]\n",str);
+ mp_tmsg(MSGT_VFILTER,MSGL_INFO,"Opening video filter: " "[%s]\n",str);
}
} else if(strcmp(name,"vo")) {
if(args && strcmp(args[0],"_oldargs_") == 0)
- mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter
+ mp_tmsg(MSGT_VFILTER,MSGL_INFO,"Opening video filter: "
"[%s=%s]\n", name,args[1]);
else
- mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter
+ mp_tmsg(MSGT_VFILTER,MSGL_INFO,"Opening video filter: "
"[%s]\n", name);
}
- return vf_open_plugin(filter_list,next,name,args);
+ return vf_open_plugin(opts, filter_list,next,name,args);
}
/**
@@ -518,11 +517,12 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args
* \return pointer to the filter instance that was created.
*/
vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) {
+ struct MPOpts *opts = (*vf)->opts;
vf_instance_t *vo, *prev = NULL, *new;
// Find the last filter (should be vf_vo)
for (vo = *vf; vo->next; vo = vo->next)
prev = vo;
- new = vf_open_filter(vo, name, args);
+ new = vf_open_filter(opts, vo, name, args);
if (prev)
prev->next = new;
else
@@ -534,6 +534,7 @@ vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) {
unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred){
vf_instance_t* vf=*vfp;
+ struct MPOpts *opts = vf->opts;
const unsigned int* p;
unsigned int best=0;
int ret;
@@ -547,7 +548,7 @@ unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned
if(best) return best; // bingo, they have common csp!
// ok, then try with scale:
if(vf->info == &vf_info_scale) return 0; // avoid infinite recursion!
- vf=vf_open_filter(vf,"scale",NULL);
+ vf=vf_open_filter(opts, vf,"scale",NULL);
if(!vf) return 0; // failed to init "scale"
// try the preferred csp first:
if(preferred && vf->query_format(vf,preferred)) best=preferred; else
@@ -598,12 +599,6 @@ int vf_output_queued_frame(vf_instance_t *vf)
tmp = last->continue_buffered_image;
last->continue_buffered_image = NULL;
ret = tmp(last);
- if (ret > 0) {
- vf->control(vf, VFCTRL_DRAW_OSD, NULL);
-#ifdef CONFIG_ASS
- vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
-#endif
- }
if (ret)
return ret;
}
@@ -622,7 +617,7 @@ int vf_output_queued_frame(vf_instance_t *vf)
* are unchanged, and returns either success or error.
*
*/
-int vf_config_wrapper(struct vf_instance_s* vf,
+int vf_config_wrapper(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -631,7 +626,7 @@ int vf_config_wrapper(struct vf_instance_s* vf,
if ((vf->fmt.orig_width != width)
|| (vf->fmt.orig_height != height)
|| (vf->fmt.orig_fmt != outfmt)) {
- mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_ResolutionDoesntMatch);
+ mp_tmsg(MSGT_VFILTER,MSGL_ERR,"\nNew video file has different resolution or colorspace than the previous one.\n");
return 0;
}
return 1;
@@ -645,9 +640,10 @@ int vf_config_wrapper(struct vf_instance_s* vf,
return r;
}
-int vf_next_config(struct vf_instance_s* vf,
+int vf_next_config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int voflags, unsigned int outfmt){
+ struct MPOpts *opts = vf->opts;
int miss;
int flags=vf->next->query_format(vf->next,outfmt);
if(!flags){
@@ -655,12 +651,12 @@ int vf_next_config(struct vf_instance_s* vf,
// let's insert the 'scale' filter, it does the job for us:
vf_instance_t* vf2;
if(vf->next->info==&vf_info_scale) return 0; // scale->scale
- vf2=vf_open_filter(vf->next,"scale",NULL);
+ vf2=vf_open_filter(opts, vf->next,"scale",NULL);
if(!vf2) return 0; // shouldn't happen!
vf->next=vf2;
flags=vf->next->query_format(vf->next,outfmt);
if(!flags){
- mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CannotFindColorspace);
+ mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Cannot find matching colorspace, even by inserting 'scale' :(\n");
return 0; // FAIL
}
}
@@ -669,7 +665,7 @@ int vf_next_config(struct vf_instance_s* vf,
if(miss&VFCAP_ACCEPT_STRIDE){
// vf requires stride support but vf->next doesn't support it!
// let's insert the 'expand' filter, it does the job for us:
- vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL);
+ vf_instance_t* vf2=vf_open_filter(opts, vf->next,"expand",NULL);
if(!vf2) return 0; // shouldn't happen!
vf->next=vf2;
}
@@ -677,29 +673,21 @@ int vf_next_config(struct vf_instance_s* vf,
return vf_config_wrapper(vf->next,width,height,d_width,d_height,voflags,outfmt);
}
-int vf_next_control(struct vf_instance_s* vf, int request, void* data){
+int vf_next_control(struct vf_instance* vf, int request, void* data){
return vf->next->control(vf->next,request,data);
}
-void vf_extra_flip(struct vf_instance_s* vf) {
- vf_next_control(vf, VFCTRL_DRAW_OSD, NULL);
-#ifdef CONFIG_ASS
- vf_next_control(vf, VFCTRL_DRAW_EOSD, NULL);
-#endif
- vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
-}
-
-int vf_next_query_format(struct vf_instance_s* vf, unsigned int fmt){
+int vf_next_query_format(struct vf_instance* vf, unsigned int fmt){
int flags=vf->next->query_format(vf->next,fmt);
if(flags) flags|=vf->default_caps;
return flags;
}
-int vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi, double pts){
+int vf_next_put_image(struct vf_instance* vf,mp_image_t *mpi, double pts){
return vf->next->put_image(vf->next,mpi, pts);
}
-void vf_next_draw_slice(struct vf_instance_s* vf,unsigned char** src, int * stride,int w, int h, int x, int y){
+void vf_next_draw_slice(struct vf_instance* vf,unsigned char** src, int * stride,int w, int h, int x, int y){
if (vf->next->draw_slice) {
vf->next->draw_slice(vf->next,src,stride,w,h,x,y);
return;
@@ -723,7 +711,10 @@ void vf_next_draw_slice(struct vf_instance_s* vf,unsigned char** src, int * stri
//============================================================================
-vf_instance_t* append_filters(vf_instance_t* last){
+vf_instance_t *append_filters(vf_instance_t* last,
+ struct m_obj_settings *vf_settings)
+{
+ struct MPOpts *opts = last->opts;
vf_instance_t* vf;
int i;
@@ -733,7 +724,7 @@ vf_instance_t* append_filters(vf_instance_t* last){
/* NOP */;
for(i-- ; i >= 0 ; i--) {
//printf("Open filter %s\n",vf_settings[i].name);
- vf = vf_open_filter(last,vf_settings[i].name,vf_settings[i].attribs);
+ vf = vf_open_filter(opts, last,vf_settings[i].name,vf_settings[i].attribs);
if(vf) last=vf;
}
}
diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h
index 67c2272bb2..99321b3afa 100644
--- a/libmpcodecs/vf.h
+++ b/libmpcodecs/vf.h
@@ -3,7 +3,8 @@
#include "mp_image.h"
-struct vf_instance_s;
+struct MPOpts;
+struct vf_instance;
struct vf_priv_s;
typedef struct vf_info_s {
@@ -11,7 +12,7 @@ typedef struct vf_info_s {
const char *name;
const char *author;
const char *comment;
- int (*open)(struct vf_instance_s* vf,char* args);
+ int (*open)(struct vf_instance* vf,char* args);
// Ptr to a struct dscribing the options
const void* opts;
} vf_info_t;
@@ -31,27 +32,27 @@ typedef struct vf_format_context_t {
int orig_width, orig_height, orig_fmt;
} vf_format_context_t;
-typedef struct vf_instance_s {
+typedef struct vf_instance {
const vf_info_t* info;
// funcs:
- int (*config)(struct vf_instance_s* vf,
+ int (*config)(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt);
- int (*control)(struct vf_instance_s* vf,
+ int (*control)(struct vf_instance* vf,
int request, void* data);
- int (*query_format)(struct vf_instance_s* vf,
+ int (*query_format)(struct vf_instance* vf,
unsigned int fmt);
- void (*get_image)(struct vf_instance_s* vf,
+ void (*get_image)(struct vf_instance* vf,
mp_image_t *mpi);
- int (*put_image)(struct vf_instance_s* vf,
+ int (*put_image)(struct vf_instance* vf,
mp_image_t *mpi, double pts);
- void (*start_slice)(struct vf_instance_s* vf,
+ void (*start_slice)(struct vf_instance* vf,
mp_image_t *mpi);
- void (*draw_slice)(struct vf_instance_s* vf,
+ void (*draw_slice)(struct vf_instance* vf,
unsigned char** src, int* stride, int w,int h, int x, int y);
- void (*uninit)(struct vf_instance_s* vf);
+ void (*uninit)(struct vf_instance* vf);
- int (*continue_buffered_image)(struct vf_instance_s* vf);
+ int (*continue_buffered_image)(struct vf_instance* vf);
// caps:
unsigned int default_caps; // used by default query_format()
unsigned int default_reqs; // used by default config()
@@ -59,9 +60,10 @@ typedef struct vf_instance_s {
int w, h;
vf_image_context_t imgctx;
vf_format_context_t fmt;
- struct vf_instance_s* next;
+ struct vf_instance* next;
mp_image_t *dmpi;
struct vf_priv_s* priv;
+ struct MPOpts *opts;
} vf_instance_t;
// control codes:
@@ -89,6 +91,10 @@ typedef struct vf_seteq_s
#define VFCTRL_GET_PTS 17 /* Return last pts value that reached vf_vo*/
#define VFCTRL_SET_DEINTERLACE 18 /* Set deinterlacing status */
#define VFCTRL_GET_DEINTERLACE 19 /* Get deinterlacing status */
+/* Hack to make the OSD state object available to vf_expand which accesses
+ * the OSD state outside of normal OSD draw time. */
+#define VFCTRL_SET_OSD_OBJ 20
+#define VFCTRL_REDRAW_OSD 21 /* Change user-visible OSD immediately */
#include "vfcap.h"
@@ -100,10 +106,10 @@ typedef struct vf_seteq_s
void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h);
mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h);
-vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args);
-vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args);
+vf_instance_t* vf_open_plugin(struct MPOpts *opts, const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args);
+vf_instance_t* vf_open_filter(struct MPOpts *opts, vf_instance_t* next, const char *name, char **args);
vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args);
-vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args);
+vf_instance_t* vf_open_encoder(struct MPOpts *opts, vf_instance_t* next, const char *name, char *args);
unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred);
void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src);
@@ -111,21 +117,21 @@ void vf_queue_frame(vf_instance_t *vf, int (*)(vf_instance_t *));
int vf_output_queued_frame(vf_instance_t *vf);
// default wrappers:
-int vf_next_config(struct vf_instance_s* vf,
+int vf_next_config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt);
-int vf_next_control(struct vf_instance_s* vf, int request, void* data);
-void vf_extra_flip(struct vf_instance_s* vf);
-int vf_next_query_format(struct vf_instance_s* vf, unsigned int fmt);
-int vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi, double pts);
-void vf_next_draw_slice (struct vf_instance_s* vf, unsigned char** src, int* stride, int w,int h, int x, int y);
+int vf_next_control(struct vf_instance* vf, int request, void* data);
+int vf_next_query_format(struct vf_instance* vf, unsigned int fmt);
+int vf_next_put_image(struct vf_instance* vf,mp_image_t *mpi, double pts);
+void vf_next_draw_slice (struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y);
-vf_instance_t* append_filters(vf_instance_t* last);
+struct m_obj_settings;
+vf_instance_t* append_filters(vf_instance_t* last, struct m_obj_settings *vf_settings);
void vf_uninit_filter(vf_instance_t* vf);
void vf_uninit_filter_chain(vf_instance_t* vf);
-int vf_config_wrapper(struct vf_instance_s* vf,
+int vf_config_wrapper(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt);
diff --git a/libmpcodecs/vf_1bpp.c b/libmpcodecs/vf_1bpp.c
index 039fa8e895..3dd544bfd9 100644
--- a/libmpcodecs/vf_1bpp.c
+++ b/libmpcodecs/vf_1bpp.c
@@ -40,7 +40,7 @@ static const unsigned int bgr_list[]={
0
};
-static unsigned int find_best(struct vf_instance_s* vf){
+static unsigned int find_best(struct vf_instance* vf){
unsigned int best=0;
int ret;
const unsigned int* p=bgr_list;
@@ -60,7 +60,7 @@ struct vf_priv_s {
unsigned int fmt;
};
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
if (!vf->priv->fmt)
@@ -103,7 +103,7 @@ static void convert(mp_image_t *mpi, mp_image_t *dmpi, int value0, int value1,in
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -154,7 +154,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
int best;
if(fmt!=IMGFMT_RGB1 && fmt!=IMGFMT_BGR1) return 0;
best=find_best(vf);
diff --git a/libmpcodecs/vf_2xsai.c b/libmpcodecs/vf_2xsai.c
index bc05b5b64d..2b2d435be6 100644
--- a/libmpcodecs/vf_2xsai.c
+++ b/libmpcodecs/vf_2xsai.c
@@ -25,7 +25,7 @@ static int PixelsPerMask = 2;
#define makecol(r,g,b) (r+(g<<8)+(b<<16))
#define makecol_depth(d,r,g,b) (r+(g<<8)+(b<<16))
-int Init_2xSaI(int d)
+static int Init_2xSaI(int d)
{
int minr = 0, ming = 0, minb = 0;
@@ -77,7 +77,7 @@ int Init_2xSaI(int d)
+ ((((A & qlowpixelMask) + (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask)) >> 2) & qlowpixelMask)
-void Super2xSaI_ex(uint8_t *src, uint32_t src_pitch,
+static void Super2xSaI_ex(uint8_t *src, uint32_t src_pitch,
uint8_t *dst, uint32_t dst_pitch,
uint32_t width, uint32_t height, int sbpp) {
@@ -262,7 +262,7 @@ void Super2xSaI_ex(uint8_t *src, uint32_t src_pitch,
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -271,7 +271,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,2*width,2*height,2*d_width,2*d_height,flags,outfmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -288,7 +288,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
// case IMGFMT_BGR15:
// case IMGFMT_BGR16:
diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c
index b88e7b37df..b13b148600 100644
--- a/libmpcodecs/vf_ass.c
+++ b/libmpcodecs/vf_ass.c
@@ -31,6 +31,7 @@
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
@@ -65,33 +66,34 @@ static const struct vf_priv_s {
ass_renderer_t* ass_priv;
unsigned char* planes[3];
- unsigned char* dirty_rows;
+ struct line_limits {
+ uint16_t start;
+ uint16_t end;
+ } *line_limits;
} vf_priv_dflt;
-extern int opt_screen_size_x;
-extern int opt_screen_size_y;
-
extern ass_track_t* ass_track;
extern float sub_delay;
extern int sub_visibility;
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
+ struct MPOpts *opts = vf->opts;
if (outfmt == IMGFMT_IF09) return 0;
vf->priv->outh = height + ass_top_margin + ass_bottom_margin;
vf->priv->outw = width;
- if(!opt_screen_size_x && !opt_screen_size_y){
+ if (!opts->screen_size_x && !opts->screen_size_y) {
d_width = d_width * vf->priv->outw / width;
d_height = d_height * vf->priv->outh / height;
}
vf->priv->planes[1] = malloc(vf->priv->outw * vf->priv->outh);
vf->priv->planes[2] = malloc(vf->priv->outw * vf->priv->outh);
- vf->priv->dirty_rows = malloc(vf->priv->outh);
+ vf->priv->line_limits = malloc((vf->priv->outh + 1) / 2 * sizeof(*vf->priv->line_limits));
if (vf->priv->ass_priv) {
ass_configure(vf->priv->ass_priv, vf->priv->outw, vf->priv->outh, 0);
@@ -101,7 +103,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width, d_height, flags, outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
+static void get_image(struct vf_instance* vf, mp_image_t *mpi)
{
if(mpi->type == MP_IMGTYPE_IPB) return;
if(mpi->flags & MP_IMGFLAG_PRESERVE) return;
@@ -115,7 +117,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) &&
!(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){
- mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible);
+ mp_tmsg(MSGT_ASS, MSGL_INFO, "Full DR not possible, trying SLICES instead!\n");
return;
}
@@ -160,11 +162,11 @@ static void blank(mp_image_t *mpi, int y1, int y2)
}
}
-static int prepare_image(struct vf_instance_s* vf, mp_image_t *mpi)
+static int prepare_image(struct vf_instance* vf, mp_image_t *mpi)
{
if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
vf->dmpi = mpi->priv;
- if (!vf->dmpi) { mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); return 0; }
+ if (!vf->dmpi) { mp_tmsg(MSGT_ASS, MSGL_WARN, "Why do we get NULL??\n"); return 0; }
mpi->priv = NULL;
// we've used DR, so we're ready...
if (ass_top_margin)
@@ -205,55 +207,58 @@ static int prepare_image(struct vf_instance_s* vf, mp_image_t *mpi)
return 0;
}
+static void update_limits(struct vf_instance *vf, int starty, int endy,
+ int startx, int endx)
+{
+ starty >>= 1;
+ endy = (endy + 1) >> 1;
+ startx >>= 1;
+ endx = (endx + 1) >> 1;
+ for (int i = starty; i < endy; i++) {
+ struct line_limits *ll = vf->priv->line_limits + i;
+ if (startx < ll->start)
+ ll->start = startx;
+ if (endx > ll->end)
+ ll->end = endx;
+ }
+}
+
/**
* \brief Copy specified rows from render_context.dmpi to render_context.planes, upsampling to 4:4:4
*/
-static void copy_from_image(struct vf_instance_s* vf, int first_row, int last_row)
+static void copy_from_image(struct vf_instance* vf)
{
int pl;
- int i, j, k;
- unsigned char val;
- int chroma_rows;
-
- first_row -= (first_row % 2);
- last_row += (last_row % 2);
- chroma_rows = (last_row - first_row) / 2;
for (pl = 1; pl < 3; ++pl) {
int dst_stride = vf->priv->outw;
int src_stride = vf->dmpi->stride[pl];
- unsigned char* src = vf->dmpi->planes[pl] + (first_row/2) * src_stride;
- unsigned char* dst = vf->priv->planes[pl] + first_row * dst_stride;
- unsigned char* dst_next = dst + dst_stride;
- for(i = 0; i < chroma_rows; ++i)
- {
- if ((vf->priv->dirty_rows[first_row + i*2] == 0) ||
- (vf->priv->dirty_rows[first_row + i*2 + 1] == 0)) {
- for (j = 0, k = 0; j < vf->dmpi->chroma_width; ++j, k+=2) {
- val = *(src + j);
- *(dst + k) = val;
- *(dst + k + 1) = val;
- *(dst_next + k) = val;
- *(dst_next + k + 1) = val;
- }
+ unsigned char* src = vf->dmpi->planes[pl];
+ unsigned char* dst = vf->priv->planes[pl];
+ for (int i = 0; i < (vf->priv->outh + 1) / 2; i++) {
+ struct line_limits *ll = vf->priv->line_limits + i;
+ unsigned char* dst_next = dst + dst_stride;
+ for (int j = ll->start; j < ll->end; j++) {
+ unsigned char val = src[j];
+ dst[j << 1] = val;
+ dst[(j << 1) + 1] = val;
+ dst_next[j << 1] = val;
+ dst_next[(j << 1) + 1] = val;
}
src += src_stride;
dst = dst_next + dst_stride;
- dst_next = dst + dst_stride;
}
}
- for (i = first_row; i < last_row; ++i)
- vf->priv->dirty_rows[i] = 1;
}
/**
* \brief Copy all previously copied rows back to render_context.dmpi
*/
-static void copy_to_image(struct vf_instance_s* vf)
+static void copy_to_image(struct vf_instance* vf)
{
int pl;
- int i, j, k;
+ int i, j;
for (pl = 1; pl < 3; ++pl) {
int dst_stride = vf->dmpi->stride[pl];
int src_stride = vf->priv->outw;
@@ -261,18 +266,14 @@ static void copy_to_image(struct vf_instance_s* vf)
unsigned char* dst = vf->dmpi->planes[pl];
unsigned char* src = vf->priv->planes[pl];
unsigned char* src_next = vf->priv->planes[pl] + src_stride;
- for(i = 0; i < vf->dmpi->chroma_height; ++i)
- {
- if ((vf->priv->dirty_rows[i*2] == 1)) {
- assert(vf->priv->dirty_rows[i*2 + 1] == 1);
- for (j = 0, k = 0; j < vf->dmpi->chroma_width; ++j, k+=2) {
- unsigned val = 0;
- val += *(src + k);
- val += *(src + k + 1);
- val += *(src_next + k);
- val += *(src_next + k + 1);
- *(dst + j) = val >> 2;
- }
+ for (i = 0; i < vf->dmpi->chroma_height; ++i) {
+ for (j = vf->priv->line_limits[i].start; j < vf->priv->line_limits[i].end; j++) {
+ unsigned val = 0;
+ val += src[j << 1];
+ val += src[(j << 1) + 1];
+ val += src_next[j << 1];
+ val += src_next[(j << 1) + 1];
+ dst[j] = val >> 2;
}
dst += dst_stride;
src = src_next + src_stride;
@@ -281,7 +282,7 @@ static void copy_to_image(struct vf_instance_s* vf)
}
}
-static void my_draw_bitmap(struct vf_instance_s* vf, unsigned char* bitmap, int bitmap_w, int bitmap_h, int stride, int dst_x, int dst_y, unsigned color)
+static void my_draw_bitmap(struct vf_instance* vf, unsigned char* bitmap, int bitmap_w, int bitmap_h, int stride, int dst_x, int dst_y, unsigned color)
{
unsigned char y = rgba2y(color);
unsigned char u = rgba2u(color);
@@ -297,10 +298,10 @@ static void my_draw_bitmap(struct vf_instance_s* vf, unsigned char* bitmap, int
dstv = vf->priv->planes[2] + dst_x + dst_y * vf->priv->outw;
for (i = 0; i < bitmap_h; ++i) {
for (j = 0; j < bitmap_w; ++j) {
- unsigned k = ((unsigned)src[j]) * opacity / 255;
- dsty[j] = (k*y + (255-k)*dsty[j]) / 255;
- dstu[j] = (k*u + (255-k)*dstu[j]) / 255;
- dstv[j] = (k*v + (255-k)*dstv[j]) / 255;
+ unsigned k = (src[j] * opacity + 255) >> 8;
+ dsty[j] = (k*y + (255-k)*dsty[j] + 255) >> 8;
+ dstu[j] = (k*u + (255-k)*dstu[j] + 255) >> 8;
+ dstv[j] = (k*v + (255-k)*dstv[j] + 255) >> 8;
}
src += stride;
dsty += dmpi->stride[0];
@@ -309,12 +310,15 @@ static void my_draw_bitmap(struct vf_instance_s* vf, unsigned char* bitmap, int
}
}
-static int render_frame(struct vf_instance_s* vf, mp_image_t *mpi, const ass_image_t* img)
+static int render_frame(struct vf_instance* vf, mp_image_t *mpi, const ass_image_t* img)
{
if (img) {
- memset(vf->priv->dirty_rows, 0, vf->priv->outh); // reset dirty rows
+ for (int i = 0; i < (vf->priv->outh + 1) / 2; i++)
+ vf->priv->line_limits[i] = (struct line_limits){65535, 0};
+ for (const ass_image_t *im = img; im; im = im->next)
+ update_limits(vf, im->dst_y, im->dst_y + im->h, im->dst_x, im->dst_x + im->w);
+ copy_from_image(vf);
while (img) {
- copy_from_image(vf, img->dst_y, img->dst_y + img->h);
my_draw_bitmap(vf, img->bitmap, img->w, img->h, img->stride,
img->dst_x, img->dst_y, img->color);
img = img->next;
@@ -324,7 +328,7 @@ static int render_frame(struct vf_instance_s* vf, mp_image_t *mpi, const ass_ima
return 0;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
ass_image_t* images = 0;
if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE))
@@ -336,7 +340,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf, vf->dmpi, pts);
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch(fmt){
case IMGFMT_YV12:
@@ -362,16 +366,14 @@ static int control(vf_instance_t *vf, int request, void *data)
return vf_next_control(vf, request, data);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
if (vf->priv->ass_priv)
ass_renderer_done(vf->priv->ass_priv);
- if (vf->priv->planes[1])
- free(vf->priv->planes[1]);
- if (vf->priv->planes[2])
- free(vf->priv->planes[2]);
- if (vf->priv->dirty_rows)
- free(vf->priv->dirty_rows);
+ free(vf->priv->planes[1]);
+ free(vf->priv->planes[2]);
+ free(vf->priv->line_limits);
+ free(vf->priv);
}
static const unsigned int fmt_list[]={
@@ -427,4 +429,3 @@ const vf_info_t vf_info_ass = {
open,
&vf_opts
};
-
diff --git a/libmpcodecs/vf_blackframe.c b/libmpcodecs/vf_blackframe.c
index dce13ea927..34d2f1f506 100644
--- a/libmpcodecs/vf_blackframe.c
+++ b/libmpcodecs/vf_blackframe.c
@@ -40,12 +40,12 @@ struct vf_priv_s {
unsigned int bamount, bthresh, frame, lastkeyframe;
};
-static int config(struct vf_instance_s* vf, int width, int height, int d_width,
+static int config(struct vf_instance* vf, int width, int height, int d_width,
int d_height, unsigned int flags, unsigned int outfmt) {
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static int query_format(struct vf_instance_s *vf, unsigned fmt) {
+static int query_format(struct vf_instance *vf, unsigned fmt) {
switch(fmt) {
case IMGFMT_YVU9:
case IMGFMT_IF09:
@@ -66,7 +66,7 @@ static int query_format(struct vf_instance_s *vf, unsigned fmt) {
return 0;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
int x, y;
int nblack=0, pblack=0;
@@ -110,11 +110,11 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf, dmpi, pts);
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
return vf_next_control(vf,request,data);
}
-static void uninit(struct vf_instance_s *vf) {
+static void uninit(struct vf_instance *vf) {
if (vf->priv) free(vf->priv);
}
diff --git a/libmpcodecs/vf_bmovl.c b/libmpcodecs/vf_bmovl.c
index ee4eb9a942..0277751527 100644
--- a/libmpcodecs/vf_bmovl.c
+++ b/libmpcodecs/vf_bmovl.c
@@ -125,14 +125,14 @@ struct vf_priv_s {
};
static int
-query_format(struct vf_instance_s* vf, unsigned int fmt){
+query_format(struct vf_instance* vf, unsigned int fmt){
if(fmt==IMGFMT_YV12) return VFCAP_CSP_SUPPORTED;
return 0;
}
static int
-config(struct vf_instance_s* vf,
+config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -162,7 +162,7 @@ config(struct vf_instance_s* vf,
}
static void
-uninit(struct vf_instance_s *vf)
+uninit(struct vf_instance *vf)
{
if(vf->priv) {
free(vf->priv->bitmap.y);
@@ -214,7 +214,7 @@ _read_cmd(int fd, char *cmd, char *args) {
static int
-put_image(struct vf_instance_s* vf, mp_image_t* mpi, double pts){
+put_image(struct vf_instance* vf, mp_image_t* mpi, double pts){
int buf_x=0, buf_y=0, buf_pos=0;
int have, got, want;
int xpos=0, ypos=0, pos=0;
diff --git a/libmpcodecs/vf_boxblur.c b/libmpcodecs/vf_boxblur.c
index f8f2026566..e75f261375 100644
--- a/libmpcodecs/vf_boxblur.c
+++ b/libmpcodecs/vf_boxblur.c
@@ -46,7 +46,7 @@ struct vf_priv_s {
/***************************************************************************/
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -127,7 +127,7 @@ static void vBlur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int s
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int cw= mpi->w >> mpi->chroma_x_shift;
int ch= mpi->h >> mpi->chroma_y_shift;
@@ -156,7 +156,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_crop.c b/libmpcodecs/vf_crop.c
index 5916f611e0..14bbcd9d7c 100644
--- a/libmpcodecs/vf_crop.c
+++ b/libmpcodecs/vf_crop.c
@@ -5,6 +5,7 @@
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
@@ -21,14 +22,12 @@ static const struct vf_priv_s {
-1,-1
};
-extern int opt_screen_size_x;
-extern int opt_screen_size_y;
-
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
+ struct MPOpts *opts = vf->opts;
// calculate the missing parameters:
if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width;
if(vf->priv->crop_h<=0 || vf->priv->crop_h>height) vf->priv->crop_h=height;
@@ -58,17 +57,17 @@ static int config(struct vf_instance_s* vf,
// check:
if(vf->priv->crop_w+vf->priv->crop_x>width ||
vf->priv->crop_h+vf->priv->crop_y>height){
- mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_CropBadPositionWidthHeight);
+ mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[CROP] Bad position/width/height - cropped area outside of the original!\n");
return 0;
}
- if(!opt_screen_size_x && !opt_screen_size_y){
+ if(!opts->screen_size_x && !opts->screen_size_y){
d_width=d_width*vf->priv->crop_w/width;
d_height=d_height*vf->priv->crop_h/height;
}
return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)
return vf_next_put_image(vf,vf->dmpi, pts);
@@ -95,12 +94,12 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
+static void start_slice(struct vf_instance* vf, mp_image_t *mpi){
vf->dmpi = vf_get_image(vf->next, mpi->imgfmt, mpi->type, mpi->flags,
vf->priv->crop_w, vf->priv->crop_h);
}
-static void draw_slice(struct vf_instance_s* vf,
+static void draw_slice(struct vf_instance* vf,
unsigned char** src, int* stride, int w,int h, int x, int y){
unsigned char *src2[3];
src2[0] = src[0];
diff --git a/libmpcodecs/vf_cropdetect.c b/libmpcodecs/vf_cropdetect.c
index d0d4eb489a..e91f537a04 100644
--- a/libmpcodecs/vf_cropdetect.c
+++ b/libmpcodecs/vf_cropdetect.c
@@ -42,7 +42,7 @@ static int checkline(unsigned char* src,int stride,int len,int bpp){
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
vf->priv->x1=width - 1;
@@ -53,7 +53,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
int bpp=mpi->bpp/8;
int w,h,x,y,shrink_by;
@@ -125,7 +125,7 @@ if(++vf->priv->fno>2){ // ignore first 2 frames - they may be empty
h -= shrink_by;
y += (shrink_by / 2 + 1) & ~1;
- mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea,
+ mp_tmsg(MSGT_VFILTER, MSGL_INFO, "[CROP] Crop area: X: %d..%d Y: %d..%d (-vf crop=%d:%d:%d:%d).\n",
vf->priv->x1,vf->priv->x2,
vf->priv->y1,vf->priv->y2,
w,h,x,y);
@@ -136,7 +136,7 @@ if(++vf->priv->fno>2){ // ignore first 2 frames - they may be empty
return vf_next_put_image(vf,dmpi, pts);
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt) {
+static int query_format(struct vf_instance* vf, unsigned int fmt) {
switch(fmt) {
// the default limit value works only right with YV12 right now.
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_decimate.c b/libmpcodecs/vf_decimate.c
index 4d1748d91c..616085115b 100644
--- a/libmpcodecs/vf_decimate.c
+++ b/libmpcodecs/vf_decimate.c
@@ -110,7 +110,7 @@ static int diff_to_drop(int hi, int lo, float frac, mp_image_t *old, mp_image_t
new->w*(new->bpp/8), new->h, old->stride[0], new->stride[0]);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -146,7 +146,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf, dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -178,5 +178,3 @@ const vf_info_t vf_info_decimate = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_delogo.c b/libmpcodecs/vf_delogo.c
index 7654b627de..d9234b6eab 100644
--- a/libmpcodecs/vf_delogo.c
+++ b/libmpcodecs/vf_delogo.c
@@ -117,7 +117,7 @@ static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int
}
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -125,7 +125,7 @@ static int config(struct vf_instance_s* vf,
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ
// ok, we can do pp in-place (or pp disabled):
@@ -143,7 +143,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
@@ -169,7 +169,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
free(vf->priv);
@@ -178,7 +178,7 @@ static void uninit(struct vf_instance_s* vf){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
@@ -189,7 +189,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return 0;
}
-static unsigned int fmt_list[]={
+static const unsigned int fmt_list[]={
IMGFMT_YV12,
IMGFMT_I420,
IMGFMT_IYUV,
@@ -249,7 +249,7 @@ static int open(vf_instance_t *vf, char* args){
}
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
-static m_option_t vf_opts_fields[] = {
+static const m_option_t vf_opts_fields[] = {
{ "x", ST_OFF(xoff), CONF_TYPE_INT, 0, 0, 0, NULL },
{ "y", ST_OFF(yoff), CONF_TYPE_INT, 0, 0, 0, NULL },
{ "w", ST_OFF(lw), CONF_TYPE_INT, 0, 0, 0, NULL },
@@ -259,7 +259,7 @@ static m_option_t vf_opts_fields[] = {
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
-static m_struct_t vf_opts = {
+static const m_struct_t vf_opts = {
"delogo",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
diff --git a/libmpcodecs/vf_denoise3d.c b/libmpcodecs/vf_denoise3d.c
index 0958305936..fc9924cbe9 100644
--- a/libmpcodecs/vf_denoise3d.c
+++ b/libmpcodecs/vf_denoise3d.c
@@ -45,7 +45,7 @@ struct vf_priv_s {
/***************************************************************************/
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -58,7 +58,7 @@ static int config(struct vf_instance_s* vf,
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv->Line);
}
@@ -109,7 +109,7 @@ static void deNoise(unsigned char *Frame, // mpi->planes[x]
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int cw= mpi->w >> mpi->chroma_x_shift;
int ch= mpi->h >> mpi->chroma_y_shift;
int W = mpi->w, H = mpi->h;
@@ -147,7 +147,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_detc.c b/libmpcodecs/vf_detc.c
index c11dac9fcd..d46218b688 100644
--- a/libmpcodecs/vf_detc.c
+++ b/libmpcodecs/vf_detc.c
@@ -267,7 +267,7 @@ static void copy_image(mp_image_t *dmpi, mp_image_t *mpi, int field)
}
}
-static int do_put_image(struct vf_instance_s* vf, mp_image_t *dmpi)
+static int do_put_image(struct vf_instance* vf, mp_image_t *dmpi)
{
struct vf_priv_s *p = vf->priv;
int dropflag;
@@ -295,7 +295,7 @@ static int do_put_image(struct vf_instance_s* vf, mp_image_t *dmpi)
return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
int ret=0;
mp_image_t *dmpi;
@@ -339,7 +339,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return ret;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - figure out which other formats work */
switch (fmt) {
@@ -351,14 +351,14 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -433,5 +433,3 @@ const vf_info_t vf_info_detc = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_dint.c b/libmpcodecs/vf_dint.c
index b978062d73..62422fb1c4 100644
--- a/libmpcodecs/vf_dint.c
+++ b/libmpcodecs/vf_dint.c
@@ -24,7 +24,7 @@ struct vf_priv_s {
#define MAXROWSIZE 1200
-static int config (struct vf_instance_s* vf,
+static int config (struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -61,7 +61,7 @@ static int config (struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static int put_image (struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image (struct vf_instance* vf, mp_image_t *mpi, double pts)
{
char rrow0[MAXROWSIZE];
char rrow1[MAXROWSIZE];
diff --git a/libmpcodecs/vf_divtc.c b/libmpcodecs/vf_divtc.c
index 5eba70bb8b..b9326e6d8a 100644
--- a/libmpcodecs/vf_divtc.c
+++ b/libmpcodecs/vf_divtc.c
@@ -206,7 +206,7 @@ static int imgop(int(*planeop)(unsigned char *, unsigned char *,
static int match(struct vf_priv_s *p, int *diffs,
int phase1, int phase2, double *strength)
{
- static const int pattern1[]={ -4, 1, 1, 1, 1 },
+ const int pattern1[]={ -4, 1, 1, 1, 1 },
pattern2[]={ -2, -3, 4, 4, -3 }, *pattern;
int f, m, n, t[5];
@@ -239,7 +239,7 @@ static int match(struct vf_priv_s *p, int *diffs,
return m;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi, *tmpi=0;
int n, m, f, newphase;
@@ -550,7 +550,7 @@ static int analyze(struct vf_priv_s *p)
return 1;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch(fmt)
{
@@ -565,7 +565,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
if(vf->priv)
{
diff --git a/libmpcodecs/vf_down3dright.c b/libmpcodecs/vf_down3dright.c
index feb591cb30..7db8900133 100644
--- a/libmpcodecs/vf_down3dright.c
+++ b/libmpcodecs/vf_down3dright.c
@@ -78,7 +78,7 @@ static void toright(unsigned char *dst[3], unsigned char *src[3],
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -95,7 +95,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf,dmpi, pts);
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -105,7 +105,7 @@ static int config(struct vf_instance_s* vf,
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - really any YUV 4:2:0 input format should work */
switch (fmt) {
@@ -117,7 +117,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -146,4 +146,3 @@ const vf_info_t vf_info_down3dright = {
open,
NULL
};
-
diff --git a/libmpcodecs/vf_dsize.c b/libmpcodecs/vf_dsize.c
index 324ddf169a..ad298d0d19 100644
--- a/libmpcodecs/vf_dsize.c
+++ b/libmpcodecs/vf_dsize.c
@@ -17,7 +17,7 @@ struct vf_priv_s {
float aspect;
};
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -103,4 +103,3 @@ const vf_info_t vf_info_dsize = {
open,
NULL
};
-
diff --git a/libmpcodecs/vf_dvbscale.c b/libmpcodecs/vf_dvbscale.c
index 9ba79b4a57..3a28984fc1 100644
--- a/libmpcodecs/vf_dvbscale.c
+++ b/libmpcodecs/vf_dvbscale.c
@@ -16,7 +16,7 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
diff --git a/libmpcodecs/vf_eq.c b/libmpcodecs/vf_eq.c
index e85deeacff..c038355f52 100644
--- a/libmpcodecs/vf_eq.c
+++ b/libmpcodecs/vf_eq.c
@@ -114,7 +114,7 @@ static void (*process)(unsigned char *dest, int dstride, unsigned char *src, int
/* FIXME: add packed yuv version of process */
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -143,7 +143,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf,dmpi, pts);
}
-static int control(struct vf_instance_s* vf, int request, void* data)
+static int control(struct vf_instance* vf, int request, void* data)
{
vf_equalizer_t *eq;
@@ -174,7 +174,7 @@ static int control(struct vf_instance_s* vf, int request, void* data)
return vf_next_control(vf, request, data);
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch (fmt) {
case IMGFMT_YVU9:
@@ -195,7 +195,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
if (vf->priv->buf) free(vf->priv->buf);
free(vf->priv);
@@ -223,13 +223,13 @@ static int open(vf_instance_t *vf, char* args)
}
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
-static m_option_t vf_opts_fields[] = {
+static const m_option_t vf_opts_fields[] = {
{"brightness", ST_OFF(brightness), CONF_TYPE_INT, M_OPT_RANGE,-100 ,100, NULL},
{"contrast", ST_OFF(contrast), CONF_TYPE_INT, M_OPT_RANGE,-100 ,100, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
-static m_struct_t vf_opts = {
+static const m_struct_t vf_opts = {
"eq",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
@@ -244,4 +244,3 @@ const vf_info_t vf_info_eq = {
open,
&vf_opts
};
-
diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c
index 5804ce41c1..dc3928b0da 100644
--- a/libmpcodecs/vf_expand.c
+++ b/libmpcodecs/vf_expand.c
@@ -3,10 +3,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdbool.h>
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
@@ -27,12 +29,13 @@
static struct vf_priv_s {
int exp_w,exp_h;
int exp_x,exp_y;
- int osd;
+ int osd_enabled;
double aspect;
int round;
unsigned char* fb_ptr;
int passthrough;
int first_slice;
+ struct osd_state *osd;
} const vf_priv_dflt = {
-1,-1,
-1,-1,
@@ -44,13 +47,10 @@ static struct vf_priv_s {
0
};
-extern int opt_screen_size_x;
-extern int opt_screen_size_y;
-
//===========================================================================//
#ifdef OSD_SUPPORT
-static struct vf_instance_s* vf=NULL; // fixme (needs sub.c changes)
+static struct vf_instance* vf=NULL; // fixme (needs sub.c changes)
static int orig_w,orig_h;
static void remove_func_2(int x0,int y0, int w,int h){
@@ -96,7 +96,7 @@ static void remove_func(int x0,int y0, int w,int h){
}
}
-static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){
+static void draw_func(void *ctx, int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){
unsigned char* dst;
if(!vo_osd_changed_flag && vf->dmpi->planes[0]==vf->priv->fb_ptr){
// ok, enough to update the area inside the video, leave the black bands
@@ -156,7 +156,7 @@ static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned ch
}
}
-static void draw_osd(struct vf_instance_s* vf_,int w,int h){
+static void draw_osd(struct vf_instance* vf_,int w,int h){
vf=vf_;orig_w=w;orig_h=h;
// printf("======================================\n");
if(vf->priv->exp_w!=w || vf->priv->exp_h!=h ||
@@ -174,10 +174,10 @@ static void draw_osd(struct vf_instance_s* vf_,int w,int h){
remove_func_2(vf->priv->exp_x+w,vf->priv->exp_y,vf->priv->exp_w-w-vf->priv->exp_x,h);
} else {
// partial clear:
- vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func);
+ osd_remove_text(vf->priv->osd, vf->priv->exp_w,vf->priv->exp_h,remove_func);
}
}
- vo_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func);
+ osd_draw_text(vf->priv->osd, vf->priv->exp_w,vf->priv->exp_h,draw_func, NULL);
// save buffer pointer for double buffering detection - yes, i know it's
// ugly method, but note that codecs with DR support does the same...
if(vf->dmpi)
@@ -187,9 +187,11 @@ static void draw_osd(struct vf_instance_s* vf_,int w,int h){
#endif
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt){
+ unsigned int flags, unsigned int outfmt)
+{
+ struct MPOpts *opts = vf->opts;
if(outfmt == IMGFMT_MPEGPES) {
vf->priv->passthrough = 1;
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
@@ -225,7 +227,7 @@ static int config(struct vf_instance_s* vf,
if(vf->priv->exp_y<0 || vf->priv->exp_y+height>vf->priv->exp_h) vf->priv->exp_y=(vf->priv->exp_h-height)/2;
vf->priv->fb_ptr=NULL;
- if(!opt_screen_size_x && !opt_screen_size_y){
+ if(!opts->screen_size_x && !opts->screen_size_y){
d_width=d_width*vf->priv->exp_w/width;
d_height=d_height*vf->priv->exp_h/height;
}
@@ -238,12 +240,12 @@ static int config(struct vf_instance_s* vf,
// codec -copy-> expand --DR--> vo
// codec -copy-> expand -copy-> vo (worst case)
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
// if(mpi->type==MP_IMGTYPE_IPB) return; // not yet working
#ifdef OSD_SUPPORT
- if(vf->priv->osd && (mpi->flags&MP_IMGFLAG_PRESERVE)){
+ if(vf->priv->osd_enabled && (mpi->flags&MP_IMGFLAG_PRESERVE)){
// check if we have to render osd!
- vo_update_osd(vf->priv->exp_w, vf->priv->exp_h);
+ osd_update(vf->priv->osd, vf->priv->exp_w, vf->priv->exp_h);
if(vo_osd_check_range_update(vf->priv->exp_x,vf->priv->exp_y,
vf->priv->exp_x+mpi->w,vf->priv->exp_y+mpi->h)) return;
}
@@ -258,7 +260,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
#if 1
if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) &&
!(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){
- mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible);
+ mp_tmsg(MSGT_VFILTER, MSGL_INFO, "Full DR not possible, trying SLICES instead!\n");
return;
}
#endif
@@ -285,7 +287,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
}
}
-static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
+static void start_slice(struct vf_instance* vf, mp_image_t *mpi){
// printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK);
if(!vf->next->draw_slice){
mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
@@ -299,11 +301,11 @@ static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),
MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
if(!(vf->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK))
- mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupportSlices); // shouldn't happen.
+ mp_tmsg(MSGT_VFILTER, MSGL_WARN, "WARNING! Next filter doesn't support SLICES, get ready for sig11...\n"); // shouldn't happen.
vf->priv->first_slice = 1;
}
-static void draw_top_blackbar_slice(struct vf_instance_s* vf,
+static void draw_top_blackbar_slice(struct vf_instance* vf,
unsigned char** src, int* stride, int w,int h, int x, int y){
if(vf->priv->exp_y>0 && y == 0) {
vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride,
@@ -312,7 +314,7 @@ static void draw_top_blackbar_slice(struct vf_instance_s* vf,
}
-static void draw_bottom_blackbar_slice(struct vf_instance_s* vf,
+static void draw_bottom_blackbar_slice(struct vf_instance* vf,
unsigned char** src, int* stride, int w,int h, int x, int y){
if(vf->priv->exp_y+vf->h<vf->dmpi->h && y+h == vf->h) {
unsigned char *src2[MP_MAX_PLANES];
@@ -332,7 +334,7 @@ static void draw_bottom_blackbar_slice(struct vf_instance_s* vf,
}
}
-static void draw_slice(struct vf_instance_s* vf,
+static void draw_slice(struct vf_instance* vf,
unsigned char** src, int* stride, int w,int h, int x, int y){
// printf("draw_slice() called %d at %d\n",h,y);
@@ -355,7 +357,7 @@ static void draw_slice(struct vf_instance_s* vf,
vf->priv->first_slice = 0;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
if (vf->priv->passthrough) {
mp_image_t *dmpi = vf_get_image(vf->next, IMGFMT_MPEGPES,
MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h);
@@ -365,10 +367,10 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
vf->dmpi=mpi->priv;
- if(!vf->dmpi) { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); return 0; }
+ if(!vf->dmpi) { mp_tmsg(MSGT_VFILTER, MSGL_WARN, "Why do we get NULL??\n"); return 0; }
mpi->priv=NULL;
#ifdef OSD_SUPPORT
- if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);
+ if(vf->priv->osd_enabled) draw_osd(vf,mpi->w,mpi->h);
#endif
// we've used DR, so we're ready...
if(!(mpi->flags&MP_IMGFLAG_PLANAR))
@@ -403,24 +405,32 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette
}
#ifdef OSD_SUPPORT
- if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);
+ if(vf->priv->osd_enabled) draw_osd(vf,mpi->w,mpi->h);
#endif
return vf_next_put_image(vf,vf->dmpi, pts);
}
//===========================================================================//
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
#ifdef OSD_SUPPORT
switch(request){
+ case VFCTRL_SET_OSD_OBJ:
+ vf->priv->osd = data;
+ break;
case VFCTRL_DRAW_OSD:
- if(vf->priv->osd) return CONTROL_TRUE;
+ if(vf->priv->osd_enabled) return CONTROL_TRUE;
+ break;
+ case VFCTRL_REDRAW_OSD:
+ if (vf->priv->osd_enabled)
+ return false;
+ break;
}
#endif
return vf_next_control(vf,request,data);
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
return vf_next_query_format(vf,fmt);
}
@@ -437,25 +447,25 @@ static int open(vf_instance_t *vf, char* args){
vf->priv->exp_h,
vf->priv->exp_x,
vf->priv->exp_y,
- vf->priv->osd,
+ vf->priv->osd_enabled,
vf->priv->aspect,
vf->priv->round);
return 1;
}
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
-static m_option_t vf_opts_fields[] = {
+static const m_option_t vf_opts_fields[] = {
{"w", ST_OFF(exp_w), CONF_TYPE_INT, 0, 0 ,0, NULL},
{"h", ST_OFF(exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL},
{"x", ST_OFF(exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
{"y", ST_OFF(exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
- {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL},
+ {"osd", ST_OFF(osd_enabled), CONF_TYPE_FLAG, 0 , 0, 1, NULL},
{"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL},
{"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
-static m_struct_t vf_opts = {
+static const m_struct_t vf_opts = {
"expand",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
diff --git a/libmpcodecs/vf_field.c b/libmpcodecs/vf_field.c
index ca4547ad52..48e4cb0f21 100644
--- a/libmpcodecs/vf_field.c
+++ b/libmpcodecs/vf_field.c
@@ -14,13 +14,13 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
return vf_next_config(vf,width,height/2,d_width,d_height,flags,outfmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
mpi->width, mpi->height/2);
@@ -43,7 +43,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
diff --git a/libmpcodecs/vf_fil.c b/libmpcodecs/vf_fil.c
index 110c5d7b47..089ec29409 100644
--- a/libmpcodecs/vf_fil.c
+++ b/libmpcodecs/vf_fil.c
@@ -17,7 +17,7 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int pixel_stride= (width+15)&~15; //FIXME this is ust a guess ... especially for non planar its somewhat bad one
@@ -45,7 +45,7 @@ static int config(struct vf_instance_s* vf,
(d_width*vf->priv->stridefactor)>>1, 2*d_height/vf->priv->stridefactor, flags, outfmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
if(mpi->flags&MP_IMGFLAG_DIRECT){
// we've used DR, so we're ready...
return vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts);
@@ -71,7 +71,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
diff --git a/libmpcodecs/vf_filmdint.c b/libmpcodecs/vf_filmdint.c
index 29c4f8bf6b..bdb8d57bdb 100644
--- a/libmpcodecs/vf_filmdint.c
+++ b/libmpcodecs/vf_filmdint.c
@@ -6,6 +6,7 @@
#include "config.h"
#include "mp_msg.h"
#include "cpudetect.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
@@ -79,9 +80,6 @@ struct vf_priv_s {
static const struct frame_stats ppzs = {PPZ,PPZ,PPZ,PPZ,PPZ,PPZ,PPZ,0,0,9999};
static const struct frame_stats pprs = {PPR,PPR,PPR,PPR,PPR,PPR,PPR,0,0,9999};
-extern int opt_screen_size_x;
-extern int opt_screen_size_y;
-
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
@@ -916,7 +914,7 @@ static inline double get_time(void)
return tv.tv_sec + tv.tv_usec * 1e-6;
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
+static void get_image(struct vf_instance* vf, mp_image_t *mpi)
{
struct vf_priv_s *p = vf->priv;
static unsigned char **planes, planes_idx;
@@ -1120,7 +1118,7 @@ find_breaks(struct vf_priv_s *p, struct frame_stats *s)
#define ITOC(X) (!(X) ? ' ' : (X) + ((X)>9 ? 'a'-10 : '0'))
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
struct vf_priv_s *p = vf->priv;
@@ -1318,7 +1316,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return show_fields ? vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE) : 0;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - support more formats */
switch (fmt) {
@@ -1333,10 +1331,11 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
+ struct MPOpts *opts = vf->opts;
unsigned long cxm = 0;
unsigned long cym = 0;
struct vf_priv_s *p = vf->priv;
@@ -1371,14 +1370,14 @@ static int config(struct vf_instance_s* vf,
if (p->crop_x + p->w > width ) p->crop_x = 0;
if (p->crop_y + p->h > height) p->crop_y = 0;
- if(!opt_screen_size_x && !opt_screen_size_y){
+ if(!opts->screen_size_x && !opts->screen_size_y){
d_width = d_width * p->w/width;
d_height = d_height * p->h/height;
}
return vf_next_config(vf, p->w, p->h, d_width, d_height, flags, outfmt);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
struct vf_priv_s *p = vf->priv;
mp_msg(MSGT_VFILTER, MSGL_INFO, "diff_time: %.3f, merge_time: %.3f, "
diff --git a/libmpcodecs/vf_flip.c b/libmpcodecs/vf_flip.c
index f3d8341391..40e895a022 100644
--- a/libmpcodecs/vf_flip.c
+++ b/libmpcodecs/vf_flip.c
@@ -12,14 +12,14 @@
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
flags&=~VOFLAG_FLIPPING; // remove the FLIP flag
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE){
// try full DR !
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
@@ -41,7 +41,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
if(mpi->flags&MP_IMGFLAG_DIRECT){
// we've used DR, so we're ready...
if(!(mpi->flags&MP_IMGFLAG_PLANAR))
diff --git a/libmpcodecs/vf_format.c b/libmpcodecs/vf_format.c
index d97db98a9b..deb0e8fb02 100644
--- a/libmpcodecs/vf_format.c
+++ b/libmpcodecs/vf_format.c
@@ -22,7 +22,7 @@ static struct vf_priv_s {
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
if(fmt==vf->priv->fmt)
return vf_next_query_format(vf,fmt);
return 0;
@@ -66,7 +66,7 @@ static int open(vf_instance_t *vf, char* args){
if(!strcasecmp(args,"argb")) vf->priv->fmt=IMGFMT_ARGB; else
if(!strcasecmp(args,"bgra")) vf->priv->fmt=IMGFMT_BGRA; else
if(!strcasecmp(args,"abgr")) vf->priv->fmt=IMGFMT_ABGR; else
- { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_UnknownFormatName, args);return 0;}
+ { mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[VF_FORMAT] Unknown format name: '%s'.\n", args);return 0;}
}
@@ -74,12 +74,12 @@ static int open(vf_instance_t *vf, char* args){
}
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
-static m_option_t vf_opts_fields[] = {
+static const m_option_t vf_opts_fields[] = {
{"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
-static m_struct_t vf_opts = {
+static const m_struct_t vf_opts = {
"format",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
diff --git a/libmpcodecs/vf_framestep.c b/libmpcodecs/vf_framestep.c
index 9f6d331d87..28daa3f804 100644
--- a/libmpcodecs/vf_framestep.c
+++ b/libmpcodecs/vf_framestep.c
@@ -73,7 +73,7 @@ struct vf_priv_s {
};
/* Filter handler */
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
struct vf_priv_s *priv;
@@ -130,7 +130,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
/* Free private data */
free(vf->priv);
@@ -170,7 +170,7 @@ static int open(vf_instance_t *vf, char* args)
if (*args != '\0') {
p->frame_step = atoi(args);
if (p->frame_step <= 0) {
- mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_ErrorParsingArgument);
+ mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[VF_FRAMESTEP] Error parsing argument.\n");
return 0;
}
}
@@ -187,5 +187,3 @@ const vf_info_t vf_info_framestep = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_fspp.c b/libmpcodecs/vf_fspp.c
index 44bafb61bf..7264199c21 100644
--- a/libmpcodecs/vf_fspp.c
+++ b/libmpcodecs/vf_fspp.c
@@ -485,7 +485,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src,
}
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -499,7 +499,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
+static void get_image(struct vf_instance* vf, mp_image_t *mpi)
{
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
// ok, we can do pp in-place (or pp disabled):
@@ -517,7 +517,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
@@ -565,7 +565,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
if(!vf->priv) return;
@@ -584,7 +584,7 @@ static void uninit(struct vf_instance_s* vf)
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch(fmt){
case IMGFMT_YVU9:
@@ -603,7 +603,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static int control(struct vf_instance_s* vf, int request, void* data)
+static int control(struct vf_instance* vf, int request, void* data)
{
switch(request){
case VFCTRL_QUERY_MAX_PP_LEVEL:
diff --git a/libmpcodecs/vf_geq.c b/libmpcodecs/vf_geq.c
index 21da7e2000..d2cbe6554b 100644
--- a/libmpcodecs/vf_geq.c
+++ b/libmpcodecs/vf_geq.c
@@ -42,13 +42,13 @@ struct vf_priv_s {
mp_image_t *mpi;
};
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static inline double getpix(struct vf_instance_s* vf, double x, double y, int plane){
+static inline double getpix(struct vf_instance* vf, double x, double y, int plane){
int xi, yi;
mp_image_t *mpi= vf->priv->mpi;
int stride= mpi->stride[plane];
@@ -66,19 +66,19 @@ static inline double getpix(struct vf_instance_s* vf, double x, double y, int pl
//FIXME cubic interpolate
//FIXME keep the last few frames
-static double lum(struct vf_instance_s* vf, double x, double y){
+static double lum(struct vf_instance* vf, double x, double y){
return getpix(vf, x, y, 0);
}
-static double cb(struct vf_instance_s* vf, double x, double y){
+static double cb(struct vf_instance* vf, double x, double y){
return getpix(vf, x, y, 1);
}
-static double cr(struct vf_instance_s* vf, double x, double y){
+static double cr(struct vf_instance* vf, double x, double y){
return getpix(vf, x, y, 2);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
int x,y, plane;
@@ -126,7 +126,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
av_free(vf->priv);
@@ -151,7 +151,7 @@ static int open(vf_instance_t *vf, char* args){
if (!eq[2][0]) strncpy(eq[2], eq[1], sizeof(eq[0])-1);
for(plane=0; plane<3; plane++){
- static const char *const_names[]={
+ const char * const const_names[]={
"PI",
"E",
"X",
@@ -163,7 +163,7 @@ static int open(vf_instance_t *vf, char* args){
"SH",
NULL
};
- static const char *func2_names[]={
+ const char * const func2_names[]={
"lum",
"cb",
"cr",
diff --git a/libmpcodecs/vf_halfpack.c b/libmpcodecs/vf_halfpack.c
index 246518e8e0..682b80a91e 100644
--- a/libmpcodecs/vf_halfpack.c
+++ b/libmpcodecs/vf_halfpack.c
@@ -142,7 +142,7 @@ static void (*halfpack)(unsigned char *dst, unsigned char *src[3],
int dststride, int srcstride[3], int w, int h);
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -166,7 +166,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf,dmpi, pts);
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -175,7 +175,7 @@ static int config(struct vf_instance_s* vf,
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - really any YUV 4:2:0 input format should work */
switch (fmt) {
@@ -187,7 +187,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -218,4 +218,3 @@ const vf_info_t vf_info_halfpack = {
open,
NULL
};
-
diff --git a/libmpcodecs/vf_harddup.c b/libmpcodecs/vf_harddup.c
index 627aa523c8..94fbcc2563 100644
--- a/libmpcodecs/vf_harddup.c
+++ b/libmpcodecs/vf_harddup.c
@@ -13,7 +13,7 @@ struct vf_priv_s {
mp_image_t *last_mpi;
};
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -34,7 +34,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf, dmpi, pts);
}
-static int control(struct vf_instance_s* vf, int request, void* data)
+static int control(struct vf_instance* vf, int request, void* data)
{
switch (request) {
case VFCTRL_DUPLICATE_FRAME:
@@ -50,7 +50,7 @@ static int control(struct vf_instance_s* vf, int request, void* data)
return vf_next_control(vf, request, data);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -72,5 +72,3 @@ const vf_info_t vf_info_harddup = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_hqdn3d.c b/libmpcodecs/vf_hqdn3d.c
index a04cb6d558..8906060719 100644
--- a/libmpcodecs/vf_hqdn3d.c
+++ b/libmpcodecs/vf_hqdn3d.c
@@ -44,14 +44,14 @@ struct vf_priv_s {
/***************************************************************************/
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(vf->priv->Line){free(vf->priv->Line);vf->priv->Line=NULL;}
if(vf->priv->Frame[0]){free(vf->priv->Frame[0]);vf->priv->Frame[0]=NULL;}
if(vf->priv->Frame[1]){free(vf->priv->Frame[1]);vf->priv->Frame[1]=NULL;}
if(vf->priv->Frame[2]){free(vf->priv->Frame[2]);vf->priv->Frame[2]=NULL;}
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -202,7 +202,7 @@ static void deNoise(unsigned char *Frame, // mpi->planes[x]
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int cw= mpi->w >> mpi->chroma_x_shift;
int ch= mpi->h >> mpi->chroma_y_shift;
int W = mpi->w, H = mpi->h;
@@ -237,7 +237,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_hue.c b/libmpcodecs/vf_hue.c
index 89ed3ee243..a289543c48 100644
--- a/libmpcodecs/vf_hue.c
+++ b/libmpcodecs/vf_hue.c
@@ -58,7 +58,7 @@ static void (*process)(uint8_t *udst, uint8_t *vdst, uint8_t *usrc, uint8_t *vsr
/* FIXME: add packed yuv version of process */
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -92,7 +92,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf,dmpi, pts);
}
-static int control(struct vf_instance_s* vf, int request, void* data)
+static int control(struct vf_instance* vf, int request, void* data)
{
vf_equalizer_t *eq;
@@ -121,7 +121,7 @@ static int control(struct vf_instance_s* vf, int request, void* data)
return vf_next_control(vf, request, data);
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch (fmt) {
case IMGFMT_YVU9:
@@ -138,7 +138,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
if (vf->priv->buf[0]) free(vf->priv->buf[0]);
if (vf->priv->buf[1]) free(vf->priv->buf[1]);
@@ -164,13 +164,13 @@ static int open(vf_instance_t *vf, char* args)
}
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
-static m_option_t vf_opts_fields[] = {
+static const m_option_t vf_opts_fields[] = {
{"hue", ST_OFF(hue), CONF_TYPE_FLOAT, M_OPT_RANGE,-180.0 ,180.0, NULL},
{"saturation", ST_OFF(saturation), CONF_TYPE_FLOAT, M_OPT_RANGE,-10.0 ,10.0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
-static m_struct_t vf_opts = {
+static const m_struct_t vf_opts = {
"hue",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
@@ -185,4 +185,3 @@ const vf_info_t vf_info_hue = {
open,
&vf_opts
};
-
diff --git a/libmpcodecs/vf_il.c b/libmpcodecs/vf_il.c
index cc70192fe1..724dedb2d0 100644
--- a/libmpcodecs/vf_il.c
+++ b/libmpcodecs/vf_il.c
@@ -73,7 +73,7 @@ static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dstStride,
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int w;
FilterParam *luma = &vf->priv->lumaParam;
FilterParam *chroma= &vf->priv->chromaParam;
diff --git a/libmpcodecs/vf_ilpack.c b/libmpcodecs/vf_ilpack.c
index b0a3f55300..dc586762b4 100644
--- a/libmpcodecs/vf_ilpack.c
+++ b/libmpcodecs/vf_ilpack.c
@@ -349,7 +349,7 @@ static void ilpack(unsigned char *dst, unsigned char *src[3],
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -363,7 +363,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf,dmpi, pts);
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -372,7 +372,7 @@ static int config(struct vf_instance_s* vf,
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - really any YUV 4:2:0 input format should work */
switch (fmt) {
@@ -429,4 +429,3 @@ const vf_info_t vf_info_ilpack = {
open,
NULL
};
-
diff --git a/libmpcodecs/vf_ivtc.c b/libmpcodecs/vf_ivtc.c
index c29a797f69..a5e2356eaa 100644
--- a/libmpcodecs/vf_ivtc.c
+++ b/libmpcodecs/vf_ivtc.c
@@ -408,7 +408,7 @@ static void copy_image(mp_image_t *dmpi, mp_image_t *mpi, int field)
}
}
-static int do_put_image(struct vf_instance_s* vf, mp_image_t *dmpi)
+static int do_put_image(struct vf_instance* vf, mp_image_t *dmpi)
{
struct vf_priv_s *p = vf->priv;
int dropflag=0;
@@ -437,7 +437,7 @@ static int do_put_image(struct vf_instance_s* vf, mp_image_t *dmpi)
return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
int ret=0;
struct vf_priv_s *p = vf->priv;
@@ -488,7 +488,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return ret;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch (fmt) {
case IMGFMT_YV12:
@@ -499,7 +499,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -530,5 +530,3 @@ const vf_info_t vf_info_ivtc = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_kerndeint.c b/libmpcodecs/vf_kerndeint.c
index a2bc0ed0c0..359dfb9469 100644
--- a/libmpcodecs/vf_kerndeint.c
+++ b/libmpcodecs/vf_kerndeint.c
@@ -47,7 +47,7 @@ struct vf_priv_s {
/***************************************************************************/
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -55,7 +55,7 @@ static int config(struct vf_instance_s* vf,
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -74,7 +74,7 @@ static inline int IsYUY2(mp_image_t *mpi)
#define PLANAR_U 1
#define PLANAR_V 2
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int cw= mpi->w >> mpi->chroma_x_shift;
int ch= mpi->h >> mpi->chroma_y_shift;
int W = mpi->w, H = mpi->h;
@@ -278,7 +278,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
@@ -289,7 +289,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return 0;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
switch (request)
{
case VFCTRL_GET_DEINTERLACE:
diff --git a/libmpcodecs/vf_lavc.c b/libmpcodecs/vf_lavc.c
index e11d52a840..4583e4372e 100644
--- a/libmpcodecs/vf_lavc.c
+++ b/libmpcodecs/vf_lavc.c
@@ -27,7 +27,7 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
if(vf_next_query_format(vf,IMGFMT_MPEGPES)<=0) return 0;
@@ -57,7 +57,7 @@ static int config(struct vf_instance_s* vf,
vf->priv->outbuf = malloc(vf->priv->outbuf_size);
if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) {
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec);
+ mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Could not open codec.\n");
return 0;
}
@@ -69,7 +69,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_MPEGPES);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t* dmpi;
int out_size;
AVFrame *pic= vf->priv->pic;
@@ -102,7 +102,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
@@ -130,7 +130,7 @@ static int open(vf_instance_t *vf, char* args){
vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name("mpeg1video");
if (!vf->priv->codec) {
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_MissingLAVCcodec, "mpeg1video");
+ mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Cannot find codec '%s' in libavcodec...\n", "mpeg1video");
return 0;
}
diff --git a/libmpcodecs/vf_lavcdeint.c b/libmpcodecs/vf_lavcdeint.c
index 061a7d392e..1e0a3f2d32 100644
--- a/libmpcodecs/vf_lavcdeint.c
+++ b/libmpcodecs/vf_lavcdeint.c
@@ -70,7 +70,7 @@ imgfmt_to_pixfmt (int imgfmt)
static int
-config (struct vf_instance_s* vf,
+config (struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -96,7 +96,7 @@ config (struct vf_instance_s* vf,
}
static int
-put_image (struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+put_image (struct vf_instance* vf, mp_image_t *mpi, double pts)
{
struct vf_priv_s *priv = vf->priv;
mp_image_t* dmpi;
@@ -133,7 +133,7 @@ put_image (struct vf_instance_s* vf, mp_image_t *mpi, double pts)
static int
-query_format (struct vf_instance_s* vf, unsigned int fmt)
+query_format (struct vf_instance* vf, unsigned int fmt)
{
if(imgfmt_to_pixfmt(fmt) == -1)
return 0;
diff --git a/libmpcodecs/vf_mcdeint.c b/libmpcodecs/vf_mcdeint.c
index 2bd3c9da73..0b6547359a 100644
--- a/libmpcodecs/vf_mcdeint.c
+++ b/libmpcodecs/vf_mcdeint.c
@@ -178,7 +178,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int ds
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int i;
@@ -235,7 +235,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
return; //caused problems, dunno why
// ok, we can do pp in-place (or pp disabled):
@@ -253,7 +253,7 @@ return; //caused problems, dunno why
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
@@ -272,7 +272,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
#if 0
@@ -294,7 +294,7 @@ static void uninit(struct vf_instance_s* vf){
}
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
diff --git a/libmpcodecs/vf_mirror.c b/libmpcodecs/vf_mirror.c
index a659ddf2bd..267d9fe407 100644
--- a/libmpcodecs/vf_mirror.c
+++ b/libmpcodecs/vf_mirror.c
@@ -65,7 +65,7 @@ static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcst
//===========================================================================//
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
// hope we'll get DR buffer:
diff --git a/libmpcodecs/vf_noformat.c b/libmpcodecs/vf_noformat.c
index 1938da10cc..4d6a9b106b 100644
--- a/libmpcodecs/vf_noformat.c
+++ b/libmpcodecs/vf_noformat.c
@@ -22,7 +22,7 @@ static struct vf_priv_s {
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
if(fmt!=vf->priv->fmt)
return vf_next_query_format(vf,fmt);
return 0;
@@ -66,7 +66,7 @@ static int open(vf_instance_t *vf, char* args){
if(!strcasecmp(args,"argb")) vf->priv->fmt=IMGFMT_ARGB; else
if(!strcasecmp(args,"bgra")) vf->priv->fmt=IMGFMT_BGRA; else
if(!strcasecmp(args,"abgr")) vf->priv->fmt=IMGFMT_ABGR; else
- { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_UnknownFormatName, args);return 0;}
+ { mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[VF_FORMAT] Unknown format name: '%s'.\n", args);return 0;}
}
@@ -74,12 +74,12 @@ static int open(vf_instance_t *vf, char* args){
}
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
-static m_option_t vf_opts_fields[] = {
+static const m_option_t vf_opts_fields[] = {
{"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
-static m_struct_t vf_opts = {
+static const m_struct_t vf_opts = {
"noformat",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
diff --git a/libmpcodecs/vf_noise.c b/libmpcodecs/vf_noise.c
index 625fe67cc3..6fdc5e20c5 100644
--- a/libmpcodecs/vf_noise.c
+++ b/libmpcodecs/vf_noise.c
@@ -312,14 +312,14 @@ static void noise(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int
if (fp->shiftptr == 3) fp->shiftptr = 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ
// ok, we can do pp in-place (or pp disabled):
@@ -337,7 +337,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
@@ -366,7 +366,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
if(vf->priv->chromaParam.noise) free(vf->priv->chromaParam.noise);
@@ -381,7 +381,7 @@ static void uninit(struct vf_instance_s* vf){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
@@ -416,7 +416,7 @@ static void parse(FilterParam *fp, char* args){
if(fp->strength) initNoise(fp);
}
-static unsigned int fmt_list[]={
+static const unsigned int fmt_list[]={
IMGFMT_YV12,
IMGFMT_I420,
IMGFMT_IYUV,
diff --git a/libmpcodecs/vf_ow.c b/libmpcodecs/vf_ow.c
index 543d6c8289..16d6ccbc56 100644
--- a/libmpcodecs/vf_ow.c
+++ b/libmpcodecs/vf_ow.c
@@ -203,7 +203,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, int dst_stri
// printf("%f\n", sum/height/width);
}
-static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){
+static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){
int h= (height+15)&(~15);
int i,j;
@@ -216,7 +216,7 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
// ok, we can do pp in-place (or pp disabled):
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
@@ -233,7 +233,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
@@ -254,7 +254,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
int i,j;
if(!vf->priv) return;
@@ -270,7 +270,7 @@ static void uninit(struct vf_instance_s* vf){
}
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YVU9:
case IMGFMT_IF09:
diff --git a/libmpcodecs/vf_palette.c b/libmpcodecs/vf_palette.c
index 7e7cb1c7c0..a867a4ce44 100644
--- a/libmpcodecs/vf_palette.c
+++ b/libmpcodecs/vf_palette.c
@@ -19,14 +19,14 @@
// routines are incorrrect. they assume the palette to be of the same
// depth as the output, which is incorrect. --Joey
-static unsigned int bgr_list[]={
+static const unsigned int bgr_list[]={
IMGFMT_BGR32,
IMGFMT_BGR24,
// IMGFMT_BGR16,
// IMGFMT_BGR15,
0
};
-static unsigned int rgb_list[]={
+static const unsigned int rgb_list[]={
IMGFMT_RGB32,
IMGFMT_RGB24,
// IMGFMT_RGB16,
@@ -36,10 +36,10 @@ static unsigned int rgb_list[]={
static unsigned int gray_pal[256];
-static unsigned int find_best(struct vf_instance_s* vf, unsigned int fmt){
+static unsigned int find_best(struct vf_instance* vf, unsigned int fmt){
unsigned int best=0;
int ret;
- unsigned int* p;
+ const unsigned int* p;
if(fmt==IMGFMT_BGR8) p=bgr_list;
else if(fmt==IMGFMT_RGB8) p=rgb_list;
else return 0;
@@ -60,7 +60,7 @@ struct vf_priv_s {
int pal_msg;
};
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
if (!vf->priv->fmt)
@@ -74,7 +74,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -158,7 +158,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
int best=find_best(vf,fmt);
if(!best) return 0; // no match
return vf->next->query_format(vf->next,best);
@@ -188,7 +188,7 @@ static int open(vf_instance_t *vf, char* args){
if (!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else
if (!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else
{
- mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_UnknownFormatName, args);
+ mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[VF_FORMAT] Unknown format name: '%s'.\n", args);
return 0;
}
}
diff --git a/libmpcodecs/vf_perspective.c b/libmpcodecs/vf_perspective.c
index 8cc3dc8e17..daba3cd2a9 100644
--- a/libmpcodecs/vf_perspective.c
+++ b/libmpcodecs/vf_perspective.c
@@ -102,7 +102,7 @@ static double getCoeff(double d){
return coeff;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int i, j;
@@ -129,7 +129,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
if(vf->priv->pv) free(vf->priv->pv);
@@ -258,7 +258,7 @@ static inline void resampleLinear(uint8_t *dst, uint8_t *src, int w, int h, int
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int cw= mpi->w >> mpi->chroma_x_shift;
int ch= mpi->h >> mpi->chroma_y_shift;
@@ -289,7 +289,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_phase.c b/libmpcodecs/vf_phase.c
index 267c2f373c..bdb5c19383 100644
--- a/libmpcodecs/vf_phase.c
+++ b/libmpcodecs/vf_phase.c
@@ -178,7 +178,7 @@ static enum mode analyze_plane(unsigned char *old, unsigned char *new,
return mode;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
int w;
@@ -222,7 +222,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv->buf[0]);
free(vf->priv->buf[1]);
diff --git a/libmpcodecs/vf_pp.c b/libmpcodecs/vf_pp.c
index 2aae8ac45d..933688d1e6 100644
--- a/libmpcodecs/vf_pp.c
+++ b/libmpcodecs/vf_pp.c
@@ -34,7 +34,7 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int voflags, unsigned int outfmt){
int flags=
@@ -55,7 +55,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,voflags,outfmt);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
int i;
for(i=0; i<=PP_QUALITY_MAX; i++){
if(vf->priv->ppMode[i])
@@ -64,7 +64,7 @@ static void uninit(struct vf_instance_s* vf){
if(vf->priv->context) pp_free_context(vf->priv->context);
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
@@ -77,7 +77,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return 0;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
switch(request){
case VFCTRL_QUERY_MAX_PP_LEVEL:
return PP_QUALITY_MAX;
@@ -88,7 +88,7 @@ static int control(struct vf_instance_s* vf, int request, void* data){
return vf_next_control(vf,request,data);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(vf->priv->pp&0xFFFF) return; // non-local filters enabled
if((mpi->type==MP_IMGTYPE_IPB || vf->priv->pp) &&
mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
@@ -109,7 +109,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
// no DR, so get a new image! hope we'll get DR buffer:
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
@@ -141,7 +141,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
extern int divx_quality;
-static unsigned int fmt_list[]={
+static const unsigned int fmt_list[]={
IMGFMT_YV12,
IMGFMT_I420,
IMGFMT_IYUV,
@@ -224,4 +224,3 @@ const vf_info_t vf_info_pp = {
};
//===========================================================================//
-
diff --git a/libmpcodecs/vf_pp7.c b/libmpcodecs/vf_pp7.c
index 42c8512250..472838ecd6 100644
--- a/libmpcodecs/vf_pp7.c
+++ b/libmpcodecs/vf_pp7.c
@@ -344,7 +344,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, int dst_stri
}
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int h= (height+16+15)&(~15);
@@ -355,7 +355,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
// ok, we can do pp in-place (or pp disabled):
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
@@ -372,7 +372,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if(mpi->flags&MP_IMGFLAG_DIRECT){
@@ -407,7 +407,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
if(vf->priv->src) free(vf->priv->src);
@@ -418,7 +418,7 @@ static void uninit(struct vf_instance_s* vf){
}
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YVU9:
case IMGFMT_IF09:
@@ -436,7 +436,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return 0;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
return vf_next_control(vf,request,data);
}
diff --git a/libmpcodecs/vf_pullup.c b/libmpcodecs/vf_pullup.c
index 51295b90db..efd5a56d80 100644
--- a/libmpcodecs/vf_pullup.c
+++ b/libmpcodecs/vf_pullup.c
@@ -24,7 +24,7 @@ struct vf_priv_s {
char *qbuf;
};
-static void init_pullup(struct vf_instance_s* vf, mp_image_t *mpi)
+static void init_pullup(struct vf_instance* vf, mp_image_t *mpi)
{
struct pullup_context *c = vf->priv->ctx;
@@ -60,7 +60,7 @@ static void init_pullup(struct vf_instance_s* vf, mp_image_t *mpi)
#if 0
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
+static void get_image(struct vf_instance* vf, mp_image_t *mpi)
{
struct pullup_context *c = vf->priv->ctx;
struct pullup_buffer *b;
@@ -86,7 +86,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
}
#endif
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
struct pullup_context *c = vf->priv->ctx;
struct pullup_buffer *b;
@@ -236,7 +236,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return ret;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - support more formats */
switch (fmt) {
@@ -248,7 +248,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -256,7 +256,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
pullup_free_context(vf->priv->ctx);
free(vf->priv);
@@ -294,5 +294,3 @@ const vf_info_t vf_info_pullup = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_qp.c b/libmpcodecs/vf_qp.c
index 68449f62d0..ec0646265f 100644
--- a/libmpcodecs/vf_qp.c
+++ b/libmpcodecs/vf_qp.c
@@ -42,7 +42,7 @@ struct vf_priv_s {
int qp_stride;
};
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int h= (height+15)>>4;
@@ -59,7 +59,7 @@ static int config(struct vf_instance_s* vf,
i,
0
};
- static const char *const_names[]={
+ const char * const const_names[]={
"PI",
"E",
"known",
@@ -76,7 +76,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
// ok, we can do pp in-place (or pp disabled):
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
@@ -93,7 +93,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
int x,y;
@@ -136,7 +136,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
if(vf->priv->qp) av_free(vf->priv->qp);
diff --git a/libmpcodecs/vf_rectangle.c b/libmpcodecs/vf_rectangle.c
index 3431d5b90f..4251540476 100644
--- a/libmpcodecs/vf_rectangle.c
+++ b/libmpcodecs/vf_rectangle.c
@@ -13,7 +13,7 @@ struct vf_priv_s {
};
static int
-config(struct vf_instance_s* vf,
+config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -34,7 +34,7 @@ config(struct vf_instance_s* vf,
}
static int
-control(struct vf_instance_s* vf, int request, void *data)
+control(struct vf_instance* vf, int request, void *data)
{
const int *const tmp = data;
switch(request){
@@ -65,7 +65,7 @@ control(struct vf_instance_s* vf, int request, void *data)
return 0;
}
static int
-put_image(struct vf_instance_s* vf, mp_image_t* mpi, double pts){
+put_image(struct vf_instance* vf, mp_image_t* mpi, double pts){
mp_image_t* dmpi;
unsigned int bpp = mpi->bpp / 8;
int x, y, w, h;
diff --git a/libmpcodecs/vf_remove_logo.c b/libmpcodecs/vf_remove_logo.c
index 7b9c66aeb1..8397ae53cf 100644
--- a/libmpcodecs/vf_remove_logo.c
+++ b/libmpcodecs/vf_remove_logo.c
@@ -670,7 +670,7 @@ static pgm_structure * generate_half_size_image(vf_instance_t * vf, pgm_structur
/**
* \brief Checks if YV12 is supported by the next filter.
*/
-static unsigned int find_best(struct vf_instance_s* vf){
+static unsigned int find_best(struct vf_instance* vf){
int is_format_okay = vf->next->query_format(vf->next, IMGFMT_YV12);
if ((is_format_okay & VFCAP_CSP_SUPPORTED_BY_HW) || (is_format_okay & VFCAP_CSP_SUPPORTED))
return IMGFMT_YV12;
@@ -683,7 +683,7 @@ static unsigned int find_best(struct vf_instance_s* vf){
/**
* \brief Configure the filter and call the next filter's config function.
*/
-static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
+static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt)
{
if(!(((vf_priv_s *)vf->priv)->fmt=find_best(vf)))
return 0;
@@ -764,7 +764,7 @@ static void convert_yv12(const vf_instance_t * const vf, const char * const sour
* filter, has the logo removed by the filter, and is then sent to the next
* filter.
*/
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
dmpi=vf_get_image(vf->next,((vf_priv_s *)vf->priv)->fmt,
@@ -811,7 +811,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
/**
* \brief Checks to see if the next filter accepts YV12 images.
*/
-static int query_format(struct vf_instance_s * vf, unsigned int fmt)
+static int query_format(struct vf_instance * vf, unsigned int fmt)
{
if (fmt == IMGFMT_YV12)
return vf->next->query_format(vf->next, IMGFMT_YV12);
@@ -877,7 +877,7 @@ static int open(vf_instance_t * vf, char * args)
*
* This is called at exit-time.
*/
-void uninit(vf_instance_t * vf)
+static void uninit(vf_instance_t * vf)
{
/* Destroy our masks and images. */
destroy_pgm(((vf_priv_s *)vf->priv)->filter);
diff --git a/libmpcodecs/vf_rgb2bgr.c b/libmpcodecs/vf_rgb2bgr.c
index 58fd217be6..f3cbfaed86 100644
--- a/libmpcodecs/vf_rgb2bgr.c
+++ b/libmpcodecs/vf_rgb2bgr.c
@@ -36,14 +36,14 @@ static unsigned int getfmt(unsigned int outfmt,int forced){
return 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
vf->priv->fmt=getfmt(outfmt,vf->priv->forced);
return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -76,7 +76,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int outfmt){
+static int query_format(struct vf_instance* vf, unsigned int outfmt){
unsigned int fmt=getfmt(outfmt,vf->priv->forced);
if(!fmt) return 0;
return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW);
diff --git a/libmpcodecs/vf_rgbtest.c b/libmpcodecs/vf_rgbtest.c
index afe4584350..4910e703cc 100644
--- a/libmpcodecs/vf_rgbtest.c
+++ b/libmpcodecs/vf_rgbtest.c
@@ -77,7 +77,7 @@ static void put_pixel(uint8_t *buf, int x, int y, int stride, int r, int g, int
}
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
if (vf->priv->w > 0) { d_width = width = vf->priv->w; }
@@ -87,7 +87,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
int x, y;
int w = vf->priv->w > 0 ? vf->priv->w : mpi->w;
@@ -116,7 +116,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int outfmt){
+static int query_format(struct vf_instance* vf, unsigned int outfmt){
unsigned int fmt=getfmt(outfmt);
if(!fmt) return 0;
return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW);
diff --git a/libmpcodecs/vf_rotate.c b/libmpcodecs/vf_rotate.c
index c6a8b356d9..33b8392d20 100644
--- a/libmpcodecs/vf_rotate.c
+++ b/libmpcodecs/vf_rotate.c
@@ -50,7 +50,7 @@ static void rotate(unsigned char* dst,unsigned char* src,int dststride,int srcst
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
if (vf->priv->direction & 4) {
@@ -66,7 +66,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,height,width,d_height,d_width,flags,outfmt);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -96,7 +96,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
if(IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt)) return vf_next_query_format(vf, fmt);
// we can support only symmetric (chroma_x_shift==chroma_y_shift) YUV formats:
switch(fmt) {
diff --git a/libmpcodecs/vf_sab.c b/libmpcodecs/vf_sab.c
index 1616f1eba1..839392d9e0 100644
--- a/libmpcodecs/vf_sab.c
+++ b/libmpcodecs/vf_sab.c
@@ -135,7 +135,7 @@ static int allocStuff(FilterParam *f, int width, int height){
return 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -160,7 +160,7 @@ static void freeBuffers(FilterParam *f){
f->distCoeff=NULL;
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
freeBuffers(&vf->priv->luma);
@@ -238,7 +238,7 @@ if((x/32)&1){
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int cw= mpi->w >> mpi->chroma_x_shift;
int ch= mpi->h >> mpi->chroma_y_shift;
@@ -257,7 +257,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c
index 6c741cfad9..f1388fb1b0 100644
--- a/libmpcodecs/vf_scale.c
+++ b/libmpcodecs/vf_scale.c
@@ -6,6 +6,7 @@
#include "config.h"
#include "mp_msg.h"
#include "cpudetect.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
@@ -41,15 +42,11 @@ static struct vf_priv_s {
NULL
};
-extern int opt_screen_size_x;
-extern int opt_screen_size_y;
-extern float screen_size_xy;
-
//===========================================================================//
void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam);
-static unsigned int outfmt_list[]={
+static const unsigned int outfmt_list[]={
// YUV:
IMGFMT_444P,
IMGFMT_422P,
@@ -109,9 +106,10 @@ static unsigned int find_best_out(vf_instance_t *vf){
return best;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
+ struct MPOpts *opts = vf->opts;
unsigned int best=find_best_out(vf);
int vo_flags;
int int_sws_flags=0;
@@ -293,7 +291,8 @@ static int config(struct vf_instance_s* vf,
break; }
}
- if(!opt_screen_size_x && !opt_screen_size_y && !(screen_size_xy >= 0.001)){
+ if (!opts->screen_size_x && !opts->screen_size_y
+ && !(opts->screen_size_xy >= 0.001)) {
// Compute new d_width and d_height, preserving aspect
// while ensuring that both are >= output size in pixels.
if (vf->priv->h * d_width > vf->priv->w * d_height) {
@@ -309,7 +308,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best);
}
-static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
+static void start_slice(struct vf_instance* vf, mp_image_t *mpi){
// printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK);
if(!(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) return; // shouldn't happen
// they want slices!!! allocate the buffer.
@@ -349,7 +348,7 @@ static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src
}
}
-static void draw_slice(struct vf_instance_s* vf,
+static void draw_slice(struct vf_instance* vf,
unsigned char** src, int* stride, int w,int h, int x, int y){
mp_image_t *dmpi=vf->dmpi;
if(!dmpi){
@@ -360,7 +359,7 @@ static void draw_slice(struct vf_instance_s* vf,
scale(vf->priv->ctx, vf->priv->ctx2, src, stride, y, h, dmpi->planes, dmpi->stride, vf->priv->interlaced);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi=mpi->priv;
// printf("vf_scale::put_image(): processing whole frame! dmpi=%p flag=%d\n",
@@ -387,7 +386,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
int *table;
int *inv_table;
int r;
@@ -450,7 +449,7 @@ static int control(struct vf_instance_s* vf, int request, void* data){
// supported Input formats: YV12, I420, IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8, Y800
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
@@ -489,7 +488,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return 0; // nomatching in-fmt
}
-static void uninit(struct vf_instance_s *vf){
+static void uninit(struct vf_instance *vf){
if(vf->priv->ctx) sws_freeContext(vf->priv->ctx);
if(vf->priv->ctx2) sws_freeContext(vf->priv->ctx2);
if(vf->priv->palette) free(vf->priv->palette);
@@ -610,7 +609,7 @@ struct SwsContext *sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat,
}
/// An example of presets usage
-static struct size_preset {
+static const struct size_preset {
char* name;
int w, h;
} vf_size_presets_defs[] = {
@@ -625,21 +624,21 @@ static struct size_preset {
};
#define ST_OFF(f) M_ST_OFF(struct size_preset,f)
-static m_option_t vf_size_preset_fields[] = {
+static const m_option_t vf_size_preset_fields[] = {
{"w", ST_OFF(w), CONF_TYPE_INT, M_OPT_MIN,1 ,0, NULL},
{"h", ST_OFF(h), CONF_TYPE_INT, M_OPT_MIN,1 ,0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
-static m_struct_t vf_size_preset = {
+static const m_struct_t vf_size_preset = {
"scale_size_preset",
sizeof(struct size_preset),
NULL,
vf_size_preset_fields
};
-static m_struct_t vf_opts;
-static m_obj_presets_t size_preset = {
+static const m_struct_t vf_opts;
+static const m_obj_presets_t size_preset = {
&vf_size_preset, // Input struct desc
&vf_opts, // Output struct desc
vf_size_presets_defs, // The list of presets
@@ -649,7 +648,7 @@ static m_obj_presets_t size_preset = {
/// Now the options
#undef ST_OFF
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
-static m_option_t vf_opts_fields[] = {
+static const m_option_t vf_opts_fields[] = {
{"w", ST_OFF(w), CONF_TYPE_INT, M_OPT_MIN,-11,0, NULL},
{"h", ST_OFF(h), CONF_TYPE_INT, M_OPT_MIN,-11,0, NULL},
{"interlaced", ST_OFF(interlaced), CONF_TYPE_INT, M_OPT_RANGE, 0, 1, NULL},
@@ -664,7 +663,7 @@ static m_option_t vf_opts_fields[] = {
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
-static m_struct_t vf_opts = {
+static const m_struct_t vf_opts = {
"scale",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c
index 93fef3e186..1fb37a623b 100644
--- a/libmpcodecs/vf_screenshot.c
+++ b/libmpcodecs/vf_screenshot.c
@@ -40,7 +40,7 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -119,7 +119,7 @@ static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi)
sws_scale_ordered(priv->ctx, mpi->planes, mpi->stride, 0, priv->dh, dst, dst_stride);
}
-static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi)
+static void start_slice(struct vf_instance* vf, mp_image_t *mpi)
{
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
mpi->type, mpi->flags, mpi->width, mpi->height);
@@ -131,7 +131,7 @@ static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi)
}
-static void draw_slice(struct vf_instance_s* vf, unsigned char** src,
+static void draw_slice(struct vf_instance* vf, unsigned char** src,
int* stride, int w,int h, int x, int y)
{
if (vf->priv->store_slices) {
@@ -144,7 +144,7 @@ static void draw_slice(struct vf_instance_s* vf, unsigned char** src,
vf_next_draw_slice(vf,src,stride,w,h,x,y);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
+static void get_image(struct vf_instance* vf, mp_image_t *mpi)
{
// FIXME: should vf.c really call get_image when using slices??
if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
@@ -167,7 +167,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi)
mpi->priv=(void*)vf->dmpi;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi = (mp_image_t *)mpi->priv;
@@ -204,7 +204,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf, dmpi, pts);
}
-int control (vf_instance_t *vf, int request, void *data)
+static int control (vf_instance_t *vf, int request, void *data)
{
/** data contains an integer argument
* 0: take screenshot with the next frame
@@ -228,7 +228,7 @@ int control (vf_instance_t *vf, int request, void *data)
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch(fmt){
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_smartblur.c b/libmpcodecs/vf_smartblur.c
index a5a1265111..92aeece529 100644
--- a/libmpcodecs/vf_smartblur.c
+++ b/libmpcodecs/vf_smartblur.c
@@ -94,7 +94,7 @@ static int allocStuff(FilterParam *f, int width, int height){
return 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -113,7 +113,7 @@ static void freeBuffers(FilterParam *f){
f->filterContext=NULL;
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
freeBuffers(&vf->priv->luma);
@@ -180,7 +180,7 @@ static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride,
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int cw= mpi->w >> mpi->chroma_x_shift;
int ch= mpi->h >> mpi->chroma_y_shift;
FilterParam *f= &vf->priv;
@@ -201,7 +201,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_softpulldown.c b/libmpcodecs/vf_softpulldown.c
index 30bb405eb5..c8f1c4cf79 100644
--- a/libmpcodecs/vf_softpulldown.c
+++ b/libmpcodecs/vf_softpulldown.c
@@ -17,7 +17,7 @@ struct vf_priv_s {
long long out;
};
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
int ret = 0;
@@ -111,14 +111,14 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return ret;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
mp_msg(MSGT_VFILTER, MSGL_INFO, "softpulldown: %lld frames in, %lld frames out\n", vf->priv->in, vf->priv->out);
free(vf->priv);
diff --git a/libmpcodecs/vf_softskip.c b/libmpcodecs/vf_softskip.c
index 5edb4babed..4e69b3eb8b 100644
--- a/libmpcodecs/vf_softskip.c
+++ b/libmpcodecs/vf_softskip.c
@@ -13,7 +13,7 @@ struct vf_priv_s {
int skipflag;
};
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -36,7 +36,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return vf_next_put_image(vf, dmpi, pts);
}
-static int control(struct vf_instance_s* vf, int request, void* data)
+static int control(struct vf_instance* vf, int request, void* data)
{
switch (request) {
case VFCTRL_SKIP_NEXT_FRAME:
@@ -47,7 +47,7 @@ static int control(struct vf_instance_s* vf, int request, void* data)
}
#if 0
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - figure out which other formats work */
switch (fmt) {
@@ -60,7 +60,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
}
#endif
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -82,5 +82,3 @@ const vf_info_t vf_info_softskip = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_spp.c b/libmpcodecs/vf_spp.c
index 5a6ed294e3..73c9e54ee6 100644
--- a/libmpcodecs/vf_spp.c
+++ b/libmpcodecs/vf_spp.c
@@ -435,7 +435,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, int dst_stri
//FIXME reorder for better caching
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int h= (height+16+15)&(~15);
@@ -447,7 +447,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
// ok, we can do pp in-place (or pp disabled):
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
@@ -464,7 +464,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
@@ -510,7 +510,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
if(vf->priv->temp) free(vf->priv->temp);
@@ -527,7 +527,7 @@ static void uninit(struct vf_instance_s* vf){
}
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YVU9:
case IMGFMT_IF09:
@@ -545,7 +545,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return 0;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
switch(request){
case VFCTRL_QUERY_MAX_PP_LEVEL:
return 6;
diff --git a/libmpcodecs/vf_swapuv.c b/libmpcodecs/vf_swapuv.c
index 1800e583fd..5276c752f4 100644
--- a/libmpcodecs/vf_swapuv.c
+++ b/libmpcodecs/vf_swapuv.c
@@ -32,7 +32,7 @@
//===========================================================================//
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
mp_image_t *dmpi= vf_get_image(vf->next, mpi->imgfmt,
mpi->type, mpi->flags, mpi->w, mpi->h);
@@ -48,7 +48,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->priv=(void*)dmpi;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if(mpi->flags&MP_IMGFLAG_DIRECT){
@@ -72,7 +72,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt)
{
case IMGFMT_YV12:
diff --git a/libmpcodecs/vf_telecine.c b/libmpcodecs/vf_telecine.c
index fc6fb57546..a30ab8121b 100644
--- a/libmpcodecs/vf_telecine.c
+++ b/libmpcodecs/vf_telecine.c
@@ -15,7 +15,7 @@ struct vf_priv_s {
int frame;
};
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
int ret;
@@ -88,7 +88,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
}
#if 0
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - figure out which other formats work */
switch (fmt) {
@@ -100,7 +100,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -108,7 +108,7 @@ static int config(struct vf_instance_s* vf,
}
#endif
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -135,5 +135,3 @@ const vf_info_t vf_info_telecine = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_test.c b/libmpcodecs/vf_test.c
index 1f51011e57..a59f5c37b2 100644
--- a/libmpcodecs/vf_test.c
+++ b/libmpcodecs/vf_test.c
@@ -47,12 +47,12 @@ struct vf_priv_s {
int frame_num;
};
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
if(vf_next_query_format(vf,IMGFMT_YV12)<=0){
- mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupport, "YV12");
+ mp_tmsg(MSGT_VFILTER, MSGL_WARN, "%s not supported by next filter/vo :(\n", "YV12");
return 0;
}
@@ -269,7 +269,7 @@ static void ring2Test(uint8_t *dst, int stride, int off)
}
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
int frame= vf->priv->frame_num;
@@ -307,7 +307,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
return vf_next_query_format(vf,IMGFMT_YV12) & (~VFCAP_CSP_SUPPORTED_BY_HW);
}
diff --git a/libmpcodecs/vf_tfields.c b/libmpcodecs/vf_tfields.c
index dd754256d5..5ec60e3cde 100644
--- a/libmpcodecs/vf_tfields.c
+++ b/libmpcodecs/vf_tfields.c
@@ -3,6 +3,7 @@
#include <string.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "cpudetect.h"
@@ -299,10 +300,9 @@ static void qpel_4tap_C(unsigned char *d, unsigned char *s, int w, int h, int ds
static void (*qpel_li)(unsigned char *d, unsigned char *s, int w, int h, int ds, int ss, int up);
static void (*qpel_4tap)(unsigned char *d, unsigned char *s, int w, int h, int ds, int ss, int up);
-static int continue_buffered_image(struct vf_instance_s *);
-extern int correct_pts;
+static int continue_buffered_image(struct vf_instance *);
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
vf->priv->buffered_mpi = mpi;
vf->priv->buffered_pts = pts;
@@ -310,7 +310,9 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return continue_buffered_image(vf);
}
-static int continue_buffered_image(struct vf_instance_s *vf)
+extern const int under_mencoder;
+
+static int continue_buffered_image(struct vf_instance *vf)
{
int i=vf->priv->buffered_i;
double pts = vf->priv->buffered_pts;
@@ -362,10 +364,10 @@ static int continue_buffered_image(struct vf_instance_s *vf)
dmpi->stride[2] = 2*mpi->stride[2];
}
ret |= vf_next_put_image(vf, dmpi, pts);
- if (correct_pts)
+ if (!under_mencoder)
break;
else
- if (!i) vf_extra_flip(vf);
+ if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
}
break;
case 1:
@@ -392,10 +394,10 @@ static int continue_buffered_image(struct vf_instance_s *vf)
mpi->chroma_width, mpi->chroma_height, (i^!tff));
}
ret |= vf_next_put_image(vf, dmpi, pts);
- if (correct_pts)
+ if (!under_mencoder)
break;
else
- if (!i) vf_extra_flip(vf);
+ if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
}
break;
case 2:
@@ -418,10 +420,10 @@ static int continue_buffered_image(struct vf_instance_s *vf)
dmpi->stride[2], mpi->stride[2]*2, (i^!tff));
}
ret |= vf_next_put_image(vf, dmpi, pts);
- if (correct_pts)
+ if (!under_mencoder)
break;
else
- if (!i) vf_extra_flip(vf);
+ if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
}
break;
}
@@ -430,7 +432,7 @@ static int continue_buffered_image(struct vf_instance_s *vf)
}
#if 0
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - figure out which other formats work */
switch (fmt) {
@@ -443,7 +445,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
}
#endif
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -459,7 +461,7 @@ static int config(struct vf_instance_s* vf,
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
@@ -499,5 +501,3 @@ const vf_info_t vf_info_tfields = {
open,
NULL
};
-
-
diff --git a/libmpcodecs/vf_tile.c b/libmpcodecs/vf_tile.c
index 6bb43eaae6..3bc1859c6a 100644
--- a/libmpcodecs/vf_tile.c
+++ b/libmpcodecs/vf_tile.c
@@ -68,7 +68,7 @@ struct vf_priv_s {
};
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -91,7 +91,7 @@ static int config(struct vf_instance_s* vf,
}
/* Filter handler */
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
struct vf_priv_s *priv;
@@ -176,14 +176,14 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
}
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
/* free local data */
free(vf->priv);
}
/* rgb/bgr 15->32 supported & some Yxxx */
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
switch (fmt) {
/* rgb 15 -> 32 bit */
@@ -279,7 +279,7 @@ static int open(vf_instance_t *vf, char* args)
// er |= parse_int( &args, &p->bkgSet, 0 );
if (er) {
- mp_msg(MSGT_VFILTER, MSGL_ERR, MSGTR_MPCODECS_ErrorParsingArgument);
+ mp_tmsg(MSGT_VFILTER, MSGL_ERR, "[VF_FRAMESTEP] Error parsing argument.\n");
return 0;
}
/* Load some default */
diff --git a/libmpcodecs/vf_tinterlace.c b/libmpcodecs/vf_tinterlace.c
index 988e55d8d0..fa69986856 100644
--- a/libmpcodecs/vf_tinterlace.c
+++ b/libmpcodecs/vf_tinterlace.c
@@ -37,7 +37,7 @@ struct vf_priv_s {
mp_image_t *dmpi;
};
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
int ret = 0;
mp_image_t *dmpi;
@@ -176,7 +176,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
return ret;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+static int query_format(struct vf_instance* vf, unsigned int fmt)
{
/* FIXME - figure out which other formats work */
switch (fmt) {
@@ -188,7 +188,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt)
return 0;
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
@@ -204,7 +204,7 @@ static int config(struct vf_instance_s* vf,
return 0;
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
free(vf->priv);
}
diff --git a/libmpcodecs/vf_unsharp.c b/libmpcodecs/vf_unsharp.c
index 1f7e16bc61..09d276d3d7 100644
--- a/libmpcodecs/vf_unsharp.c
+++ b/libmpcodecs/vf_unsharp.c
@@ -126,7 +126,7 @@ static void unsharp( uint8_t *dst, uint8_t *src, int dstStride, int srcStride, i
//===========================================================================//
-static int config( struct vf_instance_s* vf,
+static int config( struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt ) {
@@ -159,7 +159,7 @@ static int config( struct vf_instance_s* vf,
//===========================================================================//
-static void get_image( struct vf_instance_s* vf, mp_image_t *mpi ) {
+static void get_image( struct vf_instance* vf, mp_image_t *mpi ) {
if( mpi->flags & MP_IMGFLAG_PRESERVE )
return; // don't change
if( mpi->imgfmt!=vf->priv->outfmt )
@@ -178,7 +178,7 @@ static void get_image( struct vf_instance_s* vf, mp_image_t *mpi ) {
mpi->flags |= MP_IMGFLAG_DIRECT;
}
-static int put_image( struct vf_instance_s* vf, mp_image_t *mpi, double pts) {
+static int put_image( struct vf_instance* vf, mp_image_t *mpi, double pts) {
mp_image_t *dmpi;
if( !(mpi->flags & MP_IMGFLAG_DIRECT) )
@@ -204,7 +204,7 @@ static int put_image( struct vf_instance_s* vf, mp_image_t *mpi, double pts) {
return vf_next_put_image( vf, dmpi, pts);
}
-static void uninit( struct vf_instance_s* vf ) {
+static void uninit( struct vf_instance* vf ) {
unsigned int z;
FilterParam *fp;
@@ -227,7 +227,7 @@ static void uninit( struct vf_instance_s* vf ) {
//===========================================================================//
-static int query_format( struct vf_instance_s* vf, unsigned int fmt ) {
+static int query_format( struct vf_instance* vf, unsigned int fmt ) {
switch(fmt) {
case IMGFMT_YV12:
case IMGFMT_I420:
@@ -263,7 +263,7 @@ static void parse( FilterParam *fp, char* args ) {
//===========================================================================//
-static unsigned int fmt_list[] = {
+static const unsigned int fmt_list[] = {
IMGFMT_YV12,
IMGFMT_I420,
IMGFMT_IYUV,
diff --git a/libmpcodecs/vf_uspp.c b/libmpcodecs/vf_uspp.c
index 286d9d1bdd..db67ec775f 100644
--- a/libmpcodecs/vf_uspp.c
+++ b/libmpcodecs/vf_uspp.c
@@ -204,7 +204,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int ds
}
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int i;
@@ -245,7 +245,7 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static void get_image(struct vf_instance* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
// ok, we can do pp in-place (or pp disabled):
vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
@@ -262,7 +262,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
@@ -297,7 +297,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return vf_next_put_image(vf,dmpi, pts);
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
int i;
if(!vf->priv) return;
@@ -316,7 +316,7 @@ static void uninit(struct vf_instance_s* vf){
}
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
@@ -328,7 +328,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return 0;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
switch(request){
case VFCTRL_QUERY_MAX_PP_LEVEL:
return 8;
diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c
index affffa6bde..2e4257fb21 100644
--- a/libmpcodecs/vf_vo.c
+++ b/libmpcodecs/vf_vo.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdbool.h>
#include "config.h"
#include "mp_msg.h"
@@ -23,7 +24,7 @@ extern float sub_delay;
struct vf_priv_s {
double pts;
- const vo_functions_t *vo;
+ struct vo *vo;
#ifdef CONFIG_ASS
ass_renderer_t* ass_priv;
int prev_visibility;
@@ -31,10 +32,10 @@ struct vf_priv_s {
};
#define video_out (vf->priv->vo)
-static int query_format(struct vf_instance_s* vf, unsigned int fmt); /* forward declaration */
-static void draw_slice(struct vf_instance_s* vf, unsigned char** src, int* stride, int w,int h, int x, int y);
+static int query_format(struct vf_instance* vf, unsigned int fmt); /* forward declaration */
+static void draw_slice(struct vf_instance *vf, unsigned char **src, int *stride, int w,int h, int x, int y);
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
@@ -44,8 +45,7 @@ static int config(struct vf_instance_s* vf,
return 0;
}
- if(video_out->info)
- { const vo_info_t *info = video_out->info;
+ const vo_info_t *info = video_out->driver->info;
mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name,
width, height,
d_width, d_height,
@@ -58,13 +58,12 @@ static int config(struct vf_instance_s* vf,
mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Author: %s\n", info->author);
if(info->comment && strlen(info->comment) > 0)
mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment);
- }
// save vo's stride capability for the wanted colorspace:
vf->default_caps=query_format(vf,outfmt);
vf->draw_slice = (vf->default_caps & VOCAP_NOSLICES) ? NULL : draw_slice;
- if(config_video_out(video_out,width,height,d_width,d_height,flags,"MPlayer",outfmt))
+ if (vo_config(video_out, width, height, d_width, d_height, flags, "MPlayer", outfmt))
return 0;
#ifdef CONFIG_ASS
@@ -72,46 +71,47 @@ static int config(struct vf_instance_s* vf,
ass_configure(vf->priv->ass_priv, width, height, !!(vf->default_caps & VFCAP_EOSD_UNSCALED));
#endif
- ++vo_config_count;
return 1;
}
-static int control(struct vf_instance_s* vf, int request, void* data)
+static int control(struct vf_instance* vf, int request, void* data)
{
switch(request){
case VFCTRL_GET_DEINTERLACE:
{
if(!video_out) return CONTROL_FALSE; // vo not configured?
- return(video_out->control(VOCTRL_GET_DEINTERLACE, data)
- == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+ return vo_control(video_out, VOCTRL_GET_DEINTERLACE, data) == VO_TRUE;
}
case VFCTRL_SET_DEINTERLACE:
{
if(!video_out) return CONTROL_FALSE; // vo not configured?
- return(video_out->control(VOCTRL_SET_DEINTERLACE, data)
- == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+ return vo_control(video_out, VOCTRL_SET_DEINTERLACE, data) == VO_TRUE;
}
case VFCTRL_DRAW_OSD:
- if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
- video_out->draw_osd();
+ if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured?
+ vo_draw_osd(video_out, data);
return CONTROL_TRUE;
+ case VFCTRL_REDRAW_OSD:
+ return vo_control(video_out, VOCTRL_REDRAW_OSD, data) == true;
case VFCTRL_FLIP_PAGE:
{
- if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
- video_out->flip_page();
+ if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured?
+ vo_flip_page(video_out);
return CONTROL_TRUE;
}
case VFCTRL_SET_EQUALIZER:
{
vf_equalizer_t *eq=data;
- if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
- return (video_out->control(VOCTRL_SET_EQUALIZER, eq->item, eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+ if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured?
+ struct voctrl_set_equalizer_args param = {eq->item, eq->value};
+ return vo_control(video_out, VOCTRL_SET_EQUALIZER, &param) == VO_TRUE;
}
case VFCTRL_GET_EQUALIZER:
{
vf_equalizer_t *eq=data;
- if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
- return (video_out->control(VOCTRL_GET_EQUALIZER, eq->item, &eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+ if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured?
+ struct voctrl_get_equalizer_args param = {eq->item, &eq->value};
+ return vo_control(video_out, VOCTRL_GET_EQUALIZER, &param) == VO_TRUE;
}
#ifdef CONFIG_ASS
case VFCTRL_INIT_EOSD:
@@ -126,11 +126,11 @@ static int control(struct vf_instance_s* vf, int request, void* data)
{
mp_eosd_images_t images = {NULL, 2};
double pts = vf->priv->pts;
- if (!vo_config_count || !vf->priv->ass_priv) return CONTROL_FALSE;
+ if (!video_out->config_ok || !vf->priv->ass_priv) return CONTROL_FALSE;
if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) {
mp_eosd_res_t res;
memset(&res, 0, sizeof(res));
- if (video_out->control(VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) {
+ if (vo_control(video_out, VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) {
ass_set_frame_size(vf->priv->ass_priv, res.w, res.h);
ass_set_margins(vf->priv->ass_priv, res.mt, res.mb, res.ml, res.mr);
ass_set_aspect_ratio(vf->priv->ass_priv, (double)res.w / res.h);
@@ -143,7 +143,7 @@ static int control(struct vf_instance_s* vf, int request, void* data)
} else
vf->priv->prev_visibility = 0;
vf->priv->prev_visibility = sub_visibility;
- return (video_out->control(VOCTRL_DRAW_EOSD, &images) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+ return vo_control(video_out, VOCTRL_DRAW_EOSD, &images) == VO_TRUE;
}
#endif
case VFCTRL_GET_PTS:
@@ -152,12 +152,11 @@ static int control(struct vf_instance_s* vf, int request, void* data)
return CONTROL_TRUE;
}
}
- // return video_out->control(request,data);
return CONTROL_UNKNOWN;
}
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
- int flags=video_out->control(VOCTRL_QUERY_FORMAT,&fmt);
+static int query_format(struct vf_instance* vf, unsigned int fmt){
+ int flags = vo_control(video_out, VOCTRL_QUERY_FORMAT, &fmt);
// draw_slice() accepts stride, draw_frame() doesn't:
if(flags)
if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV)
@@ -165,47 +164,48 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return flags;
}
-static void get_image(struct vf_instance_s* vf,
+static void get_image(struct vf_instance* vf,
mp_image_t *mpi){
- if(!vo_config_count) return;
+ if (!video_out->config_ok)
+ return;
// GET_IMAGE is required for hardware-accelerated formats
if(vo_directrendering ||
IMGFMT_IS_XVMC(mpi->imgfmt) || IMGFMT_IS_VDPAU(mpi->imgfmt))
- video_out->control(VOCTRL_GET_IMAGE,mpi);
+ vo_control(video_out, VOCTRL_GET_IMAGE, mpi);
}
-static int put_image(struct vf_instance_s* vf,
+static int put_image(struct vf_instance* vf,
mp_image_t *mpi, double pts){
- if(!vo_config_count) return 0; // vo not configured?
+ if(!video_out->config_ok) return 0; // vo not configured?
// record pts (potentially modified by filters) for main loop
vf->priv->pts = pts;
// first check, maybe the vo/vf plugin implements draw_image using mpi:
- if(video_out->control(VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return 1; // done.
+ if (vo_control(video_out, VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return 1; // done.
// nope, fallback to old draw_frame/draw_slice:
if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){
// blit frame:
// if(mpi->flags&MP_IMGFLAG_PLANAR)
if(vf->default_caps&VFCAP_ACCEPT_STRIDE)
- video_out->draw_slice(mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y);
+ vo_draw_slice(video_out, mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y);
else
- video_out->draw_frame(mpi->planes);
+ vo_draw_frame(video_out, mpi->planes);
}
return 1;
}
-static void start_slice(struct vf_instance_s* vf,
+static void start_slice(struct vf_instance* vf,
mp_image_t *mpi) {
- if(!vo_config_count) return; // vo not configured?
- video_out->control(VOCTRL_START_SLICE,mpi);
+ if(!video_out->config_ok) return; // vo not configured?
+ vo_control(video_out, VOCTRL_START_SLICE,mpi);
}
-static void draw_slice(struct vf_instance_s* vf,
+static void draw_slice(struct vf_instance* vf,
unsigned char** src, int* stride, int w,int h, int x, int y){
- if(!vo_config_count) return; // vo not configured?
- video_out->draw_slice(src,stride,w,h,x,y);
+ if(!video_out->config_ok) return; // vo not configured?
+ vo_draw_slice(video_out, src,stride,w,h,x,y);
}
-static void uninit(struct vf_instance_s* vf)
+static void uninit(struct vf_instance* vf)
{
if (vf->priv) {
#ifdef CONFIG_ASS
@@ -227,9 +227,8 @@ static int open(vf_instance_t *vf, char* args){
vf->start_slice=start_slice;
vf->uninit=uninit;
vf->priv=calloc(1, sizeof(struct vf_priv_s));
- vf->priv->vo = (const vo_functions_t *)args;
+ vf->priv->vo = (struct vo *)args;
if(!video_out) return 0; // no vo ?
-// if(video_out->preinit(args)) return 0; // preinit failed
return 1;
}
diff --git a/libmpcodecs/vf_yadif.c b/libmpcodecs/vf_yadif.c
index 4b408a2e21..8c73ebacef 100644
--- a/libmpcodecs/vf_yadif.c
+++ b/libmpcodecs/vf_yadif.c
@@ -26,6 +26,7 @@
#include "config.h"
#include "cpudetect.h"
+#include "options.h"
#include "mp_msg.h"
#include "img_format.h"
@@ -363,7 +364,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], int dst_stride[3], int
#endif
}
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
int i, j;
@@ -381,10 +382,9 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static int continue_buffered_image(struct vf_instance_s *vf);
-extern int correct_pts;
+static int continue_buffered_image(struct vf_instance *vf);
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int tff;
if(vf->priv->parity < 0) {
@@ -411,7 +411,9 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
return continue_buffered_image(vf);
}
-static int continue_buffered_image(struct vf_instance_s *vf)
+extern const int under_mencoder;
+
+static int continue_buffered_image(struct vf_instance *vf)
{
mp_image_t *mpi = vf->priv->buffered_mpi;
int tff = vf->priv->buffered_tff;
@@ -429,19 +431,19 @@ static int continue_buffered_image(struct vf_instance_s *vf)
mpi->width,mpi->height);
vf_clone_mpi_attributes(dmpi, mpi);
filter(vf->priv, dmpi->planes, dmpi->stride, mpi->w, mpi->h, i ^ tff ^ 1, tff);
- if (correct_pts && i < (vf->priv->mode & 1))
+ if (i < (vf->priv->mode & 1) && !under_mencoder)
vf_queue_frame(vf, continue_buffered_image);
ret |= vf_next_put_image(vf, dmpi, pts /*FIXME*/);
- if (correct_pts)
+ if (!under_mencoder)
break;
if(i<(vf->priv->mode&1))
- vf_extra_flip(vf);
+ vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
}
vf->priv->buffered_i = 1;
return ret;
}
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
int i;
if(!vf->priv) return;
@@ -455,7 +457,7 @@ static void uninit(struct vf_instance_s* vf){
}
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
@@ -467,7 +469,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return 0;
}
-static int control(struct vf_instance_s* vf, int request, void* data){
+static int control(struct vf_instance* vf, int request, void* data){
switch (request){
case VFCTRL_GET_DEINTERLACE:
*(int*)data = vf->priv->do_deinterlace;
diff --git a/libmpcodecs/vf_yuvcsp.c b/libmpcodecs/vf_yuvcsp.c
index 6801a5b60d..06cf31ce28 100644
--- a/libmpcodecs/vf_yuvcsp.c
+++ b/libmpcodecs/vf_yuvcsp.c
@@ -16,7 +16,7 @@ struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
@@ -30,7 +30,7 @@ static inline int clamp_c(int x){
return (x > 240) ? 240 : (x < 16) ? 16 : x;
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
int i,j;
uint8_t *y_in, *cb_in, *cr_in;
uint8_t *y_out, *cb_out, *cr_out;
@@ -64,12 +64,12 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
/*
-static void uninit(struct vf_instance_s* vf){
+static void uninit(struct vf_instance* vf){
free(vf->priv);
}
*/
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
diff --git a/libmpcodecs/vf_yuy2.c b/libmpcodecs/vf_yuy2.c
index b9fb24d090..e19461f387 100644
--- a/libmpcodecs/vf_yuy2.c
+++ b/libmpcodecs/vf_yuy2.c
@@ -16,21 +16,21 @@
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
sws_rgb2rgb_init(get_sws_cpuflags());
if(vf_next_query_format(vf,IMGFMT_YUY2)<=0){
- mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupport, "YUY2");
+ mp_tmsg(MSGT_VFILTER, MSGL_WARN, "%s not supported by next filter/vo :(\n", "YUY2");
return 0;
}
return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YUY2);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -52,7 +52,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
switch(fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
diff --git a/libmpcodecs/vf_yvu9.c b/libmpcodecs/vf_yvu9.c
index 2858103922..19976da5da 100644
--- a/libmpcodecs/vf_yvu9.c
+++ b/libmpcodecs/vf_yvu9.c
@@ -15,19 +15,19 @@
//===========================================================================//
-static int config(struct vf_instance_s* vf,
+static int config(struct vf_instance* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
if(vf_next_query_format(vf,IMGFMT_YV12)<=0){
- mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupport, "YVU9");
+ mp_tmsg(MSGT_VFILTER, MSGL_WARN, "%s not supported by next filter/vo :(\n", "YVU9");
return 0;
}
return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YV12);
}
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
int y,w,h;
@@ -62,7 +62,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
//===========================================================================//
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
if (fmt == IMGFMT_YVU9 || fmt == IMGFMT_IF09)
return vf_next_query_format(vf,IMGFMT_YV12) & (~VFCAP_CSP_SUPPORTED_BY_HW);
return 0;
diff --git a/libmpcodecs/vf_zrmjpeg.c b/libmpcodecs/vf_zrmjpeg.c
index 6b4c9a7c64..87c50351d9 100644
--- a/libmpcodecs/vf_zrmjpeg.c
+++ b/libmpcodecs/vf_zrmjpeg.c
@@ -668,7 +668,7 @@ struct vf_priv_s {
* arrange to dispatch to the config() entry pointer for the one
* selected.
*/
-static int config(struct vf_instance_s* vf, int width, int height, int d_width,
+static int config(struct vf_instance* vf, int width, int height, int d_width,
int d_height, unsigned int flags, unsigned int outfmt){
struct vf_priv_s *priv = vf->priv;
float aspect_decision;
@@ -828,7 +828,7 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width,
* \param mpi pointer to mp_image_t structure
* \param pts
*/
-static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
+static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
struct vf_priv_s *priv = vf->priv;
int size = 0;
int i;
@@ -857,7 +857,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
* Given the image format specified by \a fmt, this routine is called
* to ask if the format is supported or not.
*/
-static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+static int query_format(struct vf_instance* vf, unsigned int fmt){
VERBOSE("query_format() called\n");
switch (fmt) {
@@ -1066,4 +1066,3 @@ const vf_info_t vf_info_zrmjpeg = {
open,
NULL
};
-
diff --git a/libmpdemux/asfheader.c b/libmpdemux/asfheader.c
index d6e72f2497..7cf0111e67 100644
--- a/libmpdemux/asfheader.c
+++ b/libmpdemux/asfheader.c
@@ -54,7 +54,7 @@ static char* get_ucs2str(const uint16_t* inbuf, uint16_t inlen)
int i;
if (!outbuf) {
- mp_msg(MSGT_HEADER, MSGL_ERR, MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_HEADER, MSGL_ERR, "Memory allocation failed.\n");
return NULL;
}
q = outbuf;
@@ -286,7 +286,7 @@ static int get_meta(char *buf, int buf_len, int this_stream_num,
if (record_entry.stream_num && record_entry.stream_num != this_stream_num)
continue;
if (!(name = get_ucs2str(record_entry.name, record_entry.name_length))) {
- mp_msg(MSGT_HEADER, MSGL_ERR, MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_HEADER, MSGL_ERR, "Memory allocation failed.\n");
continue;
}
if (strcmp(name, "AspectRatioX") == 0)
@@ -339,7 +339,7 @@ static int is_drm(char* buf, int buf_len)
buf += 4;
buf[url_len - 1] = '\0';
- mp_msg(MSGT_HEADER, MSGL_INFO, MSGTR_MPDEMUX_ASFHDR_DRMLicenseURL, buf);
+ mp_tmsg(MSGT_HEADER, MSGL_INFO, "DRM License URL: %s\n", buf);
return 1;
}
@@ -402,14 +402,14 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){
}
if (hdr_len > 1024 * 1024) {
- mp_msg(MSGT_HEADER, MSGL_ERR, MSGTR_MPDEMUX_ASFHDR_HeaderSizeOver1MB,
+ mp_tmsg(MSGT_HEADER, MSGL_ERR, "FATAL: header size bigger than 1 MB (%d)!\nPlease contact MPlayer authors, and upload/send this file.\n",
hdr_len);
hdr_skip = hdr_len - 1024 * 1024;
hdr_len = 1024 * 1024;
}
hdr = malloc(hdr_len);
if (!hdr) {
- mp_msg(MSGT_HEADER, MSGL_FATAL, MSGTR_MPDEMUX_ASFHDR_HeaderMallocFailed,
+ mp_tmsg(MSGT_HEADER, MSGL_FATAL, "Could not allocate %d bytes for header.\n",
hdr_len);
return 0;
}
@@ -417,12 +417,12 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){
if (hdr_skip)
stream_skip(demuxer->stream, hdr_skip);
if (stream_eof(demuxer->stream)) {
- mp_msg(MSGT_HEADER, MSGL_FATAL, MSGTR_MPDEMUX_ASFHDR_EOFWhileReadingHeader);
+ mp_tmsg(MSGT_HEADER, MSGL_FATAL, "EOF while reading ASF header, broken/incomplete file?\n");
goto err_out;
}
if (is_drm(hdr, hdr_len))
- mp_msg(MSGT_HEADER, MSGL_FATAL, MSGTR_MPDEMUX_ASFHDR_DRMProtected);
+ mp_tmsg(MSGT_HEADER, MSGL_FATAL, "This file has been encumbered with DRM encryption, it will not play in MPlayer!\n");
if ((pos = find_asf_guid(hdr, asf_ext_stream_audio, 0, hdr_len)) >= 0)
{
@@ -444,7 +444,7 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){
audio_pos += 64; //16+16+4+4+4+16+4;
buffer = &hdr[audio_pos];
sh_audio=new_sh_audio(demuxer,streamh->stream_no & 0x7F);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "asfheader", streamh->stream_no & 0x7F);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "asfheader", streamh->stream_no & 0x7F);
++audio_streams;
if (!asf_init_audio_stream(demuxer, asf, sh_audio, streamh, &audio_pos, &buffer, hdr, hdr_len))
goto len_err_out;
@@ -481,7 +481,7 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){
switch(ASF_LOAD_GUID_PREFIX(streamh->type)){
case ASF_GUID_PREFIX_audio_stream: {
sh_audio_t* sh_audio=new_sh_audio(demuxer,streamh->stream_no & 0x7F);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "asfheader", streamh->stream_no & 0x7F);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "asfheader", streamh->stream_no & 0x7F);
++audio_streams;
if (!asf_init_audio_stream(demuxer, asf, sh_audio, streamh, &pos, &buffer, hdr, hdr_len))
goto len_err_out;
@@ -492,7 +492,7 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){
unsigned int len;
float asp_ratio;
sh_video_t* sh_video=new_sh_video(demuxer,streamh->stream_no & 0x7F);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "asfheader", streamh->stream_no & 0x7F);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Video stream found, -vid %d\n", "asfheader", streamh->stream_no & 0x7F);
len=streamh->type_size-(4+4+1+2);
++video_streams;
// sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize);
@@ -502,7 +502,7 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){
if (sh_video->bih->biSize > len && sh_video->bih->biSize > sizeof(BITMAPINFOHEADER))
sh_video->bih->biSize = len;
if (sh_video->bih->biCompression == mmioFOURCC('D', 'V', 'R', ' ')) {
- //mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_MPDEMUX_ASFHDR_DVRWantsLibavformat);
+ //mp_tmsg(MSGT_DEMUXER, MSGL_WARN, "DVR will probably only work with libavformat, try -demuxer 35 if you have problems\n");
//sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
//sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
asf->asf_frame_state=-1;
@@ -648,7 +648,7 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){
start = stream_tell(demuxer->stream); // start of first data chunk
stream_read(demuxer->stream, guid_buffer, 16);
if (memcmp(guid_buffer, asf_data_chunk_guid, 16) != 0) {
- mp_msg(MSGT_HEADER, MSGL_FATAL, MSGTR_MPDEMUX_ASFHDR_NoDataChunkAfterHeader);
+ mp_tmsg(MSGT_HEADER, MSGL_FATAL, "No data chunk following header!\n");
free(streams);
streams = NULL;
return 0;
@@ -695,7 +695,7 @@ if(!audio_streams) demuxer->audio->id=-2; // nosound
else if(best_audio > 0 && demuxer->audio->id == -1) demuxer->audio->id=best_audio;
if(!video_streams){
if(!audio_streams){
- mp_msg(MSGT_HEADER,MSGL_ERR,MSGTR_MPDEMUX_ASFHDR_AudioVideoHeaderNotFound);
+ mp_tmsg(MSGT_HEADER,MSGL_ERR,"ASF: no audio or video headers found - broken file?\n");
return 0;
}
demuxer->video->id=-2; // audio-only
@@ -712,7 +712,7 @@ if( mp_msg_test(MSGT_HEADER,MSGL_V) ){
return 1;
len_err_out:
- mp_msg(MSGT_HEADER, MSGL_FATAL, MSGTR_MPDEMUX_ASFHDR_InvalidLengthInASFHeader);
+ mp_tmsg(MSGT_HEADER, MSGL_FATAL, "Invalid length in ASF header!\n");
err_out:
if (hdr) free(hdr);
if (streams) free(streams);
diff --git a/libmpdemux/aviheader.c b/libmpdemux/aviheader.c
index dae0313108..a7b2b2c434 100644
--- a/libmpdemux/aviheader.c
+++ b/libmpdemux/aviheader.c
@@ -59,7 +59,7 @@ static int odml_get_vstream_id(int id, unsigned char res[])
return 0;
}
-int avi_idx_cmp(const void *elem1,const void *elem2) {
+static int avi_idx_cmp(const void *elem1,const void *elem2) {
register off_t a = AVI_IDX_OFFSET((AVIINDEXENTRY *)elem1);
register off_t b = AVI_IDX_OFFSET((AVIINDEXENTRY *)elem2);
return (a > b) - (b > a);
@@ -97,7 +97,7 @@ while(1){
len -= 4;
list_end=stream_tell(demuxer->stream)+((len+1)&(~1));
} else {
- mp_msg(MSGT_HEADER,MSGL_WARN,MSGTR_MPDEMUX_AVIHDR_EmptyList);
+ mp_tmsg(MSGT_HEADER,MSGL_WARN,"** empty list?!\n");
list_end = 0;
}
mp_msg(MSGT_HEADER,MSGL_V,"list_end=0x%X\n",(int)list_end);
@@ -105,7 +105,7 @@ while(1){
// found MOVI header
if(!demuxer->movi_start) demuxer->movi_start=stream_tell(demuxer->stream);
demuxer->movi_end=stream_tell(demuxer->stream)+len;
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_FoundMovieAt,(int)demuxer->movi_start,(int)demuxer->movi_end);
+ mp_tmsg(MSGT_HEADER,MSGL_V,"Found movie at 0x%X - 0x%X\n",(int)demuxer->movi_start,(int)demuxer->movi_end);
if(demuxer->stream->end_pos>demuxer->movi_end) demuxer->movi_end=demuxer->stream->end_pos;
if(index_mode==-2 || index_mode==2 || index_mode==0)
break; // reading from non-seekable source (stdin) or forced index or no index forced
@@ -210,13 +210,13 @@ while(1){
++stream_id;
if(h.fccType==streamtypeVIDEO){
sh_video=new_sh_video(demuxer,stream_id);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "aviheader", stream_id);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Video stream found, -vid %d\n", "aviheader", stream_id);
memcpy(&sh_video->video,&h,sizeof(h));
sh_video->stream_delay = (float)sh_video->video.dwStart * sh_video->video.dwScale/sh_video->video.dwRate;
} else
if(h.fccType==streamtypeAUDIO){
sh_audio=new_sh_audio(demuxer,stream_id);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "aviheader", stream_id);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "aviheader", stream_id);
memcpy(&sh_audio->audio,&h,sizeof(h));
sh_audio->stream_delay = (float)sh_audio->audio.dwStart * sh_audio->audio.dwScale/sh_audio->audio.dwRate;
}
@@ -279,7 +279,7 @@ while(1){
if(last_fccType==streamtypeVIDEO){
sh_video->bih=calloc(FFMAX(chunksize, sizeof(BITMAPINFOHEADER)), 1);
// sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize);
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_FoundBitmapInfoHeader,chunksize,sizeof(BITMAPINFOHEADER));
+ mp_tmsg(MSGT_HEADER,MSGL_V,"Found 'bih', %u bytes of %d\n",chunksize,sizeof(BITMAPINFOHEADER));
stream_read(demuxer->stream,(char*) sh_video->bih,chunksize);
le2me_BITMAPINFOHEADER(sh_video->bih); // swap to machine endian
if (sh_video->bih->biSize > chunksize && sh_video->bih->biSize > sizeof(BITMAPINFOHEADER))
@@ -300,7 +300,7 @@ while(1){
case mmioFOURCC('m', 'p', 'g', '4'):
case mmioFOURCC('D', 'I', 'V', '1'):
idxfix_divx=3; // set index recovery mpeg4 flavour: msmpeg4v1
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForMPG4V1);
+ mp_tmsg(MSGT_HEADER,MSGL_V,"Regenerating keyframe table for M$ mpg4v1 video.\n");
break;
case mmioFOURCC('D', 'I', 'V', '3'):
case mmioFOURCC('d', 'i', 'v', '3'):
@@ -317,7 +317,7 @@ while(1){
case mmioFOURCC('D', 'I', 'V', '2'):
case mmioFOURCC('A', 'P', '4', '1'):
idxfix_divx=1; // set index recovery mpeg4 flavour: msmpeg4v3
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForDIVX3);
+ mp_tmsg(MSGT_HEADER,MSGL_V,"Regenerating keyframe table for DIVX3 video.\n");
break;
case mmioFOURCC('D', 'I', 'V', 'X'):
case mmioFOURCC('d', 'i', 'v', 'x'):
@@ -327,7 +327,7 @@ while(1){
case mmioFOURCC('F', 'M', 'P', '4'):
case mmioFOURCC('f', 'm', 'p', '4'):
idxfix_divx=2; // set index recovery mpeg4 flavour: generic mpeg4
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForMPEG4);
+ mp_tmsg(MSGT_HEADER,MSGL_V,"Regenerating keyframe table for MPEG-4 video.\n");
break;
}
} else
@@ -335,7 +335,7 @@ while(1){
unsigned wf_size = chunksize<sizeof(WAVEFORMATEX)?sizeof(WAVEFORMATEX):chunksize;
sh_audio->wf=calloc(wf_size,1);
// sh_audio->wf=malloc(chunksize); memset(sh_audio->wf,0,chunksize);
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_FoundWaveFmt,chunksize,sizeof(WAVEFORMATEX));
+ mp_tmsg(MSGT_HEADER,MSGL_V,"Found 'wf', %d bytes of %d\n",chunksize,sizeof(WAVEFORMATEX));
stream_read(demuxer->stream,(char*) sh_audio->wf,chunksize);
le2me_WAVEFORMATEX(sh_audio->wf);
if (sh_audio->wf->cbSize != 0 &&
@@ -378,7 +378,7 @@ while(1){
case mmioFOURCC('d', 'm', 'l', 'h'): {
// dmlh 00 00 00 04 frms
unsigned int total_frames = stream_read_dword_le(demuxer->stream);
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_FoundAVIV2Header, chunksize, total_frames);
+ mp_tmsg(MSGT_HEADER,MSGL_V,"AVI: dmlh found (size=%d) (total_frames=%d)\n", chunksize, total_frames);
stream_skip(demuxer->stream, chunksize-4);
chunksize = 0;
}
@@ -389,7 +389,7 @@ while(1){
if(index_mode && !priv->isodml){
int i;
priv->idx_size=size2>>4;
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_ReadingIndexBlockChunksForFrames,
+ mp_tmsg(MSGT_HEADER,MSGL_V,"Reading INDEX block, %d chunks for %d frames (fpos=%"PRId64").\n",
priv->idx_size,avih.dwTotalFrames, (int64_t)stream_tell(demuxer->stream));
priv->idx=malloc(priv->idx_size<<4);
// printf("\nindex to %p !!!!! (priv=%p)\n",priv->idx,priv);
@@ -412,10 +412,10 @@ while(1){
case mmioFOURCC('R','I','F','F'): {
char riff_type[4];
- mp_msg(MSGT_HEADER, MSGL_V, MSGTR_MPDEMUX_AVIHDR_AdditionalRIFFHdr);
+ mp_tmsg(MSGT_HEADER, MSGL_V, "Additional RIFF header...\n");
stream_read(demuxer->stream, riff_type, sizeof riff_type);
if (strncmp(riff_type, "AVIX", sizeof riff_type))
- mp_msg(MSGT_HEADER, MSGL_WARN, MSGTR_MPDEMUX_AVIHDR_WarnNotExtendedAVIHdr);
+ mp_tmsg(MSGT_HEADER, MSGL_WARN, "** Warning: this is no extended AVI header..\n");
else {
/*
* We got an extended AVI header, so we need to switch to
@@ -453,7 +453,7 @@ while(1){
if(list_end>0 &&
chunksize+stream_tell(demuxer->stream) == list_end) list_end=0;
if(list_end>0 && chunksize+stream_tell(demuxer->stream)>list_end){
- mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_BrokenChunk,chunksize,(char *) &id);
+ mp_tmsg(MSGT_HEADER,MSGL_V,"Broken chunk? chunksize=%d (id=%.4s)\n",chunksize,(char *) &id);
stream_seek(demuxer->stream,list_end);
list_end=0;
} else
@@ -481,7 +481,7 @@ if (priv->isodml && (index_mode==-1 || index_mode==0 || index_mode==1)) {
priv->idx_offset = 0;
priv->idx = NULL;
- mp_msg(MSGT_HEADER, MSGL_INFO, MSGTR_MPDEMUX_AVIHDR_BuildingODMLidx, priv->suidx_size);
+ mp_tmsg(MSGT_HEADER, MSGL_INFO, "AVI: ODML: Building ODML index (%d superindexchunks).\n", priv->suidx_size);
// read the standard indices
for (cx = &priv->suidx[0], i=0; i<priv->suidx_size; cx++, i++) {
@@ -496,7 +496,7 @@ if (priv->isodml && (index_mode==-1 || index_mode==0 || index_mode==1)) {
// gen_index routine handle this
priv->isodml = 0;
priv->idx_size = 0;
- mp_msg(MSGT_HEADER, MSGL_WARN, MSGTR_MPDEMUX_AVIHDR_BrokenODMLfile);
+ mp_tmsg(MSGT_HEADER, MSGL_WARN, "AVI: ODML: Broken (incomplete?) file detected. Will use traditional index.\n");
goto freeout;
}
@@ -600,18 +600,18 @@ if (index_file_load) {
unsigned int i;
if ((fp = fopen(index_file_load, "r")) == NULL) {
- mp_msg(MSGT_HEADER,MSGL_ERR, MSGTR_MPDEMUX_AVIHDR_CantReadIdxFile, index_file_load, strerror(errno));
+ mp_tmsg(MSGT_HEADER,MSGL_ERR, "Can't read index file %s: %s\n", index_file_load, strerror(errno));
goto gen_index;
}
fread(&magic, 6, 1, fp);
if (strncmp(magic, "MPIDX1", 6)) {
- mp_msg(MSGT_HEADER,MSGL_ERR, MSGTR_MPDEMUX_AVIHDR_NotValidMPidxFile, index_file_load);
+ mp_tmsg(MSGT_HEADER,MSGL_ERR, "%s is not a valid MPlayer index file.\n", index_file_load);
goto gen_index;
}
fread(&priv->idx_size, sizeof(priv->idx_size), 1, fp);
priv->idx=malloc(priv->idx_size*sizeof(AVIINDEXENTRY));
if (!priv->idx) {
- mp_msg(MSGT_HEADER,MSGL_ERR, MSGTR_MPDEMUX_AVIHDR_FailedMallocForIdxFile, index_file_load);
+ mp_tmsg(MSGT_HEADER,MSGL_ERR, "Could not allocate memory for index data from %s.\n", index_file_load);
priv->idx_size = 0;
goto gen_index;
}
@@ -621,14 +621,14 @@ if (index_file_load) {
idx=&((AVIINDEXENTRY *)priv->idx)[i];
fread(idx, sizeof(AVIINDEXENTRY), 1, fp);
if (feof(fp)) {
- mp_msg(MSGT_HEADER,MSGL_ERR, MSGTR_MPDEMUX_AVIHDR_PrematureEOF, index_file_load);
+ mp_tmsg(MSGT_HEADER,MSGL_ERR, "premature end of index file %s\n", index_file_load);
free(priv->idx);
priv->idx_size = 0;
goto gen_index;
}
}
fclose(fp);
- mp_msg(MSGT_HEADER,MSGL_INFO, MSGTR_MPDEMUX_AVIHDR_IdxFileLoaded, index_file_load);
+ mp_tmsg(MSGT_HEADER,MSGL_INFO, "Loaded index file: %s\n", index_file_load);
}
gen_index:
if(index_mode>=2 || (priv->idx_size==0 && index_mode==1)){
@@ -695,7 +695,7 @@ if(index_mode>=2 || (priv->idx_size==0 && index_mode==1)){
}
if(pos!=lastpos){
lastpos=pos;
- mp_msg(MSGT_HEADER,MSGL_STATUS,MSGTR_MPDEMUX_AVIHDR_GeneratingIdx,
+ mp_tmsg(MSGT_HEADER,MSGL_STATUS, "Generating Index: %3lu %s \r",
(unsigned long)pos, len?"%":"MB");
}
}
@@ -714,7 +714,7 @@ skip_chunk:
stream_seek(demuxer->stream,8+demuxer->filepos+skip);
}
priv->idx_size=priv->idx_pos;
- mp_msg(MSGT_HEADER,MSGL_INFO,MSGTR_MPDEMUX_AVIHDR_IdxGeneratedForHowManyChunks,priv->idx_size);
+ mp_tmsg(MSGT_HEADER,MSGL_INFO,"AVI: Generated index table for %d chunks!\n",priv->idx_size);
if( mp_msg_test(MSGT_HEADER,MSGL_DBG2) ) print_index(priv->idx,priv->idx_size,MSGL_DBG2);
/* Write generated index to a file */
@@ -723,7 +723,7 @@ skip_chunk:
unsigned int i;
if ((fp=fopen(index_file_save, "w")) == NULL) {
- mp_msg(MSGT_HEADER,MSGL_ERR, MSGTR_MPDEMUX_AVIHDR_Failed2WriteIdxFile, index_file_save, strerror(errno));
+ mp_tmsg(MSGT_HEADER,MSGL_ERR, "Couldn't write index file %s: %s\n", index_file_save, strerror(errno));
return;
}
fwrite("MPIDX1", 6, 1, fp);
@@ -733,8 +733,7 @@ skip_chunk:
fwrite(idx, sizeof(AVIINDEXENTRY), 1, fp);
}
fclose(fp);
- mp_msg(MSGT_HEADER,MSGL_INFO, MSGTR_MPDEMUX_AVIHDR_IdxFileSaved, index_file_save);
+ mp_tmsg(MSGT_HEADER,MSGL_INFO, "Saved index file: %s\n", index_file_save);
}
}
}
-
diff --git a/libmpdemux/aviprint.c b/libmpdemux/aviprint.c
index f12451a6b4..af90251424 100644
--- a/libmpdemux/aviprint.c
+++ b/libmpdemux/aviprint.c
@@ -188,4 +188,3 @@ void print_avisuperindex_chunk(avisuperindex_chunk *h, int verbose_level){
h->dwReserved[0], h->dwReserved[1], h->dwReserved[2]);
mp_msg (MSGT_HEADER, verbose_level, "===========================\n");
}
-
diff --git a/libmpdemux/demux_asf.c b/libmpdemux/demux_asf.c
index 07e5972ef1..e000376b40 100644
--- a/libmpdemux/demux_asf.c
+++ b/libmpdemux/demux_asf.c
@@ -642,7 +642,7 @@ static demuxer_t* demux_open_asf(demuxer_t* demuxer)
// demuxer->endpos=avi_header.movi_end;
if(demuxer->video->id != -2) {
if(!ds_fill_buffer(demuxer->video)){
- mp_msg(MSGT_DEMUXER,MSGL_WARN,"ASF: " MSGTR_MissingVideoStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_WARN,"ASF: " "No video stream found.\n");
demuxer->video->sh=NULL;
//printf("ASF: missing video stream!? contact the author, it may be a bug :(\n");
} else {
@@ -657,9 +657,9 @@ static demuxer_t* demux_open_asf(demuxer_t* demuxer)
}
if(demuxer->audio->id!=-2){
- mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_ASFSearchingForAudioStream,demuxer->audio->id);
+ mp_tmsg(MSGT_DEMUXER,MSGL_V,"ASF: Searching for audio stream (id:%d).\n",demuxer->audio->id);
if(!ds_fill_buffer(demuxer->audio)){
- mp_msg(MSGT_DEMUXER,MSGL_INFO,"ASF: " MSGTR_MissingAudioStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_INFO,"ASF: " "No audio stream found -> no sound.\n");
demuxer->audio->sh=NULL;
} else {
sh_audio=demuxer->audio->sh;sh_audio->ds=demuxer->audio;
diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c
index f99517e476..d9ea6f2f84 100644
--- a/libmpdemux/demux_audio.c
+++ b/libmpdemux/demux_audio.c
@@ -589,7 +589,7 @@ static int demux_audio_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds) {
break;
}
default:
- mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_MPDEMUX_AUDIO_UnknownFormat,priv->frmt);
+ mp_tmsg(MSGT_DEMUXER,MSGL_WARN,"Audio demuxer: unknown format %d.\n",priv->frmt);
return 0;
}
diff --git a/libmpdemux/demux_avi.c b/libmpdemux/demux_avi.c
index 21529fb588..7ceffb33c1 100644
--- a/libmpdemux/demux_avi.c
+++ b/libmpdemux/demux_avi.c
@@ -43,7 +43,9 @@ extern const demuxer_desc_t demuxer_desc_avi_nini;
int pts_from_bps=1;
// Select ds from ID
-demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id){
+static demux_stream_t* demux_avi_select_stream(demuxer_t *demux,
+ unsigned int id)
+{
int stream_id=avi_stream_id(id);
@@ -73,7 +75,7 @@ demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id){
// workaround old mencoder's bug:
if(sh->audio.dwSampleSize==1 && sh->audio.dwScale==1 &&
(sh->wf->nBlockAlign==1152 || sh->wf->nBlockAlign==576)){
- mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_WorkAroundBlockAlignHeaderBug);
+ mp_tmsg(MSGT_DEMUX,MSGL_WARN,"AVI: Working around CBR-MP3 nBlockAlign header bug!\n");
priv->audio_block_size=1;
}
}
@@ -270,7 +272,7 @@ do{
if(ds)
if(ds->packs+1>=MAX_PACKS || ds->bytes+len>=MAX_PACK_BYTES){
// this packet will cause a buffer overflow, switch to -ni mode!!!
- mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_SwitchToNi);
+ mp_tmsg(MSGT_DEMUX,MSGL_WARN,"\nBadly interleaved AVI file detected - switching to -ni mode...\n");
if(priv->idx_size>0){
// has index
demux->type=DEMUXER_TYPE_AVI_NI;
@@ -296,7 +298,7 @@ do{
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t* ds){
+static int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t* ds){
avi_priv_t *priv=demux->priv;
unsigned int id=0;
unsigned int len;
@@ -360,7 +362,7 @@ do{
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t* ds){
+static int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t* ds){
avi_priv_t *priv=demux->priv;
unsigned int id=0;
unsigned int len;
@@ -444,11 +446,11 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
read_avi_header(demuxer,(demuxer->stream->flags & STREAM_SEEK_BW)?index_mode:-2);
if(demuxer->audio->id>=0 && !demuxer->a_streams[demuxer->audio->id]){
- mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_InvalidAudioStreamNosound,demuxer->audio->id);
+ mp_tmsg(MSGT_DEMUX,MSGL_WARN,"AVI: invalid audio stream ID: %d - ignoring (nosound)\n",demuxer->audio->id);
demuxer->audio->id=-2; // disabled
}
if(demuxer->video->id>=0 && !demuxer->v_streams[demuxer->video->id]){
- mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_InvalidAudioStreamUsingDefault,demuxer->video->id);
+ mp_tmsg(MSGT_DEMUX,MSGL_WARN,"AVI: invalid video stream ID: %d - ignoring (using default)\n",demuxer->video->id);
demuxer->video->id=-1; // autodetect
}
@@ -496,14 +498,14 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
}
}
if(v_pos==-1){
- mp_msg(MSGT_DEMUX,MSGL_ERR,"AVI_NI: " MSGTR_MissingVideoStream);
+ mp_tmsg(MSGT_DEMUX,MSGL_ERR,"AVI_NI: " "No video stream found.\n");
return NULL;
}
if(a_pos==-1){
d_audio->sh=sh_audio=NULL;
} else {
if(force_ni || abs(a_pos-v_pos)>0x100000){ // distance > 1MB
- mp_msg(MSGT_DEMUX,MSGL_INFO,MSGTR_NI_Message,force_ni?MSGTR_NI_Forced:MSGTR_NI_Detected);
+ mp_tmsg(MSGT_DEMUX,MSGL_INFO,"%s NON-INTERLEAVED AVI file format.\n",force_ni?"Forced":"Detected");
demuxer->type=DEMUXER_TYPE_AVI_NI; // HACK!!!!
demuxer->desc=&demuxer_desc_avi_ni; // HACK!!!!
pts_from_bps=1; // force BPS sync!
@@ -512,7 +514,7 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
} else {
// no index
if(force_ni){
- mp_msg(MSGT_DEMUX,MSGL_INFO,MSGTR_UsingNINI);
+ mp_tmsg(MSGT_DEMUX,MSGL_INFO,"Using NON-INTERLEAVED broken AVI file format.\n");
demuxer->type=DEMUXER_TYPE_AVI_NINI; // HACK!!!!
demuxer->desc=&demuxer_desc_avi_nini; // HACK!!!!
priv->idx_pos_a=
@@ -522,14 +524,14 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
demuxer->seekable=0;
}
if(!ds_fill_buffer(d_video)){
- mp_msg(MSGT_DEMUX,MSGL_ERR,"AVI: " MSGTR_MissingVideoStreamBug);
+ mp_tmsg(MSGT_DEMUX,MSGL_ERR,"AVI: " "Missing video stream!? Contact the author, it may be a bug :(\n");
return NULL;
}
sh_video=d_video->sh;sh_video->ds=d_video;
if(d_audio->id!=-2){
mp_msg(MSGT_DEMUX,MSGL_V,"AVI: Searching for audio stream (id:%d)\n",d_audio->id);
if(!priv->audio_streams || !ds_fill_buffer(d_audio)){
- mp_msg(MSGT_DEMUX,MSGL_INFO,"AVI: " MSGTR_MissingAudioStream);
+ mp_tmsg(MSGT_DEMUX,MSGL_INFO,"AVI: " "No audio stream found -> no sound.\n");
d_audio->sh=sh_audio=NULL;
} else {
sh_audio=d_audio->sh;sh_audio->ds=d_audio;
@@ -569,7 +571,7 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
// bad video header, try to get number of frames from audio
if(sh_audio && sh_audio->wf->nAvgBytesPerSec) priv->numberofframes=sh_video->fps*sh_audio->audio.dwLength/sh_audio->audio.dwRate*sh_audio->audio.dwScale;
if(priv->numberofframes<=1){
- mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CouldntDetFNo);
+ mp_tmsg(MSGT_SEEK,MSGL_WARN,"Could not determine number of frames (for absolute seek).\n");
priv->numberofframes=0;
}
@@ -591,7 +593,7 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
}
-void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
+static void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
avi_priv_t *priv=demuxer->priv;
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
@@ -764,7 +766,7 @@ void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int
}
-void demux_close_avi(demuxer_t *demuxer) {
+static void demux_close_avi(demuxer_t *demuxer) {
avi_priv_t* priv=demuxer->priv;
if(!priv)
@@ -845,7 +847,7 @@ static int avi_check_file(demuxer_t *demuxer)
if(id==mmioFOURCC('A','V','I',0x19))
return DEMUXER_TYPE_AVI;
if(id==mmioFOURCC('O','N','2','f')){
- mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_ON2AviFormat);
+ mp_tmsg(MSGT_DEMUXER,MSGL_INFO,"ON2 AVI format");
return DEMUXER_TYPE_AVI;
}
}
@@ -856,6 +858,7 @@ static int avi_check_file(demuxer_t *demuxer)
static demuxer_t* demux_open_hack_avi(demuxer_t *demuxer)
{
+ struct MPOpts *opts = demuxer->opts;
sh_audio_t* sh_a;
demuxer = demux_open_avi(demuxer);
@@ -870,9 +873,9 @@ static demuxer_t* demux_open_hack_avi(demuxer_t *demuxer)
stream_t* s;
demuxer_t *od;
s = new_ds_stream(demuxer->audio);
- od = new_demuxer(s,DEMUXER_TYPE_OGG,-1,-2,-2,NULL);
+ od = new_demuxer(opts, s,DEMUXER_TYPE_OGG,-1,-2,-2,NULL);
if(!demux_ogg_open(od)) {
- mp_msg( MSGT_DEMUXER,MSGL_ERR,MSGTR_ErrorOpeningOGGDemuxer);
+ mp_tmsg( MSGT_DEMUXER,MSGL_ERR,"Unable to open the Ogg demuxer.\n");
free_stream(s);
demuxer->audio->id = -2;
} else
diff --git a/libmpdemux/demux_avs.c b/libmpdemux/demux_avs.c
index e52afea4dd..d8bdad6676 100644
--- a/libmpdemux/demux_avs.c
+++ b/libmpdemux/demux_avs.c
@@ -85,7 +85,7 @@ typedef struct tagAVS
imp_avs_get_audio avs_get_audio;
} AVS_T;
-AVS_T *initAVS(const char *filename)
+static AVS_T *initAVS(const char *filename)
{
AVS_T *AVS = malloc (sizeof(AVS_T));
AVS_Value arg0 = avs_new_value_string(filename);
diff --git a/libmpdemux/demux_demuxers.c b/libmpdemux/demux_demuxers.c
index 8f48cf77c1..483dd02c30 100644
--- a/libmpdemux/demux_demuxers.c
+++ b/libmpdemux/demux_demuxers.c
@@ -25,6 +25,7 @@
#include "stream/stream.h"
#include "demuxer.h"
#include "stheader.h"
+#include "talloc.h"
typedef struct dd_priv {
demuxer_t* vd;
@@ -38,7 +39,7 @@ demuxer_t* new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd) {
demuxer_t* ret;
dd_priv_t* priv;
- ret = calloc(1,sizeof(demuxer_t));
+ ret = talloc_zero(NULL, struct demuxer);
priv = malloc(sizeof(dd_priv_t));
priv->vd = vd;
@@ -77,7 +78,7 @@ static int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds) {
else if(ds->demuxer == priv->sd)
return demux_fill_buffer(priv->sd,ds);
- mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MPDEMUX_DEMUXERS_FillBufferError);
+ mp_tmsg(MSGT_DEMUX,MSGL_WARN,"fill_buffer error: bad demuxer: not vd, ad or sd.\n");
return 0;
}
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index 800e7eb3f2..310ec83c09 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -22,8 +22,10 @@
#include <stdlib.h>
// #include <unistd.h>
#include <limits.h>
+#include <stdbool.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "av_opts.h"
@@ -43,9 +45,6 @@
#define PROBE_BUF_SIZE (32*1024)
-extern char *audio_lang;
-extern char *dvdsub_lang;
-extern int dvdsub_id;
static unsigned int opt_probesize = 0;
static unsigned int opt_analyzeduration = 0;
static char *opt_format;
@@ -229,7 +228,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
WAVEFORMATEX *wf;
sh_audio_t* sh_audio;
sh_audio=new_sh_audio(demuxer, i);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "lavf", i);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "lavf", i);
if(!sh_audio)
break;
priv->astreams[priv->audio_streams] = i;
@@ -310,7 +309,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
sh_video_t* sh_video;
BITMAPINFOHEADER *bih;
sh_video=new_sh_video(demuxer, i);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "lavf", i);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Video stream found, -vid %d\n", "lavf", i);
if(!sh_video) break;
priv->vstreams[priv->video_streams] = i;
priv->video_streams++;
@@ -388,7 +387,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
else
break;
sh_sub = new_sh_sub_sid(demuxer, i, priv->sub_streams);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_SubtitleID, "lavf", priv->sub_streams);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Subtitle stream found, -sid %d\n", "lavf", priv->sub_streams);
if(!sh_sub) break;
priv->sstreams[priv->sub_streams] = i;
sh_sub->type = type;
@@ -419,6 +418,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
}
static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
+ struct MPOpts *opts = demuxer->opts;
AVFormatContext *avfc;
AVFormatParameters ap;
const AVOption *opt;
@@ -434,7 +434,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
if (opt_cryptokey)
parse_cryptokey(avfc, opt_cryptokey);
- if (user_correct_pts != 0)
+ if (opts->user_correct_pts != 0)
avfc->flags |= AVFMT_FLAG_GENPTS;
if (index_mode == 0)
avfc->flags |= AVFMT_FLAG_IGNIDX;
@@ -535,6 +535,8 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
demuxer->video->id=-2; // audio-only
} //else if (best_video > 0 && demuxer->video->id == -1) demuxer->video->id = best_video;
+ demuxer->accurate_seek = true;
+
return demuxer;
}
@@ -610,10 +612,14 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, float audio
mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %f, %d)\n", demuxer, rel_seek_secs, audio_delay, flags);
if (flags & SEEK_ABSOLUTE) {
- priv->last_pts = priv->avfc->start_time;
+ priv->last_pts = 0;
} else {
if (rel_seek_secs < 0) avsflags = AVSEEK_FLAG_BACKWARD;
}
+ if (flags & SEEK_FORWARD)
+ avsflags = 0;
+ else if (flags & SEEK_BACKWARD)
+ avsflags = AVSEEK_FLAG_BACKWARD;
if (flags & SEEK_FACTOR) {
if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE)
return;
diff --git a/libmpdemux/demux_lmlm4.c b/libmpdemux/demux_lmlm4.c
index 9657db2f1a..c091fd1ba0 100644
--- a/libmpdemux/demux_lmlm4.c
+++ b/libmpdemux/demux_lmlm4.c
@@ -344,14 +344,14 @@ static demuxer_t* demux_open_lmlm4(demuxer_t* demuxer){
demuxer->seekable = 0;
if(!ds_fill_buffer(demuxer->video)){
- mp_msg(MSGT_DEMUXER,MSGL_INFO,"LMLM4: " MSGTR_MissingVideoStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_INFO,"LMLM4: " "No video stream found.\n");
demuxer->video->sh=NULL;
} else {
sh_video=demuxer->video->sh;sh_video->ds=demuxer->video;
}
if(demuxer->audio->id!=-2) {
if(!ds_fill_buffer(demuxer->audio)){
- mp_msg(MSGT_DEMUXER,MSGL_INFO,"LMLM4: " MSGTR_MissingAudioStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_INFO,"LMLM4: " "No audio stream found -> no sound.\n");
demuxer->audio->sh=NULL;
} else {
sh_audio=demuxer->audio->sh;sh_audio->ds=demuxer->audio;
diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c
index cb4d971755..4f44646b56 100644
--- a/libmpdemux/demux_mkv.c
+++ b/libmpdemux/demux_mkv.c
@@ -27,7 +27,10 @@
#include <stdio.h>
#include <ctype.h>
#include <inttypes.h>
+#include <stdbool.h>
+#include "talloc.h"
+#include "options.h"
#include "stream/stream.h"
#include "demuxer.h"
#include "stheader.h"
@@ -70,13 +73,12 @@ static const unsigned char sipr_swaps[38][2]={
#define ATRC_FLAVORS 8
#define COOK_FLAVORS 34
static const int sipr_fl2bps[SIPR_FLAVORS] = {813, 1062, 625, 2000};
-static const int atrc_fl2bps[ATRC_FLAVORS] =
- {8269, 11714, 13092, 16538, 18260, 22050, 33075, 44100};
-static const int cook_fl2bps[COOK_FLAVORS] =
- { 1000, 1378, 2024, 2584, 4005, 5513, 8010, 4005, 750, 2498,
- 4048, 5513, 8010, 11973, 8010, 2584, 4005, 2067, 2584, 2584,
- 4005, 4005, 5513, 5513, 8010, 12059, 1550, 8010, 12059, 5513,
- 12016, 16408, 22911, 33506};
+static const int atrc_fl2bps[ATRC_FLAVORS] = {8269, 11714, 13092, 16538, 18260, 22050, 33075, 44100};
+static const int cook_fl2bps[COOK_FLAVORS] = {
+ 1000, 1378, 2024, 2584, 4005, 5513, 8010, 4005, 750, 2498,
+ 4048, 5513, 8010, 11973, 8010, 2584, 4005, 2067, 2584, 2584,
+ 4005, 4005, 5513, 5513, 8010, 12059, 1550, 8010, 12059, 5513,
+ 12016, 16408, 22911, 33506};
typedef struct
{
@@ -108,7 +110,7 @@ typedef struct mkv_track
int default_track;
- void *private_data;
+ unsigned char *private_data;
unsigned int private_size;
/* stuff for realmedia */
@@ -166,8 +168,7 @@ typedef struct mkv_demuxer
mkv_track_t **tracks;
int num_tracks;
- uint64_t tc_scale, cluster_tc, first_tc;
- int has_first_tc;
+ uint64_t tc_scale, cluster_tc;
uint64_t cluster_size;
uint64_t blockgroup_size;
@@ -186,8 +187,6 @@ typedef struct mkv_demuxer
int64_t skip_to_timecode;
int v_skip_to_keyframe, a_skip_to_keyframe;
- int64_t stop_timecode;
-
int last_aid;
int audio_tracks[MAX_A_STREAMS];
} mkv_demuxer_t;
@@ -197,20 +196,16 @@ typedef struct mkv_demuxer
#define RAPROPERTIES4_SIZE 56
#define RAPROPERTIES5_SIZE 70
-/* for e.g. "-slang ger" */
-extern char *dvdsub_lang;
-extern char *audio_lang;
-extern int dvdsub_id;
-
/**
* \brief ensures there is space for at least one additional element
* \param array array to grow
* \param nelem current number of elements in array
* \param elsize size of one array element
*/
-static void grow_array(void **array, int nelem, size_t elsize) {
+static void *grow_array(void *array, int nelem, size_t elsize) {
if (!(nelem & 31))
- *array = realloc(*array, (nelem + 32) * elsize);
+ array = realloc(array, (nelem + 32) * elsize);
+ return array;
}
static mkv_track_t *
@@ -235,8 +230,9 @@ add_cluster_position (mkv_demuxer_t *mkv_d, uint64_t position)
if (mkv_d->cluster_positions[i] == position)
return;
- grow_array(&mkv_d->cluster_positions, mkv_d->num_cluster_pos,
- sizeof(uint64_t));
+ mkv_d->cluster_positions = grow_array(mkv_d->cluster_positions,
+ mkv_d->num_cluster_pos,
+ sizeof(uint64_t));
mkv_d->cluster_positions[mkv_d->num_cluster_pos++] = position;
}
@@ -326,8 +322,8 @@ demux_mkv_decode (mkv_track_t *track, uint8_t *src, uint8_t **dest,
zstream.opaque = (voidpf) 0;
if (inflateInit (&zstream) != Z_OK)
{
- mp_msg (MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_ZlibInitializationFailed);
+ mp_tmsg (MSGT_DEMUX, MSGL_WARN,
+ "[mkv] zlib initialization failed.\n");
return modified;
}
zstream.next_in = (Bytef *) src;
@@ -343,8 +339,8 @@ demux_mkv_decode (mkv_track_t *track, uint8_t *src, uint8_t **dest,
result = inflate (&zstream, Z_NO_FLUSH);
if (result != Z_OK && result != Z_STREAM_END)
{
- mp_msg (MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_ZlibDecompressionFailed);
+ mp_tmsg (MSGT_DEMUX, MSGL_WARN,
+ "[mkv] zlib decompression failed.\n");
free(*dest);
*dest = NULL;
inflateEnd (&zstream);
@@ -375,8 +371,8 @@ demux_mkv_decode (mkv_track_t *track, uint8_t *src, uint8_t **dest,
if (!(result & AV_LZO_OUTPUT_FULL))
{
lzo_fail:
- mp_msg (MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_LzoDecompressionFailed);
+ mp_tmsg (MSGT_DEMUX, MSGL_WARN,
+ "[mkv] lzo decompression failed.\n");
free(*dest);
*dest = NULL;
return modified;
@@ -393,52 +389,67 @@ lzo_fail:
}
-static int
-demux_mkv_read_info (demuxer_t *demuxer)
+static int demux_mkv_read_info(demuxer_t *demuxer)
{
- mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
- stream_t *s = demuxer->stream;
- uint64_t length, l;
- int il;
- uint64_t tc_scale = 1000000;
- long double duration = 0.;
-
- length = ebml_read_length (s, NULL);
- while (length > 0)
- {
- switch (ebml_read_id (s, &il))
- {
+ mkv_demuxer_t *mkv_d = demuxer->priv;
+ stream_t *s = demuxer->stream;
+ uint64_t length, l;
+ int i;
+ uint64_t tc_scale = 1000000;
+ long double duration = 0.;
+
+ length = ebml_read_length(s, NULL);
+ while (length > 0) {
+ uint32_t id = ebml_read_id(s, &i);
+ length -= i;
+ switch (id) {
case MATROSKA_ID_TIMECODESCALE:
- {
- uint64_t num = ebml_read_uint (s, &l);
- if (num == EBML_UINT_INVALID)
- return 1;
- tc_scale = num;
- mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + timecode scale: %"PRIu64"\n",
+ tc_scale = ebml_read_uint(s, &l);
+ length -= l;
+ if (tc_scale == EBML_UINT_INVALID)
+ return 1;
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + timecode scale: %"PRIu64"\n",
tc_scale);
break;
- }
case MATROSKA_ID_DURATION:
- {
- long double num = ebml_read_float (s, &l);
- if (num == EBML_FLOAT_INVALID)
- return 1;
- duration = num;
- mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + duration: %.3Lfs\n",
- duration * tc_scale / 1000000000.0);
+ duration = ebml_read_float(s, &l);
+ length -= l;
+ if (duration == EBML_FLOAT_INVALID)
+ return 1;
+ break;
+
+ case MATROSKA_ID_SEGMENTUID:;
+ l = ebml_read_length(s, &i);
+ length -= i;
+ if (l != sizeof(demuxer->matroska_data.segment_uid)) {
+ mp_msg(MSGT_DEMUX, MSGL_INFO,
+ "[mkv] segment uid invalid length %"PRIu64"\n", l);
+ stream_skip(s, l);
+ } else {
+ stream_read(s, demuxer->matroska_data.segment_uid, l);
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + segment uid");
+ for (int i = 0; i < l; i++)
+ mp_msg(MSGT_DEMUX, MSGL_V, " %02x",
+ demuxer->matroska_data.segment_uid[i]);
+ mp_msg(MSGT_DEMUX, MSGL_V, "\n");
+ }
+ length -= l;
break;
- }
default:
- ebml_read_skip (s, &l);
- break;
+ ebml_read_skip(s, &l);
+ length -= l;
+ break;
}
- length -= l + il;
}
- mkv_d->tc_scale = tc_scale;
- mkv_d->duration = duration * tc_scale / 1000000000.0;
- return 0;
+ mkv_d->tc_scale = tc_scale;
+ mkv_d->duration = duration * tc_scale / 1000000000.0;
+ if (duration)
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + duration: %.3fs\n",
+ mkv_d->duration);
+
+ return 0;
}
/**
@@ -548,26 +559,26 @@ demux_mkv_read_trackencodings (demuxer_t *demuxer, mkv_track_t *track)
if (e.type == 1)
{
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_TrackEncrypted, track->tnum);
+ mp_tmsg(MSGT_DEMUX, MSGL_WARN,
+ "[mkv] Track number %u has been encrypted and decryption has not yet been\n[mkv] implemented. Skipping track.\n", track->tnum);
}
else if (e.type != 0)
{
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_UnknownContentEncoding, track->tnum);
+ mp_tmsg(MSGT_DEMUX, MSGL_WARN,
+ "[mkv] Unknown content encoding type for track %u. Skipping track.\n", track->tnum);
}
if (e.comp_algo != 0 && e.comp_algo != 2)
{
- mp_msg (MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_UnknownCompression,
+ mp_tmsg (MSGT_DEMUX, MSGL_WARN,
+ "[mkv] Track %u has been compressed with an unknown/unsupported compression\n[mkv] algorithm (%u). Skipping track.\n",
track->tnum, e.comp_algo);
}
#if !CONFIG_ZLIB
else if (e.comp_algo == 0)
{
- mp_msg (MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_ZlibCompressionUnsupported,
+ mp_tmsg (MSGT_DEMUX, MSGL_WARN,
+ "[mkv] Track %u was compressed with zlib but mplayer has not been compiled\n[mkv] with support for zlib compression. Skipping track.\n",
track->tnum);
}
#endif
@@ -1079,7 +1090,8 @@ demux_mkv_read_cues (demuxer_t *demuxer)
if (time != EBML_UINT_INVALID && track != EBML_UINT_INVALID
&& pos != EBML_UINT_INVALID)
{
- grow_array(&mkv_d->indexes, mkv_d->num_indexes, sizeof(mkv_index_t));
+ mkv_d->indexes = grow_array(mkv_d->indexes, mkv_d->num_indexes,
+ sizeof(mkv_index_t));
mkv_d->indexes[mkv_d->num_indexes].tnum = track;
mkv_d->indexes[mkv_d->num_indexes].timecode = time;
mkv_d->indexes[mkv_d->num_indexes].filepos =mkv_d->segment_start+pos;
@@ -1094,140 +1106,175 @@ demux_mkv_read_cues (demuxer_t *demuxer)
return 0;
}
-static int
-demux_mkv_read_chapters (demuxer_t *demuxer)
+static uint64_t read_one_chapter(struct demuxer *demuxer, stream_t *s)
{
- stream_t *s = demuxer->stream;
- uint64_t length, l;
- int il;
-
- if (demuxer->chapters)
- {
- ebml_read_skip (s, NULL);
- return 0;
- }
-
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing chapters ] ---------\n");
- length = ebml_read_length (s, NULL);
-
- while (length > 0)
- {
- switch (ebml_read_id (s, &il))
- {
- case MATROSKA_ID_EDITIONENTRY:
- {
- uint64_t len;
- int i;
-
- len = ebml_read_length (s, &i);
- l = len + i;
+ uint64_t len, l;
+ uint64_t start = 0, end = 0;
+ struct matroska_chapter chapter = {};
+ char *name = 0;
+ int i;
+ uint32_t id;
+
+ len = ebml_read_length(s, &i);
+ uint64_t bytes_read = len + i;
+
+ while (len > 0) {
+ id = ebml_read_id(s, &i);
+ len -= i;
+ switch (id) {
+ case MATROSKA_ID_CHAPTERTIMESTART:
+ start = ebml_read_uint(s, &l) / 1000000;
+ len -= l;
+ break;
- while (len > 0)
- {
- uint64_t l;
- int il;
+ case MATROSKA_ID_CHAPTERTIMEEND:
+ end = ebml_read_uint(s, &l) / 1000000;
+ len -= l;
+ break;
- switch (ebml_read_id (s, &il))
- {
- case MATROSKA_ID_CHAPTERATOM:
- {
- uint64_t len, start=0, end=0;
- char* name = 0;
- int i;
- int cid;
+ case MATROSKA_ID_CHAPTERDISPLAY:;
+ uint64_t displaylen = ebml_read_length(s, &i);
+ len -= displaylen + i;
+ while (displaylen > 0) {
+ id = ebml_read_id(s, &i);
+ displaylen -= i;
+ switch (id) {
+ case MATROSKA_ID_CHAPSTRING:
+ name = ebml_read_utf8(s, &l);
+ break;
+ default:
+ ebml_read_skip(s, &l);
+ break;
+ }
+ displaylen -= l;
+ }
+ break;
- len = ebml_read_length (s, &i);
- l = len + i;
+ case MATROSKA_ID_CHAPTERSEGMENTUID:
+ l = ebml_read_length(s, &i);
+ len -= l + i;
+ if (l != sizeof(chapter.segment_uid)) {
+ mp_msg(MSGT_DEMUX, MSGL_INFO,
+ "[mkv] chapter segment uid invalid length %"PRIu64"\n",
+ l);
+ stream_skip(s, l);
+ } else {
+ stream_read(s, chapter.segment_uid, l);
+ chapter.has_segment_uid = true;
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Chapter segment uid ");
+ for (int i = 0; i < l; i++)
+ mp_msg(MSGT_DEMUX, MSGL_V, "%02x ", chapter.segment_uid[i]);
+ mp_msg(MSGT_DEMUX, MSGL_V, "\n");
+ }
+ break;
- while (len > 0)
- {
- uint64_t l;
- int il;
+ default:
+ ebml_read_skip(s, &l);
+ len -= l;
+ break;
+ }
+ }
- switch (ebml_read_id (s, &il))
- {
- case MATROSKA_ID_CHAPTERTIMESTART:
- start = ebml_read_uint (s, &l) / 1000000;
- break;
+ if (!name)
+ name = strdup("(unnamed)");
+
+ int cid = demuxer_add_chapter(demuxer, name, start, end);
+ struct matroska_data *m = &demuxer->matroska_data;
+ m->ordered_chapters = talloc_realloc(demuxer, m->ordered_chapters,
+ struct matroska_chapter,
+ m->num_ordered_chapters + 1);
+ chapter.start = start;
+ chapter.end = end;
+ chapter.name = talloc_strdup(m->ordered_chapters, name);
+ // Will be undone later if this is a normal chapter rather than ordered
+ m->ordered_chapters[m->num_ordered_chapters] = chapter;
+ m->num_ordered_chapters++;
+
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Chapter %u from %02d:%02d:%02d."
+ "%03d to %02d:%02d:%02d.%03d, %s\n",
+ cid,
+ (int) (start / 60 / 60 / 1000),
+ (int) ((start / 60 / 1000) % 60),
+ (int) ((start / 1000) % 60),
+ (int) (start % 1000),
+ (int) (end / 60 / 60 / 1000),
+ (int) ((end / 60 / 1000) % 60),
+ (int) ((end / 1000) % 60),
+ (int) (end % 1000), name);
+
+ free(name);
+ return bytes_read;
+}
- case MATROSKA_ID_CHAPTERTIMEEND:
- end = ebml_read_uint (s, &l) / 1000000;
- break;
+static int demux_mkv_read_chapters(struct demuxer *demuxer)
+{
+ stream_t *s = demuxer->stream;
+ uint64_t length, l;
+ int i;
+ uint32_t id;
- case MATROSKA_ID_CHAPTERDISPLAY:
- {
- uint64_t len;
- int i;
-
- len = ebml_read_length (s, &i);
- l = len + i;
- while (len > 0)
- {
- uint64_t l;
- int il;
-
- switch (ebml_read_id (s, &il))
- {
- case MATROSKA_ID_CHAPSTRING:
- name = ebml_read_utf8 (s, &l);
- break;
- default:
- ebml_read_skip (s, &l);
- break;
- }
- len -= l + il;
- }
- }
- break;
+ if (demuxer->chapters) {
+ ebml_read_skip(s, NULL);
+ return 0;
+ }
- default:
- ebml_read_skip (s, &l);
- break;
- }
- len -= l + il;
- }
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing chapters ] ---------\n");
+ length = ebml_read_length(s, NULL);
- if (!name)
- name = strdup("(unnamed)");
-
- cid = demuxer_add_chapter(demuxer, name, start, end);
-
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] Chapter %u from %02d:%02d:%02d."
- "%03d to %02d:%02d:%02d.%03d, %s\n",
- cid,
- (int) (start / 60 / 60 / 1000),
- (int) ((start / 60 / 1000) % 60),
- (int) ((start / 1000) % 60),
- (int) (start % 1000),
- (int) (end / 60 / 60 / 1000),
- (int) ((end / 60 / 1000) % 60),
- (int) ((end / 1000) % 60),
- (int) (end % 1000), name);
-
- free(name);
- break;
- }
+ bool have_edition = false;
+ while (length > 0) {
+ id = ebml_read_id(s, &i);
+ length -= i;
+ switch (id) {
+ case MATROSKA_ID_EDITIONENTRY:
+ if (have_edition) {
+ mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Multiple edition entries"
+ " - ignoring all but first!\n");
+ ebml_read_skip(s, &l);
+ length -= l;
+ break;
+ }
+ have_edition = true;
+ uint64_t editionlen = ebml_read_length(s, &i);
+ length -= editionlen + i;
+ bool ordered = false;
+ while (editionlen > 0) {
+ id = ebml_read_id(s, &i);
+ editionlen -= i;
+ switch (id) {
+ case MATROSKA_ID_CHAPTERATOM:
+ l = read_one_chapter(demuxer, s);
+ break;
+ case MATROSKA_ID_EDITIONFLAGORDERED:
+ ordered = ebml_read_uint(s, &l);
+ mp_msg(MSGT_DEMUX, MSGL_V,
+ "[mkv] Ordered chapter flag: %d\n", ordered);
+ break;
- default:
- ebml_read_skip (s, &l);
+ default:
+ ebml_read_skip(s, &l);
break;
- }
- len -= l + il;
- }
+ }
+ editionlen -= l;
+ }
+ if (!ordered) {
+ // The chapters should be interpreted as normal ones,
+ // so undo the addition of this information.
+ talloc_free(demuxer->matroska_data.ordered_chapters);
+ demuxer->matroska_data.ordered_chapters = NULL;
+ demuxer->matroska_data.num_ordered_chapters = 0;
+ }
break;
- }
default:
- ebml_read_skip (s, &l);
- break;
+ ebml_read_skip(s, &l);
+ length -= l;
+ break;
}
-
- length -= l + il;
}
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing chapters ] ---------\n");
- return 0;
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing chapters ] ---------\n");
+ return 0;
}
static int
@@ -1501,10 +1548,10 @@ display_create_tracks (demuxer_t *demuxer)
break;
}
if (mkv_d->tracks[i]->name)
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_TrackIDName,
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: %s (%s) \"%s\", %s\n",
mkv_d->tracks[i]->tnum, type, mkv_d->tracks[i]->codec_id, mkv_d->tracks[i]->name, str);
else
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_TrackID,
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: %s (%s), %s\n",
mkv_d->tracks[i]->tnum, type, mkv_d->tracks[i]->codec_id, str);
}
}
@@ -1529,6 +1576,7 @@ static const videocodec_info_t vinfo[] = {
static int
demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid)
{
+ struct MPOpts *opts = demuxer->opts;
BITMAPINFOHEADER *bih;
void *ImageDesc = NULL;
sh_video_t *sh_v;
@@ -1639,9 +1687,9 @@ demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid)
bih = realloc (bih, bih->biSize);
memcpy (bih + 1, track->private_data, track->private_size);
}
- track->reorder_timecodes = user_correct_pts == 0;
+ track->reorder_timecodes = opts->user_correct_pts == 0;
if (!vi->id) {
- mp_msg (MSGT_DEMUX,MSGL_WARN, MSGTR_MPDEMUX_MKV_UnknownCodecID,
+ mp_tmsg (MSGT_DEMUX,MSGL_WARN, "[mkv] Unknown/unsupported CodecID (%s) or missing/bad CodecPrivate\n[mkv] data (track %u).\n",
track->codec_id, track->tnum);
free(bih);
return 1;
@@ -1755,8 +1803,8 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
{
if (track->private_data == NULL || track->private_size == 0)
{
- mp_msg (MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_FlacTrackDoesNotContainValidHeaders);
+ mp_tmsg (MSGT_DEMUX, MSGL_WARN,
+ "[mkv] FLAC track does not contain valid headers.\n");
return 1;
}
track->a_formattag = mmioFOURCC ('f', 'L', 'a', 'C');
@@ -1776,7 +1824,7 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
}
else
{
- mp_msg (MSGT_DEMUX, MSGL_WARN, MSGTR_MPDEMUX_MKV_UnknownAudioCodec,
+ mp_tmsg (MSGT_DEMUX, MSGL_WARN, "[mkv] Unknown/unsupported audio codec ID '%s' for track %u or missing/faulty\n[mkv] private codec data.\n",
track->codec_id, track->tnum);
free_sh_audio(demuxer, track->tnum);
return 1;
@@ -1965,13 +2013,13 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
if (track->a_formattag == mmioFOURCC('f', 'L', 'a', 'C'))
{
- ptr = (unsigned char *)track->private_data;
+ ptr = track->private_data;
size = track->private_size;
}
else
{
sh_a->format = mmioFOURCC('f', 'L', 'a', 'C');
- ptr = (unsigned char *) track->private_data
+ ptr = track->private_data
+ sizeof (WAVEFORMATEX);
size = track->private_size - sizeof (WAVEFORMATEX);
}
@@ -2033,7 +2081,7 @@ demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid)
}
else
{
- mp_msg (MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_MKV_SubtitleTypeNotSupported,
+ mp_tmsg (MSGT_DEMUX, MSGL_ERR, "[mkv] Subtitle type '%s' is not supported.\n",
track->codec_id);
return 1;
}
@@ -2041,8 +2089,6 @@ demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid)
return 0;
}
-static void demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags);
-
static int
demux_mkv_open (demuxer_t *demuxer)
{
@@ -2132,8 +2178,6 @@ demux_mkv_open (demuxer_t *demuxer)
uint64_t num = ebml_read_uint (s, NULL);
if (num == EBML_UINT_INVALID)
return 0;
- mkv_d->first_tc = num * mkv_d->tc_scale / 1000000.0;
- mkv_d->has_first_tc = 1;
}
stream_seek (s, p - 4);
cont = 1;
@@ -2179,14 +2223,14 @@ demux_mkv_open (demuxer_t *demuxer)
if (track && demuxer->v_streams[track->tnum])
{
- mp_msg (MSGT_DEMUX, MSGL_INFO,
- MSGTR_MPDEMUX_MKV_WillPlayVideoTrack, track->tnum);
+ mp_tmsg (MSGT_DEMUX, MSGL_INFO,
+ "[mkv] Will play video track %u.\n", track->tnum);
demuxer->video->id = track->tnum;
demuxer->video->sh = demuxer->v_streams[track->tnum];
}
else
{
- mp_msg (MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_NoVideoTrackFound);
+ mp_tmsg (MSGT_DEMUX, MSGL_INFO, "[mkv] No video track found/wanted.\n");
demuxer->video->id = -2;
}
@@ -2219,7 +2263,7 @@ demux_mkv_open (demuxer_t *demuxer)
}
else
{
- mp_msg (MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_NoAudioTrackFound);
+ mp_tmsg (MSGT_DEMUX, MSGL_INFO, "[mkv] No audio track found/wanted.\n");
demuxer->audio->id = -2;
}
@@ -2237,22 +2281,6 @@ demux_mkv_open (demuxer_t *demuxer)
}
}
- if (demuxer->chapters)
- {
- for (i=0; i < (int)demuxer->num_chapters; i++)
- {
- demuxer->chapters[i].start -= mkv_d->first_tc;
- demuxer->chapters[i].end -= mkv_d->first_tc;
- }
- if (dvd_last_chapter > 0 && dvd_last_chapter <= demuxer->num_chapters)
- {
- if (demuxer->chapters[dvd_last_chapter-1].end != 0)
- mkv_d->stop_timecode = demuxer->chapters[dvd_last_chapter-1].end;
- else if (dvd_last_chapter + 1 <= demuxer->num_chapters)
- mkv_d->stop_timecode = demuxer->chapters[dvd_last_chapter].start;
- }
- }
-
if (s->end_pos == 0 || (mkv_d->indexes == NULL && index_mode < 0))
demuxer->seekable = 0;
else
@@ -2262,6 +2290,8 @@ demux_mkv_open (demuxer_t *demuxer)
demuxer->seekable = 1;
}
+ demuxer->accurate_seek = true;
+
return DEMUXER_TYPE_MATROSKA;
}
@@ -2383,7 +2413,7 @@ handle_subtitles(demuxer_t *demuxer, mkv_track_t *track, char *block,
if (block_duration == 0)
{
mp_msg (MSGT_DEMUX, MSGL_WARN,
- MSGTR_MPDEMUX_MKV_NoBlockDurationForSubtitleTrackFound);
+ "[mkv] Warning: No BlockDuration for subtitle track found.\n");
return;
}
@@ -2640,13 +2670,9 @@ handle_block (demuxer_t *demuxer, uint8_t *block, uint64_t length,
return 0;
block += old_length - length;
- tc = ((time*mkv_d->tc_scale+mkv_d->cluster_tc) /1000000.0 - mkv_d->first_tc);
+ tc = ((time*mkv_d->tc_scale+mkv_d->cluster_tc) /1000000.0);
if (tc < 0)
tc = 0;
- if (mkv_d->stop_timecode > 0 && tc > mkv_d->stop_timecode) {
- free(lace_size);
- return -1;
- }
current_pts = tc / 1000.0;
for (i=0; i<mkv_d->num_tracks; i++)
@@ -2869,11 +2895,6 @@ demux_mkv_fill_buffer (demuxer_t *demuxer, demux_stream_t *ds)
uint64_t num = ebml_read_uint (s, &l);
if (num == EBML_UINT_INVALID)
return 0;
- if (!mkv_d->has_first_tc)
- {
- mkv_d->first_tc = num * mkv_d->tc_scale / 1000000.0;
- mkv_d->has_first_tc = 1;
- }
mkv_d->cluster_tc = num * mkv_d->tc_scale;
break;
}
@@ -2929,6 +2950,16 @@ demux_mkv_fill_buffer (demuxer_t *demuxer, demux_stream_t *ds)
static void
demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
{
+ if (!(flags & (SEEK_BACKWARD | SEEK_FORWARD))) {
+ if (flags & SEEK_ABSOLUTE || rel_seek_secs < 0)
+ flags |= SEEK_BACKWARD;
+ else
+ flags |= SEEK_FORWARD;
+ }
+ // Adjust the target a little bit to catch cases where the target position
+ // specifies a keyframe with high, but not perfect, precision.
+ rel_seek_secs += flags & SEEK_FORWARD ? -0.001 : 0.001;
+
free_cached_dps (demuxer);
if (!(flags & SEEK_FACTOR)) /* time in secs */
{
@@ -2983,12 +3014,12 @@ demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int
for (i=0; i < mkv_d->num_cluster_pos; i++)
{
diff = mkv_d->cluster_positions[i] - target_filepos;
- if (rel_seek_secs < 0 && diff < 0 && -diff < min_diff)
+ if (flags & SEEK_BACKWARD && diff < 0 && -diff < min_diff)
{
cluster_pos = mkv_d->cluster_positions[i];
min_diff = -diff;
}
- else if (rel_seek_secs > 0
+ else if (flags & SEEK_FORWARD
&& (diff < 0 ? -1 * diff : diff) < min_diff)
{
cluster_pos = mkv_d->cluster_positions[i];
@@ -3009,17 +3040,17 @@ demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int
for (i=0; i < mkv_d->num_indexes; i++)
if (mkv_d->indexes[i].tnum == seek_id)
{
- diff = target_timecode + mkv_d->first_tc -
+ diff = target_timecode -
(int64_t) mkv_d->indexes[i].timecode * mkv_d->tc_scale / 1000000.0;
- if ((flags & SEEK_ABSOLUTE || target_timecode <= mkv_d->last_pts*1000)) {
- // Absolute seek or seek backward: find the last index
- // position before target time
+ if (flags & SEEK_BACKWARD) {
+ // Seek backward: find the last index position
+ // before target time
if (diff < 0 || diff >= min_diff)
continue;
}
else {
- // Relative seek forward: find the first index position
+ // Seek forward: find the first index position
// after target time. If no such index exists, find last
// position between current position and target time.
if (diff <= 0) {
@@ -3043,8 +3074,10 @@ demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int
if (demuxer->video->id >= 0)
mkv_d->v_skip_to_keyframe = 1;
- if (rel_seek_secs > 0.0)
+ if (flags & SEEK_FORWARD)
mkv_d->skip_to_timecode = target_timecode;
+ else
+ mkv_d->skip_to_timecode = 0;
mkv_d->a_skip_to_keyframe = 1;
demux_mkv_fill_buffer(demuxer, NULL);
diff --git a/libmpdemux/demux_mng.c b/libmpdemux/demux_mng.c
index 9d6005f44e..bab7430962 100644
--- a/libmpdemux/demux_mng.c
+++ b/libmpdemux/demux_mng.c
@@ -622,4 +622,3 @@ const demuxer_desc_t demuxer_desc_mng = {
demux_mng_seek,
demux_mng_control
};
-
diff --git a/libmpdemux/demux_mov.c b/libmpdemux/demux_mov.c
index e2c77a32e0..c38fa7ee16 100644
--- a/libmpdemux/demux_mov.c
+++ b/libmpdemux/demux_mov.c
@@ -165,7 +165,7 @@ typedef struct {
void* desc; // image/sound/etc description (pointer to ImageDescription etc)
} mov_track_t;
-void mov_build_index(mov_track_t* trak,int timescale){
+static void mov_build_index(mov_track_t* trak,int timescale){
int i,j,s;
int last=trak->chunks_size;
unsigned int pts=0;
@@ -1324,7 +1324,7 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak
case MOV_FOURCC('t','r','a','k'): {
// if(trak) printf("MOV: Warning! trak in trak?\n");
if(priv->track_db>=MOV_MAX_TRACKS){
- mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MOVtooManyTrk);
+ mp_tmsg(MSGT_DEMUX,MSGL_WARN,"MOV: WARNING: too many tracks");
return;
}
if(!priv->track_db) mp_msg(MSGT_DEMUX, MSGL_V, "--------------\n");
@@ -1338,13 +1338,13 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak
switch(trak->type){
case MOV_TRAK_AUDIO: {
sh_audio_t* sh=new_sh_audio(demuxer,priv->track_db);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "mov", priv->track_db);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "mov", priv->track_db);
gen_sh_audio(sh, trak, priv->timescale);
break;
}
case MOV_TRAK_VIDEO: {
sh_video_t* sh=new_sh_video(demuxer,priv->track_db);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "mov", priv->track_db);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Video stream found, -vid %d\n", "mov", priv->track_db);
gen_sh_video(sh, trak, priv->timescale);
break;
}
@@ -1353,7 +1353,7 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak
trak->fourcc == mmioFOURCC('t','x','3','g') ||
trak->fourcc == mmioFOURCC('t','e','x','t')) {
sh_sub_t *sh = new_sh_sub(demuxer, priv->track_db);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_SubtitleID, "mov", priv->track_db);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Subtitle stream found, -sid %d\n", "mov", priv->track_db);
if (trak->fourcc == mmioFOURCC('m','p','4','s'))
init_vobsub(sh, trak);
else {
@@ -1419,13 +1419,13 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak
}
#if !CONFIG_ZLIB
case MOV_FOURCC('c','m','o','v'): {
- mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVcomprhdr);
+ mp_tmsg(MSGT_DEMUX,MSGL_ERR,"MOV: Compressed headers support requires ZLIB!\n");
return;
}
#else
case MOV_FOURCC('m','o','o','v'):
case MOV_FOURCC('c','m','o','v'): {
-// mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVcomprhdr);
+// mp_tmsg(MSGT_DEMUX,MSGL_ERR,"MOV: Compressed headers support requires ZLIB!\n");
lschunks(demuxer,level+1,pos+len,NULL);
break;
}
@@ -1749,7 +1749,7 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id,
"MOV: %*s desc #%d: %.4s (%"PRId64" bytes)\n", level, "",
i, (char *)&fourcc, (int64_t)len - 16);
if (fourcc != trak->fourcc && i)
- mp_msg(MSGT_DEMUX, MSGL_WARN, MSGTR_MOVvariableFourCC);
+ mp_tmsg(MSGT_DEMUX, MSGL_WARN, "MOV: WARNING: Variable FourCC detected!?\n");
// if(!i)
{
trak->fourcc = fourcc;
@@ -1938,6 +1938,7 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id,
}
static demuxer_t* mov_read_header(demuxer_t* demuxer){
+ struct MPOpts *opts = demuxer->opts;
mov_priv_t* priv=demuxer->priv;
int t_no;
int best_a_id=-1, best_a_len=0;
@@ -2013,7 +2014,7 @@ static demuxer_t* mov_read_header(demuxer_t* demuxer){
demuxer->video->id = t_no;
s = new_ds_stream(demuxer->video);
- od = demux_open(s, DEMUXER_TYPE_MPEG_PS, -1, -1, -1, NULL);
+ od = demux_open(opts, s, DEMUXER_TYPE_MPEG_PS, -1, -1, -1, NULL);
if(od) return new_demuxers_demuxer(od, od, od);
demuxer->video->id = -2; //new linked demuxer couldn't be allocated
break;
diff --git a/libmpdemux/demux_mpg.c b/libmpdemux/demux_mpg.c
index 09bcd95178..4de5cd5e4f 100644
--- a/libmpdemux/demux_mpg.c
+++ b/libmpdemux/demux_mpg.c
@@ -725,9 +725,9 @@ static int demux_mpg_probe(demuxer_t *demuxer) {
} else
{
if(demuxer->synced==2)
- mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug);
+ mp_tmsg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " "Missing video stream!? Contact the author, it may be a bug :(\n");
else
- mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_NotSystemStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_V,"Not MPEG System Stream format... (maybe Transport Stream?)\n");
}
}
//FIXME this shouldn't be necessary
@@ -813,7 +813,7 @@ static int demux_mpg_gxf_fill_buffer(demuxer_t *demux, demux_stream_t *ds) {
return 1;
}
-int demux_mpg_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
+static int demux_mpg_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
unsigned int head=0;
int skipped=0;
int max_packs=256; // 512kbyte
@@ -866,7 +866,7 @@ do{
if(!ret)
if(--max_packs==0){
demux->stream->eof=1;
- mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_DoesntContainSelectedStream);
+ mp_tmsg(MSGT_DEMUX,MSGL_ERR,"demux: File doesn't contain the selected audio or video stream.\n");
return 0;
}
if(demux->synced==3) demux->synced=(ret==1)?2:0; // PES detect
@@ -900,7 +900,7 @@ do{
void skip_audio_frame(sh_audio_t *sh_audio);
-void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,float audio_delay, int flags){
+static void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,float audio_delay, int flags){
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
sh_audio_t *sh_audio=d_audio->sh;
@@ -1006,7 +1006,7 @@ void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,float audio_delay, in
}
}
-int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
+static int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
mpg_demuxer_t *mpg_d=(mpg_demuxer_t*)demuxer->priv;
switch(cmd) {
@@ -1101,7 +1101,7 @@ static demuxer_t* demux_mpg_ps_open(demuxer_t* demuxer)
if(demuxer->audio->id!=-2) {
if(!ds_fill_buffer(demuxer->audio)){
- mp_msg(MSGT_DEMUXER,MSGL_INFO,"MPEG: " MSGTR_MissingAudioStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_INFO,"MPEG: " "No audio stream found -> no sound.\n");
demuxer->audio->sh=NULL;
} else {
sh_audio=demuxer->audio->sh;sh_audio->ds=demuxer->audio;
diff --git a/libmpdemux/demux_nemesi.c b/libmpdemux/demux_nemesi.c
index a252c8c984..704c31e4b1 100644
--- a/libmpdemux/demux_nemesi.c
+++ b/libmpdemux/demux_nemesi.c
@@ -455,7 +455,7 @@ static void demux_seek_rtp(demuxer_t *demuxer, float rel_seek_secs,
mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported seek type\n");
}
-static int demux_rtp_control(struct demuxer_st *demuxer, int cmd, void *arg)
+static int demux_rtp_control(struct demuxer *demuxer, int cmd, void *arg)
{
Nemesi_DemuxerStreamData * ndsd = demuxer->priv;
rtsp_ctrl * ctl = ndsd->rtsp;
diff --git a/libmpdemux/demux_nut.c b/libmpdemux/demux_nut.c
index 559d839653..7054b0d054 100644
--- a/libmpdemux/demux_nut.c
+++ b/libmpdemux/demux_nut.c
@@ -115,7 +115,7 @@ static demuxer_t * demux_open_nut(demuxer_t * demuxer) {
s[i].codec_specific_len, 1);
sh_audio_t* sh_audio = new_sh_audio(demuxer, i);
int j;
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "nut", i);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "nut", i);
sh_audio->wf= wf; sh_audio->ds = demuxer->audio;
sh_audio->audio.dwSampleSize = 0; // FIXME
@@ -151,7 +151,7 @@ static demuxer_t * demux_open_nut(demuxer_t * demuxer) {
s[i].codec_specific_len, 1);
sh_video_t * sh_video = new_sh_video(demuxer, i);
int j;
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "nut", i);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Video stream found, -vid %d\n", "nut", i);
sh_video->bih = bih;
sh_video->ds = demuxer->video;
diff --git a/libmpdemux/demux_ogg.c b/libmpdemux/demux_ogg.c
index 2667b4ce1b..af730bb712 100644
--- a/libmpdemux/demux_ogg.c
+++ b/libmpdemux/demux_ogg.c
@@ -25,6 +25,7 @@
#include <math.h>
#include <inttypes.h>
+#include "options.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "stream/stream.h"
@@ -163,7 +164,6 @@ typedef struct ogg_demuxer {
#define PACKET_IS_SYNCPOINT 0x08
extern char *dvdsub_lang, *audio_lang;
-extern int dvdsub_id;
//-------- subtitle support - should be moved to decoder layer, and queue
// - subtitles up in demuxer buffer...
@@ -175,7 +175,7 @@ extern int dvdsub_id;
static subtitle ogg_sub;
//FILE* subout;
-void demux_ogg_add_sub (ogg_stream_t* os,ogg_packet* pack) {
+static void demux_ogg_add_sub (ogg_stream_t* os,ogg_packet* pack) {
int lcv;
char *packet = pack->packet;
@@ -412,7 +412,7 @@ static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os, int id, vor
if (os->text && d->sub->id < 0 && demux_ogg_check_lang(val, dvdsub_lang))
{
d->sub->id = index;
- dvdsub_id = index;
+ d->opts->sub_id = index;
mp_msg(MSGT_DEMUX, MSGL_V, "Ogg demuxer: Displaying subtitle stream id %d which matched -slang %s\n", id, val);
}
else
@@ -508,7 +508,7 @@ static int demux_ogg_add_packet(demux_stream_t* ds,ogg_stream_t* os,int id,ogg_p
/// if -forceidx build a table of all syncpoints to make seeking easier
/// otherwise try to get at least the final_granulepos
-void demux_ogg_scan_stream(demuxer_t* demuxer) {
+static void demux_ogg_scan_stream(demuxer_t* demuxer) {
ogg_demuxer_t* ogg_d = demuxer->priv;
stream_t *s = demuxer->stream;
ogg_sync_state* sync = &ogg_d->sync;
@@ -1233,6 +1233,7 @@ static int demux_ogg_fill_buffer(demuxer_t *d, demux_stream_t *dsds) {
/// For avi with Ogg audio stream we have to create an ogg demuxer for this
// stream, then we join the avi and ogg demuxer with a demuxers demuxer
demuxer_t* init_avi_with_ogg(demuxer_t* demuxer) {
+ struct MPOpts *opts = demuxer->opts;
demuxer_t *od;
ogg_demuxer_t *ogg_d;
stream_t* s;
@@ -1294,7 +1295,7 @@ demuxer_t* init_avi_with_ogg(demuxer_t* demuxer) {
// Create the ds_stream and the ogg demuxer
s = new_ds_stream(demuxer->audio);
- od = new_demuxer(s,DEMUXER_TYPE_OGG,0,-2,-2,NULL);
+ od = new_demuxer(opts, s,DEMUXER_TYPE_OGG,0,-2,-2,NULL);
/// Add the header packets in the ogg demuxer audio stream
for (i = 0; i < 3; i++) {
diff --git a/libmpdemux/demux_pva.c b/libmpdemux/demux_pva.c
index 29c705fb4d..ee9b4158bd 100644
--- a/libmpdemux/demux_pva.c
+++ b/libmpdemux/demux_pva.c
@@ -73,7 +73,7 @@ typedef struct {
-int pva_sync(demuxer_t * demuxer)
+static int pva_sync(demuxer_t * demuxer)
{
uint8_t buffer[5]={0,0,0,0,0};
int count;
diff --git a/libmpdemux/demux_real.c b/libmpdemux/demux_real.c
index de6ff785ee..f6611eb2ed 100644
--- a/libmpdemux/demux_real.c
+++ b/libmpdemux/demux_real.c
@@ -1280,7 +1280,7 @@ static demuxer_t* demux_open_real(demuxer_t* demuxer)
int i;
char *buft;
int hdr_size;
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "real", stream_id);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "real", stream_id);
mp_msg(MSGT_DEMUX,MSGL_V,"Found audio stream!\n");
version = stream_read_word(demuxer->stream);
mp_msg(MSGT_DEMUX,MSGL_V,"version: %d\n", version);
@@ -1481,7 +1481,7 @@ static demuxer_t* demux_open_real(demuxer_t* demuxer)
}
} else if (strstr(mimet,"X-MP3-draft-00")) {
sh_audio_t *sh = new_sh_audio(demuxer, stream_id);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "real", stream_id);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "real", stream_id);
/* Emulate WAVEFORMATEX struct: */
sh->wf = malloc(sizeof(WAVEFORMATEX));
@@ -1517,7 +1517,7 @@ static demuxer_t* demux_open_real(demuxer_t* demuxer)
} else {
/* video header */
sh_video_t *sh = new_sh_video(demuxer, stream_id);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "real", stream_id);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Video stream found, -vid %d\n", "real", stream_id);
sh->format = stream_read_dword_le(demuxer->stream); /* fourcc */
mp_msg(MSGT_DEMUX,MSGL_V,"video fourcc: %.4s (%x)\n", (char *)&sh->format, sh->format);
@@ -1740,13 +1740,13 @@ header_end:
if(demuxer->video->id==-1 && v_streams>0){
// find the valid video stream:
if(!ds_fill_buffer(demuxer->video)){
- mp_msg(MSGT_DEMUXER,MSGL_INFO,"RM: " MSGTR_MissingVideoStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_INFO,"RM: " "No video stream found.\n");
}
}
if(demuxer->audio->id==-1 && a_streams>0){
// find the valid audio stream:
if(!ds_fill_buffer(demuxer->audio)){
- mp_msg(MSGT_DEMUXER,MSGL_INFO,"RM: " MSGTR_MissingAudioStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_INFO,"RM: " "No audio stream found -> no sound.\n");
}
}
diff --git a/libmpdemux/demux_rtp.cpp b/libmpdemux/demux_rtp.cpp
index c59bf5bf7e..afe550b284 100644
--- a/libmpdemux/demux_rtp.cpp
+++ b/libmpdemux/demux_rtp.cpp
@@ -26,6 +26,7 @@ extern "C" {
#endif
#include "demux_rtp.h"
#include "stheader.h"
+#include "options.h"
}
#include "demux_rtp_internal.h"
@@ -118,8 +119,8 @@ int rtsp_transport_tcp = 0;
extern int rtsp_port;
-extern "C" int audio_id, video_id, dvdsub_id;
extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
+ struct MPOpts *opts = demuxer->opts;
Boolean success = False;
do {
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
@@ -279,8 +280,9 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
// code to recognize this:
if (demux_is_multiplexed_rtp_stream(demuxer)) {
stream_t* s = new_ds_stream(demuxer->video);
- demuxer_t* od = demux_open(s, DEMUXER_TYPE_UNKNOWN,
- audio_id, video_id, dvdsub_id, NULL);
+ demuxer_t* od = demux_open(opts, s, DEMUXER_TYPE_UNKNOWN,
+ opts->audio_id, opts->video_id, opts->sub_id,
+ NULL);
demuxer = new_demuxers_demuxer(od, od, od);
}
@@ -660,7 +662,7 @@ demux_packet_t* ReadBufferQueue::getPendingBuffer() {
return dp;
}
-static int demux_rtp_control(struct demuxer_st *demuxer, int cmd, void *arg) {
+static int demux_rtp_control(struct demuxer *demuxer, int cmd, void *arg) {
double endpts = ((RTPState*)demuxer->priv)->mediaSession->playEndTime();
switch(cmd) {
diff --git a/libmpdemux/demux_ty.c b/libmpdemux/demux_ty.c
index 2b51fb6006..77dfbe7fd5 100644
--- a/libmpdemux/demux_ty.c
+++ b/libmpdemux/demux_ty.c
@@ -870,7 +870,7 @@ static demuxer_t* demux_open_ty(demuxer_t* demuxer)
if(demuxer->audio->id!=-2) {
if(!ds_fill_buffer(demuxer->audio)){
- mp_msg(MSGT_DEMUXER,MSGL_INFO,"MPEG: " MSGTR_MissingAudioStream);
+ mp_tmsg(MSGT_DEMUXER,MSGL_INFO,"MPEG: " "No audio stream found -> no sound.\n");
demuxer->audio->sh=NULL;
} else {
sh_audio=demuxer->audio->sh;sh_audio->ds=demuxer->audio;
diff --git a/libmpdemux/demux_ty_osd.c b/libmpdemux/demux_ty_osd.c
index 9ae04ece5d..0fb35c2d61 100644
--- a/libmpdemux/demux_ty_osd.c
+++ b/libmpdemux/demux_ty_osd.c
@@ -909,6 +909,3 @@ void ty_processuserdata( unsigned char* buf, int len )
}
}
}
-
-
-
diff --git a/libmpdemux/demux_viv.c b/libmpdemux/demux_viv.c
index b642ee761f..d0a2615d42 100644
--- a/libmpdemux/demux_viv.c
+++ b/libmpdemux/demux_viv.c
@@ -562,7 +562,7 @@ static demuxer_t* demux_open_vivo(demuxer_t* demuxer){
vivo_priv_t* priv=demuxer->priv;
if(!ds_fill_buffer(demuxer->video)){
- mp_msg(MSGT_DEMUX,MSGL_ERR,"VIVO: " MSGTR_MissingVideoStreamBug);
+ mp_tmsg(MSGT_DEMUX,MSGL_ERR,"VIVO: " "Missing video stream!? Contact the author, it may be a bug :(\n");
return NULL;
}
@@ -645,7 +645,7 @@ static demuxer_t* demux_open_vivo(demuxer_t* demuxer){
/* AUDIO init */
if (demuxer->audio->id >= -1){
if(!ds_fill_buffer(demuxer->audio)){
- mp_msg(MSGT_DEMUX,MSGL_ERR,"VIVO: " MSGTR_MissingAudioStream);
+ mp_tmsg(MSGT_DEMUX,MSGL_ERR,"VIVO: " "No audio stream found -> no sound.\n");
} else
{ sh_audio_t* sh=new_sh_audio(demuxer,1);
diff --git a/libmpdemux/demux_xmms.c b/libmpdemux/demux_xmms.c
index 9263621a0b..a75def6e33 100644
--- a/libmpdemux/demux_xmms.c
+++ b/libmpdemux/demux_xmms.c
@@ -195,7 +195,7 @@ static void init_plugins_from_dir(const char *plugin_dir){
gpi=dlsym(handle, "get_iplugin_info");
if(gpi){
InputPlugin *p=gpi();
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_XMMS_FoundPlugin,
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "Found plugin: %s (%s).\n",
ent->d_name,p->description);
p->handle = handle;
p->filename = strdup(filename);
@@ -230,7 +230,7 @@ static void init_plugins(void) {
static void cleanup_plugins(void) {
while(no_plugins>0){
--no_plugins;
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_XMMS_ClosingPlugin,
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "Closing plugin: %s.\n",
input_plugins[no_plugins]->filename);
if(input_plugins[no_plugins]->cleanup)
input_plugins[no_plugins]->cleanup();
@@ -284,7 +284,7 @@ static int demux_xmms_open(demuxer_t* demuxer) {
ip->get_song_info(demuxer->stream->url,&xmms_title,&xmms_length);
if (xmms_length<=0) demuxer->seekable=0;
- mp_msg(MSGT_DEMUX,MSGL_INFO,MSGTR_MPDEMUX_XMMS_WaitForStart,
+ mp_tmsg(MSGT_DEMUX,MSGL_INFO,"Waiting for the XMMS plugin to start playback of '%s'...\n",
demuxer->stream->url);
while (xmms_channels==0) {
usleep(10000);
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index c46ba9d43d..c9142f1441 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -27,6 +27,8 @@
#include <sys/stat.h>
#include "config.h"
+#include "options.h"
+#include "talloc.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "m_config.h"
@@ -184,7 +186,7 @@ void free_demuxer_stream(demux_stream_t *ds)
free(ds);
}
-demux_stream_t *new_demuxer_stream(struct demuxer_st *demuxer, int id)
+demux_stream_t *new_demuxer_stream(struct demuxer *demuxer, int id)
{
demux_stream_t *ds = malloc(sizeof(demux_stream_t));
ds->buffer_pos = ds->buffer_size = 0;
@@ -230,11 +232,10 @@ static const demuxer_desc_t *get_demuxer_desc_from_type(int file_format)
}
-demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
- int s_id, char *filename)
+demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
+ int a_id, int v_id, int s_id, char *filename)
{
- demuxer_t *d = malloc(sizeof(demuxer_t));
- memset(d, 0, sizeof(demuxer_t));
+ struct demuxer *d = talloc_zero(NULL, struct demuxer);
d->stream = stream;
d->stream_pts = MP_NOPTS_VALUE;
d->reference_clock = MP_NOPTS_VALUE;
@@ -247,6 +248,7 @@ demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
d->video = new_demuxer_stream(d, v_id);
d->sub = new_demuxer_stream(d, s_id);
d->type = type;
+ d->opts = opts;
if (type)
if (!(d->desc = get_demuxer_desc_from_type(type)))
mp_msg(MSGT_DEMUXER, MSGL_ERR,
@@ -259,8 +261,6 @@ demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
return d;
}
-extern int dvdsub_id;
-
sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid)
{
if (id > MAX_S_STREAMS - 1 || id < 0) {
@@ -275,16 +275,17 @@ sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid)
sh_sub_t *sh = calloc(1, sizeof(sh_sub_t));
demuxer->s_streams[id] = sh;
sh->sid = sid;
+ sh->opts = demuxer->opts;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sid);
}
- if (sid == dvdsub_id) {
+ if (sid == demuxer->opts->sub_id) {
demuxer->sub->id = id;
demuxer->sub->sh = demuxer->s_streams[id];
}
return demuxer->s_streams[id];
}
-void free_sh_sub(sh_sub_t *sh)
+static void free_sh_sub(sh_sub_t *sh)
{
mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_sub at %p\n", sh);
free(sh->extradata);
@@ -304,11 +305,11 @@ sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid)
MAX_A_STREAMS);
return NULL;
}
- if (demuxer->a_streams[id])
- mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_AudioStreamRedefined, id);
- else {
+ if (demuxer->a_streams[id]) {
+ mp_tmsg(MSGT_DEMUXER, MSGL_WARN, "WARNING: Audio stream header %d redefined.\n", id);
+ } else {
+ mp_tmsg(MSGT_DEMUXER, MSGL_V, "==> Found audio stream: %d\n", id);
sh_audio_t *sh = calloc(1, sizeof(sh_audio_t));
- mp_msg(MSGT_DEMUXER, MSGL_V, MSGTR_FoundAudioStream, id);
demuxer->a_streams[id] = sh;
sh->aid = aid;
sh->ds = demuxer->audio;
@@ -317,6 +318,7 @@ sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid)
sh->sample_format = AF_FORMAT_S16_NE;
sh->audio_out_minsize = 8192; /* default size, maybe not enough for Win32/ACM */
sh->pts = MP_NOPTS_VALUE;
+ sh->opts = demuxer->opts;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", aid);
}
return demuxer->a_streams[id];
@@ -342,13 +344,14 @@ sh_video_t *new_sh_video_vid(demuxer_t *demuxer, int id, int vid)
return NULL;
}
if (demuxer->v_streams[id])
- mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_VideoStreamRedefined, id);
+ mp_tmsg(MSGT_DEMUXER, MSGL_WARN, "WARNING: Video stream header %d redefined.\n", id);
else {
- sh_video_t *sh = calloc(1, sizeof(sh_video_t));
- mp_msg(MSGT_DEMUXER, MSGL_V, MSGTR_FoundVideoStream, id);
+ mp_tmsg(MSGT_DEMUXER, MSGL_V, "==> Found video stream: %d\n", id);
+ sh_video_t *sh = calloc(1, sizeof *sh);
demuxer->v_streams[id] = sh;
sh->vid = vid;
sh->ds = demuxer->video;
+ sh->opts = demuxer->opts;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", vid);
}
return demuxer->v_streams[id];
@@ -405,7 +408,7 @@ void free_demuxer(demuxer_t *demuxer)
}
free(demuxer->attachments);
}
- free(demuxer);
+ talloc_free(demuxer);
}
@@ -510,20 +513,32 @@ int ds_fill_buffer(demux_stream_t *ds)
if (!ds->first)
ds->last = NULL;
--ds->packs;
+ /* The code below can set ds->eof to 1 when another stream runs
+ * out of buffer space. That makes sense because in that situation
+ * the calling code should not count on being able to demux more
+ * packets from this stream.
+ * If however the situation improves and we're called again
+ * despite the eof flag then it's better to clear it to avoid
+ * weird behavior. */
+ ds->eof = 0;
return 1;
}
+
+#define MaybeNI _("Maybe you are playing a non-interleaved stream/file or the codec failed?\n" \
+ "For AVI files, try to force non-interleaved mode with the -ni option.\n")
+
if (demux->audio->packs >= MAX_PACKS
|| demux->audio->bytes >= MAX_PACK_BYTES) {
- mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyAudioInBuffer,
+ mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "\nToo many audio packets in the buffer: (%d in %d bytes).\n",
demux->audio->packs, demux->audio->bytes);
- mp_msg(MSGT_DEMUXER, MSGL_HINT, MSGTR_MaybeNI);
+ mp_tmsg(MSGT_DEMUXER, MSGL_HINT, MaybeNI);
break;
}
if (demux->video->packs >= MAX_PACKS
|| demux->video->bytes >= MAX_PACK_BYTES) {
- mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyVideoInBuffer,
+ mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "\nToo many video packets in the buffer: (%d in %d bytes).\n",
demux->video->packs, demux->video->bytes);
- mp_msg(MSGT_DEMUXER, MSGL_HINT, MSGTR_MaybeNI);
+ mp_tmsg(MSGT_DEMUXER, MSGL_HINT, MaybeNI);
break;
}
if (!demux_fill_buffer(demux, ds)) {
@@ -684,16 +699,16 @@ double ds_get_next_pts(demux_stream_t *ds)
while (!ds->first) {
if (demux->audio->packs >= MAX_PACKS
|| demux->audio->bytes >= MAX_PACK_BYTES) {
- mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyAudioInBuffer,
+ mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "\nToo many audio packets in the buffer: (%d in %d bytes).\n",
demux->audio->packs, demux->audio->bytes);
- mp_msg(MSGT_DEMUXER, MSGL_HINT, MSGTR_MaybeNI);
+ mp_tmsg(MSGT_DEMUXER, MSGL_HINT, MaybeNI);
return MP_NOPTS_VALUE;
}
if (demux->video->packs >= MAX_PACKS
|| demux->video->bytes >= MAX_PACK_BYTES) {
- mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyVideoInBuffer,
+ mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "\nToo many video packets in the buffer: (%d in %d bytes).\n",
demux->video->packs, demux->video->bytes);
- mp_msg(MSGT_DEMUXER, MSGL_HINT, MSGTR_MaybeNI);
+ mp_tmsg(MSGT_DEMUXER, MSGL_HINT, MaybeNI);
return MP_NOPTS_VALUE;
}
if (!demux_fill_buffer(demux, ds))
@@ -765,9 +780,6 @@ int get_demuxer_type_from_name(char *demuxer_name, int *force)
int extension_parsing = 1; // 0=off 1=mixed (used only for unstable formats)
-int correct_pts = 0;
-int user_correct_pts = -1;
-
/*
NOTE : Several demuxers may be opened at the same time so
demuxers should NEVER rely on an external var to enable them
@@ -781,9 +793,10 @@ int user_correct_pts = -1;
(ex: tv,mf).
*/
-static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
- int force, int audio_id, int video_id,
- int dvdsub_id, char *filename)
+static demuxer_t *demux_open_stream(struct MPOpts *opts, stream_t *stream,
+ int file_format, int force, int audio_id,
+ int video_id, int dvdsub_id,
+ char *filename)
{
demuxer_t *demuxer = NULL;
@@ -796,7 +809,7 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
// If somebody requested a demuxer check it
if (file_format) {
if ((demuxer_desc = get_demuxer_desc_from_type(file_format))) {
- demuxer = new_demuxer(stream, demuxer_desc->type, audio_id,
+ demuxer = new_demuxer(opts, stream, demuxer_desc->type, audio_id,
video_id, dvdsub_id, filename);
if (demuxer_desc->check_file)
fformat = demuxer_desc->check_file(demuxer);
@@ -806,8 +819,8 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
if (fformat == demuxer_desc->type) {
demuxer_t *demux2 = demuxer;
// Move messages to demuxer detection code?
- mp_msg(MSGT_DEMUXER, MSGL_INFO,
- MSGTR_Detected_XXX_FileFormat,
+ mp_tmsg(MSGT_DEMUXER, MSGL_INFO,
+ "%s file format detected.\n",
demuxer_desc->shortdesc);
file_format = fformat;
if (!demuxer->desc->open
@@ -818,8 +831,9 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
} else {
// Format changed after check, recurse
free_demuxer(demuxer);
- return demux_open_stream(stream, fformat, force, audio_id,
- video_id, dvdsub_id, filename);
+ return demux_open_stream(opts, stream, fformat, force,
+ audio_id, video_id, dvdsub_id,
+ filename);
}
}
// Check failed for forced demuxer, quit
@@ -830,13 +844,13 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
// Test demuxers with safe file checks
for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
if (demuxer_desc->safe_check) {
- demuxer = new_demuxer(stream, demuxer_desc->type, audio_id,
+ demuxer = new_demuxer(opts, stream, demuxer_desc->type, audio_id,
video_id, dvdsub_id, filename);
if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
if (fformat == demuxer_desc->type) {
demuxer_t *demux2 = demuxer;
- mp_msg(MSGT_DEMUXER, MSGL_INFO,
- MSGTR_Detected_XXX_FileFormat,
+ mp_tmsg(MSGT_DEMUXER, MSGL_INFO,
+ "%s file format detected.\n",
demuxer_desc->shortdesc);
file_format = fformat;
if (!demuxer->desc->open
@@ -849,7 +863,7 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
return demuxer; // handled in mplayer.c
// Format changed after check, recurse
free_demuxer(demuxer);
- demuxer = demux_open_stream(stream, fformat, force,
+ demuxer = demux_open_stream(opts, stream, fformat, force,
audio_id, video_id,
dvdsub_id, filename);
if (demuxer)
@@ -871,8 +885,9 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
file_format = demuxer_type_by_filename(filename);
if (file_format != DEMUXER_TYPE_UNKNOWN) {
// we like recursion :)
- demuxer = demux_open_stream(stream, file_format, force, audio_id,
- video_id, dvdsub_id, filename);
+ demuxer = demux_open_stream(opts, stream, file_format, force,
+ audio_id, video_id, dvdsub_id,
+ filename);
if (demuxer)
return demuxer; // done!
file_format = DEMUXER_TYPE_UNKNOWN; // continue fuzzy guessing...
@@ -883,13 +898,13 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
// Try detection for all other demuxers
for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
if (!demuxer_desc->safe_check && demuxer_desc->check_file) {
- demuxer = new_demuxer(stream, demuxer_desc->type, audio_id,
+ demuxer = new_demuxer(opts, stream, demuxer_desc->type, audio_id,
video_id, dvdsub_id, filename);
if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
if (fformat == demuxer_desc->type) {
demuxer_t *demux2 = demuxer;
- mp_msg(MSGT_DEMUXER, MSGL_INFO,
- MSGTR_Detected_XXX_FileFormat,
+ mp_tmsg(MSGT_DEMUXER, MSGL_INFO,
+ "%s file format detected.\n",
demuxer_desc->shortdesc);
file_format = fformat;
if (!demuxer->desc->open
@@ -902,7 +917,7 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
return demuxer; // handled in mplayer.c
// Format changed after check, recurse
free_demuxer(demuxer);
- demuxer = demux_open_stream(stream, fformat, force,
+ demuxer = demux_open_stream(opts, stream, fformat, force,
audio_id, video_id,
dvdsub_id, filename);
if (demuxer)
@@ -960,8 +975,9 @@ extern int hr_mp3_seek;
extern float stream_cache_min_percent;
extern float stream_cache_seek_min_percent;
-demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
- int video_id, int dvdsub_id, char *filename)
+demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format,
+ int audio_id, int video_id, int dvdsub_id,
+ char *filename)
{
stream_t *as = NULL, *ss = NULL;
demuxer_t *vd, *ad = NULL, *sd = NULL;
@@ -992,7 +1008,7 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
if (audio_stream) {
as = open_stream(audio_stream, 0, &afmt);
if (!as) {
- mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_CannotOpenAudioStream,
+ mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "Cannot open audio stream: %s\n",
audio_stream);
return NULL;
}
@@ -1013,13 +1029,13 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
if (sub_stream) {
ss = open_stream(sub_stream, 0, &sfmt);
if (!ss) {
- mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_CannotOpenSubtitlesStream,
+ mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "Cannot open subtitle stream: %s\n",
sub_stream);
return NULL;
}
}
- vd = demux_open_stream(vs, demuxer_type ? demuxer_type : file_format,
+ vd = demux_open_stream(opts, vs, demuxer_type ? demuxer_type : file_format,
demuxer_force, audio_stream ? -2 : audio_id,
video_id, sub_stream ? -2 : dvdsub_id, filename);
if (!vd) {
@@ -1030,12 +1046,12 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
return NULL;
}
if (as) {
- ad = demux_open_stream(as,
+ ad = demux_open_stream(opts, as,
audio_demuxer_type ? audio_demuxer_type : afmt,
audio_demuxer_force, audio_id, -2, -2,
audio_stream);
if (!ad) {
- mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_OpeningAudioDemuxerFailed,
+ mp_tmsg(MSGT_DEMUXER, MSGL_WARN, "Failed to open audio demuxer: %s\n",
audio_stream);
free_stream(as);
} else if (ad->audio->sh
@@ -1043,12 +1059,13 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
hr_mp3_seek = 1; // Enable high res seeking
}
if (ss) {
- sd = demux_open_stream(ss, sub_demuxer_type ? sub_demuxer_type : sfmt,
+ sd = demux_open_stream(opts, ss,
+ sub_demuxer_type ? sub_demuxer_type : sfmt,
sub_demuxer_force, -2, -2, dvdsub_id,
sub_stream);
if (!sd) {
- mp_msg(MSGT_DEMUXER, MSGL_WARN,
- MSGTR_OpeningSubtitlesDemuxerFailed, sub_stream);
+ mp_tmsg(MSGT_DEMUXER, MSGL_WARN,
+ "Failed to open subtitle demuxer: %s\n", sub_stream);
free_stream(ss);
}
}
@@ -1062,10 +1079,11 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
else
res = vd;
- correct_pts = user_correct_pts;
- if (correct_pts < 0)
- correct_pts = demux_control(res, DEMUXER_CTRL_CORRECT_PTS, NULL)
- == DEMUXER_CTRL_OK;
+ opts->correct_pts = opts->user_correct_pts;
+ if (opts->correct_pts < 0)
+ opts->correct_pts =
+ demux_control(res, DEMUXER_CTRL_CORRECT_PTS,
+ NULL) == DEMUXER_CTRL_OK;
return res;
}
@@ -1089,18 +1107,17 @@ int demux_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay,
if (!demuxer->seekable) {
if (demuxer->file_format == DEMUXER_TYPE_AVI)
- mp_msg(MSGT_SEEK, MSGL_WARN, MSGTR_CantSeekRawAVI);
+ mp_tmsg(MSGT_SEEK, MSGL_WARN, "Cannot seek in raw AVI streams. (Index required, try with the -idx switch.)\n");
#ifdef CONFIG_TV
else if (demuxer->file_format == DEMUXER_TYPE_TV)
- mp_msg(MSGT_SEEK, MSGL_WARN, MSGTR_TVInputNotSeekable);
+ mp_tmsg(MSGT_SEEK, MSGL_WARN, "TV input is not seekable! (Seeking will probably be for changing channels ;)\n");
#endif
else
- mp_msg(MSGT_SEEK, MSGL_WARN, MSGTR_CantSeekFile);
+ mp_tmsg(MSGT_SEEK, MSGL_WARN, "Cannot seek in this file.\n");
return 0;
}
-
- demux_flush(demuxer);
// clear demux buffers:
+ demux_flush(demuxer);
if (sh_audio)
sh_audio->a_buffer_len = 0;
@@ -1151,7 +1168,7 @@ int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param)
for (n = 0; info && info[2 * n] != NULL; n++) {
if (!strcasecmp(opt, info[2 * n])) {
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_DemuxerInfoChanged, opt,
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "Demuxer info %s changed to %s\n", opt,
param);
free(info[2 * n + 1]);
info[2 * n + 1] = strdup(param);
@@ -1159,8 +1176,8 @@ int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param)
}
}
- info = demuxer->info = (char **) realloc(info,
- (2 * (n + 2)) * sizeof(char *));
+ info = demuxer->info =
+ (char **) realloc(info, (2 * (n + 2)) * sizeof(char *));
info[2 * n] = strdup(opt);
info[2 * n + 1] = strdup(param);
memset(&info[2 * (n + 1)], 0, 2 * sizeof(char *));
@@ -1176,7 +1193,7 @@ int demux_info_print(demuxer_t *demuxer)
if (!info)
return 0;
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_ClipInfo);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "Clip info:\n");
for (n = 0; info[2 * n] != NULL; n++) {
mp_msg(MSGT_DEMUX, MSGL_INFO, " %s: %s\n", info[2 * n],
info[2 * n + 1]);
@@ -1326,7 +1343,7 @@ int demuxer_add_chapter(demuxer_t *demuxer, const char *name, uint64_t start,
demuxer->chapters[demuxer->num_chapters].start = start;
demuxer->chapters[demuxer->num_chapters].end = end;
- demuxer->chapters[demuxer->num_chapters].name = strdup(name ? name : MSGTR_Unknown);
+ demuxer->chapters[demuxer->num_chapters].name = strdup(name ? name : mp_gtext("unknown"));
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CHAPTER_ID=%d\n", demuxer->num_chapters);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CHAPTER_%d_START=%"PRIu64"\n", demuxer->num_chapters, start);
@@ -1343,31 +1360,19 @@ int demuxer_add_chapter(demuxer_t *demuxer, const char *name, uint64_t start,
* either using the demuxer->chapters structure set by the demuxer
* or asking help to the stream layer (e.g. dvd)
* \param chapter - chapter number wished - 0-based
- * \param mode 0: relative to current main pts, 1: absolute
* \param seek_pts set by the function to the pts to seek to (if demuxer->chapters is set)
- * \param num_chapters number of chapters present (set by this function is param is not null)
* \param chapter_name name of chapter found (set by this function is param is not null)
* \return -1 on error, current chapter if successful
*/
-int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode,
- float *seek_pts, int *num_chapters,
+int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, double *seek_pts,
char **chapter_name)
{
int ris;
- int current, total;
sh_video_t *sh_video = demuxer->video->sh;
sh_audio_t *sh_audio = demuxer->audio->sh;
if (!demuxer->num_chapters || !demuxer->chapters) {
- if (!mode) {
- ris = stream_control(demuxer->stream,
- STREAM_CTRL_GET_CURRENT_CHAPTER, &current);
- if (ris == STREAM_UNSUPPORTED)
- return -1;
- chapter += current;
- }
-
demux_flush(demuxer);
ris = stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_CHAPTER,
@@ -1387,60 +1392,31 @@ int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode,
// (because e.g. dvds depend on sectors, not on pts)
*seek_pts = -1.0;
- if (num_chapters) {
- if (stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_CHAPTERS,
- num_chapters) == STREAM_UNSUPPORTED)
- *num_chapters = 0;
- }
-
if (chapter_name) {
*chapter_name = NULL;
- if (num_chapters && *num_chapters) {
- char *tmp = malloc(16);
- if (tmp) {
- sprintf(tmp, " of %3d", *num_chapters);
- *chapter_name = tmp;
- }
+ int num_chapters;
+ if (stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_CHAPTERS,
+ &num_chapters) == STREAM_UNSUPPORTED)
+ num_chapters = 0;
+ if (num_chapters) {
+ *chapter_name = talloc_size(NULL, 16);
+ sprintf(*chapter_name, " of %3d", num_chapters);
}
}
return ris != STREAM_UNSUPPORTED ? chapter : -1;
} else { // chapters structure is set in the demuxer
- total = demuxer->num_chapters;
-
- if (mode == 1) //absolute seeking
- current = chapter;
- else { //relative seeking
- uint64_t now;
- now = (sh_video ? sh_video->pts : (sh_audio ? sh_audio->pts : 0.))
- * 1000 + .5;
-
- for (current = total - 1; current >= 0; --current) {
- demux_chapter_t *chapter = demuxer->chapters + current;
- if (chapter->start <= now)
- break;
- }
- current += chapter;
- }
-
- if (current >= total)
+ if (chapter >= demuxer->num_chapters)
return -1;
- if (current < 0)
- current = 0;
-
- *seek_pts = demuxer->chapters[current].start / 1000.0;
+ if (chapter < 0)
+ chapter = 0;
- if (num_chapters)
- *num_chapters = demuxer->num_chapters;
+ *seek_pts = demuxer->chapters[chapter].start / 1000.0;
- if (chapter_name) {
- if (demuxer->chapters[current].name)
- *chapter_name = strdup(demuxer->chapters[current].name);
- else
- *chapter_name = NULL;
- }
+ if (chapter_name)
+ *chapter_name = talloc_strdup(NULL, demuxer->chapters[chapter].name);
- return current;
+ return chapter;
}
}
diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h
index 8035fd24e8..ee1cd2cce5 100644
--- a/libmpdemux/demuxer.h
+++ b/libmpdemux/demuxer.h
@@ -23,11 +23,11 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <stdbool.h>
#include "stream/stream.h"
-#ifdef CONFIG_ASS
-#include "libass/ass_types.h"
-#endif
+
+struct MPOpts;
#ifdef HAVE_BUILTIN_EXPECT
#define likely(x) __builtin_expect ((x) != 0, 1)
@@ -38,7 +38,7 @@
#endif
#define MAX_PACKS 4096
-#define MAX_PACK_BYTES 0x2000000
+#define MAX_PACK_BYTES 0x8000000 // 128 MiB
#define DEMUXER_TYPE_UNKNOWN 0
#define DEMUXER_TYPE_MPEG_ES 1
@@ -114,11 +114,13 @@
#define SEEK_ABSOLUTE (1 << 0)
#define SEEK_FACTOR (1 << 1)
+#define SEEK_FORWARD (1 << 2)
+#define SEEK_BACKWARD (1 << 3)
#define MP_INPUT_BUFFER_PADDING_SIZE 8
// Holds one packet/frame/whatever
-typedef struct demux_packet_st {
+typedef struct demux_packet {
int len;
double pts;
double endpts;
@@ -127,11 +129,11 @@ typedef struct demux_packet_st {
unsigned char* buffer;
int flags; // keyframe, etc
int refcount; //refcounter for the master packet, if 0, buffer can be free()d
- struct demux_packet_st* master; //pointer to the master packet if this one is a cloned one
- struct demux_packet_st* next;
+ struct demux_packet *master; //pointer to the master packet if this one is a cloned one
+ struct demux_packet *next;
} demux_packet_t;
-typedef struct {
+typedef struct demux_stream {
int buffer_pos; // current buffer position
int buffer_size; // current buffer size
unsigned char* buffer; // current buffer, never free() it, always use free_demux_packet(buffer_ref);
@@ -149,7 +151,7 @@ typedef struct {
demux_packet_t *last; // append new packets from input stream to here
demux_packet_t *current;// needed for refcounting of the buffer
int id; // stream ID (for multiple audio/video streams)
- struct demuxer_st *demuxer; // parent demuxer structure (stream handler)
+ struct demuxer *demuxer; // parent demuxer structure (stream handler)
// ---- asf -----
demux_packet_t *asf_packet; // read asf fragments here
int asf_seq;
@@ -159,7 +161,7 @@ typedef struct {
void* sh;
} demux_stream_t;
-typedef struct demuxer_info_st {
+typedef struct demuxer_info {
char *name;
char *author;
char *encoder;
@@ -171,15 +173,12 @@ typedef struct demuxer_info_st {
#define MAX_V_STREAMS 256
#define MAX_S_STREAMS 256
-struct demuxer_st;
-
-extern int correct_pts;
-extern int user_correct_pts;
+struct demuxer;
/**
* Demuxer description structure
*/
-typedef struct demuxers_desc_st {
+typedef struct demuxer_desc {
const char *info; ///< What is it (long name and/or description)
const char *name; ///< Demuxer name, used with -demuxer switch
const char *shortdesc; ///< Description printed at demuxer detection
@@ -190,26 +189,39 @@ typedef struct demuxers_desc_st {
int safe_check; ///< If 1 detection is safe and fast, do it before file extension check
/// Check if can demux the file, return DEMUXER_TYPE_xxx on success
- int (*check_file)(struct demuxer_st *demuxer); ///< Mandatory if safe_check == 1, else optional
+ int (*check_file)(struct demuxer *demuxer); ///< Mandatory if safe_check == 1, else optional
/// Get packets from file, return 0 on eof
- int (*fill_buffer)(struct demuxer_st *demuxer, demux_stream_t *ds); ///< Mandatory
+ int (*fill_buffer)(struct demuxer *demuxer, demux_stream_t *ds); ///< Mandatory
/// Open the demuxer, return demuxer on success, NULL on failure
- struct demuxer_st* (*open)(struct demuxer_st *demuxer); ///< Optional
+ struct demuxer* (*open)(struct demuxer *demuxer); ///< Optional
/// Close the demuxer
- void (*close)(struct demuxer_st *demuxer); ///< Optional
+ void (*close)(struct demuxer *demuxer); ///< Optional
// Seek
- void (*seek)(struct demuxer_st *demuxer, float rel_seek_secs, float audio_delay, int flags); ///< Optional
+ void (*seek)(struct demuxer *demuxer, float rel_seek_secs, float audio_delay, int flags); ///< Optional
// Control
- int (*control)(struct demuxer_st *demuxer, int cmd, void *arg); ///< Optional
+ int (*control)(struct demuxer *demuxer, int cmd, void *arg); ///< Optional
} demuxer_desc_t;
-typedef struct demux_chapter_s
+typedef struct demux_chapter
{
uint64_t start, end;
char* name;
} demux_chapter_t;
-typedef struct demux_attachment_s
+struct matroska_data {
+ unsigned char segment_uid[16];
+ // Ordered chapter information if any
+ struct matroska_chapter {
+ uint64_t start;
+ uint64_t end;
+ bool has_segment_uid;
+ unsigned char segment_uid[16];
+ char *name;
+ } *ordered_chapters;
+ int num_ordered_chapters;
+};
+
+typedef struct demux_attachment
{
char* name;
char* type;
@@ -217,7 +229,7 @@ typedef struct demux_attachment_s
unsigned int data_size;
} demux_attachment_t;
-typedef struct demuxer_st {
+typedef struct demuxer {
const demuxer_desc_t *desc; ///< Demuxer description structure
off_t filepos; // input stream current pos.
off_t movi_start;
@@ -230,15 +242,18 @@ typedef struct demuxer_st {
int type; // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf
int file_format; // file format: mpeg/avi/asf
int seekable; // flag
+ /* Set if using absolute seeks for small movements is OK (no pts resets
+ * that would make pts ambigious, preferably supports back/forward flags */
+ bool accurate_seek;
//
demux_stream_t *audio; // audio buffer/demuxer
demux_stream_t *video; // video buffer/demuxer
demux_stream_t *sub; // dvd subtitle buffer/demuxer
// stream headers:
- void* a_streams[MAX_A_STREAMS]; // audio streams (sh_audio_t)
- void* v_streams[MAX_V_STREAMS]; // video sterams (sh_video_t)
- void *s_streams[MAX_S_STREAMS]; // dvd subtitles (flag)
+ struct sh_audio *a_streams[MAX_A_STREAMS];
+ struct sh_video *v_streams[MAX_V_STREAMS];
+ struct sh_sub *s_streams[MAX_S_STREAMS];
demux_chapter_t* chapters;
int num_chapters;
@@ -246,8 +261,11 @@ typedef struct demuxer_st {
demux_attachment_t* attachments;
int num_attachments;
+ struct matroska_data matroska_data;
+
void* priv; // fileformat-dependent data
char** info;
+ struct MPOpts *opts;
} demuxer_t;
typedef struct {
@@ -329,8 +347,8 @@ static inline void *realloc_struct(void *ptr, size_t nmemb, size_t size) {
return realloc(ptr, nmemb * size);
}
-demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id);
-demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id,char *filename);
+demux_stream_t* new_demuxer_stream(struct demuxer *demuxer,int id);
+demuxer_t* new_demuxer(struct MPOpts *opts, stream_t *stream,int type,int a_id,int v_id,int s_id,char *filename);
void free_demuxer_stream(demux_stream_t *ds);
void free_demuxer(demuxer_t *demuxer);
@@ -393,7 +411,7 @@ static inline int avi_stream_id(unsigned int id){
return a*10+b;
}
-demuxer_t* demux_open(stream_t *stream,int file_format,int aid,int vid,int sid,char* filename);
+demuxer_t* demux_open(struct MPOpts *opts, stream_t *stream,int file_format,int aid,int vid,int sid,char* filename);
void demux_flush(demuxer_t *demuxer);
int demux_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags);
demuxer_t* new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd);
@@ -432,7 +450,8 @@ int demuxer_add_attachment(demuxer_t* demuxer, const char* name,
const char* type, const void* data, size_t size);
int demuxer_add_chapter(demuxer_t* demuxer, const char* name, uint64_t start, uint64_t end);
-int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode, float *seek_pts, int *num_chapters, char **chapter_name);
+int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, double *seek_pts,
+ char **chapter_name);
/// Get current chapter index if available.
int demuxer_get_current_chapter(demuxer_t *demuxer);
diff --git a/libmpdemux/ebml.h b/libmpdemux/ebml.h
index fb44faa43c..4faf2495f1 100644
--- a/libmpdemux/ebml.h
+++ b/libmpdemux/ebml.h
@@ -72,6 +72,7 @@
#define MATROSKA_ID_WRITINGAPP 0x5741
#define MATROSKA_ID_MUXINGAPP 0x4D80
#define MATROSKA_ID_DATEUTC 0x4461
+#define MATROSKA_ID_SEGMENTUID 0x73A4
/* ID in the tracks master */
#define MATROSKA_ID_TRACKENTRY 0xAE
@@ -144,11 +145,13 @@
/* IDs in the chapters master */
#define MATROSKA_ID_EDITIONENTRY 0x45B9
+#define MATROSKA_ID_EDITIONFLAGORDERED 0x45DD
#define MATROSKA_ID_CHAPTERATOM 0xB6
#define MATROSKA_ID_CHAPTERTIMESTART 0x91
#define MATROSKA_ID_CHAPTERTIMEEND 0x92
#define MATROSKA_ID_CHAPTERDISPLAY 0x80
#define MATROSKA_ID_CHAPSTRING 0x85
+#define MATROSKA_ID_CHAPTERSEGMENTUID 0x6E67
/* IDs in the cluster master */
#define MATROSKA_ID_CLUSTERTIMECODE 0xE7
diff --git a/libmpdemux/extension.c b/libmpdemux/extension.c
index dc20214b87..539dd043b4 100644
--- a/libmpdemux/extension.c
+++ b/libmpdemux/extension.c
@@ -104,4 +104,3 @@ int demuxer_type_by_filename(char* filename){
}
return DEMUXER_TYPE_UNKNOWN;
}
-
diff --git a/libmpdemux/mf.c b/libmpdemux/mf.c
index 74778b628a..ee4de16dcc 100644
--- a/libmpdemux/mf.c
+++ b/libmpdemux/mf.c
@@ -167,4 +167,3 @@ exit_mf:
return 0;
#endif
}
-
diff --git a/libmpdemux/mp3_hdr.c b/libmpdemux/mp3_hdr.c
index 9c649d7e1b..7095efeb78 100644
--- a/libmpdemux/mp3_hdr.c
+++ b/libmpdemux/mp3_hdr.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include "config.h"
+#include "mp3_hdr.h"
#include "mp_msg.h"
//----------------------- mp3 audio frame header parser -----------------------
@@ -37,7 +38,7 @@ static long freqs[9] = { 44100, 48000, 32000, // MPEG 1.0
22050, 24000, 16000, // MPEG 2.0
11025, 12000, 8000}; // MPEG 2.5
-int mp_mp3_get_lsf(unsigned char* hbuf){
+static int mp_mp3_get_lsf(unsigned char* hbuf){
unsigned long newhead =
hbuf[0] << 24 |
hbuf[1] << 16 |
@@ -155,4 +156,3 @@ int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* srate, int* spf, int*
return framesize;
}
-
diff --git a/libmpdemux/mp_taglists.c b/libmpdemux/mp_taglists.c
index 6cba293130..037ada5eb0 100644
--- a/libmpdemux/mp_taglists.c
+++ b/libmpdemux/mp_taglists.c
@@ -97,4 +97,3 @@ static const AVCodecTag mp_bmp_tags[] = {
};
const struct AVCodecTag *mp_bmp_taglists[] = {ff_codec_bmp_tags, mp_bmp_tags, 0};
-
diff --git a/libmpdemux/muxer.c b/libmpdemux/muxer.c
index 62537085d8..39cbb94fab 100644
--- a/libmpdemux/muxer.c
+++ b/libmpdemux/muxer.c
@@ -85,7 +85,7 @@ void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double
tmp = realloc_struct(s->muxer->muxbuf, (num+1), sizeof(muxbuf_t));
if(!tmp) {
- mp_msg(MSGT_MUXER, MSGL_FATAL, MSGTR_MuxbufReallocErr);
+ mp_tmsg(MSGT_MUXER, MSGL_FATAL, "Muxer frame buffer cannot reallocate memory!\n");
return;
}
s->muxer->muxbuf = tmp;
@@ -99,7 +99,7 @@ void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double
buf->flags = flags;
buf->buffer = malloc(len);
if (!buf->buffer) {
- mp_msg(MSGT_MUXER, MSGL_FATAL, MSGTR_MuxbufMallocErr);
+ mp_tmsg(MSGT_MUXER, MSGL_FATAL, "Muxer frame buffer cannot allocate memory!\n");
return;
}
memcpy(buf->buffer, s->buffer, buf->len);
@@ -113,7 +113,7 @@ void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double
/* see if we can flush buffer now */
if (s->muxer->muxbuf_skip_buffer) {
- mp_msg(MSGT_MUXER, MSGL_V, MSGTR_MuxbufSending, s->muxer->muxbuf_num);
+ mp_tmsg(MSGT_MUXER, MSGL_V, "Muxer frame buffer sending %d frame(s) to the muxer.\n", s->muxer->muxbuf_num);
/* fix parameters for all streams */
for (num = 0; s->muxer->streams[num]; ++num) {
@@ -156,7 +156,7 @@ void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double
if(s->h.dwSampleSize){
// CBR
s->h.dwLength+=len/s->h.dwSampleSize;
- if(len%s->h.dwSampleSize) mp_msg(MSGT_MUXER, MSGL_WARN, MSGTR_WarningLenIsntDivisible);
+ if(len%s->h.dwSampleSize) mp_tmsg(MSGT_MUXER, MSGL_WARN, "Warning, len isn't divisible by samplesize!\n");
} else {
// VBR
s->h.dwLength++;
@@ -166,4 +166,3 @@ void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double
return;
}
-
diff --git a/libmpdemux/muxer_avi.c b/libmpdemux/muxer_avi.c
index 5d7e267756..f8531ac868 100644
--- a/libmpdemux/muxer_avi.c
+++ b/libmpdemux/muxer_avi.c
@@ -291,7 +291,7 @@ static void avifile_write_header(muxer_t *muxer){
struct avi_stream_info *vsi = muxer->def_v->priv;
int isodml = vsi->riffofspos > 0;
- mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingHeader);
+ mp_tmsg(MSGT_MUXER, MSGL_INFO, "Writing header...\n");
if (aspect == 0) {
mp_msg(MSGT_MUXER, MSGL_INFO, "ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.\n");
} else {
@@ -303,11 +303,11 @@ static void avifile_write_header(muxer_t *muxer){
muxer_stream_t *s = muxer->streams[i];
if (s->type == MUXER_TYPE_AUDIO && muxer->audio_delay_fix > 0.0) {
s->h.dwStart = muxer->audio_delay_fix * s->h.dwRate/s->h.dwScale + 0.5;
- mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_SettingAudioDelay, (float)s->h.dwStart * s->h.dwScale/s->h.dwRate);
+ mp_tmsg(MSGT_MUXER, MSGL_INFO, "Setting audio delay to %5.3fs.\n", (float)s->h.dwStart * s->h.dwScale/s->h.dwRate);
}
if (s->type == MUXER_TYPE_VIDEO && muxer->audio_delay_fix < 0.0) {
s->h.dwStart = -muxer->audio_delay_fix * s->h.dwRate/s->h.dwScale + 0.5;
- mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_SettingVideoDelay, (float)s->h.dwStart * s->h.dwScale/s->h.dwRate);
+ mp_tmsg(MSGT_MUXER, MSGL_INFO, "Setting video delay to %5.3fs.\n", (float)s->h.dwStart * s->h.dwScale/s->h.dwRate);
}
}
@@ -670,7 +670,7 @@ static void avifile_write_standard_index(muxer_t *muxer){
static void avifile_write_index(muxer_t *muxer){
struct avi_stream_info *vsi = muxer->def_v->priv;
- mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingTrailer);
+ mp_tmsg(MSGT_MUXER, MSGL_INFO, "Writing index...\n");
if (vsi->riffofspos > 0){
avifile_odml_write_index(muxer);
} else {
diff --git a/libmpdemux/muxer_lavf.c b/libmpdemux/muxer_lavf.c
index 5026d5c912..7a73706589 100644
--- a/libmpdemux/muxer_lavf.c
+++ b/libmpdemux/muxer_lavf.c
@@ -290,7 +290,7 @@ static void write_header(muxer_t *muxer)
{
muxer_priv_t *priv = (muxer_priv_t *) muxer->priv;
- mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingHeader);
+ mp_tmsg(MSGT_MUXER, MSGL_INFO, "Writing header...\n");
av_write_header(priv->oc);
muxer->cont_write_header = NULL;
}
@@ -301,7 +301,7 @@ static void write_trailer(muxer_t *muxer)
int i;
muxer_priv_t *priv = (muxer_priv_t *) muxer->priv;
- mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingTrailer);
+ mp_tmsg(MSGT_MUXER, MSGL_INFO, "Writing index...\n");
av_write_trailer(priv->oc);
for(i = 0; i < priv->oc->nb_streams; i++)
{
diff --git a/libmpdemux/muxer_mpeg.c b/libmpdemux/muxer_mpeg.c
index 20b552a96e..321b6546b0 100644
--- a/libmpdemux/muxer_mpeg.c
+++ b/libmpdemux/muxer_mpeg.c
@@ -2393,7 +2393,7 @@ static void mpegfile_write_index(muxer_t *muxer)
double fake_timer;
muxer_priv_t *priv = (muxer_priv_t *) muxer->priv;
- mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingTrailer);
+ mp_tmsg(MSGT_MUXER, MSGL_INFO, "Writing index...\n");
for(i = 0; i < muxer->avih.dwStreams; i++)
{
@@ -2415,7 +2415,7 @@ static void mpegfile_write_header(muxer_t *muxer)
{
muxer_priv_t *priv = (muxer_priv_t*) muxer->priv;
- mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingHeader);
+ mp_tmsg(MSGT_MUXER, MSGL_INFO, "Writing header...\n");
priv->headers_cnt++;
@@ -2733,4 +2733,3 @@ int muxer_init_muxer_mpeg(muxer_t *muxer)
muxer->fix_stream_parameters = &fix_parameters;
return 1;
}
-
diff --git a/libmpdemux/muxer_rawaudio.c b/libmpdemux/muxer_rawaudio.c
index 8c86d467d5..341999ee1d 100644
--- a/libmpdemux/muxer_rawaudio.c
+++ b/libmpdemux/muxer_rawaudio.c
@@ -34,7 +34,7 @@ static muxer_stream_t* rawaudiofile_new_stream(muxer_t *muxer,int type){
muxer_stream_t* s;
if (!muxer) return NULL;
if(type==MUXER_TYPE_AUDIO && muxer->avih.dwStreams>=1){
- mp_msg(MSGT_MUXER,MSGL_ERR,MSGTR_TooManyStreams" "MSGTR_RawMuxerOnlyOneStream);
+ mp_tmsg(MSGT_MUXER,MSGL_ERR,"Too many streams!"" ""Rawaudio muxer supports only one audio stream!\n");
return NULL;
}
s=malloc(sizeof(muxer_stream_t));
@@ -53,12 +53,12 @@ static muxer_stream_t* rawaudiofile_new_stream(muxer_t *muxer,int type){
muxer->avih.dwStreams++;
break;
case MUXER_TYPE_VIDEO:
- mp_msg(MSGT_MUXER,MSGL_WARN,MSGTR_IgnoringVideoStream);
+ mp_tmsg(MSGT_MUXER,MSGL_WARN,"Ignoring video stream!\n");
s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
s->h.fccType=streamtypeAUDIO;
break;
default:
- mp_msg(MSGT_MUXER,MSGL_ERR,MSGTR_UnknownStreamType,type);
+ mp_tmsg(MSGT_MUXER,MSGL_ERR,"Warning, unknown stream type: %d\n",type);
return NULL;
}
return s;
diff --git a/libmpdemux/parse_mp4.c b/libmpdemux/parse_mp4.c
index bdae91a0fe..2a5ee3a4af 100644
--- a/libmpdemux/parse_mp4.c
+++ b/libmpdemux/parse_mp4.c
@@ -33,7 +33,7 @@
#define MP4_DL MSGL_V
#define freereturn(a,b) free(a); return b
-int mp4_read_descr_len(stream_t *s) {
+static int mp4_read_descr_len(stream_t *s) {
uint8_t b;
uint8_t numBytes = 0;
uint32_t length = 0;
@@ -170,4 +170,3 @@ void mp4_free_esds(esds_t *esds) {
#undef freereturn
#undef MP4_DL
-
diff --git a/libmpdemux/parse_mp4.h b/libmpdemux/parse_mp4.h
index 3b81fef99b..27d4d44d7d 100644
--- a/libmpdemux/parse_mp4.h
+++ b/libmpdemux/parse_mp4.h
@@ -125,4 +125,3 @@ int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds);
void mp4_free_esds(esds_t *esds);
#endif /* MPLAYER_PARSE_MP4_H */
-
diff --git a/libmpdemux/stheader.h b/libmpdemux/stheader.h
index a64e65fb73..f80cd2cf6a 100644
--- a/libmpdemux/stheader.h
+++ b/libmpdemux/stheader.h
@@ -19,16 +19,18 @@
#ifndef MPLAYER_STHEADER_H
#define MPLAYER_STHEADER_H
-#include "demuxer.h"
#include "aviheader.h"
#include "ms_hdr.h"
+struct MPOpts;
+struct demuxer;
// Stream headers:
-typedef struct {
+typedef struct sh_audio {
+ struct MPOpts *opts;
int aid;
- demux_stream_t *ds;
- struct codecs_st *codec;
+ struct demux_stream *ds;
+ struct codecs *codec;
unsigned int format;
int initialized;
float stream_delay; // number of seconds stream should be delayed (according to dwStart or similar)
@@ -54,8 +56,8 @@ typedef struct {
int a_out_buffer_len;
int a_out_buffer_size;
// void* audio_out; // the audio_out handle, used for this audio stream
- struct af_stream_s *afilter; // the audio filter stream
- struct ad_functions_s* ad_driver;
+ struct af_stream *afilter; // the audio filter stream
+ struct ad_functions *ad_driver;
#ifdef CONFIG_DYNAMIC_PLUGINS
void *dec_handle;
#endif
@@ -72,10 +74,11 @@ typedef struct {
int default_track;
} sh_audio_t;
-typedef struct {
+typedef struct sh_video {
+ struct MPOpts *opts;
int vid;
- demux_stream_t *ds;
- struct codecs_st *codec;
+ struct demux_stream *ds;
+ struct codecs *codec;
unsigned int format;
int initialized;
float timer; // absolute time in video stream, since last start/seek
@@ -99,7 +102,9 @@ typedef struct {
int disp_w,disp_h; // display size (filled by fileformat parser)
// output driver/filters: (set by libmpcodecs core)
unsigned int outfmtidx;
- struct vf_instance_s *vfilter; // the video filter chain, used for this video stream
+ struct vf_instance *vfilter; // the video filter chain, used for this video stream
+ int output_flags; // query_format() results for output filters+vo
+ const struct vd_functions *vd_driver;
int vf_initialized;
#ifdef CONFIG_DYNAMIC_PLUGINS
void *dec_handle;
@@ -112,26 +117,25 @@ typedef struct {
void* context; // codec-specific stuff (usually HANDLE or struct pointer)
} sh_video_t;
-typedef struct {
+typedef struct sh_sub {
+ struct MPOpts *opts;
int sid;
char type; // t = text, v = VobSub, a = SSA/ASS
unsigned char* extradata; // extra header data passed from demuxer
int extradata_len;
-#ifdef CONFIG_ASS
- ass_track_t* ass_track; // for SSA/ASS streams (type == 'a')
-#endif
+ struct ass_track_s *ass_track; // for SSA/ASS streams (type == 'a')
char* lang; // track language
int default_track;
} sh_sub_t;
// demuxer.c:
#define new_sh_audio(d, i) new_sh_audio_aid(d, i, i)
-sh_audio_t* new_sh_audio_aid(demuxer_t *demuxer,int id,int aid);
+sh_audio_t* new_sh_audio_aid(struct demuxer *demuxer,int id,int aid);
#define new_sh_video(d, i) new_sh_video_vid(d, i, i)
-sh_video_t* new_sh_video_vid(demuxer_t *demuxer,int id,int vid);
+sh_video_t* new_sh_video_vid(struct demuxer *demuxer,int id,int vid);
#define new_sh_sub(d, i) new_sh_sub_sid(d, i, i)
-sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid);
-void free_sh_audio(demuxer_t *demuxer, int id);
+sh_sub_t *new_sh_sub_sid(struct demuxer *demuxer, int id, int sid);
+void free_sh_audio(struct demuxer *demuxer, int id);
void free_sh_video(sh_video_t *sh);
// video.c:
diff --git a/libmpdemux/video.c b/libmpdemux/video.c
index fba4077207..b7e8aabb1b 100644
--- a/libmpdemux/video.c
+++ b/libmpdemux/video.c
@@ -132,7 +132,7 @@ switch(video_codec){
videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
else {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory.\n");
return 0;
}
}
@@ -225,7 +225,7 @@ switch(video_codec){
videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
else {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory.\n");
return 0;
}
}
@@ -278,7 +278,7 @@ mpeg_header_parser:
if(i==0x1B3) break; // found it!
if(!i || !skip_video_packet(d_video)){
if( mp_msg_test(MSGT_DECVIDEO,MSGL_V) ) mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MpegNoSequHdr);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"MPEG: FATAL: EOF while searching for sequence header.\n");
return 0;
}
}
@@ -288,27 +288,27 @@ mpeg_header_parser:
videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
else {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory.\n");
return 0;
}
}
if(!read_video_packet(d_video)){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CannotReadMpegSequHdr);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"FATAL: Cannot read sequence header.\n");
return 0;
}
if(mp_header_process_sequence_header (&picture, &videobuffer[4])) {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_BadMpegSequHdr);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"MPEG: bad sequence header\n");
goto mpeg_header_parser;
}
if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext.
int pos=videobuf_len;
if(!read_video_packet(d_video)){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CannotReadMpegSequHdrEx);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"FATAL: Cannot read sequence header extension.\n");
return 0;
}
if(mp_header_process_extension (&picture, &videobuffer[pos+4])) {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_BadMpegSequHdrEx);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"MPEG: bad sequence header extension\n");
return 0;
}
}
@@ -356,7 +356,7 @@ mpeg_header_parser:
videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
else {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory.\n");
return 0;
}
}
@@ -490,14 +490,14 @@ int video_read_frame(sh_video_t* sh_video,float* frame_time_ptr,unsigned char**
if(telecine){
frame_time=1;
if(telecine_cnt<-1.5 || telecine_cnt>1.5){
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_LeaveTelecineMode);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_INFO,"\ndemux_mpg: 30000/1001fps NTSC content detected, switching framerate.\n");
telecine=0;
}
} else
if(telecine_cnt>-0.5 && telecine_cnt<0.5 && !force_fps){
sh_video->fps=sh_video->fps*4/5;
sh_video->frametime=sh_video->frametime*5/4;
- mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_EnterTelecineMode);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_INFO,"\ndemux_mpg: 24000/1001fps progressive NTSC content detected, switching framerate.\n");
telecine=1;
}
} else if(video_codec == VIDEO_MPEG4){
@@ -644,4 +644,3 @@ int video_read_frame(sh_video_t* sh_video,float* frame_time_ptr,unsigned char**
if(frame_time_ptr) *frame_time_ptr=frame_time;
return in_size;
}
-
diff --git a/libmpdemux/yuv4mpeg.c b/libmpdemux/yuv4mpeg.c
index cb78176ea6..efee4e18bf 100644
--- a/libmpdemux/yuv4mpeg.c
+++ b/libmpdemux/yuv4mpeg.c
@@ -764,5 +764,3 @@ const char *y4m_strerr(int err)
return "unknown error code";
}
}
-
-
diff --git a/libmpdemux/yuv4mpeg.h b/libmpdemux/yuv4mpeg.h
index fd4dba805a..6e97662111 100644
--- a/libmpdemux/yuv4mpeg.h
+++ b/libmpdemux/yuv4mpeg.h
@@ -450,5 +450,3 @@ int y4m_allow_unknown_tags(int yn);
************************************************************************/
#endif /* MPLAYER_YUV4MPEG_H */
-
-
diff --git a/libmpdemux/yuv4mpeg_ratio.c b/libmpdemux/yuv4mpeg_ratio.c
index a9169fa4de..be5475c1b1 100644
--- a/libmpdemux/yuv4mpeg_ratio.c
+++ b/libmpdemux/yuv4mpeg_ratio.c
@@ -110,4 +110,3 @@ int y4m_parse_ratio(y4m_ratio_t *r, const char *s)
y4m_ratio_reduce(r);
return Y4M_OK;
}
-
diff --git a/libvo/aclib_template.c b/libvo/aclib_template.c
index a0c5aae55d..0d486bdaec 100644
--- a/libvo/aclib_template.c
+++ b/libvo/aclib_template.c
@@ -458,4 +458,3 @@ static void * RENAME(mem2agpcpy)(void * to, const void * from, size_t len)
if(len) small_memcpy(to, from, len);
return retval;
}
-
diff --git a/libvo/aspect.c b/libvo/aspect.c
index e54e8deb43..6fa9905731 100644
--- a/libvo/aspect.c
+++ b/libvo/aspect.c
@@ -19,9 +19,11 @@
/* Stuff for correct aspect scaling. */
#include "aspect.h"
#include "geometry.h"
+#include "video_out.h"
//#ifndef ASPECT_TEST
#include "mp_msg.h"
#include "help_mp.h"
+#include "options.h"
//#endif
//#define ASPECT_DEBUG
@@ -30,131 +32,117 @@
#include <stdio.h>
#endif
-int vo_panscan_x = 0;
-int vo_panscan_y = 0;
-float vo_panscan_amount = 0;
-float vo_panscanrange = 1.0;
-
#include "video_out.h"
-float force_monitor_aspect=0;
-float monitor_aspect=0;
-float monitor_pixel_aspect=1;
-extern float movie_aspect;
-
-static struct {
- int orgw; // real width
- int orgh; // real height
- int prew; // prescaled width
- int preh; // prescaled height
- int scrw; // horizontal resolution
- int scrh; // vertical resolution
- float asp;
-} aspdat;
-
-void aspect_save_orig(int orgw, int orgh){
+void aspect_save_orig(struct vo *vo, int orgw, int orgh)
+{
#ifdef ASPECT_DEBUG
printf("aspect_save_orig %dx%d \n",orgw,orgh);
#endif
- aspdat.orgw = orgw;
- aspdat.orgh = orgh;
+ vo->aspdat.orgw = orgw;
+ vo->aspdat.orgh = orgh;
}
-void aspect_save_prescale(int prew, int preh){
+void aspect_save_prescale(struct vo *vo, int prew, int preh)
+{
#ifdef ASPECT_DEBUG
printf("aspect_save_prescale %dx%d \n",prew,preh);
#endif
- aspdat.prew = prew;
- aspdat.preh = preh;
+ vo->aspdat.prew = prew;
+ vo->aspdat.preh = preh;
}
-void aspect_save_screenres(int scrw, int scrh){
+void aspect_save_screenres(struct vo *vo, int scrw, int scrh)
+{
#ifdef ASPECT_DEBUG
printf("aspect_save_screenres %dx%d \n",scrw,scrh);
#endif
- aspdat.scrw = scrw;
- aspdat.scrh = scrh;
- if (force_monitor_aspect)
- monitor_aspect = force_monitor_aspect;
- else
- monitor_aspect = monitor_pixel_aspect * scrw / scrh;
+ struct MPOpts *opts = vo->opts;
+ vo->aspdat.scrw = scrw;
+ vo->aspdat.scrh = scrh;
+ if (opts->force_monitor_aspect)
+ vo->monitor_aspect = opts->force_monitor_aspect;
+ else
+ vo->monitor_aspect = opts->monitor_pixel_aspect * scrw / scrh;
}
/* aspect is called with the source resolution and the
* resolution, that the scaled image should fit into
*/
-void aspect_fit(int *srcw, int *srch, int fitw, int fith){
+void aspect_fit(struct vo *vo, int *srcw, int *srch, int fitw, int fith)
+{
+ struct aspect_data *aspdat = &vo->aspdat;
int tmpw;
#ifdef ASPECT_DEBUG
- printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
+ printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat->scrw,aspdat->scrh,
monitor_aspect);
- printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
+ printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat->prew,aspdat->preh);
#endif
*srcw = fitw;
- *srch = (int)(((float)fitw / (float)aspdat.prew * (float)aspdat.preh)
- * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect)));
+ *srch = (int)(((float)fitw / (float)aspdat->prew * (float)aspdat->preh)
+ * ((float)aspdat->scrh / ((float)aspdat->scrw / vo->monitor_aspect)));
*srch+= *srch%2; // round
#ifdef ASPECT_DEBUG
- printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
+ printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat->prew,aspdat->preh);
#endif
- if(*srch>aspdat.scrh || *srch<aspdat.orgh){
- tmpw = (int)(((float)fith / (float)aspdat.preh * (float)aspdat.prew)
- * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
+ if(*srch>aspdat->scrh || *srch<aspdat->orgh){
+ tmpw = (int)(((float)fith / (float)aspdat->preh * (float)aspdat->prew)
+ * ((float)aspdat->scrw / ((float)aspdat->scrh / (1.0/vo->monitor_aspect))));
tmpw+= tmpw%2; // round
- if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){
+ if(tmpw<=aspdat->scrw /*&& tmpw>=aspdat->orgw*/){
*srch = fith;
*srcw = tmpw;
}else{
#ifndef ASPECT_TEST
- mp_msg(MSGT_VO,MSGL_WARN,MSGTR_LIBVO_ASPECT_NoSuitableNewResFound);
+ mp_tmsg(MSGT_VO,MSGL_WARN,"[ASPECT] Warning: No suitable new res found!\n");
#else
- mp_msg(MSGT_VO,MSGL_WARN,MSGTR_LIBVO_ASPECT_NoNewSizeFoundThatFitsIntoRes);
+ mp_tmsg(MSGT_VO,MSGL_WARN,"[ASPECT] Error: No new size found that fits into res!\n");
#endif
}
}
- aspdat.asp=*srcw / (float)*srch;
+ aspdat->asp=*srcw / (float)*srch;
#ifdef ASPECT_DEBUG
- printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
+ printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat->prew,aspdat->preh);
#endif
}
-void aspect(int *srcw, int *srch, int zoom){
- int fitw = zoom ? aspdat.scrw : aspdat.prew;
- int fith = zoom ? aspdat.scrh : aspdat.preh;
+void aspect(struct vo *vo, int *srcw, int *srch, int zoom){
+ int fitw = zoom ? vo->aspdat.scrw : vo->aspdat.prew;
+ int fith = zoom ? vo->aspdat.scrh : vo->aspdat.preh;
if( !zoom && geometry_wh_changed ) {
#ifdef ASPECT_DEBUG
printf("aspect(0) no aspect forced!\n");
#endif
return; // the user doesn't want to fix aspect
}
- aspect_fit(srcw, srch, fitw, fith);
+ aspect_fit(vo, srcw, srch, fitw, fith);
}
-void panscan_init( void )
+void panscan_init(struct vo *vo)
{
- vo_panscan_x=0;
- vo_panscan_y=0;
- vo_panscan_amount=0.0f;
+ vo->panscan_x = 0;
+ vo->panscan_y = 0;
+ vo->panscan_amount = 0.0f;
}
-void panscan_calc( void )
+void panscan_calc(struct vo *vo)
{
int fwidth,fheight;
int vo_panscan_area;
-
- if (vo_panscanrange > 0) {
- aspect(&fwidth,&fheight,A_ZOOM);
- vo_panscan_area = (aspdat.scrh-fheight);
- if (!vo_panscan_area)
- vo_panscan_area = aspdat.scrw - fwidth;
- vo_panscan_area *= vo_panscanrange;
- } else
- vo_panscan_area = -vo_panscanrange * aspdat.scrh;
-
- vo_panscan_amount = vo_fs ? vo_panscan : 0;
- vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp;
- vo_panscan_y = vo_panscan_area * vo_panscan_amount;
+ struct MPOpts *opts = vo->opts;
+
+ if (opts->vo_panscanrange > 0) {
+ aspect(vo, &fwidth, &fheight, A_ZOOM);
+ vo_panscan_area = (vo->aspdat.scrh - fheight);
+ if (!vo_panscan_area)
+ vo_panscan_area = vo->aspdat.scrw - fwidth;
+ vo_panscan_area *= opts->vo_panscanrange;
+ } else
+ vo_panscan_area = -opts->vo_panscanrange * vo->aspdat.scrh;
+
+ vo->panscan_amount = vo_fs ? vo_panscan : 0;
+ vo->panscan_x = vo_panscan_area * vo->panscan_amount * vo->aspdat.asp;
+ vo->panscan_y = vo_panscan_area * vo->panscan_amount;
}
-
diff --git a/libvo/aspect.h b/libvo/aspect.h
index 0c741d4ae3..89839e2c94 100644
--- a/libvo/aspect.h
+++ b/libvo/aspect.h
@@ -20,23 +20,35 @@
#define MPLAYER_ASPECT_H
/* Stuff for correct aspect scaling. */
-extern int vo_panscan_x;
-extern int vo_panscan_y;
-extern float vo_panscan_amount;
+struct vo;
+void panscan_init(struct vo *vo);
+void panscan_calc(struct vo *vo);
-void panscan_init(void);
-void panscan_calc(void);
+void aspect_save_orig(struct vo *vo, int orgw, int orgh);
-void aspect_save_orig(int orgw, int orgh);
+void aspect_save_prescale(struct vo *vo, int prew, int preh);
-void aspect_save_prescale(int prew, int preh);
-
-void aspect_save_screenres(int scrw, int scrh);
+void aspect_save_screenres(struct vo *vo, int scrw, int scrh);
#define A_ZOOM 1
#define A_NOZOOM 0
-void aspect(int *srcw, int *srch, int zoom);
-void aspect_fit(int *srcw, int *srch, int fitw, int fith);
+void aspect(struct vo *vo, int *srcw, int *srch, int zoom);
+void aspect_fit(struct vo *vo, int *srcw, int *srch, int fitw, int fith);
+
+
+#ifdef IS_OLD_VO
+#define vo_panscan_x global_vo->panscan_x
+#define vo_panscan_y global_vo->panscan_y
+#define vo_panscan_amount global_vo->panscan_amount
+#define monitor_aspect global_vo->monitor_aspect
+
+#define panscan_init() panscan_init(global_vo)
+#define panscan_calc() panscan_calc(global_vo)
+#define aspect_save_orig(...) aspect_save_orig(global_vo, __VA_ARGS__)
+#define aspect_save_prescale(...) aspect_save_prescale(global_vo, __VA_ARGS__)
+#define aspect_save_screenres(...) aspect_save_screenres(global_vo, __VA_ARGS__)
+#define aspect(...) aspect(global_vo, __VA_ARGS__)
+#endif
#endif /* MPLAYER_ASPECT_H */
diff --git a/libvo/aspecttest.c b/libvo/aspecttest.c
index 5fe6416fce..3d6064c577 100644
--- a/libvo/aspecttest.c
+++ b/libvo/aspecttest.c
@@ -59,4 +59,3 @@ int main(int argc, char *argv[]) {
printf("new size: %dx%d\n",w,h);
return 0;
}
-
diff --git a/libvo/font_load.h b/libvo/font_load.h
index 8dd494b941..4776ff135d 100644
--- a/libvo/font_load.h
+++ b/libvo/font_load.h
@@ -80,7 +80,6 @@ typedef struct font_desc {
} font_desc_t;
extern font_desc_t* vo_font;
-extern font_desc_t* sub_font;
extern char *subtitle_font_encoding;
extern float text_font_scale_factor;
diff --git a/libvo/font_load_ft.c b/libvo/font_load_ft.c
index ddaf598069..f44c2c5796 100644
--- a/libvo/font_load_ft.c
+++ b/libvo/font_load_ft.c
@@ -84,13 +84,13 @@ static FT_Library library;
#define OSD_CHARSET_SIZE 15
-static FT_ULong osd_charset[OSD_CHARSET_SIZE] =
+static const FT_ULong osd_charset[OSD_CHARSET_SIZE] =
{
0xe001, 0xe002, 0xe003, 0xe004, 0xe005, 0xe006, 0xe007, 0xe008,
0xe009, 0xe00a, 0xe00b, 0xe010, 0xe011, 0xe012, 0xe013
};
-static FT_ULong osd_charcodes[OSD_CHARSET_SIZE] =
+static const FT_ULong osd_charcodes[OSD_CHARSET_SIZE] =
{
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0a,0x0b,0x10,0x11,0x12,0x13
@@ -920,7 +920,7 @@ static int load_sub_face(const char *name, int face_index, FT_Face *face)
if (err) {
err = FT_New_Face(library, MPLAYER_DATADIR "/subfont.ttf", 0, face);
if (err) {
- mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_NewFaceFailed);
+ mp_tmsg(MSGT_OSD, MSGL_ERR, "New_Face failed. Maybe the font path is wrong.\nPlease supply the text font file (~/.mplayer/subfont.ttf).\n");
return -1;
}
}
@@ -931,7 +931,7 @@ static int load_sub_face(const char *name, int face_index, FT_Face *face)
static int load_osd_face(FT_Face *face)
{
if ( FT_New_Memory_Face(library, osd_font_pfb, sizeof(osd_font_pfb), 0, face) ) {
- mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_NewMemoryFaceFailed);
+ mp_tmsg(MSGT_OSD, MSGL_ERR, "New_Memory_Face failed..\n");
return -1;
}
return 0;
@@ -1018,7 +1018,7 @@ font_desc_t* read_font_desc_ft(const char *fname, int face_index, int movie_widt
/* generate the subtitle font */
err = load_sub_face(fname, face_index, &face);
if (err) {
- mp_msg(MSGT_OSD, MSGL_WARN, MSGTR_LIBVO_FONT_LOAD_FT_SubFaceFailed);
+ mp_tmsg(MSGT_OSD, MSGL_WARN, "subtitle font: load_sub_face failed.\n");
goto gen_osd;
}
desc->face_cnt++;
@@ -1035,7 +1035,7 @@ font_desc_t* read_font_desc_ft(const char *fname, int face_index, int movie_widt
}
if (charset_size < 0) {
- mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_SubFontCharsetFailed);
+ mp_tmsg(MSGT_OSD, MSGL_ERR, "subtitle font: prepare_charset failed.\n");
goto err_out;
}
#else
@@ -1049,7 +1049,7 @@ font_desc_t* read_font_desc_ft(const char *fname, int face_index, int movie_widt
subtitle_font_thickness, subtitle_font_radius);
if (err) {
- mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_CannotPrepareSubtitleFont);
+ mp_tmsg(MSGT_OSD, MSGL_ERR, "Cannot prepare subtitle font.\n");
goto err_out;
}
@@ -1067,14 +1067,14 @@ gen_osd:
subtitle_font_thickness, subtitle_font_radius);
if (err) {
- mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_CannotPrepareOSDFont);
+ mp_tmsg(MSGT_OSD, MSGL_ERR, "Cannot prepare OSD font.\n");
goto err_out;
}
err = generate_tables(desc, subtitle_font_thickness, subtitle_font_radius);
if (err) {
- mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_CannotGenerateTables);
+ mp_tmsg(MSGT_OSD, MSGL_ERR, "Cannot generate tables.\n");
goto err_out;
}
@@ -1129,7 +1129,7 @@ int done_freetype(void)
err = FT_Done_FreeType(library);
if (err) {
- mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_DoneFreeTypeFailed);
+ mp_tmsg(MSGT_OSD, MSGL_ERR, "FT_Done_FreeType failed.\n");
return -1;
}
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index b9ded01436..bb351f90d6 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -32,6 +32,7 @@
#include <string.h>
#include <ctype.h>
#include <math.h>
+#include "old_vo_defines.h"
#include "gl_common.h"
#include "libavutil/common.h"
@@ -1661,4 +1662,3 @@ void swapGlBuffers(void) {
glXSwapBuffers(mDisplay, vo_window);
}
#endif
-
diff --git a/libvo/gl_common.h b/libvo/gl_common.h
index 8f9ce55dab..56fcbba0e3 100644
--- a/libvo/gl_common.h
+++ b/libvo/gl_common.h
@@ -353,18 +353,18 @@ void glDisableYUVConversion(GLenum target, int type);
/** \} */
#ifdef GL_WIN32
-#define vo_border() vo_w32_border()
+#define vo_gl_border(vo) vo_w32_border()
#define vo_check_events() vo_w32_check_events()
#define vo_fullscreen() vo_w32_fullscreen()
-#define vo_ontop() vo_w32_ontop()
+#define vo_gl_ontop() vo_w32_ontop()
#define vo_uninit() vo_w32_uninit()
int setGlWindow(int *vinfo, HGLRC *context, HWND win);
void releaseGlContext(int *vinfo, HGLRC *context);
#else
-#define vo_border() vo_x11_border()
+#define vo_gl_border(vo) vo_x11_border(vo)
#define vo_check_events() vo_x11_check_events(mDisplay)
#define vo_fullscreen() vo_x11_fullscreen()
-#define vo_ontop() vo_x11_ontop()
+#define vo_gl_ontop() vo_x11_ontop()
#define vo_uninit() vo_x11_uninit()
int setGlWindow(XVisualInfo **vinfo, GLXContext *context, Window win);
void releaseGlContext(XVisualInfo **vinfo, GLXContext *context);
diff --git a/libvo/gtf.c b/libvo/gtf.c
index ce82d39a70..6dd64a57c8 100644
--- a/libvo/gtf.c
+++ b/libvo/gtf.c
@@ -302,5 +302,3 @@ void GTF_calcTimings(double X,double Y,double freq, int type,
result-> RefreshRate = actual_V_frame_freq*100;/* Refresh rate in units of 0.01 Hz*/
}
-
-
diff --git a/libvo/mga_common.c b/libvo/mga_common.c
index 13b73d1b45..a40f934ee5 100644
--- a/libvo/mga_common.c
+++ b/libvo/mga_common.c
@@ -23,6 +23,7 @@
#include "libmpcodecs/vf_scale.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "old_vo_wrapper.h"
// mga_vid drawing functions
static void set_window( void ); /* forward declaration to kill warnings */
@@ -242,11 +243,11 @@ static void mga_fullscreen(void)
mga_vid_config.x_org=(vo_screenwidth-w)/2;
mga_vid_config.y_org=(vo_screenheight-h)/2;
if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) )
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_ErrorInConfigIoctl );
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] error in mga_vid_config ioctl (wrong mga_vid.o version?)" );
}
#endif
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -257,36 +258,35 @@ static int control(uint32_t request, void *data, ...)
return draw_image(data);
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
short value;
uint32_t luma,prev;
+ struct voctrl_set_equalizer_args *args = data;
- if ( strcmp( data,"brightness" ) && strcmp( data,"contrast" ) ) return VO_FALSE;
+ if (strcmp(args->name, "brightness") && strcmp(args->name, "contrast"))
+ return VO_FALSE;
if (ioctl(f,MGA_VID_GET_LUMA,&prev)) {
perror("Error in mga_vid_config ioctl()");
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_CouldNotGetLumaValuesFromTheKernelModule);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] Could not get luma values from the kernel module!\n");
return VO_FALSE;
}
// printf("GET: 0x%4X 0x%4X \n",(prev>>16),(prev&0xffff));
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
+ value = args->value;
// printf("value: %d -> ",value);
value=((value+100)*255)/200-128; // maps -100=>-128 and +100=>127
// printf("%d \n",value);
- if(!strcmp(data,"contrast"))
+ if (!strcmp(args->name, "contrast"))
luma = (prev&0xFFFF0000)|(value&0xFFFF);
else
luma = (prev&0xFFFF)|(value<<16);
if (ioctl(f,MGA_VID_SET_LUMA,luma)) {
perror("Error in mga_vid_config ioctl()");
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_CouldNotSetLumaValuesFromTheKernelModule);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] Could not set luma values from the kernel module!\n");
return VO_FALSE;
}
@@ -295,29 +295,25 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int * value;
short val;
uint32_t luma;
+ struct voctrl_get_equalizer_args *args = data;
- if ( strcmp( data,"brightness" ) && strcmp( data,"contrast" ) ) return VO_FALSE;
+ if (strcmp(args->name, "brightness") && strcmp(args->name, "contrast"))
+ return VO_FALSE;
if (ioctl(f,MGA_VID_GET_LUMA,&luma)) {
perror("Error in mga_vid_config ioctl()");
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_CouldNotGetLumaValuesFromTheKernelModule);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] Could not get luma values from the kernel module!\n");
return VO_FALSE;
}
- if ( !strcmp( data,"contrast" ) )
+ if (!strcmp(args->name, "contrast"))
val=(luma & 0xFFFF);
else
val=(luma >> 16);
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- *value = (val*200)/255;
+ *args->valueptr = (val*200)/255;
return VO_TRUE;
}
@@ -327,7 +323,7 @@ static int control(uint32_t request, void *data, ...)
if (vo_screenwidth && vo_screenheight)
mga_fullscreen();
else
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_ScreenWidthHeightUnknown);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] Screen width/height unknown!\n");
return VO_TRUE;
case VOCTRL_GET_PANSCAN:
if ( !vo_fs ) return VO_FALSE;
@@ -384,7 +380,7 @@ static int mga_init(int width,int height,unsigned int format){
mga_vid_config.frame_size = ((width + 31) & ~31) * height * 2;
mga_vid_config.format=MGA_VID_FORMAT_UYVY; break;
default:
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_InvalidOutputFormat,format);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] invalid output format %0X\n",format);
return -1;
}
@@ -402,7 +398,7 @@ static int mga_init(int width,int height,unsigned int format){
if(width > 1024 && height > 1024)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_MGA_ResolutionTooHigh);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[MGA] Source resolution exceeds 1023x1023 in at least one dimension.\n[MGA] Rescale in software or use -lavdopts lowres=1.\n");
return -1;
} else if(height <= 1024)
{
@@ -413,13 +409,13 @@ static int mga_init(int width,int height,unsigned int format){
if(mga_vid_config.card_type != MGA_G550)
{
// we don't have a G550, so our resolution is too high
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_MGA_ResolutionTooHigh);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[MGA] Source resolution exceeds 1023x1023 in at least one dimension.\n[MGA] Rescale in software or use -lavdopts lowres=1.\n");
return -1;
} else {
// there is a deeper problem
// we have a G550, but still couldn't configure mga_vid
perror("Error in mga_vid_config ioctl()");
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_IncompatibleDriverVersion);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] Your mga_vid driver version is incompatible with this MPlayer version!\n");
return -1;
}
// if we arrived here, then we could successfully configure mga_vid
@@ -430,7 +426,7 @@ static int mga_init(int width,int height,unsigned int format){
if (ioctl(f,MGA_VID_CONFIG,&mga_vid_config))
{
perror("Error in mga_vid_config ioctl()");
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_IncompatibleDriverVersion);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] Your mga_vid driver version is incompatible with this MPlayer version!\n");
return -1;
}
}
@@ -474,7 +470,7 @@ static int preinit(const char *vo_subdevice)
if(f == -1)
{
perror("open");
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_CouldntOpen,devname);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[MGA] Couldn't open: %s\n",devname);
return -1;
}
@@ -484,7 +480,7 @@ static int preinit(const char *vo_subdevice)
ioctl(f,MGA_VID_GET_VERSION,&ver);
if(MGA_VID_VERSION != ver)
{
- mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_MGA_mgavidVersionMismatch, ver, MGA_VID_VERSION);
+ mp_tmsg(MSGT_VO, MSGL_ERR, "[MGA] mismatch between kernel (%u) and MPlayer (%u) mga_vid driver versions\n", ver, MGA_VID_VERSION);
return -1;
}
diff --git a/libvo/old_vo_defines.h b/libvo/old_vo_defines.h
new file mode 100644
index 0000000000..feded12d5b
--- /dev/null
+++ b/libvo/old_vo_defines.h
@@ -0,0 +1,24 @@
+#ifndef MPLAYER_OLD_VO_DEFINES_H
+#define MPLAYER_OLD_VO_DEFINES_H
+
+#include "options.h"
+#include "video_out.h"
+#include "old_vo_wrapper.h"
+
+// Triggers more defines in x11_common.h
+#define IS_OLD_VO 1
+
+#define vo_ontop global_vo->opts->vo_ontop
+#define vo_config_count global_vo->config_count
+#define vo_dx global_vo->dx
+#define vo_dy global_vo->dy
+#define vo_dwidth global_vo->dwidth
+#define vo_dheight global_vo->dheight
+#define vo_dbpp global_vo->opts->vo_dbpp
+#define vo_screenwidth global_vo->opts->vo_screenwidth
+#define vo_screenheight global_vo->opts->vo_screenheight
+#define vidmode global_vo->opts->vidmode
+#define movie_aspect global_vo->opts->movie_aspect
+
+#define calc_src_dst_rects(...) calc_src_dst_rects(global_vo, __VA_ARGS__)
+#endif
diff --git a/libvo/old_vo_wrapper.c b/libvo/old_vo_wrapper.c
new file mode 100644
index 0000000000..bdbc8b8349
--- /dev/null
+++ b/libvo/old_vo_wrapper.c
@@ -0,0 +1,116 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include <stdint.h>
+#include "old_vo_wrapper.h"
+#include "video_out.h"
+#include "sub.h"
+
+struct vo *global_vo;
+struct osd_state *global_osd;
+
+int old_vo_preinit(struct vo *vo, const char *arg)
+{
+ global_vo = vo;
+ return vo->driver->old_functions->preinit(arg);
+}
+
+
+int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height,
+ uint32_t flags, char *title, uint32_t format)
+{
+ return vo->driver->old_functions->config(width, height, d_width,
+ d_height, flags, title, format);
+}
+
+
+int old_vo_control(struct vo *vo, uint32_t request, void *data)
+{
+ return vo->driver->old_functions->control(request, data);
+}
+
+
+int old_vo_draw_frame(struct vo *vo, uint8_t *src[])
+{
+ return vo->driver->old_functions->draw_frame(src);
+}
+
+
+int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
+ int w, int h, int x, int y)
+{
+ return vo->driver->old_functions->draw_slice(src, stride, w, h, x, y);
+}
+
+
+void old_vo_draw_osd(struct vo *vo, struct osd_state *osd)
+{
+ global_osd = osd;
+ vo->driver->old_functions->draw_osd();
+}
+
+
+void old_vo_flip_page(struct vo *vo)
+{
+ vo->driver->old_functions->flip_page();
+}
+
+
+void old_vo_check_events(struct vo *vo)
+{
+ vo->driver->old_functions->check_events();
+}
+
+
+void old_vo_uninit(struct vo *vo)
+{
+ vo->driver->old_functions->uninit();
+}
+
+
+static void draw_alpha_wrapper(void *ctx, int x0, int y0, int w, int h,
+ unsigned char *src, unsigned char *srca,
+ int stride)
+{
+ void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) = ctx;
+ draw_alpha(x0, y0, w, h, src, srca, stride);
+}
+
+
+void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))
+{
+ osd_draw_text(global_osd, dxs, dys, draw_alpha_wrapper, draw_alpha);
+}
+
+void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
+ int right_border, int bottom_border, int orig_w, int orig_h,
+ void (*draw_alpha)(int x0, int y0, int w,int h,
+ unsigned char* src,
+ unsigned char *srca, int stride))
+{
+ osd_draw_text_ext(global_osd, dxs, dys, left_border, top_border,
+ right_border, bottom_border, orig_w, orig_h,
+ draw_alpha_wrapper, draw_alpha);
+}
+
+int vo_update_osd(int dxs, int dys)
+{
+ return osd_update(global_osd, dxs, dys);
+}
diff --git a/libvo/old_vo_wrapper.h b/libvo/old_vo_wrapper.h
new file mode 100644
index 0000000000..250a1187fe
--- /dev/null
+++ b/libvo/old_vo_wrapper.h
@@ -0,0 +1,29 @@
+#ifndef MPLAYER_OLD_VO_WRAPPER_H
+#define MPLAYER_OLD_VO_WRAPPER_H
+
+#include <stdint.h>
+#include "video_out.h"
+
+extern struct vo *global_vo;
+extern struct osd_state *global_osd;
+
+int old_vo_preinit(struct vo *vo, const char *);
+int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height,
+ uint32_t flags, char *title, uint32_t format);
+int old_vo_control(struct vo *vo, uint32_t request, void *data);
+int old_vo_draw_frame(struct vo *vo, uint8_t *src[]);
+int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
+ int w, int h, int x, int y);
+void old_vo_draw_osd(struct vo *vo, struct osd_state *osd);
+void old_vo_flip_page(struct vo *vo);
+void old_vo_check_events(struct vo *vo);
+void old_vo_uninit(struct vo *vo);
+
+void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
+void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
+ int right_border, int bottom_border, int orig_w, int orig_h,
+ void (*draw_alpha)(int x0, int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride));
+int vo_update_osd(int dxs, int dys);
+
+#endif
diff --git a/libvo/osd.c b/libvo/osd.c
index 9f17bdb31e..a3664dadb3 100644
--- a/libvo/osd.c
+++ b/libvo/osd.c
@@ -391,4 +391,3 @@ void vo_draw_alpha_rgb16(int w,int h, unsigned char* src, unsigned char *srca, i
}
return;
}
-
diff --git a/libvo/spuenc.c b/libvo/spuenc.c
index 670a393bc2..bc35a06d18 100644
--- a/libvo/spuenc.c
+++ b/libvo/spuenc.c
@@ -229,50 +229,3 @@ pixbuf_encode_rle(int x, int y, int w, int h, char *inbuf, int stride,encodedat
}
encode_do_control(x,y, ed, &pb);
}
-
-
-void
-pixbuf_load_xpm( pixbuf* pb, char* xpm[] ) {
- int colors, chrs, l, n;
- char c[4], table[256];
- unsigned char *b, *i;
-
- sscanf( xpm[0], "%d %d %d %d", &pb->x, &pb->y, &colors, &chrs);
- if( colors > 4 ) {
- fprintf( stderr, "the pixmap MUST be 4 colors or less\n");
- exit (-1);
- }
- if( chrs != 1 ) {
- fprintf( stderr, "the XPM format MUST be 1 char per pixel\n");
- exit (-1);
- }
- if( pb->x > 0xFFF || pb->y > 0xFFF ) {
- fprintf( stderr, "the size is excesive\n");
- exit (-1);
- }
-
- for( l=0; l<colors; l++ ) {
- n= sscanf( xpm[l+1], "%c c #%x", &c[l], &pb->rgb[l]);
- if( n < 2 ) {
- /* this one is transparent */
- pb->rgb[l]=0xff000000;
- }
- table[(int)c[l]]=l;
- }
-
- pb->pixels= malloc( pb->x * pb->y );
- b= pb->pixels;
-
- for( l= colors+1; l <= pb->y + colors; l++ ) {
- i= xpm[l];
- while( (int)*i) {
- *b++ = table[*i++];
- }
- }
-}
-
-void
-pixbuf_delete( pixbuf* pb ) {
- free( pb->pixels );
-}
-
diff --git a/libvo/spuenc.h b/libvo/spuenc.h
index 5bc83b329b..7f4590b4ac 100644
--- a/libvo/spuenc.h
+++ b/libvo/spuenc.h
@@ -41,6 +41,5 @@ typedef struct {
} encodedata;
void pixbuf_encode_rle(int x, int y, int w, int h, char *inbuf, int stride, encodedata *ed);
-void pixbuf_delete(pixbuf* pb);
#endif /* MPLAYER_SPUENC_H */
diff --git a/libvo/sub.c b/libvo/sub.c
index 665c935b34..f729f56ad8 100644
--- a/libvo/sub.c
+++ b/libvo/sub.c
@@ -32,6 +32,7 @@
#include "stream/tv.h"
#include "osdep/timer.h"
+#include "talloc.h"
#include "mplayer.h"
#include "mp_msg.h"
#include "help_mp.h"
@@ -64,28 +65,26 @@ struct osd_text_p {
};
//^
-char * sub_osd_names[]={
- MSGTR_VO_SUB_Seekbar,
- MSGTR_VO_SUB_Play,
- MSGTR_VO_SUB_Pause,
- MSGTR_VO_SUB_Stop,
- MSGTR_VO_SUB_Rewind,
- MSGTR_VO_SUB_Forward,
- MSGTR_VO_SUB_Clock,
- MSGTR_VO_SUB_Contrast,
- MSGTR_VO_SUB_Saturation,
- MSGTR_VO_SUB_Volume,
- MSGTR_VO_SUB_Brightness,
- MSGTR_VO_SUB_Hue,
- MSGTR_VO_SUB_Balance
+char * const sub_osd_names[]={
+ _("Seekbar"),
+ _("Play"),
+ _("Pause"),
+ _("Stop"),
+ _("Rewind"),
+ _("Forward"),
+ _("Clock"),
+ _("Contrast"),
+ _("Saturation"),
+ _("Volume"),
+ _("Brightness"),
+ _("Hue"),
+ _("Balance")
};
-char * sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" };
+char * const sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" };
//static int vo_font_loaded=-1;
font_desc_t* vo_font=NULL;
-font_desc_t* sub_font=NULL;
-unsigned char* vo_osd_text=NULL;
#ifdef CONFIG_TV_TELETEXT
void* vo_osd_teletext_page=NULL;
int vo_osd_teletext_half = 0;
@@ -167,9 +166,11 @@ static void alloc_buf(mp_osd_obj_t* obj)
}
// renders the buffer
-inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
+inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx)
+{
if (obj->allocated > 0) {
- draw_alpha(obj->bbox.x1,obj->bbox.y1,
+ draw_alpha(ctx,
+ obj->bbox.x1,obj->bbox.y1,
obj->bbox.x2-obj->bbox.x1,
obj->bbox.y2-obj->bbox.y1,
obj->bitmap_buffer,
@@ -192,8 +193,10 @@ no_utf8:
return c;
}
-inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
- const char *cp=vo_osd_text;
+inline static void vo_update_text_osd(struct osd_state *osd, mp_osd_obj_t* obj,
+ int dxs, int dys)
+{
+ const char *cp = osd->osd_text;
int x=20;
int h=0;
int font;
@@ -214,7 +217,7 @@ inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
alloc_buf(obj);
- cp=vo_osd_text;
+ cp = osd->osd_text;
x = obj->x;
while (*cp){
uint16_t c=utf8_get_char(&cp);
@@ -669,7 +672,7 @@ inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){
subtitle* vo_sub=NULL;
-inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){
+inline static void vo_update_text_sub(struct osd_state *osd, mp_osd_obj_t* obj,int dxs,int dys){
unsigned char *t;
int c,i,j,l,x,y,font,prevc,counter;
int k;
@@ -678,10 +681,11 @@ inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){
int xmin=dxs,xmax=0;
int h,lasth;
int xtblc, utblc;
+ struct font_desc *sub_font = osd->sub_font;
obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
- if(!vo_sub || !sub_font || !sub_visibility || (sub_font->font[40]<0)){
+ if(!vo_sub || !osd->sub_font || !sub_visibility || (sub_font->font[40]<0)){
obj->flags&=~OSDFLAG_VISIBLE;
return;
}
@@ -1052,9 +1056,9 @@ inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys)
obj->flags |= OSDFLAG_BBOX;
}
-inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride))
+inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(void *ctx, int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride), void *ctx)
{
- spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha);
+ spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha, ctx);
}
void *vo_spudec=NULL;
@@ -1078,7 +1082,8 @@ static mp_osd_obj_t* new_osd_obj(int type){
return osd;
}
-void free_osd_list(void){
+void osd_free(struct osd_state *osd)
+{
mp_osd_obj_t* obj=vo_osd_list;
while(obj){
mp_osd_obj_t* next=obj->next;
@@ -1088,12 +1093,15 @@ void free_osd_list(void){
obj=next;
}
vo_osd_list=NULL;
+ talloc_free(osd);
}
#define FONT_LOAD_DEFER 6
-int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
- int right_border, int bottom_border, int orig_w, int orig_h){
+int osd_update_ext(struct osd_state *osd, int dxs, int dys, int left_border,
+ int top_border, int right_border, int bottom_border,
+ int orig_w, int orig_h)
+{
mp_osd_obj_t* obj=vo_osd_list;
int chg=0;
#ifdef CONFIG_FREETYPE
@@ -1123,20 +1131,20 @@ int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
force_load_font = 0;
load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor);
if (sub_font_name)
- load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor);
+ load_font_ft(dxs, dys, &osd->sub_font, sub_font_name, text_font_scale_factor);
else
- load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor);
+ load_font_ft(dxs, dys, &osd->sub_font, font_name, text_font_scale_factor);
prev_dxs = dxs;
prev_dys = dys;
defer_counter = 0;
} else {
if (!vo_font)
load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor);
- if (!sub_font) {
+ if (!osd->sub_font) {
if (sub_font_name)
- load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor);
+ load_font_ft(dxs, dys, &osd->sub_font, sub_font_name, text_font_scale_factor);
else
- load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor);
+ load_font_ft(dxs, dys, &osd->sub_font, font_name, text_font_scale_factor);
}
}
#endif
@@ -1152,7 +1160,7 @@ int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
break;
#endif
case OSDTYPE_SUBTITLE:
- vo_update_text_sub(obj,dxs,dys);
+ vo_update_text_sub(osd, obj,dxs,dys);
break;
#ifdef CONFIG_TV_TELETEXT
case OSDTYPE_TELETEXT:
@@ -1171,8 +1179,8 @@ int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
obj->flags&=~OSDFLAG_VISIBLE;
break;
case OSDTYPE_OSD:
- if(vo_font && vo_osd_text && vo_osd_text[0]){
- vo_update_text_osd(obj,dxs,dys); // update bbox
+ if(vo_font && osd->osd_text[0]){
+ vo_update_text_osd(osd, obj, dxs, dys); // update bbox
obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
} else
obj->flags&=~OSDFLAG_VISIBLE;
@@ -1212,16 +1220,20 @@ int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
return chg;
}
-int vo_update_osd(int dxs, int dys) {
- return vo_update_osd_ext(dxs, dys, 0, 0, 0, 0, dxs, dys);
+int osd_update(struct osd_state *osd, int dxs, int dys)
+{
+ return osd_update_ext(osd, dxs, dys, 0, 0, 0, 0, dxs, dys);
}
-void vo_init_osd(void){
+struct osd_state *osd_create(void)
+{
+ struct osd_state *osd = talloc_zero(NULL, struct osd_state);
+ *osd = (struct osd_state){
+ };
if(!draw_alpha_init_flag){
draw_alpha_init_flag=1;
vo_draw_alpha_init();
}
- if(vo_osd_list) free_osd_list();
// temp hack, should be moved to mplayer/mencoder later
new_osd_obj(OSDTYPE_OSD);
new_osd_obj(OSDTYPE_SUBTITLE);
@@ -1236,13 +1248,16 @@ void vo_init_osd(void){
#ifdef CONFIG_FREETYPE
force_load_font = 1;
#endif
+ return osd;
}
int vo_osd_changed_flag=0;
-void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
+void osd_remove_text(struct osd_state *osd, int dxs, int dys,
+ void (*remove)(int x0, int y0, int w, int h))
+{
mp_osd_obj_t* obj=vo_osd_list;
- vo_update_osd(dxs,dys);
+ osd_update(osd, dxs, dys);
while(obj){
if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) &&
(obj->flags&OSDFLAG_OLD_BBOX)){
@@ -1258,17 +1273,24 @@ void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
}
}
-void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
- int right_border, int bottom_border, int orig_w, int orig_h,
- void (*draw_alpha)(int x0, int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) {
+void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys,
+ int left_border, int top_border, int right_border,
+ int bottom_border, int orig_w, int orig_h,
+ void (*draw_alpha)(void *ctx, int x0, int y0, int w,
+ int h, unsigned char* src,
+ unsigned char *srca,
+ int stride),
+ void *ctx)
+{
mp_osd_obj_t* obj=vo_osd_list;
- vo_update_osd_ext(dxs, dys, left_border, top_border, right_border, bottom_border, orig_w, orig_h);
+ osd_update_ext(osd, dxs, dys, left_border, top_border, right_border,
+ bottom_border, orig_w, orig_h);
while(obj){
if(obj->flags&OSDFLAG_VISIBLE){
vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack
switch(obj->type){
case OSDTYPE_SPU:
- vo_draw_spudec_sub(obj, draw_alpha); // FIXME
+ vo_draw_spudec_sub(obj, draw_alpha, ctx); // FIXME
break;
#ifdef CONFIG_DVDNAV
case OSDTYPE_DVDNAV:
@@ -1279,7 +1301,7 @@ void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
case OSDTYPE_OSD:
case OSDTYPE_SUBTITLE:
case OSDTYPE_PROGBAR:
- vo_draw_text_from_buffer(obj,draw_alpha);
+ vo_draw_text_from_buffer(obj, draw_alpha, ctx);
break;
}
obj->old_bbox=obj->bbox;
@@ -1290,8 +1312,13 @@ void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
}
}
-void vo_draw_text(int dxs, int dys, void (*draw_alpha)(int x0, int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) {
- vo_draw_text_ext(dxs, dys, 0, 0, 0, 0, dxs, dys, draw_alpha);
+void osd_draw_text(struct osd_state *osd, int dxs, int dys,
+ void (*draw_alpha)(void *ctx, int x0, int y0, int w, int h,
+ unsigned char* src, unsigned char *srca,
+ int stride),
+ void *ctx)
+{
+ osd_draw_text_ext(osd, dxs, dys, 0, 0, 0, 0, dxs, dys, draw_alpha, ctx);
}
static int vo_osd_changed_status = 0;
diff --git a/libvo/sub.h b/libvo/sub.h
index 978b4c940d..d5a30e0b86 100644
--- a/libvo/sub.h
+++ b/libvo/sub.h
@@ -66,14 +66,16 @@ typedef struct mp_osd_obj_s {
unsigned char *bitmap_buffer;
} mp_osd_obj_t;
+struct osd_state {
+ unsigned char osd_text[128];
+ struct font_desc *sub_font;
+};
#include "subreader.h"
extern sub_data* subdata; //currently used subtitles
extern subtitle* vo_sub;
-extern unsigned char* vo_osd_text;
-
extern void* vo_osd_teletext_page;
extern int vo_osd_teletext_half;
extern int vo_osd_teletext_mode;
@@ -105,8 +107,8 @@ extern void* vo_vobsub;
#define OSD_PB_1 0x13
/* now in textform */
-extern char * sub_osd_names[];
-extern char * sub_osd_names_short[];
+extern char * const sub_osd_names[];
+extern char * const sub_osd_names_short[];
extern int sub_unicode;
extern int sub_utf8;
@@ -122,17 +124,27 @@ extern int spu_alignment;
extern int spu_aamode;
extern float spu_gaussvar;
-void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
-void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
- int right_border, int bottom_border, int orig_w, int orig_h,
- void (*draw_alpha)(int x0, int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
-void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h));
-
-void vo_init_osd(void);
-int vo_update_osd(int dxs,int dys);
+void osd_draw_text(struct osd_state *osd, int dxs, int dys,
+ void (*draw_alpha)(void *ctx, int x0, int y0, int w, int h,
+ unsigned char* src, unsigned char *srca,
+ int stride),
+ void *ctx);
+void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys,
+ int left_border, int top_border, int right_border,
+ int bottom_border, int orig_w, int orig_h,
+ void (*draw_alpha)(void *ctx, int x0, int y0, int w,
+ int h, unsigned char* src,
+ unsigned char *srca,
+ int stride),
+ void *ctx);
+void osd_remove_text(struct osd_state *osd, int dxs, int dys,
+ void (*remove)(int x0, int y0, int w, int h));
+
+struct osd_state *osd_create(void);
+int osd_update(struct osd_state *osd, int dxs, int dys);
int vo_osd_changed(int new_value);
int vo_osd_check_range_update(int,int,int,int);
-void free_osd_list(void);
+void osd_free(struct osd_state *osd);
extern int vo_osd_changed_flag;
@@ -143,4 +155,9 @@ unsigned utf8_get_char(const char **str);
void osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey);
#endif
+
+#ifdef IS_OLD_VO
+#define vo_remove_text(...) osd_remove_text(global_osd, __VA_ARGS__)
+#endif
+
#endif /* MPLAYER_SUB_H */
diff --git a/libvo/vesa_lvo.c b/libvo/vesa_lvo.c
index a7b1120ceb..27ce03c63b 100644
--- a/libvo/vesa_lvo.c
+++ b/libvo/vesa_lvo.c
@@ -54,24 +54,24 @@ static uint8_t *lvo_mem = NULL;
static uint8_t next_frame;
static mga_vid_config_t mga_vid_config;
static unsigned image_bpp,image_height,image_width,src_format;
-uint32_t vlvo_control(uint32_t request, void *data, ...);
+int vlvo_control(uint32_t request, void *data);
#define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8)
#define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) )
#define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size))
-extern vo_functions_t video_out_vesa;
+extern struct vo_old_functions video_out_vesa;
int vlvo_preinit(const char *drvname)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_ThisBranchIsNoLongerSupported);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VESA_LVO] This branch is no longer supported.\n[VESA_LVO] Please use -vo vesa:vidix instead.\n");
return -1;
if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
mp_msg(MSGT_VO,MSGL_DBG2, "vesa_lvo: vlvo_preinit(%s) was called\n",drvname);}
lvo_handler = open(drvname,O_RDWR);
if(lvo_handler == -1)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_CouldntOpen,drvname);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VESA_LVO] Couldn't open: '%s'\n",drvname);
return -1;
}
/* we are able to tune up this stuff depend on fourcc format */
@@ -88,7 +88,7 @@ int vlvo_init(unsigned src_width,unsigned src_height,
unsigned dst_height,unsigned format,unsigned dest_bpp)
{
size_t i,awidth;
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_ThisBranchIsNoLongerSupported);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VESA_LVO] This branch is no longer supported.\n[VESA_LVO] Please use -vo vesa:vidix instead.\n");
return -1;
if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
mp_msg(MSGT_VO,MSGL_DBG2, "vesa_lvo: vlvo_init() was called\n");}
@@ -127,7 +127,7 @@ int vlvo_init(unsigned src_width,unsigned src_height,
mga_vid_config.frame_size = awidth*src_height*4;
break;
default:
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_InvalidOutputFormat,vo_format_name(format),format);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VESA_LVI] Invalid output format: %s(%0X)\n",vo_format_name(format),format);
return -1;
}
mga_vid_config.colkey_on=0;
@@ -141,7 +141,7 @@ int vlvo_init(unsigned src_width,unsigned src_height,
if (ioctl(lvo_handler,MGA_VID_CONFIG,&mga_vid_config))
{
perror("vesa_lvo: Error in mga_vid_config ioctl()");
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_IncompatibleDriverVersion);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VESA_LVO] Your fb_vid driver version is incompatible with this MPlayer version!\n");
return -1;
}
ioctl(lvo_handler,MGA_VID_ON,0);
@@ -166,7 +166,7 @@ void vlvo_term( void )
if(lvo_handler != -1) close(lvo_handler);
}
-uint32_t vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
+int vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -206,7 +206,7 @@ uint32_t vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,i
return 0;
}
-uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
+int vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
mp_msg(MSGT_VO,MSGL_DBG2, "vesa_lvo: vlvo_draw_slice() was called\n");}
@@ -224,7 +224,7 @@ uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y
return 0;
}
-uint32_t vlvo_draw_frame(uint8_t *image[])
+int vlvo_draw_frame(uint8_t *image[])
{
/* Note it's very strange but sometime for YUY2 draw_frame is called */
fast_memcpy(lvo_mem,image[0],mga_vid_config.frame_size);
@@ -314,7 +314,7 @@ uint32_t vlvo_query_info(uint32_t format)
return VFCAP_CSP_SUPPORTED;
}
-uint32_t vlvo_control(uint32_t request, void *data, ...)
+int vlvo_control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vesa_lvo.h b/libvo/vesa_lvo.h
index 1e7887c8ae..9d77f60045 100644
--- a/libvo/vesa_lvo.h
+++ b/libvo/vesa_lvo.h
@@ -32,8 +32,8 @@ int vlvo_init(unsigned src_width,unsigned src_height,
void vlvo_term( void );
uint32_t vlvo_query_info(uint32_t format);
-uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y);
-uint32_t vlvo_draw_frame(uint8_t *src[]);
+int vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y);
+int vlvo_draw_frame(uint8_t *src[]);
void vlvo_flip_page(void);
void vlvo_draw_osd(void);
diff --git a/libvo/video_out.c b/libvo/video_out.c
index b7c0ed1f0a..f81544fc93 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -26,6 +26,8 @@
//#include <sys/mman.h>
#include "config.h"
+#include "options.h"
+#include "talloc.h"
#include "video_out.h"
#include "aspect.h"
#include "geometry.h"
@@ -34,27 +36,14 @@
#include "help_mp.h"
#include "osdep/shmem.h"
-
-//int vo_flags=0;
+#ifdef CONFIG_X11
+#include "x11_common.h"
+#endif
int xinerama_screen = -1;
int xinerama_x;
int xinerama_y;
-// currect resolution/bpp on screen: (should be autodetected by vo_init())
-int vo_depthonscreen=0;
-int vo_screenwidth=0;
-int vo_screenheight=0;
-
-int vo_config_count=0;
-
-// requested resolution/bpp: (-x -y -bpp options)
-int vo_dx=0;
-int vo_dy=0;
-int vo_dwidth=0;
-int vo_dheight=0;
-int vo_dbpp=0;
-
int vo_nomouse_input = 0;
int vo_grabpointer = 1;
int vo_doublebuffering = 1;
@@ -62,7 +51,6 @@ int vo_vsync = 0;
int vo_fs = 0;
int vo_fsmode = 0;
float vo_panscan = 0.0f;
-int vo_ontop = 0;
int vo_adapter_num=0;
int vo_refresh_rate=0;
int vo_keepaspect=1;
@@ -82,58 +70,58 @@ int vo_colorkey = 0x0000ff00; // default colorkey is green
//
// Externally visible list of all vo drivers
//
-extern vo_functions_t video_out_mga;
-extern vo_functions_t video_out_xmga;
-extern vo_functions_t video_out_x11;
-extern vo_functions_t video_out_xover;
-extern vo_functions_t video_out_xvmc;
-extern vo_functions_t video_out_vdpau;
-extern vo_functions_t video_out_xv;
-extern vo_functions_t video_out_gl;
-extern vo_functions_t video_out_gl2;
-extern vo_functions_t video_out_dga;
-extern vo_functions_t video_out_sdl;
-extern vo_functions_t video_out_3dfx;
-extern vo_functions_t video_out_tdfxfb;
-extern vo_functions_t video_out_s3fb;
-extern vo_functions_t video_out_wii;
-extern vo_functions_t video_out_null;
-extern vo_functions_t video_out_zr;
-extern vo_functions_t video_out_zr2;
-extern vo_functions_t video_out_bl;
-extern vo_functions_t video_out_fbdev;
-extern vo_functions_t video_out_fbdev2;
-extern vo_functions_t video_out_svga;
-extern vo_functions_t video_out_png;
-extern vo_functions_t video_out_ggi;
-extern vo_functions_t video_out_aa;
-extern vo_functions_t video_out_caca;
-extern vo_functions_t video_out_mpegpes;
-extern vo_functions_t video_out_yuv4mpeg;
-extern vo_functions_t video_out_direct3d;
-extern vo_functions_t video_out_directx;
-extern vo_functions_t video_out_kva;
-extern vo_functions_t video_out_dxr2;
-extern vo_functions_t video_out_dxr3;
-extern vo_functions_t video_out_ivtv;
-extern vo_functions_t video_out_v4l2;
-extern vo_functions_t video_out_jpeg;
-extern vo_functions_t video_out_gif89a;
-extern vo_functions_t video_out_vesa;
-extern vo_functions_t video_out_directfb;
-extern vo_functions_t video_out_dfbmga;
-extern vo_functions_t video_out_xvidix;
-extern vo_functions_t video_out_winvidix;
-extern vo_functions_t video_out_cvidix;
-extern vo_functions_t video_out_tdfx_vid;
-extern vo_functions_t video_out_xvr100;
-extern vo_functions_t video_out_tga;
-extern vo_functions_t video_out_corevideo;
-extern vo_functions_t video_out_quartz;
-extern vo_functions_t video_out_pnm;
-extern vo_functions_t video_out_md5sum;
-
-const vo_functions_t* const video_out_drivers[] =
+extern struct vo_driver video_out_mga;
+extern struct vo_driver video_out_xmga;
+extern struct vo_driver video_out_x11;
+extern struct vo_driver video_out_xover;
+extern struct vo_driver video_out_xvmc;
+extern struct vo_driver video_out_vdpau;
+extern struct vo_driver video_out_xv;
+extern struct vo_driver video_out_gl;
+extern struct vo_driver video_out_gl2;
+extern struct vo_driver video_out_dga;
+extern struct vo_driver video_out_sdl;
+extern struct vo_driver video_out_3dfx;
+extern struct vo_driver video_out_tdfxfb;
+extern struct vo_driver video_out_s3fb;
+extern struct vo_driver video_out_wii;
+extern struct vo_driver video_out_null;
+extern struct vo_driver video_out_zr;
+extern struct vo_driver video_out_zr2;
+extern struct vo_driver video_out_bl;
+extern struct vo_driver video_out_fbdev;
+extern struct vo_driver video_out_fbdev2;
+extern struct vo_driver video_out_svga;
+extern struct vo_driver video_out_png;
+extern struct vo_driver video_out_ggi;
+extern struct vo_driver video_out_aa;
+extern struct vo_driver video_out_caca;
+extern struct vo_driver video_out_mpegpes;
+extern struct vo_driver video_out_yuv4mpeg;
+extern struct vo_driver video_out_direct3d;
+extern struct vo_driver video_out_directx;
+extern struct vo_driver video_out_kva;
+extern struct vo_driver video_out_dxr2;
+extern struct vo_driver video_out_dxr3;
+extern struct vo_driver video_out_ivtv;
+extern struct vo_driver video_out_v4l2;
+extern struct vo_driver video_out_jpeg;
+extern struct vo_driver video_out_gif89a;
+extern struct vo_driver video_out_vesa;
+extern struct vo_driver video_out_directfb;
+extern struct vo_driver video_out_dfbmga;
+extern struct vo_driver video_out_xvidix;
+extern struct vo_driver video_out_winvidix;
+extern struct vo_driver video_out_cvidix;
+extern struct vo_driver video_out_tdfx_vid;
+extern struct vo_driver video_out_xvr100;
+extern struct vo_driver video_out_tga;
+extern struct vo_driver video_out_corevideo;
+extern struct vo_driver video_out_quartz;
+extern struct vo_driver video_out_pnm;
+extern struct vo_driver video_out_md5sum;
+
+const struct vo_driver *video_out_drivers[] =
{
#ifdef CONFIG_XVR100
&video_out_xvr100,
@@ -174,12 +162,12 @@ const vo_functions_t* const video_out_drivers[] =
#ifdef CONFIG_3DFX
&video_out_3dfx,
#endif
-#if CONFIG_VDPAU
- &video_out_vdpau,
-#endif
#ifdef CONFIG_XV
&video_out_xv,
#endif
+#if CONFIG_VDPAU
+ &video_out_vdpau,
+#endif
#ifdef CONFIG_X11
&video_out_x11,
&video_out_xover,
@@ -277,79 +265,154 @@ const vo_functions_t* const video_out_drivers[] =
NULL
};
-void list_video_out(void){
- int i=0;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
- while (video_out_drivers[i]) {
+
+static int vo_preinit(struct vo *vo, const char *arg)
+{
+ return vo->driver->preinit(vo, arg);
+}
+
+int vo_control(struct vo *vo, uint32_t request, void *data)
+{
+ return vo->driver->control(vo, request, data);
+}
+
+int vo_draw_frame(struct vo *vo, uint8_t *src[])
+{
+ if (!vo->config_ok)
+ return 0;
+ return vo->driver->draw_frame(vo, src);
+}
+
+int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y)
+{
+ return vo->driver->draw_slice(vo, src, stride, w, h, x, y);
+}
+
+void vo_draw_osd(struct vo *vo, struct osd_state *osd)
+{
+ if (!vo->config_ok)
+ return;
+ vo->driver->draw_osd(vo, osd);
+}
+
+void vo_flip_page(struct vo *vo)
+{
+ if (!vo->config_ok)
+ return;
+ vo->driver->flip_page(vo);
+}
+
+void vo_check_events(struct vo *vo)
+{
+ if (!vo->config_ok)
+ return;
+ vo->driver->check_events(vo);
+}
+
+void vo_destroy(struct vo *vo)
+{
+ vo->driver->uninit(vo);
+ talloc_free(vo);
+}
+
+void list_video_out(void)
+{
+ int i = 0;
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available video output drivers:\n");
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
+ while (video_out_drivers[i]) {
const vo_info_t *info = video_out_drivers[i++]->info;
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
- }
- mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
+ }
+ mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
}
-const vo_functions_t* init_best_video_out(char** vo_list){
+struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
+ struct mp_fifo *key_fifo,
+ struct input_ctx *input_ctx)
+{
+ char **vo_list = opts->video_driver_list;
int i;
+ struct vo *vo = talloc_ptrtype(NULL, vo);
+ struct vo initial_values = {
+ .opts = opts,
+ .x11 = x11,
+ .key_fifo = key_fifo,
+ .input_ctx = input_ctx,
+ };
// first try the preferred drivers, with their optional subdevice param:
- if(vo_list && vo_list[0])
- while(vo_list[0][0]){
- char* vo=strdup(vo_list[0]);
- vo_subdevice=strchr(vo,':');
- if (!strcmp(vo, "pgm"))
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_PGM_HasBeenReplaced);
- if (!strcmp(vo, "md5"))
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_MD5_HasBeenReplaced);
- if(vo_subdevice){
- vo_subdevice[0]=0;
- ++vo_subdevice;
- }
- for(i=0;video_out_drivers[i];i++){
- const vo_functions_t* video_driver=video_out_drivers[i];
- const vo_info_t *info = video_driver->info;
- if(!strcmp(info->short_name,vo)){
- // name matches, try it
- if(!video_driver->preinit(vo_subdevice))
- {
- free(vo);
- return video_driver; // success!
+ if (vo_list && vo_list[0])
+ while (vo_list[0][0]) {
+ char *name = strdup(vo_list[0]);
+ vo_subdevice = strchr(name,':');
+ if (!strcmp(name, "pgm"))
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The pgm video output driver has been replaced by -vo pnm:pgmyuv.\n");
+ if (!strcmp(name, "md5"))
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The md5 video output driver has been replaced by -vo md5sum.\n");
+ if (vo_subdevice) {
+ vo_subdevice[0] = 0;
+ ++vo_subdevice;
+ }
+ for (i = 0; video_out_drivers[i]; i++) {
+ const struct vo_driver *video_driver = video_out_drivers[i];
+ const vo_info_t *info = video_driver->info;
+ if (!strcmp(info->short_name, name)) {
+ // name matches, try it
+ *vo = initial_values;
+ vo->driver = video_driver;
+ if (!vo_preinit(vo, vo_subdevice)) {
+ free(name);
+ return vo; // success!
+ }
+ talloc_free_children(vo);
}
}
+ // continue...
+ free(name);
+ ++vo_list;
+ if (!(vo_list[0]))
+ return NULL; // do NOT fallback to others
}
- // continue...
- free(vo);
- ++vo_list;
- if(!(vo_list[0])) return NULL; // do NOT fallback to others
- }
// now try the rest...
- vo_subdevice=NULL;
- for(i=0;video_out_drivers[i];i++){
- const vo_functions_t* video_driver=video_out_drivers[i];
- if(!video_driver->preinit(vo_subdevice))
- return video_driver; // success!
+ vo_subdevice = NULL;
+ for (i = 0; video_out_drivers[i]; i++) {
+ const struct vo_driver *video_driver = video_out_drivers[i];
+ *vo = initial_values;
+ vo->driver = video_driver;
+ if (!vo_preinit(vo, vo_subdevice))
+ return vo; // success!
+ talloc_free_children(vo);
}
+ free(vo);
return NULL;
}
-int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
+int vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
- char *title, uint32_t format) {
- panscan_init();
- aspect_save_orig(width,height);
- aspect_save_prescale(d_width,d_height);
-
- if (vo->control(VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
- aspect(&d_width,&d_height,A_NOZOOM);
- vo_dx = (int)(vo_screenwidth - d_width) / 2;
- vo_dy = (int)(vo_screenheight - d_height) / 2;
- geometry(&vo_dx, &vo_dy, &d_width, &d_height,
- vo_screenwidth, vo_screenheight);
- vo_dx += xinerama_x;
- vo_dy += xinerama_y;
- vo_dwidth = d_width;
- vo_dheight = d_height;
- }
+ char *title, uint32_t format)
+{
+ struct MPOpts *opts = vo->opts;
+ panscan_init(vo);
+ aspect_save_orig(vo, width, height);
+ aspect_save_prescale(vo, d_width, d_height);
+
+ if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
+ aspect(vo, &d_width, &d_height, A_NOZOOM);
+ vo->dx = (int)(opts->vo_screenwidth - d_width) / 2;
+ vo->dy = (int)(opts->vo_screenheight - d_height) / 2;
+ geometry(&vo->dx, &vo->dy, &d_width, &d_height,
+ opts->vo_screenwidth, opts->vo_screenheight);
+ vo->dx += xinerama_x;
+ vo->dy += xinerama_y;
+ vo->dwidth = d_width;
+ vo->dheight = d_height;
+ }
- return vo->config(width, height, d_width, d_height, flags, title, format);
+ int ret = vo->driver->config(vo, width, height, d_width, d_height, flags,
+ title, format);
+ vo->config_ok = (ret == 0);
+ vo->config_count += vo->config_ok;
+ return ret;
}
/**
@@ -394,8 +457,10 @@ static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_siz
* \param borders the border values as e.g. EOSD (ASS) and properly placed DVD highlight support requires,
* may be NULL and only left and top are currently valid.
*/
-void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst,
- struct vo_rect *borders, const struct vo_rect *crop) {
+void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
+ struct vo_rect *src, struct vo_rect *dst,
+ struct vo_rect *borders, const struct vo_rect *crop)
+{
static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0};
int scaled_width = 0;
int scaled_height = 0;
@@ -404,25 +469,25 @@ void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, stru
src_height -= crop->top + crop->bottom;
if (src_width < 2) src_width = 2;
if (src_height < 2) src_height = 2;
- dst->left = 0; dst->right = vo_dwidth;
- dst->top = 0; dst->bottom = vo_dheight;
+ dst->left = 0; dst->right = vo->dwidth;
+ dst->top = 0; dst->bottom = vo->dheight;
src->left = 0; src->right = src_width;
src->top = 0; src->bottom = src_height;
if (borders) {
borders->left = 0; borders->top = 0;
}
if (vo_fs) {
- aspect(&scaled_width, &scaled_height, A_ZOOM);
- panscan_calc();
- scaled_width += vo_panscan_x;
- scaled_height += vo_panscan_y;
+ aspect(vo, &scaled_width, &scaled_height, A_ZOOM);
+ panscan_calc(vo);
+ scaled_width += vo->panscan_x;
+ scaled_height += vo->panscan_y;
if (borders) {
- borders->left = (vo_dwidth - scaled_width ) / 2;
- borders->top = (vo_dheight - scaled_height) / 2;
+ borders->left = (vo->dwidth - scaled_width ) / 2;
+ borders->top = (vo->dheight - scaled_height) / 2;
}
- src_dst_split_scaling(src_width, vo_dwidth, scaled_width,
+ src_dst_split_scaling(src_width, vo->dwidth, scaled_width,
&src->left, &src->right, &dst->left, &dst->right);
- src_dst_split_scaling(src_height, vo_dheight, scaled_height,
+ src_dst_split_scaling(src_height, vo->dheight, scaled_height,
&src->top, &src->bottom, &dst->top, &dst->bottom);
}
src->left += crop->left; src->right += crop->left;
@@ -514,4 +579,3 @@ out_err:
/* Borrowed from vo_fbdev.c END */
#endif
-
diff --git a/libvo/video_out.h b/libvo/video_out.h
index f90123ddee..6d4b405e56 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -60,7 +60,15 @@
#define VOCTRL_SET_PANSCAN 16
/* equalizer controls */
#define VOCTRL_SET_EQUALIZER 17
+struct voctrl_set_equalizer_args {
+ const char *name;
+ int value;
+};
#define VOCTRL_GET_EQUALIZER 18
+struct voctrl_get_equalizer_args {
+ const char *name;
+ int *valueptr;
+};
//#define VOCTRL_GUI_NOWINDOW 19
/* Frame duplication */
#define VOCTRL_DUPLICATE_FRAME 20
@@ -92,6 +100,8 @@ typedef struct {
} mp_colorkey_t;
#define VOCTRL_XOVERLAY_SET_WIN 23
+#define VOCTRL_REDRAW_OSD 24
+
typedef struct {
int x,y;
int w,h;
@@ -121,15 +131,24 @@ typedef struct vo_info_s
const char *comment;
} vo_info_t;
-typedef struct vo_functions_s
-{
+struct vo;
+struct osd_state;
+
+struct vo_driver {
+ // Driver uses new API
+ int is_new;
+
+ // This is set if the driver is not new and contains pointers to
+ // old-API functions to be used instead of the ones below.
+ struct vo_old_functions *old_functions;
+
const vo_info_t *info;
/*
* Preinitializes driver (real INITIALIZATION)
* arg - currently it's vo_subdevice
* returns: zero on successful initialization, non-zero on error.
*/
- int (*preinit)(const char *arg);
+ int (*preinit)(struct vo *vo, const char *arg);
/*
* Initialize (means CONFIGURE) the display driver.
* params:
@@ -140,21 +159,21 @@ typedef struct vo_functions_s
* format: fourcc of pixel format
* returns : zero on successful initialization, non-zero on error.
*/
- int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
- uint32_t d_height, uint32_t fullscreen, char *title,
- uint32_t format);
+ int (*config)(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
+ char *title, uint32_t format);
/*
* Control interface
*/
- int (*control)(uint32_t request, void *data, ...);
+ int (*control)(struct vo *vo, uint32_t request, void *data);
/*
* Display a new RGB/BGR frame of the video to the screen.
* params:
* src[0] - pointer to the image
*/
- int (*draw_frame)(uint8_t *src[]);
+ int (*draw_frame)(struct vo *vo, uint8_t *src[]);
/*
* Draw a planar YUV slice to the buffer:
@@ -164,60 +183,100 @@ typedef struct vo_functions_s
* w,h = width*height of area to be copied (in Y pixels)
* x,y = position at the destination image (in Y pixels)
*/
- int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
+ int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
+ int h, int x, int y);
/*
* Draws OSD to the screen buffer
*/
- void (*draw_osd)(void);
+ void (*draw_osd)(struct vo *vo, struct osd_state *osd);
/*
* Blit/Flip buffer to the screen. Must be called after each frame!
*/
- void (*flip_page)(void);
+ void (*flip_page)(struct vo *vo);
/*
* This func is called after every frames to handle keyboard and
* other events. It's called in PAUSE mode too!
*/
- void (*check_events)(void);
+ void (*check_events)(struct vo *vo);
/*
* Closes driver. Should restore the original state of the system.
*/
- void (*uninit)(void);
+ void (*uninit)(struct vo *vo);
+};
-} vo_functions_t;
+struct vo_old_functions {
+ int (*preinit)(const char *arg);
+ int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
+ uint32_t d_height, uint32_t fullscreen, char *title,
+ uint32_t format);
+ int (*control)(uint32_t request, void *data);
+ int (*draw_frame)(uint8_t *src[]);
+ int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
+ void (*draw_osd)(void);
+ void (*flip_page)(void);
+ void (*check_events)(void);
+ void (*uninit)(void);
+};
+
+struct vo {
+ int config_ok; // Last config call was successful?
+ int config_count; // Total number of successful config calls
+ const struct vo_driver *driver;
+ void *priv;
+ struct MPOpts *opts;
+ struct vo_x11_state *x11;
+ struct mp_fifo *key_fifo;
+ struct input_ctx *input_ctx;
+
+ // requested position/resolution
+ int dx;
+ int dy;
+ int dwidth;
+ int dheight;
+
+ int panscan_x;
+ int panscan_y;
+ float panscan_amount;
+ float monitor_aspect;
+ struct aspect_data {
+ int orgw; // real width
+ int orgh; // real height
+ int prew; // prescaled width
+ int preh; // prescaled height
+ int scrw; // horizontal resolution
+ int scrh; // vertical resolution
+ float asp;
+ } aspdat;
+};
-const vo_functions_t* init_best_video_out(char** vo_list);
-int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
+struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
+ struct mp_fifo *key_fifo,
+ struct input_ctx *input_ctx);
+int vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format);
void list_video_out(void);
-// NULL terminated array of all drivers
-extern const vo_functions_t* const video_out_drivers[];
+int vo_control(struct vo *vo, uint32_t request, void *data);
+int vo_draw_frame(struct vo *vo, uint8_t *src[]);
+int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
+void vo_draw_osd(struct vo *vo, struct osd_state *osd);
+void vo_flip_page(struct vo *vo);
+void vo_check_events(struct vo *vo);
+void vo_destroy(struct vo *vo);
-extern int vo_flags;
-extern int vo_config_count;
+// NULL terminated array of all drivers
+extern const struct vo_driver *video_out_drivers[];
extern int xinerama_screen;
extern int xinerama_x;
extern int xinerama_y;
-// correct resolution/bpp on screen: (should be autodetected by vo_init())
-extern int vo_depthonscreen;
-extern int vo_screenwidth;
-extern int vo_screenheight;
-
-// requested resolution/bpp: (-x -y -bpp options)
-extern int vo_dx;
-extern int vo_dy;
-extern int vo_dwidth;
-extern int vo_dheight;
-extern int vo_dbpp;
-
extern int vo_grabpointer;
extern int vo_doublebuffering;
extern int vo_directrendering;
@@ -229,18 +288,8 @@ extern int vo_adapter_num;
extern int vo_refresh_rate;
extern int vo_keepaspect;
extern int vo_rootwin;
-extern int vo_ontop;
extern int vo_border;
-extern int vo_gamma_gamma;
-extern int vo_gamma_brightness;
-extern int vo_gamma_saturation;
-extern int vo_gamma_contrast;
-extern int vo_gamma_hue;
-extern int vo_gamma_red_intensity;
-extern int vo_gamma_green_intensity;
-extern int vo_gamma_blue_intensity;
-
extern int vo_nomouse_input;
extern int vo_pts;
@@ -272,7 +321,8 @@ int lookup_keymap_table(const struct keymap *map, int key);
struct vo_rect {
int left, right, top, bottom, width, height;
};
-void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst,
+void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
+ struct vo_rect *src, struct vo_rect *dst,
struct vo_rect *borders, const struct vo_rect *crop);
#endif /* MPLAYER_VIDEO_OUT_H */
diff --git a/libvo/video_out_internal.h b/libvo/video_out_internal.h
index 36aa210fdd..166a91cc1c 100644
--- a/libvo/video_out_internal.h
+++ b/libvo/video_out_internal.h
@@ -27,8 +27,10 @@
#include "libmpcodecs/vfcap.h"
#include "libmpcodecs/mp_image.h"
#include "geometry.h"
+#include "old_vo_wrapper.h"
+#include "old_vo_defines.h"
-static int control(uint32_t request, void *data, ...);
+static int control(uint32_t request, void *data);
static int config(uint32_t width, uint32_t height, uint32_t d_width,
uint32_t d_height, uint32_t fullscreen, char *title,
uint32_t format);
@@ -41,9 +43,20 @@ static void uninit(void);
static int query_format(uint32_t format);
static int preinit(const char *);
-#define LIBVO_EXTERN(x) vo_functions_t video_out_##x =\
+#define LIBVO_EXTERN(x) struct vo_driver video_out_##x =\
{\
- &info,\
+ .is_new = 0,\
+ .info = &info,\
+ .preinit = old_vo_preinit,\
+ .config = old_vo_config,\
+ .control = old_vo_control,\
+ .draw_frame = old_vo_draw_frame,\
+ .draw_slice = old_vo_draw_slice,\
+ .draw_osd = old_vo_draw_osd,\
+ .flip_page = old_vo_flip_page,\
+ .check_events = old_vo_check_events,\
+ .uninit = old_vo_uninit,\
+ .old_functions = &(struct vo_old_functions){\
preinit,\
config,\
control,\
@@ -52,7 +65,8 @@ static int preinit(const char *);
draw_osd,\
flip_page,\
check_events,\
- uninit\
+ uninit,\
+ }\
};
#include "osd.h"
diff --git a/libvo/vo_3dfx.c b/libvo/vo_3dfx.c
index b86e593281..9295a65a67 100644
--- a/libvo/vo_3dfx.c
+++ b/libvo/vo_3dfx.c
@@ -169,12 +169,12 @@ create_window(Display *display, char *title)
bpp = attribs.depth;
if (bpp != 16)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_Only16BppSupported);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_3DFX] Only 16bpp supported!");
exit(-1);
}
XMatchVisualInfo(display,screen,bpp,TrueColor,&vinfo);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_3DFX_VisualIdIs,vinfo.visualid);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_3DFX] Visual ID is %lx.\n",vinfo.visualid);
theCmap = XCreateColormap(display, RootWindow(display,screen),
vinfo.visual, AllocNone);
@@ -335,7 +335,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
// Open driver device
if ( fd == -1 )
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_UnableToOpenDevice);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_3DFX] Unable to open /dev/3dfx.\n");
return -1;
}
@@ -354,7 +354,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
data.device = 0;
if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_Error,retval);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_3DFX] Error: %d.\n",retval);
return -1;
}
@@ -365,7 +365,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
data.device = 0;
if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_Error,retval);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_3DFX] Error: %d.\n",retval);
return -1;
}
@@ -374,7 +374,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
memBase1 = mmap(0,3*page_space,PROT_READ | PROT_WRITE,MAP_SHARED,fd,baseAddr1);
if (memBase0 == (uint32_t *) 0xFFFFFFFF || memBase1 == (uint32_t *) 0xFFFFFFFF)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_CouldntMapMemoryArea,
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_3DFX] Couldn't map 3dfx memory areas: %p,%p,%d.\n",
memBase0,memBase1,errno);
}
@@ -413,7 +413,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
atexit(restore);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_3DFX_DisplayInitialized,memBase1);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_3DFX] Initialized: %p.\n",memBase1);
return 0;
}
@@ -485,19 +485,19 @@ static int preinit(const char *arg)
{
if ( (fd = open("/dev/3dfx",O_RDWR) ) == -1)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_UnableToOpenDevice);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_3DFX] Unable to open /dev/3dfx.\n");
return -1;
}
if(arg)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_UnknownSubdevice,arg);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_3DFX] Unknown subdevice: %s.\n",arg);
return ENOSYS;
}
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_aa.c b/libvo/vo_aa.c
index 41d5de6294..5e9dfbae10 100644
--- a/libvo/vo_aa.c
+++ b/libvo/vo_aa.c
@@ -96,7 +96,9 @@ static struct SwsContext *sws=NULL;
int aaopt_osdcolor = AA_SPECIAL;
int aaopt_subcolor = AA_SPECIAL;
-void
+static unsigned char vo_osd_text[64];
+
+static void
resize(void){
/*
* this function is called by aa lib if windows resizes
@@ -190,15 +192,10 @@ osdpercent(int duration, int deko, int min, int max, int val, const char * desc,
static void
printosdtext(void)
{
- if(osd_text_length > 0 && !vo_osd_text) {
- memset(c->textbuffer,' ',osd_text_length);
- memset(c->attrbuffer,0,osd_text_length);
- osd_text_length = 0;
- }
/*
* places the mplayer status osd
*/
- if (vo_osd_text && vo_osd_text[0] != 0) {
+ if (vo_osd_text[0] != 0) {
int len;
if(vo_osd_text[0] < 32) {
len = strlen(sub_osd_names_short[vo_osd_text[0]]) + strlen(vo_osd_text+1) + 2;
@@ -542,18 +539,18 @@ static void clear_alpha(int x0,int y0, int w,int h) {
static void
draw_osd(void){
- char * vo_osd_text_save;
+ char vo_osd_text_save;
int vo_osd_progbar_type_save;
printosdprogbar();
/* let vo_draw_text only write subtitle */
- vo_osd_text_save=vo_osd_text; /* we have to save the osd_text */
- vo_osd_text=NULL;
+ vo_osd_text_save = global_osd->osd_text[0];
+ global_osd->osd_text[0] = 0;
vo_osd_progbar_type_save=vo_osd_progbar_type;
vo_osd_progbar_type=-1;
vo_remove_text(aa_scrwidth(c), aa_scrheight(c),clear_alpha);
vo_draw_text(aa_scrwidth(c), aa_scrheight(c), draw_alpha);
- vo_osd_text=vo_osd_text_save;
+ global_osd->osd_text[0] = vo_osd_text_save;
vo_osd_progbar_type=vo_osd_progbar_type_save;
}
@@ -620,9 +617,16 @@ static int parse_suboptions(const char *arg) {
helpmsg = strdup(aa_help);
for (i=0; i<(signed)strlen(helpmsg); i++)
if (helpmsg[i] == '-') helpmsg[i] = ' ';
- mp_msg(MSGT_VO, MSGL_INFO, MSGTR_VO_AA_HelpHeader);
+ mp_tmsg(MSGT_VO, MSGL_INFO, "\n\nHere are the aalib vo_aa suboptions:\n");
mp_msg(MSGT_VO, MSGL_INFO, "%s\n\n", helpmsg);
- mp_msg(MSGT_VO, MSGL_INFO, MSGTR_VO_AA_AdditionalOptions);
+#define VO_AA_AdditionalOptions _("Additional options vo_aa provides:\n" \
+" help print this help message\n" \
+" osdcolor set OSD color\n subcolor set subtitle color\n" \
+" the color parameters are:\n 0 : normal\n" \
+" 1 : dim\n 2 : bold\n 3 : boldfont\n" \
+" 4 : reverse\n 5 : special\n\n\n")
+
+ mp_tmsg(MSGT_VO, MSGL_INFO, VO_AA_AdditionalOptions);
retval = -1;
}
if (retval == 0) {
@@ -726,37 +730,26 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
case VOCTRL_SET_EQUALIZER: {
- va_list ap;
- int val;
-
- va_start(ap, data);
- val = va_arg(ap, int);
- va_end(ap);
-
- if(strcmp((char*)data,"contrast") == 0)
- p->contrast = ( val + 100 ) * 64 / 100;
- else if(strcmp((char*)data,"brightness") == 0)
- p->bright = ( val + 100) * 128 / 100;
+ struct voctrl_set_equalizer_args *args = data;
+ if (strcmp(args->name, "contrast") == 0)
+ p->contrast = (args->value + 100) * 64 / 100;
+ else if (strcmp(args->name, "brightness") == 0)
+ p->bright = (args->value + 100) * 128 / 100;
return VO_TRUE;
}
case VOCTRL_GET_EQUALIZER: {
- va_list ap;
- int* val;
-
- va_start(ap, data);
- val = va_arg(ap, int*);
- va_end(ap);
+ struct voctrl_get_equalizer_args *args = data;
- if(strcmp((char*)data,"contrast") == 0)
- *val = (p->contrast - 64) * 100 / 64;
- else if(strcmp((char*)data,"brightness") == 0)
- *val = (p->bright - 128) * 100 / 128;
+ if (strcmp(args->name, "contrast") == 0)
+ *args->valueptr = (p->contrast - 64) * 100 / 64;
+ else if (strcmp(args->name, "brightness") == 0)
+ *args->valueptr = (p->bright - 128) * 100 / 128;
return VO_TRUE;
}
diff --git a/libvo/vo_bl.c b/libvo/vo_bl.c
index 9e98130adb..8a4c29edd7 100644
--- a/libvo/vo_bl.c
+++ b/libvo/vo_bl.c
@@ -470,7 +470,7 @@ static int preinit(const char *arg) {
return 0;
}
-static int control(uint32_t request, void *data, ...) {
+static int control(uint32_t request, void *data) {
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
diff --git a/libvo/vo_caca.c b/libvo/vo_caca.c
index 4415459080..2c36700be8 100644
--- a/libvo/vo_caca.c
+++ b/libvo/vo_caca.c
@@ -335,7 +335,7 @@ static int query_format(uint32_t format)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch(request)
{
diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m
index 73d5bf961a..7967921467 100644
--- a/libvo/vo_corevideo.m
+++ b/libvo/vo_corevideo.m
@@ -47,6 +47,7 @@
#include "input/mouse.h"
#include "osdep/keycodes.h"
+#include "mp_fifo.h"
//Cocoa
NSDistantObject *mplayerosxProxy;
@@ -83,8 +84,6 @@ static uint32_t image_format;
static int isFullscreen;
static int isOntop;
static int isRootwin;
-extern float monitor_aspect;
-extern float movie_aspect;
static float old_movie_aspect;
extern int enable_mouse_movements;
@@ -415,7 +414,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
@@ -1065,7 +1064,7 @@ static int control(uint32_t request, void *data, ...)
snprintf(cmdstr, sizeof(cmdstr), "set_mouse_pos %i %i",
(int)(vo_fs ? p.x : (p.x - textureFrame.origin.x)),
(int)(vo_fs ? [self frame].size.height - p.y: (NSMaxY(textureFrame) - p.y)));
- mp_input_queue_cmd(mp_input_parse_cmd(cmdstr));
+ mp_input_queue_cmd(global_vo->input_ctx, mp_input_parse_cmd(cmdstr));
}
}
}
diff --git a/libvo/vo_cvidix.c b/libvo/vo_cvidix.c
index 70ea155535..a4a29719de 100644
--- a/libvo/vo_cvidix.c
+++ b/libvo/vo_cvidix.c
@@ -171,11 +171,11 @@ static int preinit(const char *arg){
mp_msg(MSGT_VO, MSGL_INFO, "vo_cvidix: No vidix driver name provided, probing available ones (-v option for details)!\n");
vidix_name = NULL;
}
- if(vidix_preinit(vidix_name, &video_out_cvidix))return 1;
+ if (vidix_preinit(vidix_name, video_out_cvidix.old_functions))return 1;
return 0;
}
-static int control(uint32_t request, void *data, ...){
+static int control(uint32_t request, void *data){
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
@@ -184,24 +184,6 @@ static int control(uint32_t request, void *data, ...){
else vo_fs=1;
setup_vidix();
return VO_TRUE;
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
- return vidix_control(request, data, value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
- va_start(ap, data);
- value = va_arg(ap, int *);
- va_end(ap);
- return vidix_control(request, data, value);
- }
}
return vidix_control(request, data);
}
diff --git a/libvo/vo_dfbmga.c b/libvo/vo_dfbmga.c
index fd1a3638db..73d67c4f8e 100644
--- a/libvo/vo_dfbmga.c
+++ b/libvo/vo_dfbmga.c
@@ -1465,7 +1465,7 @@ get_equalizer( char *data, int *value )
}
static int
-control( uint32_t request, void *data, ... )
+control( uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GUISUPPORT:
@@ -1483,25 +1483,13 @@ control( uint32_t request, void *data, ... )
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start( ap, data );
- value = va_arg( ap, int );
- va_end( ap );
-
- return set_equalizer( data, value );
+ struct voctrl_set_equalizer_args *args = data;
+ return set_equalizer(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start( ap, data );
- value = va_arg( ap, int* );
- va_end( ap );
-
- return get_equalizer( data, value );
+ struct voctrl_get_equalizer_args *args = data;
+ return get_equalizer(args->name, args->valueptr);
}
}
diff --git a/libvo/vo_dga.c b/libvo/vo_dga.c
index 51527bdc6a..879831761d 100644
--- a/libvo/vo_dga.c
+++ b/libvo/vo_dga.c
@@ -984,7 +984,7 @@ static uint32_t get_image(mp_image_t * mpi)
return VO_FALSE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index bfeb82e562..c0f79d45d4 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -740,7 +740,7 @@ static int preinit(const char *arg)
/** @brief libvo Callback: Handle control requests.
* @return VO_TRUE on success, VO_NOTIMPL when not implemented
*/
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_directfb2.c b/libvo/vo_directfb2.c
index d2e17593b2..a502647a6d 100644
--- a/libvo/vo_directfb2.c
+++ b/libvo/vo_directfb2.c
@@ -1412,7 +1412,7 @@ static uint32_t put_image(mp_image_t *mpi){
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -1423,25 +1423,13 @@ static int control(uint32_t request, void *data, ...)
return put_image(data);
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return directfb_set_video_eq(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return directfb_set_video_eq(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return directfb_get_video_eq(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return directfb_get_video_eq(args->name, args->valueptr);
}
};
return VO_NOTIMPL;
diff --git a/libvo/vo_directx.c b/libvo/vo_directx.c
index 9aa27de2cc..37a12567dc 100644
--- a/libvo/vo_directx.c
+++ b/libvo/vo_directx.c
@@ -90,8 +90,6 @@ static float window_aspect;
static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL;
static RECT last_rect = {0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE};
-extern int vidmode;
-
/*****************************************************************************
* DirectDraw GUIDs.
* Defining them here allows us to get rid of the dxguid library during
@@ -1474,7 +1472,7 @@ static uint32_t color_ctrl_get(char *what, int *value)
return r;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
@@ -1566,22 +1564,12 @@ static int control(uint32_t request, void *data, ...)
return VO_TRUE;
}
case VOCTRL_SET_EQUALIZER: {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
- return color_ctrl_set(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return color_ctrl_set(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER: {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
- return color_ctrl_get(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return color_ctrl_get(args->name, args->valueptr);
}
case VOCTRL_UPDATE_SCREENINFO:
if (vidmode) {
diff --git a/libvo/vo_dxr2.c b/libvo/vo_dxr2.c
index 0e1ac2fc35..66f73f1d6d 100644
--- a/libvo/vo_dxr2.c
+++ b/libvo/vo_dxr2.c
@@ -42,8 +42,7 @@
#include <dxr2ioctl.h>
-extern float monitor_aspect;
-extern float movie_aspect;
+#include "aspect.h"
int dxr2_fd = -1;
@@ -51,7 +50,8 @@ static int movie_w,movie_h;
static int playing = 0;
// vo device used to blank the screen for the overlay init
-static const vo_functions_t* sub_vo = NULL;
+static const struct vo_old_functions *sub_vo = NULL;
+static const struct vo_info_s *sub_info;
static uint8_t* sub_img = NULL;
static int sub_x,sub_y,sub_w,sub_h;
@@ -446,7 +446,7 @@ static int dxr2_load_vga_params(dxr2_vgaParams_t* vga,char* name) {
}
static int dxr2_setup_vga_params(void) {
- const vo_info_t* vi = sub_vo->info;
+ const vo_info_t* vi = sub_info;
dxr2_vgaParams_t vga;
int loaded = dxr2_load_vga_params(&vga,(char*)vi->short_name);
@@ -660,7 +660,7 @@ static int config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t
}
// Does the sub vo support the x11 stuff
// Fix me : test the other x11 vo's and enable them
- if(strcmp(sub_vo->info->short_name,"x11") == 0)
+ if(strcmp(sub_info->short_name,"x11") == 0)
sub_vo_win = 1;
else
sub_vo_win = 0;
@@ -834,10 +834,11 @@ static int preinit(const char *arg) {
const vo_info_t* vi = video_out_drivers[n]->info;
if(!vi)
continue;
- if(strcasecmp(arg,vi->short_name) == 0)
+ if(!video_out_drivers[n]->is_new && strcasecmp(arg,vi->short_name) == 0)
break;
}
- sub_vo = video_out_drivers[n];
+ sub_vo = video_out_drivers[n]->old_functions;
+ sub_info = video_out_drivers[n]->info;
} else {
mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] We need a sub driver to initialize the overlay\n");
use_ol = 0;
@@ -920,7 +921,7 @@ static int preinit(const char *arg) {
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_dxr3.c b/libvo/vo_dxr3.c
index 05f55aa4f9..4312c156f9 100644
--- a/libvo/vo_dxr3.c
+++ b/libvo/vo_dxr3.c
@@ -174,7 +174,7 @@ static overlay_t *overlay_data;
/* Functions for working with the em8300's internal clock */
/* End of internal clock functions */
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GUISUPPORT:
@@ -186,7 +186,7 @@ static int control(uint32_t request, void *data, ...)
return VO_TRUE;
case VOCTRL_SET_SPU_PALETTE:
if (ioctl(fd_spu, EM8300_IOCTL_SPU_SETPALETTE, data) < 0) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_UnableToLoadNewSPUPalette);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Unable to load new SPU palette!\n");
return VO_ERROR;
}
return VO_TRUE;
@@ -216,7 +216,7 @@ static int control(uint32_t request, void *data, ...)
if (dxr3_prebuf) {
ioval = EM8300_PLAYMODE_PLAY;
if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_UnableToSetPlaymode);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set playmode!\n");
}
}
return VO_TRUE;
@@ -224,7 +224,7 @@ static int control(uint32_t request, void *data, ...)
if (dxr3_prebuf) {
ioval = EM8300_PLAYMODE_PAUSED;
if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_UnableToSetPlaymode);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set playmode!\n");
}
}
return VO_TRUE;
@@ -252,22 +252,17 @@ static int control(uint32_t request, void *data, ...)
}
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
em8300_bcs_t bcs;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
+ struct voctrl_set_equalizer_args *args = data;
if (ioctl(fd_control, EM8300_IOCTL_GETBCS, &bcs) < 0)
return VO_FALSE;
- if (!strcasecmp(data, "brightness"))
- bcs.brightness = (value+100)*5;
- else if (!strcasecmp(data, "contrast"))
- bcs.contrast = (value+100)*5;
- else if (!strcasecmp(data, "saturation"))
- bcs.saturation = (value+100)*5;
+ if (!strcasecmp(args->name, "brightness"))
+ bcs.brightness = (args->value+100)*5;
+ else if (!strcasecmp(args->name, "contrast"))
+ bcs.contrast = (args->value+100)*5;
+ else if (!strcasecmp(args->name, "saturation"))
+ bcs.saturation = (args->value+100)*5;
else return VO_FALSE;
if (ioctl(fd_control, EM8300_IOCTL_SETBCS, &bcs) < 0)
@@ -276,23 +271,18 @@ static int control(uint32_t request, void *data, ...)
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
em8300_bcs_t bcs;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
+ struct voctrl_get_equalizer_args *args = data;
if (ioctl(fd_control, EM8300_IOCTL_GETBCS, &bcs) < 0)
return VO_FALSE;
- if (!strcasecmp(data, "brightness"))
- *value = (bcs.brightness/5)-100;
- else if (!strcasecmp(data, "contrast"))
- *value = (bcs.contrast/5)-100;
- else if (!strcasecmp(data, "saturation"))
- *value = (bcs.saturation/5)-100;
+ if (!strcasecmp(args->name, "brightness"))
+ *args->valueptr = (bcs.brightness/5)-100;
+ else if (!strcasecmp(args->name, "contrast"))
+ *args->valueptr = (bcs.contrast/5)-100;
+ else if (!strcasecmp(args->name, "saturation"))
+ *args->valueptr = (bcs.saturation/5)-100;
else return VO_FALSE;
return VO_TRUE;
@@ -322,7 +312,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
{
int tmp1, tmp2, size;
em8300_register_t reg;
- extern float monitor_aspect;
/* Softzoom turned on, downscale */
/* This activates the subpicture processor, you can safely disable this and still send */
@@ -330,7 +319,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
/* up in a lockup */
ioval = EM8300_SPUMODE_ON;
if (ioctl(fd_control, EM8300_IOCTL_SET_SPUMODE, &ioval) < 0) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_UnableToSetSubpictureMode);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set subpicture mode!\n");
uninit();
return -1;
}
@@ -338,7 +327,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
/* Set the playmode to play (just in case another app has set it to something else) */
ioval = EM8300_PLAYMODE_PLAY;
if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_UnableToSetPlaymode);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set playmode!\n");
}
/* Start em8300 prebuffering and sync engine */
@@ -370,7 +359,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
monitor_aspect = (float) width / (float) height;
if (ioctl(fd_control, EM8300_IOCTL_GET_VIDEOMODE, &old_vmode) < 0) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_UnableToGetTVNorm);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to get TV norm!\n");
old_vmode = -1;
}
@@ -389,7 +378,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
ioval = EM8300_VIDEOMODE_PAL;
}
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_AutoSelectedTVNormByFrameRate);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Auto-selected TV norm by framerate: ");
ioval == EM8300_VIDEOMODE_PAL60 ? mp_msg(MSGT_VO,MSGL_INFO, "PAL-60") : mp_msg(MSGT_VO,MSGL_INFO, "PAL");
printf(".\n");
} else {
@@ -399,14 +388,14 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
ioval = EM8300_VIDEOMODE_PAL;
}
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_AutoSelectedTVNormByFrameRate);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Auto-selected TV norm by framerate: ");
ioval == EM8300_VIDEOMODE_NTSC ? mp_msg(MSGT_VO,MSGL_INFO, "NTSC") : mp_msg(MSGT_VO,MSGL_INFO, "PAL");
printf(".\n");
}
if (old_vmode != ioval) {
if (ioctl(fd_control, EM8300_IOCTL_SET_VIDEOMODE, &ioval) < 0) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_UnableToSetTVNorm);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to set TV norm!\n");
}
}
}
@@ -417,10 +406,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
aspect_save_prescale(d_width, d_height);
ioctl(fd_control, EM8300_IOCTL_GET_VIDEOMODE, &ioval);
if (ioval == EM8300_VIDEOMODE_NTSC) {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_SettingUpForNTSC);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Setting up for NTSC.\n");
aspect_save_screenres(352, 240);
} else {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_SettingUpForPALSECAM);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Setting up for PAL/SECAM.\n");
aspect_save_screenres(352, 288);
}
aspect(&s_width, &s_height, A_ZOOM);
@@ -433,10 +422,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
tmp2 = abs(d_height - (int) (d_width / 2.35));
if (tmp1 < tmp2) {
ioval = EM8300_ASPECTRATIO_4_3;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_SettingAspectRatioTo43);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Setting aspect ratio to 4:3.\n");
} else {
ioval = EM8300_ASPECTRATIO_16_9;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_SettingAspectRatioTo169);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Setting aspect ratio to 16:9.\n");
}
ioctl(fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &ioval);
@@ -455,20 +444,20 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
osdpicbuf = calloc( 1,s_width * s_height);
if (osdpicbuf == NULL) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_OutOfMemory);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] out of memory\n");
return -1;
}
spued = (encodedata *) malloc(sizeof(encodedata));
if (spued == NULL) {
free( osdpicbuf );
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_OutOfMemory);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] out of memory\n");
return -1;
}
spubuf = (encodedata *) malloc(sizeof(encodedata));
if (spubuf == NULL) {
free( osdpicbuf );
free( spued );
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_OutOfMemory);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] out of memory\n");
return -1;
}
osd_w = s_width;
@@ -547,13 +536,13 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
((key_color.blue >> (16 - blue_prec)) << blue_shift));
key_color.flags = DoRed | DoGreen | DoBlue;
if (!XAllocColor(mDisplay, cmap, &key_color)) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_UnableToAllocateKeycolor);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Unable to allocate keycolor!\n");
return -1;
}
acq_color = ((key_color.red / 256) << 16) | ((key_color.green / 256) << 8) | key_color.blue;
if (key_color.pixel != KEY_COLOR) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_UnableToAllocateExactKeycolor, key_color.pixel);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Unable to allocate exact keycolor, using closest match (0x%lx).\n", key_color.pixel);
}
/* Set keycolor and activate overlay */
@@ -707,7 +696,7 @@ static int draw_slice(uint8_t *srcimg[], int stride[], int w, int h, int x0, int
static void uninit(void)
{
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_Uninitializing);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Uninitializing.\n");
#ifdef CONFIG_X11
if (dxr3_overlay) {
overlay_set_mode(overlay_data, EM8300_OVERLAY_MODE_OFF);
@@ -725,7 +714,7 @@ static void uninit(void)
#endif
if (old_vmode != -1) {
if (ioctl(fd_control, EM8300_IOCTL_SET_VIDEOMODE, &old_vmode) < 0) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedRestoringTVNorm);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed restoring TV norm!\n");
}
}
@@ -760,24 +749,24 @@ static int preinit(const char *arg)
/* Parse commandline */
while (arg) {
if (!strncmp("prebuf", arg, 6) && !dxr3_prebuf) {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_EnablingPrebuffering);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Enabling prebuffering.\n");
dxr3_prebuf = 1;
} else if (!strncmp("sync", arg, 4) && !dxr3_newsync) {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_UsingNewSyncEngine);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Using new sync engine.\n");
dxr3_newsync = 1;
} else if (!strncmp("overlay", arg, 7) && !dxr3_overlay) {
#ifdef CONFIG_X11
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_UsingOverlay);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Using overlay.\n");
dxr3_overlay = 1;
#else
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_ErrorYouNeedToCompileMplayerWithX11);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Error: Overlay requires compiling with X11 libs/headers installed.\n");
#endif
} else if (!strncmp("norm=", arg, 5)) {
arg += 5;
// dxr3_norm is 0 (-> don't change norm) by default
// but maybe someone changes this in the future
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_WillSetTVNormTo);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Will set TV norm to: ");
if (*arg == '5') {
dxr3_norm = 5;
@@ -790,16 +779,16 @@ static int preinit(const char *arg)
mp_msg(MSGT_VO,MSGL_INFO, "PAL");
} else if (*arg == '2') {
dxr3_norm = 2;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_AutoAdjustToMovieFrameRatePALPAL60);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "auto-adjust to movie framerate (PAL/PAL-60)");
} else if (*arg == '1') {
dxr3_norm = 1;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_AutoAdjustToMovieFrameRatePALNTSC);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "auto-adjust to movie framerate (PAL/NTSC)");
} else if (*arg == '0') {
dxr3_norm = 0;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_UseCurrentNorm);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "Use current norm.");
} else {
dxr3_norm = 0;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_UseUnknownNormSuppliedCurrentNorm);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "Unknown norm supplied. Use current norm.");
}
mp_msg(MSGT_VO,MSGL_INFO, ".\n");
@@ -819,15 +808,15 @@ static int preinit(const char *arg)
fd_control = open(devname, fdflags);
if (fd_control < 1) {
/* Fall back to old naming scheme */
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_ErrorOpeningForWritingTrying, devname);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Error opening %s for writing, trying /dev/em8300 instead.\n", devname);
sprintf(devname, "/dev/em8300");
fd_control = open(devname, fdflags);
if (fd_control < 1) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_ErrorOpeningForWritingAsWell);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Error opening /dev/em8300 for writing as well!\nBailing out.\n");
return -1;
}
} else {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_Opened, devname);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Opened: %s.\n", devname);
}
/* Open the video interface */
@@ -835,16 +824,16 @@ static int preinit(const char *arg)
fd_video = open(devname, fdflags);
if (fd_video < 0) {
/* Fall back to old naming scheme */
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_ErrorOpeningForWritingTryingMV, devname);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Error opening %s for writing, trying /dev/em8300_mv instead.\n", devname);
sprintf(devname, "/dev/em8300_mv");
fd_video = open(devname, fdflags);
if (fd_video < 0) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_ErrorOpeningForWritingAsWellMV);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Error opening /dev/em8300_mv for writing as well!\nBailing out.\n");
uninit();
return -1;
}
} else {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_Opened, devname);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Opened: %s.\n", devname);
}
strcpy(fdv_name, devname);
@@ -853,16 +842,16 @@ static int preinit(const char *arg)
fd_spu = open(devname, fdflags);
if (fd_spu < 0) {
/* Fall back to old naming scheme */
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_ErrorOpeningForWritingTryingSP, devname);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Error opening %s for writing, trying /dev/em8300_sp instead.\n", devname);
sprintf(devname, "/dev/em8300_sp");
fd_spu = open(devname, fdflags);
if (fd_spu < 0) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_ErrorOpeningForWritingAsWellSP);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Error opening /dev/em8300_sp for writing as well!\nBailing out.\n");
uninit();
return -1;
}
} else {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_Opened, devname);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Opened: %s.\n", devname);
}
strcpy(fds_name, devname);
@@ -879,7 +868,7 @@ static int preinit(const char *arg)
dpy = XOpenDisplay(NULL);
if (!dpy) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_UnableToOpenDisplayDuringHackSetup);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Unable to open display during overlay hack setup!\n");
return -1;
}
XGetWindowAttributes(dpy, RootWindow(dpy, DefaultScreen(dpy)), &attribs);
@@ -899,7 +888,7 @@ static int preinit(const char *arg)
if (!use_gui) {
#endif
if (!vo_init()) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_UnableToInitX11);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Unable to init X11!\n");
return -1;
}
#ifdef CONFIG_GUI
@@ -938,7 +927,7 @@ static int overlay_set_attribute(overlay_t *o, int attribute, int value)
attr.value = value;
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SET_ATTRIBUTE, &attr)==-1)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedSettingOverlayAttribute);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed setting overlay attribute.\n");
return -1;
}
@@ -1144,7 +1133,7 @@ static int overlay_set_screen(overlay_t *o, int xres, int yres, int depth)
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SETSCREEN, &scr)==-1)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedSettingOverlayScreen);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed setting overlay screen!\nExiting.\n");
return -1;
}
return 0;
@@ -1153,7 +1142,7 @@ static int overlay_set_screen(overlay_t *o, int xres, int yres, int depth)
static int overlay_set_mode(overlay_t *o, int mode)
{
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SETMODE, &mode)==-1) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedEnablingOverlay);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed enabling overlay!\nExiting.\n");
return -1;
}
return 0;
@@ -1169,7 +1158,7 @@ static int overlay_set_window(overlay_t *o, int xpos,int ypos,int width,int heig
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SETWINDOW, &win)==-1)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedResizingOverlayWindow);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed resizing overlay window!\n");
return -1;
}
return 0;
@@ -1184,7 +1173,7 @@ static int overlay_set_bcs(overlay_t *o, int brightness, int contrast, int satur
if (ioctl(o->dev, EM8300_IOCTL_GETBCS, &bcs)==-1)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedSettingOverlayBcs);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed setting overlay bcs!\n");
return -1;
}
return 0;
@@ -1272,11 +1261,11 @@ static int overlay_autocalibrate(overlay_t *o, pattern_drawer_cb pd, void *arg)
cal.cal_mode = EM8300_OVERLAY_CALMODE_YOFFSET;
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_CALIBRATE, &cal))
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedGettingOverlayYOffsetValues);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed getting overlay Y-offset values!\nExiting.\n");
return -1;
}
o->yoffset = cal.result;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_YOffset,cal.result);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Yoffset: %d.\n",cal.result);
/* Calibrate X-offset */
@@ -1285,11 +1274,11 @@ static int overlay_autocalibrate(overlay_t *o, pattern_drawer_cb pd, void *arg)
cal.cal_mode = EM8300_OVERLAY_CALMODE_XOFFSET;
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_CALIBRATE, &cal))
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedGettingOverlayXOffsetValues);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed getting overlay X-offset values!\nExiting.\n");
return -1;
}
o->xoffset = cal.result;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_XOffset,cal.result);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Xoffset: %d.\n",cal.result);
/* Calibrate X scale correction */
@@ -1298,10 +1287,10 @@ static int overlay_autocalibrate(overlay_t *o, pattern_drawer_cb pd, void *arg)
cal.cal_mode = EM8300_OVERLAY_CALMODE_XCORRECTION;
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_CALIBRATE, &cal))
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedGettingOverlayXScaleCorrection);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed getting overlay X scale correction!\nExiting.\n");
return -1;
}
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_DXR3_XCorrection,cal.result);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_DXR3] Xcorrection: %d.\n",cal.result);
o->xcorr = cal.result;
win.xpos = 10;
@@ -1309,7 +1298,7 @@ static int overlay_autocalibrate(overlay_t *o, pattern_drawer_cb pd, void *arg)
win.width = o->xres-20;
win.height = o->yres-20;
if (ioctl(o->dev, EM8300_IOCTL_OVERLAY_SETWINDOW, &win)==-1) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_FailedResizingOverlayWindow);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_DXR3] Failed resizing overlay window!\n");
exit(1);
}
@@ -1372,7 +1361,7 @@ static int overlay_autocalibrate(overlay_t *o, pattern_drawer_cb pd, void *arg)
static int overlay_signalmode(overlay_t *o, int mode) {
if(ioctl(o->dev, EM8300_IOCTL_OVERLAY_SIGNALMODE, &mode) ==-1) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_DXR3_FailedSetSignalMix);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_DXR3] Failed to set signal mix!\n");
return -1;
}
return 0;
diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c
index 24870a3c96..12700108aa 100644
--- a/libvo/vo_fbdev.c
+++ b/libvo/vo_fbdev.c
@@ -1074,7 +1074,8 @@ static int preinit(const char *vo_subdevice)
if (memcmp(vo_subdevice, "vidix", 5) == 0)
vidix_name = &vo_subdevice[5];
if (vidix_name)
- pre_init_err = vidix_preinit(vidix_name, &video_out_fbdev);
+ pre_init_err = vidix_preinit(vidix_name,
+ video_out_fbdev.old_functions);
else
#endif
{
@@ -1106,7 +1107,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GET_IMAGE:
@@ -1119,27 +1120,8 @@ static int control(uint32_t request, void *data, ...)
if (vidix_name) {
switch (request) {
case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
+ return vidix_control(request, data);
}
}
#endif
diff --git a/libvo/vo_fbdev2.c b/libvo/vo_fbdev2.c
index 3483e96456..a2b51debde 100644
--- a/libvo/vo_fbdev2.c
+++ b/libvo/vo_fbdev2.c
@@ -413,7 +413,7 @@ static void uninit(void)
fb_preinit(1); // so that later calls to preinit don't fail
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_ggi.c b/libvo/vo_ggi.c
index 645bed2577..2be65696f5 100644
--- a/libvo/vo_ggi.c
+++ b/libvo/vo_ggi.c
@@ -83,6 +83,8 @@ static struct ggi_conf_s {
} flushregion;
int voflags;
+
+ int depthonscreen;
} ggi_conf;
@@ -210,7 +212,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
ggiSetFlags(ggi_conf.drawvis, GGIFLAG_ASYNC);
}
- vo_depthonscreen = GT_DEPTH(mode.graphtype);
+ ggi_conf.depthonscreen = GT_DEPTH(mode.graphtype);
vo_screenwidth = mode.virt.x;
vo_screenheight = mode.virt.y;
@@ -374,9 +376,9 @@ static int query_format(uint32_t format)
| VFCAP_CSP_SUPPORTED_BY_HW
| VFCAP_ACCEPT_STRIDE;
- if ((!vo_depthonscreen || !vo_dbpp) && ggi_conf.vis) {
+ if ((!ggi_conf.depthonscreen || !vo_dbpp) && ggi_conf.vis) {
if (ggiGetMode(ggi_conf.vis, &mode) == 0) {
- vo_depthonscreen = GT_DEPTH(mode.graphtype);
+ ggi_conf.depthonscreen = GT_DEPTH(mode.graphtype);
vo_dbpp = GT_SIZE(mode.graphtype);
}
if (GT_SCHEME(mode.graphtype) == GT_AUTO) {
@@ -384,7 +386,7 @@ static int query_format(uint32_t format)
}
if (GT_SCHEME(mode.graphtype) != GT_TRUECOLOR) {
mode.graphtype = GT_32BIT;
- vo_depthonscreen = GT_DEPTH(mode.graphtype);
+ ggi_conf.depthonscreen = GT_DEPTH(mode.graphtype);
vo_dbpp = GT_SIZE(mode.graphtype);
}
}
@@ -468,7 +470,7 @@ static void uninit(void)
ggiExit();
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_gif89a.c b/libvo/vo_gif89a.c
index eb4c178365..3a1525f244 100644
--- a/libvo/vo_gif89a.c
+++ b/libvo/vo_gif89a.c
@@ -335,7 +335,7 @@ static int query_format(uint32_t format)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
if (request == VOCTRL_QUERY_FORMAT) {
return query_format(*((uint32_t*)data));
@@ -374,4 +374,3 @@ static void uninit(void)
reduce_data = NULL;
reduce_cmap = NULL;
}
-
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index 4cc3ebc5cf..31448e83cf 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -538,7 +538,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
image_format = format;
glFindFormat(format, NULL, &gl_texfmt, &gl_format, &gl_type);
- int_pause = 0;
vo_flipped = !!(flags & VOFLAG_FLIPPING);
#ifdef CONFIG_GUI
@@ -1123,7 +1122,7 @@ static const struct {
{NULL, NULL, 0 }
};
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_PAUSE:
@@ -1159,14 +1158,14 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_GUISUPPORT:
return VO_TRUE;
case VOCTRL_ONTOP:
- vo_ontop();
+ vo_gl_ontop();
return VO_TRUE;
case VOCTRL_FULLSCREEN:
vo_fullscreen();
resize(vo_dwidth, vo_dheight);
return VO_TRUE;
case VOCTRL_BORDER:
- vo_border();
+ vo_gl_border();
resize(vo_dwidth, vo_dheight);
return VO_TRUE;
case VOCTRL_GET_PANSCAN:
@@ -1178,33 +1177,25 @@ static int control(uint32_t request, void *data, ...)
return VO_TRUE;
case VOCTRL_GET_EQUALIZER:
if (image_format == IMGFMT_YV12) {
+ struct voctrl_get_equalizer_args *args = data;
int i;
- va_list va;
- int *value;
- va_start(va, data);
- value = va_arg(va, int *);
- va_end(va);
for (i = 0; eq_map[i].name; i++)
- if (strcmp(data, eq_map[i].name) == 0) break;
+ if (strcmp(args->name, eq_map[i].name) == 0) break;
if (!(eq_map[i].supportmask & (1 << use_yuv)))
break;
- *value = *eq_map[i].value;
+ *args->valueptr = *eq_map[i].value;
return VO_TRUE;
}
break;
case VOCTRL_SET_EQUALIZER:
if (image_format == IMGFMT_YV12) {
+ struct voctrl_set_equalizer_args *args = data;
int i;
- va_list va;
- int value;
- va_start(va, data);
- value = va_arg(va, int);
- va_end(va);
for (i = 0; eq_map[i].name; i++)
- if (strcmp(data, eq_map[i].name) == 0) break;
+ if (strcmp(args->name, eq_map[i].name) == 0) break;
if (!(eq_map[i].supportmask & (1 << use_yuv)))
break;
- *eq_map[i].value = value;
+ *eq_map[i].value = args->value;
update_yuvconv();
return VO_TRUE;
}
@@ -1212,6 +1203,14 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_UPDATE_SCREENINFO:
update_xinerama_info();
return VO_TRUE;
+ case VOCTRL_REDRAW_OSD:
+ if (vo_doublebuffering)
+ do_render();
+ draw_osd();
+ if (vo_doublebuffering)
+ do_render_osd(2);
+ flip_page();
+ return VO_TRUE;
}
return VO_NOTIMPL;
}
diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c
index 9509001165..c545165b29 100644
--- a/libvo/vo_gl2.c
+++ b/libvo/vo_gl2.c
@@ -622,8 +622,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
image_width = width;
image_format = format;
- int_pause = 0;
-
#ifdef CONFIG_GUI
if (use_gui) {
if (config_glx_gui(d_width, d_height) == -1)
@@ -876,7 +874,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_PAUSE:
@@ -888,7 +886,7 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_GUISUPPORT:
return VO_TRUE;
case VOCTRL_ONTOP:
- vo_ontop();
+ vo_gl_ontop();
return VO_TRUE;
case VOCTRL_FULLSCREEN:
vo_fullscreen();
@@ -897,7 +895,7 @@ static int control(uint32_t request, void *data, ...)
resize(&vo_dwidth, &vo_dheight);
return VO_TRUE;
case VOCTRL_BORDER:
- vo_border();
+ vo_gl_border();
return VO_TRUE;
case VOCTRL_GET_PANSCAN:
return VO_TRUE;
@@ -907,23 +905,13 @@ static int control(uint32_t request, void *data, ...)
#ifndef GL_WIN32
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
- return vo_x11_set_equalizer(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return vo_x11_set_equalizer(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
- va_end(ap);
- return vo_x11_get_equalizer(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return vo_x11_get_equalizer(args->name, args->valueptr);
}
#endif
case VOCTRL_UPDATE_SCREENINFO:
diff --git a/libvo/vo_ivtv.c b/libvo/vo_ivtv.c
index e62308722a..b80ed44dd9 100644
--- a/libvo/vo_ivtv.c
+++ b/libvo/vo_ivtv.c
@@ -108,7 +108,7 @@ ivtv_reset (int blank_screen)
}
int
-ivtv_write (unsigned char *data, int len)
+ivtv_write (const unsigned char *data, int len)
{
if (ivtv_fd < 0)
return 0;
@@ -285,7 +285,7 @@ query_format (uint32_t format)
}
static int
-control (uint32_t request, void *data, ...)
+control (uint32_t request, void *data)
{
switch (request)
{
diff --git a/libvo/vo_jpeg.c b/libvo/vo_jpeg.c
index 72cb2a5b22..b6a5a8c352 100644
--- a/libvo/vo_jpeg.c
+++ b/libvo/vo_jpeg.c
@@ -44,7 +44,7 @@
#include "mp_msg.h"
#include "video_out.h"
#include "video_out_internal.h"
-#include "mplayer.h" /* for exit_player() */
+#include "mplayer.h" /* for exit_player_bad() */
#include "help_mp.h"
/* ------------------------------------------------------------------------- */
@@ -118,36 +118,36 @@ static void jpeg_mkdir(char *buf, int verbose) {
case EEXIST:
if ( stat(buf, &stat_p ) < 0 ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
- MSGTR_VO_GenericError, strerror(errno) );
+ _("This error has occurred"), strerror(errno) );
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
- MSGTR_VO_UnableToAccess,buf);
- exit_player(MSGTR_Exit_error);
+ _("Unable to access"), buf);
+ exit_player_bad(_("Fatal error"));
}
if ( !S_ISDIR(stat_p.st_mode) ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
- buf, MSGTR_VO_ExistsButNoDirectory);
- exit_player(MSGTR_Exit_error);
+ buf, _("already exists, but is not a directory."));
+ exit_player_bad(_("Fatal error"));
}
if ( !(stat_p.st_mode & S_IWUSR) ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirExistsButNotWritable);
- exit_player(MSGTR_Exit_error);
+ buf, _("Output directory already exists, but is not writable."));
+ exit_player_bad(_("Fatal error"));
}
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirExistsAndIsWritable);
+ buf, _("Output directory already exists and is writable."));
break;
default:
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
- MSGTR_VO_GenericError, strerror(errno) );
+ _("This error has occurred"), strerror(errno) );
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_CantCreateDirectory);
- exit_player(MSGTR_Exit_error);
+ buf, _("Unable to create output directory."));
+ exit_player_bad(_("Fatal error"));
} /* end switch */
} else if ( verbose ) {
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirectoryCreateSuccess);
+ buf, _("Output directory successfully created."));
} /* end if */
}
@@ -188,11 +188,11 @@ static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer)
if ( !buffer ) return 1;
if ( (outfile = fopen(name, "wb") ) == NULL ) {
mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name,
- MSGTR_VO_CantCreateFile);
+ _("Unable to create output file."));
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
- info.short_name, MSGTR_VO_GenericError,
- strerror(errno) );
- exit_player(MSGTR_Exit_error);
+ info.short_name, _("This error has occurred"),
+ strerror(errno) );
+ exit_player_bad(_("Fatal error"));
}
cinfo.err = jpeg_std_error(&jerr);
@@ -357,7 +357,7 @@ static int preinit(const char *arg)
const char *info_message = NULL;
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name,
- MSGTR_VO_ParsingSuboptions);
+ _("Parsing suboptions."));
jpeg_progressive_mode = 0;
jpeg_baseline = 1;
@@ -372,12 +372,12 @@ static int preinit(const char *arg)
return -1;
}
- if (jpeg_progressive_mode) info_message = MSGTR_VO_JPEG_ProgressiveJPEG;
- else info_message = MSGTR_VO_JPEG_NoProgressiveJPEG;
+ if (jpeg_progressive_mode) info_message = _("Progressive JPEG enabled.");
+ else info_message = _("Progressive JPEG disabled.");
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
- if (jpeg_baseline) info_message = MSGTR_VO_JPEG_BaselineJPEG;
- else info_message = MSGTR_VO_JPEG_NoBaselineJPEG;
+ if (jpeg_baseline) info_message = _("Baseline JPEG enabled.");
+ else info_message = _("Baseline JPEG disabled.");
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
mp_msg(MSGT_VO, MSGL_V, "%s: optimize --> %d\n", info.short_name,
@@ -398,13 +398,13 @@ static int preinit(const char *arg)
}
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name,
- MSGTR_VO_SuboptionsParsedOK);
+ _("Suboptions parsed OK."));
return 0;
}
/* ------------------------------------------------------------------------- */
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -418,4 +418,3 @@ static int control(uint32_t request, void *data, ...)
#undef BUFLENGTH
/* ------------------------------------------------------------------------- */
-
diff --git a/libvo/vo_kva.c b/libvo/vo_kva.c
index 4805d51fbd..fbd670e790 100644
--- a/libvo/vo_kva.c
+++ b/libvo/vo_kva.c
@@ -933,7 +933,7 @@ static int color_ctrl_get(char *what, int *value)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GET_IMAGE:
@@ -950,26 +950,14 @@ static int control(uint32_t request, void *data, ...)
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return color_ctrl_set(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ color_ctrl_set(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
- va_end(ap);
-
- return color_ctrl_get(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return color_ctrl_get(args->name, args->valueptr);
}
case VOCTRL_UPDATE_SCREENINFO:
diff --git a/libvo/vo_md5sum.c b/libvo/vo_md5sum.c
index 754630f2da..b279ea5ad6 100644
--- a/libvo/vo_md5sum.c
+++ b/libvo/vo_md5sum.c
@@ -40,7 +40,7 @@
#include "mp_msg.h"
#include "video_out.h"
#include "video_out_internal.h"
-#include "mplayer.h" /* for exit_player() */
+#include "mplayer.h" /* for exit_player_bad() */
#include "help_mp.h"
#include "libavutil/md5.h"
@@ -85,8 +85,8 @@ int framenum = 0;
*/
static void md5sum_write_error(void) {
- mp_msg(MSGT_VO, MSGL_ERR, MSGTR_ErrorWritingFile, info.short_name);
- exit_player(MSGTR_Exit_error);
+ mp_tmsg(MSGT_VO, MSGL_ERR, "%s: Error writing file.\n", info.short_name);
+ exit_player_bad(_("Fatal error"));
}
/* ------------------------------------------------------------------------- */
@@ -113,7 +113,7 @@ static int preinit(const char *arg)
};
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name,
- MSGTR_VO_ParsingSuboptions);
+ _("Parsing suboptions."));
md5sum_outfile = strdup("md5sums");
if (subopt_parse(arg, subopts) != 0) {
@@ -124,7 +124,7 @@ static int preinit(const char *arg)
md5sum_outfile);
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name,
- MSGTR_VO_SuboptionsParsedOK);
+ _("Suboptions parsed OK."));
return 0;
}
@@ -149,10 +149,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
if ( (md5sum_fd = fopen(md5sum_outfile, "w") ) == NULL ) {
mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name,
- MSGTR_VO_CantCreateFile);
+ _("Unable to create output file."));
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
- info.short_name, MSGTR_VO_GenericError, strerror(errno) );
- exit_player(MSGTR_Exit_error);
+ info.short_name, _("This error has occurred"), strerror(errno) );
+ exit_player_bad(_("Fatal error"));
}
return 0;
@@ -264,7 +264,7 @@ static int query_format(uint32_t format)
/* ------------------------------------------------------------------------- */
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -311,4 +311,3 @@ static void flip_page (void)
#undef MD5SUM_YUV_MODE
/* ------------------------------------------------------------------------- */
-
diff --git a/libvo/vo_mga.c b/libvo/vo_mga.c
index 7a365151ac..a83b75285f 100644
--- a/libvo/vo_mga.c
+++ b/libvo/vo_mga.c
@@ -85,7 +85,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
aspect(&d_width,&d_height,A_NOZOOM);
vo_fs = VO_FALSE;
}
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_MGA_AspectResized,d_width,d_height);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_MGA] aspect(): resized to %dx%d.\n",d_width,d_height);
}
vo_dwidth=d_width; vo_dheight=d_height;
@@ -103,7 +103,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
static void uninit(void)
{
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_MGA_Uninit);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO] uninit!\n");
mga_uninit();
}
@@ -116,4 +116,3 @@ static void flip_page(void)
static void check_events(void)
{
}
-
diff --git a/libvo/vo_mpegpes.c b/libvo/vo_mpegpes.c
index 94fe08f6f2..b96b0af639 100644
--- a/libvo/vo_mpegpes.c
+++ b/libvo/vo_mpegpes.c
@@ -185,7 +185,7 @@ static void draw_osd(void)
}
-static int my_write(unsigned char* data,int len){
+static int my_write(const unsigned char* data,int len){
int orig_len = len;
#ifdef CONFIG_DVB
#define NFD 2
@@ -220,15 +220,10 @@ static int my_write(unsigned char* data,int len){
return orig_len;
}
-void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
+static void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
send_mpeg_pes_packet (data, len, id, timestamp, 1, my_write);
}
-void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){
- send_mpeg_lpcm_packet(data, len, id, timestamp, freq_id, my_write);
-}
-
-
static int draw_frame(uint8_t * src[])
{
vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
@@ -266,7 +261,7 @@ static void check_events(void)
{
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_null.c b/libvo/vo_null.c
index a6b14b4edd..9bcd4a2c24 100644
--- a/libvo/vo_null.c
+++ b/libvo/vo_null.c
@@ -92,13 +92,13 @@ static int preinit(const char *arg)
{
if(arg)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_NULL_UnknownSubdevice,arg);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_NULL] Unknown subdevice: %s.\n",arg);
return ENOSYS;
}
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_png.c b/libvo/vo_png.c
index 8110f859df..3d7d33927a 100644
--- a/libvo/vo_png.c
+++ b/libvo/vo_png.c
@@ -26,9 +26,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
#include <png.h>
@@ -39,9 +36,6 @@
#include "video_out.h"
#include "video_out_internal.h"
#include "subopt-helper.h"
-#include "mplayer.h"
-
-#define BUFLENGTH 512
static const vo_info_t info =
{
@@ -54,7 +48,6 @@ static const vo_info_t info =
const LIBVO_EXTERN (png)
static int z_compression = Z_NO_COMPRESSION;
-static char *png_outdir = NULL;
static int framenum = 0;
static int use_alpha;
@@ -65,65 +58,16 @@ struct pngdata {
enum {OK,ERROR} status;
};
-static void png_mkdir(char *buf, int verbose) {
- struct stat stat_p;
-
-#ifndef __MINGW32__
- if ( mkdir(buf, 0755) < 0 ) {
-#else
- if ( mkdir(buf) < 0 ) {
-#endif
- switch (errno) { /* use switch in case other errors need to be caught
- and handled in the future */
- case EEXIST:
- if ( stat(buf, &stat_p ) < 0 ) {
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
- MSGTR_VO_GenericError, strerror(errno) );
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
- MSGTR_VO_UnableToAccess,buf);
- exit_player(MSGTR_Exit_error);
- }
- if ( !S_ISDIR(stat_p.st_mode) ) {
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
- buf, MSGTR_VO_ExistsButNoDirectory);
- exit_player(MSGTR_Exit_error);
- }
- if ( !(stat_p.st_mode & S_IWUSR) ) {
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirExistsButNotWritable);
- exit_player(MSGTR_Exit_error);
- }
-
- mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirExistsAndIsWritable);
- break;
-
- default:
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
- MSGTR_VO_GenericError, strerror(errno) );
- mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_CantCreateDirectory);
- exit_player(MSGTR_Exit_error);
- } /* end switch */
- } else if ( verbose ) {
- mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirectoryCreateSuccess);
- } /* end if */
-}
-
static int
config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
- char buf[BUFLENGTH];
if(z_compression == 0) {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning1);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning2);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Warning: compression level set to 0, compression disabled!\n");
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Info: Use -vo png:z=<n> to set compression level from 0 to 9.\n");
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Info: (0 = no compression, 1 = fastest, lowest - 9 best, slowest compression)\n");
}
- snprintf(buf, BUFLENGTH, "%s", png_outdir);
- png_mkdir(buf, 1);
mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression);
return 0;
@@ -167,7 +111,7 @@ static struct pngdata create_png (char * fname, int image_width, int image_heigh
png.fp = fopen (fname, "wb");
if (png.fp == NULL) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno));
+ mp_tmsg(MSGT_VO,MSGL_WARN, "\n[VO_PNG] Error opening '%s' for writing!\n", strerror(errno));
png.status = ERROR;
return png;
}
@@ -220,12 +164,12 @@ static uint32_t draw_image(mp_image_t* mpi){
// if -dr or -slices then do nothing:
if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
- snprintf (buf, 100, "%s/%08d.png", png_outdir, ++framenum);
+ snprintf (buf, 100, "%08d.png", ++framenum);
png = create_png(buf, mpi->w, mpi->h, IMGFMT_IS_BGR(mpi->imgfmt));
if(png.status){
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_PNG] Error in create_png.\n");
return 1;
}
@@ -274,12 +218,7 @@ query_format(uint32_t format)
return 0;
}
-static void uninit(void){
- if (png_outdir) {
- free(png_outdir);
- png_outdir = NULL;
- }
-}
+static void uninit(void){}
static void check_events(void){}
@@ -293,14 +232,12 @@ static int int_zero_to_nine(int *sh)
static const opt_t subopts[] = {
{"alpha", OPT_ARG_BOOL, &use_alpha, NULL},
{"z", OPT_ARG_INT, &z_compression, (opt_test_f)int_zero_to_nine},
- {"outdir", OPT_ARG_MSTRZ, &png_outdir, NULL},
{NULL}
};
static int preinit(const char *arg)
{
z_compression = 0;
- png_outdir = strdup(".");
use_alpha = 0;
if (subopt_parse(arg, subopts) != 0) {
return -1;
@@ -308,7 +245,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_DRAW_IMAGE:
diff --git a/libvo/vo_pnm.c b/libvo/vo_pnm.c
index 90caf55e24..f8e0b2271b 100644
--- a/libvo/vo_pnm.c
+++ b/libvo/vo_pnm.c
@@ -39,7 +39,7 @@
#include "mp_msg.h"
#include "video_out.h"
#include "video_out_internal.h"
-#include "mplayer.h" /* for exit_player() */
+#include "mplayer.h" /* for exit_player_bad() */
#include "help_mp.h"
/* ------------------------------------------------------------------------- */
@@ -97,8 +97,8 @@ char *pnm_file_extension = NULL;
*/
static void pnm_write_error(void) {
- mp_msg(MSGT_VO, MSGL_ERR, MSGTR_ErrorWritingFile, info.short_name);
- exit_player(MSGTR_Exit_error);
+ mp_tmsg(MSGT_VO, MSGL_ERR, "%s: Error writing file.\n", info.short_name);
+ exit_player_bad(_("Fatal error"));
}
/* ------------------------------------------------------------------------- */
@@ -134,7 +134,7 @@ static int preinit(const char *arg)
const char *info_message = NULL;
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name,
- MSGTR_VO_ParsingSuboptions);
+ _("Parsing suboptions."));
pnm_maxfiles = 1000;
pnm_outdir = strdup(".");
@@ -155,29 +155,29 @@ static int preinit(const char *arg)
switch (pnm_mode) {
case PNM_ASCII_MODE:
- info_message = MSGTR_VO_PNM_ASCIIMode;
+ info_message = _("ASCII mode enabled.");
break;
case PNM_RAW_MODE:
- info_message = MSGTR_VO_PNM_RawMode;
+ info_message = _("Raw mode enabled.");
break;
}
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
switch (pnm_type) {
case PNM_TYPE_PPM:
- info_message = MSGTR_VO_PNM_PPMType;
+ info_message = _("Will write PPM files.");
break;
case PNM_TYPE_PGM:
- info_message = MSGTR_VO_PNM_PGMType;
+ info_message = _("Will write PGM files.");
break;
case PNM_TYPE_PGMYUV:
- info_message = MSGTR_VO_PNM_PGMYUVType;
+ info_message = _("Will write PGMYUV files.");
break;
}
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name,
- MSGTR_VO_SuboptionsParsedOK);
+ _("Suboptions parsed OK."));
return 0;
}
@@ -211,38 +211,38 @@ static void pnm_mkdir(char *buf, int verbose) {
case EEXIST:
if ( stat(buf, &stat_p ) < 0 ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
- MSGTR_VO_GenericError, strerror(errno) );
+ _("This error has occurred"), strerror(errno) );
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
- MSGTR_VO_UnableToAccess,buf);
- exit_player(MSGTR_Exit_error);
+ _("Unable to access"), buf);
+ exit_player_bad(_("Fatal error"));
}
if ( !S_ISDIR(stat_p.st_mode) ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
- buf, MSGTR_VO_ExistsButNoDirectory);
- exit_player(MSGTR_Exit_error);
+ buf, _("already exists, but is not a directory."));
+ exit_player_bad(_("Fatal error"));
}
if ( !(stat_p.st_mode & S_IWUSR) ) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirExistsButNotWritable);
- exit_player(MSGTR_Exit_error);
+ buf, _("Output directory already exists, but is not writable."));
+ exit_player_bad(_("Fatal error"));
}
if (strcmp(buf, ".") != 0) {
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirExistsAndIsWritable);
+ buf, _("Output directory already exists and is writable."));
}
break;
default:
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
- MSGTR_VO_GenericError, strerror(errno) );
+ _("This error has occurred"), strerror(errno) );
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_CantCreateDirectory);
- exit_player(MSGTR_Exit_error);
+ buf, _("Unable to create output directory."));
+ exit_player_bad(_("Fatal error"));
} /* end switch */
} else if ( verbose ) {
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
- buf, MSGTR_VO_DirectoryCreateSuccess);
+ buf, _("Output directory successfully created."));
} /* end if */
}
@@ -442,7 +442,7 @@ static void pnm_write_image(mp_image_t *mpi)
if (!mpi) {
mp_msg(MSGT_VO, MSGL_ERR, "%s: No image data suplied to video output driver\n", info.short_name );
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(_("Fatal error"));
}
/* Start writing to new subdirectory after a certain amount of frames */
@@ -470,11 +470,11 @@ static void pnm_write_image(mp_image_t *mpi)
if ( (outfile = fopen(buf, "wb") ) == NULL ) {
mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name,
- MSGTR_VO_CantCreateFile);
+ "Unable to create output file.");
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
- info.short_name, MSGTR_VO_GenericError,
+ info.short_name, "This error has occurred",
strerror(errno) );
- exit_player(MSGTR_Exit_error);
+ exit_player_bad(_("Fatal error"));
}
pnm_write_pnm(outfile, mpi);
@@ -542,7 +542,7 @@ static int query_format(uint32_t format)
/* ------------------------------------------------------------------------- */
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -595,4 +595,3 @@ static void flip_page (void)
#undef PNM_TYPE_PGMYUV
/* ------------------------------------------------------------------------- */
-
diff --git a/libvo/vo_quartz.c b/libvo/vo_quartz.c
index 23b3e951a7..4aa3ac289b 100644
--- a/libvo/vo_quartz.c
+++ b/libvo/vo_quartz.c
@@ -87,8 +87,6 @@ static int EnterMoviesDone = 0;
static int get_image_done = 0;
static int vo_quartz_fs; // we are in fullscreen
-extern float monitor_aspect;
-extern float movie_aspect;
static float old_movie_aspect;
static int winLevel = 1;
@@ -1273,7 +1271,7 @@ static uint32_t get_yuv_image(mp_image_t * mpi)
return VO_FALSE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
diff --git a/libvo/vo_s3fb.c b/libvo/vo_s3fb.c
index c45b2c66e4..5b884b75b8 100644
--- a/libvo/vo_s3fb.c
+++ b/libvo/vo_s3fb.c
@@ -521,7 +521,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch(request) {
case VOCTRL_GET_IMAGE:
diff --git a/libvo/vo_sdl.c b/libvo/vo_sdl.c
index 1b9a985d83..25e411a5ce 100644
--- a/libvo/vo_sdl.c
+++ b/libvo/vo_sdl.c
@@ -425,7 +425,7 @@ static int sdl_open (void *plugin, void *name)
*/
priv->sdlflags &= ~SDL_HWSURFACE;
if ((!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) && (!priv->fullmodes)) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SDL_CouldntGetAnyAcceptableSDLModeForOutput);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SDL] Couldn't get any acceptable SDL Mode for output.\n");
return -1;
}
}
@@ -706,7 +706,7 @@ static void set_fullmode (int mode) {
setup_surfaces();
}
else
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_SetVideoModeFailedFull, SDL_GetError());
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SDL] Set_fullmode: SDL_SetVideoMode failed: %s.\n", SDL_GetError());
}
@@ -728,7 +728,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
switch(format){
case IMGFMT_I420:
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_MappingI420ToIYUV);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SDL] Mapping I420 to IYUV.\n");
format = SDL_IYUV_OVERLAY;
case IMGFMT_YV12:
case IMGFMT_IYUV:
@@ -750,7 +750,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
priv->mode = RGB;
break;
default:
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_UnsupportedImageFormat,format);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SDL] Unsupported image format (0x%X).\n",format);
return -1;
}
@@ -808,7 +808,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
}
if(flags&VOFLAG_FULLSCREEN) {
mp_msg(MSGT_VO,MSGL_V, "SDL: setting zoomed fullscreen without modeswitching\n");
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_InfoPleaseUseVmOrZoom);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SDL] Info - please use -vm or -zoom to switch to the best resolution.\n");
priv->fulltype = VOFLAG_FULLSCREEN;
set_fullmode(priv->fullmode);
/*if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags)))
@@ -845,7 +845,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
}
if(!priv->surface) { // cannot SetVideoMode
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_FailedToSetVideoMode, SDL_GetError());
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SDL] Failed to set video mode: %s.\n", SDL_GetError());
return -1;
}
@@ -933,7 +933,7 @@ static int setup_surfaces(void)
default:
/* Initialize and create the YUV Overlay used for video out */
if (!(priv->overlay = SDL_CreateYUVOverlay (surfwidth, surfheight, priv->format, priv->surface))) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_CouldntCreateAYUVOverlay, SDL_GetError());
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SDL] Couldn't create a YUV overlay: %s.\n", SDL_GetError());
return -1;
}
priv->framePlaneY = priv->width * priv->height;
@@ -946,14 +946,14 @@ static int setup_surfaces(void)
if(priv->mode != YUV) {
if(!priv->rgbsurface) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_CouldntCreateARGBSurface, SDL_GetError());
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SDL] Couldn't create an RGB surface: %s.\n", SDL_GetError());
return -1;
}
priv->dblit = 0;
if((priv->format&0xFF) != priv->bpp)
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_UsingDepthColorspaceConversion, priv->format&0xFF, priv->bpp);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SDL] Using depth/colorspace conversion, this will slow things down (%ibpp -> %ibpp).\n", priv->format&0xFF, priv->bpp);
priv->framePlaneRGB = priv->width * priv->height * priv->rgbsurface->format->BytesPerPixel;
priv->stridePlaneRGB = priv->width * priv->rgbsurface->format->BytesPerPixel;
@@ -1081,7 +1081,7 @@ static int draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
break;
default:
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_UnsupportedImageFormatInDrawslice);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SDL] Unsupported image format in draw_slice, contact MPlayer developers!\n");
}
SDL_OVR_UNLOCK
@@ -1443,7 +1443,7 @@ static void flip_page (void)
if(!priv->dblit) {
/* blit to the RGB surface */
if(SDL_BlitSurface (priv->rgbsurface, NULL, priv->surface, NULL))
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_BlitFailed, SDL_GetError());
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SDL] Blit failed: %s.\n", SDL_GetError());
}
/* update screen */
@@ -1566,14 +1566,14 @@ static int preinit(const char *arg)
/* initialize the SDL Video system */
if (!SDL_WasInit(SDL_INIT_VIDEO)) {
if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE)) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SDL_InitializationFailed, SDL_GetError());
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SDL] SDL initialization failed: %s.\n", SDL_GetError());
return -1;
}
}
SDL_VideoDriverName(priv->driver, 8);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_UsingDriver, priv->driver);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SDL] Using driver: %s.\n", priv->driver);
priv->X = 0;
#ifdef CONFIG_X11
@@ -1635,7 +1635,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_FALSE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
struct sdl_priv_s *priv = &sdl_priv;
switch (request) {
diff --git a/libvo/vo_svga.c b/libvo/vo_svga.c
index 2dcaf6401f..433f8d76ef 100644
--- a/libvo/vo_svga.c
+++ b/libvo/vo_svga.c
@@ -152,7 +152,7 @@ static int preinit(const char *arg)
vidix_name[i-5]=0;
if(arg[i]==':')i++;
arg+=i;
- vidix_preinit(vidix_name, &video_out_svga);
+ vidix_preinit(vidix_name, video_out_svga.old_functions);
}
#endif
if(!strncmp(arg,"sq",2)) {
@@ -358,7 +358,7 @@ static int find_best_svga_mode(int req_w,int req_h, int req_bpp){
return bestmode;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -370,33 +370,8 @@ static int control(uint32_t request, void *data, ...)
}
#ifdef CONFIG_VIDIX
- if (vidix_name[0]) {
- switch (request) {
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
- }
+ if (vidix_name[0])
return vidix_control(request, data);
- }
#endif
return VO_NOTIMPL;
@@ -432,24 +407,24 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
}else{//force_vm
vid_mode=force_vm;
if(vga_hasmode(vid_mode) == 0){
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable,
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SVGA] Forced vid_mode %d (%s) not available.\n",
vid_mode,vga_getmodename(vid_mode));
return 1; //error;
}
modeinfo=vga_getmodeinfo(vid_mode);
if( (modeinfo->width < req_w) || (modeinfo->height < req_h) ){
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall,
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SVGA] Forced vid_mode %d (%s) too small.\n",
vid_mode,vga_getmodename(vid_mode));
return 1;
}
}
mode_bpp=bpp_from_vminfo(modeinfo);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode,
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SVGA] Vid_mode: %d, %dx%d %dbpp.\n",
vid_mode,modeinfo->width,modeinfo->height,mode_bpp);
if (vga_setmode(vid_mode) == -1) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SVGA] Vga_setmode(%d) failed.\n",vid_mode);
uninit();
return 1; // error
}
@@ -499,11 +474,11 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
}
}//fi force native
if(mode_capabilities&CAP_LINEAR){
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeIsLinearAndMemcpyCouldBeUsed);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SVGA] Video mode is linear and memcpy could be used for image transfer.\n");
}
if(mode_capabilities&CAP_ACCEL_PUTIMAGE){
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHasHardwareAcceleration);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_IfItWorksForYouIWouldLikeToKnow);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SVGA] Video mode has hardware acceleration and put_image could be used.\n");
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SVGA] If it works for you I would like to know.\n[VO_SVGA] (send log with `mplayer test.avi -v -v -v -v &> svga.log`). Thx!\n");
}
//here is the place to handle strides for accel_ modes;
@@ -537,7 +512,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
}
}
assert(max_pages>0);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHas,max_pages);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SVGA] Video mode has %d page(s).\n",max_pages);
//15bpp
if(modeinfo->bytesperpixel!=0)
vga_claimvideomemory(max_pages * modeinfo->height * modeinfo->width * modeinfo->bytesperpixel);
@@ -552,14 +527,14 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
x_pos = (modeinfo->width - req_w) / 2;
y_pos = (modeinfo->height - req_h) / 2;
x_pos &= ~(15); //align x offset position to 16 pixels
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_CenteringImageStartAt,x_pos,y_pos);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SVGA] Centering image. Starting at (%d,%d)\n",x_pos,y_pos);
#ifdef CONFIG_VIDIX
if(vidix_name[0]){
vidix_init(width, height, x_pos, y_pos, modeinfo->width, modeinfo->height,
format, mode_bpp, modeinfo->width,modeinfo->height);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_UsingVidix,width,height,
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_SVGA] Using VIDIX. w=%i h=%i mw=%i mh=%i\n",width,height,
modeinfo->width,modeinfo->height);
vidix_start();
/*set colorkey*/
diff --git a/libvo/vo_tdfx_vid.c b/libvo/vo_tdfx_vid.c
index fcd00969d2..b9fb75eec6 100644
--- a/libvo/vo_tdfx_vid.c
+++ b/libvo/vo_tdfx_vid.c
@@ -87,10 +87,10 @@ static void clear_screen(void) {
mov.dst = front_buffer;
mov.dst_stride = tdfx_cfg.screen_stride;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_Move, mov.width,mov.src_stride,mov.height,mov.dst_stride);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_TDXVID] Move %d(%d) x %d => %d.\n", mov.width,mov.src_stride,mov.height,mov.dst_stride);
if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov))
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AGPMoveFailedToClearTheScreen);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] AGP move failed to clear the screen.\n");
}
#endif
@@ -176,7 +176,7 @@ flip_page(void)
blit.dst_h = src_height;
blit.dst_format = IMGFMT_BGR16;
if(ioctl(tdfx_fd,TDFX_VID_BLIT,&blit))
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_BlitFailed);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Blit failed.\n");
}
return;
}
@@ -198,7 +198,7 @@ flip_page(void)
blit.dst_format = dst_fmt;
if(ioctl(tdfx_fd,TDFX_VID_BLIT,&blit))
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_BlitFailed);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Blit failed.\n");
}
static int
@@ -266,7 +266,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
case IMGFMT_BGR24:
case IMGFMT_BGR32:
if(use_overlay)
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_NonNativeOverlayFormatNeedConversion);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_TDFXVID] Non-native overlay format needs conversion.\n");
case IMGFMT_BGR15:
case IMGFMT_BGR16:
src_bpp = ((format & 0x3F)+7)/8;
@@ -282,7 +282,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
src_bpp = 2;
break;
default:
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_UnsupportedInputFormat,format);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Unsupported input format 0x%x.\n",format);
return 1;
}
@@ -338,28 +338,28 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
ov.use_colorkey = 0;
if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&ov)) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlaySetupFailed);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Overlay setup failed.\n");
use_overlay = 0;
break;
}
tdfx_ov = ov;
if(use_overlay == 1) {
if(ioctl(tdfx_fd,TDFX_VID_OVERLAY_ON)) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlayOnFailed);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Overlay on failed.\n");
use_overlay = 0;
break;
}
use_overlay++;
}
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_OverlayReady,
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_TDFXVID] Overlay ready: %d(%d) x %d @ %d => %d(%d) x %d @ %d.\n",
src_width,src_stride,src_height,src_bpp,
dst_width,dst_stride,dst_height,dst_bpp);
break;
}
if(!use_overlay)
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_TextureBlitReady,
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_TDFXVID] Texture blit ready: %d(%d) x %d @ %d => %d(%d) x %d @ %d.\n",
src_width,src_stride,src_height,src_bpp,
dst_width,dst_stride,dst_height,dst_bpp);
@@ -371,7 +371,7 @@ uninit(void)
{
if(use_overlay == 2) {
if(ioctl(tdfx_fd,TDFX_VID_OVERLAY_OFF))
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlayOffFailed);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Overlay off failed\n");
use_overlay--;
}
close(tdfx_fd);
@@ -388,13 +388,13 @@ static int preinit(const char *arg)
tdfx_fd = open(arg ? arg : "/dev/tdfx_vid", O_RDWR);
if(tdfx_fd < 0) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_CantOpen,arg ? arg : "/dev/tdfx_vid",
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Can't open %s: %s.\n",arg ? arg : "/dev/tdfx_vid",
strerror(errno));
return 1;
}
if(ioctl(tdfx_fd,TDFX_VID_GET_CONFIG,&tdfx_cfg)) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_CantGetCurrentCfg,strerror(errno));
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Can't get current configuration: %s.\n",strerror(errno));
return 1;
}
@@ -413,7 +413,7 @@ static int preinit(const char *arg)
tdfx_fd, 0);
if(agp_mem == MAP_FAILED) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_MemmapFailed);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Memmap failed !!!!!\n");
return 1;
}
@@ -465,7 +465,7 @@ static uint32_t get_image(mp_image_t *mpi) {
mpi->stride[2] = mpi->chroma_width;
break;
default:
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_GetImageTodo);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "Get image todo.\n");
return VO_FALSE;
}
mpi->flags |= MP_IMGFLAG_DIRECT;
@@ -531,7 +531,7 @@ static uint32_t draw_image(mp_image_t *mpi){
mov.dst_stride = src_stride;
if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov))
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailed);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] AGP move failed.\n");
break;
case IMGFMT_YV12:
@@ -560,7 +560,7 @@ static uint32_t draw_image(mp_image_t *mpi){
yuv.base = back_buffer;
yuv.stride = src_stride;
if(ioctl(tdfx_fd,TDFX_VID_SET_YUV,&yuv)) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_SetYuvFailed);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] Set YUV failed.\n");
break;
}
@@ -576,7 +576,7 @@ static uint32_t draw_image(mp_image_t *mpi){
mov.dst_stride = TDFX_VID_YUV_STRIDE;
if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnYPlane);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] AGP move failed on Y plane.\n");
break;
}
//return 0;
@@ -588,7 +588,7 @@ static uint32_t draw_image(mp_image_t *mpi){
mov.src_stride = buffer_stride[p];
mov.dst += TDFX_VID_YUV_PLANE_SIZE;
if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnUPlane);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] AGP move failed on U plane.\n");
break;
}
// V
@@ -597,12 +597,12 @@ static uint32_t draw_image(mp_image_t *mpi){
mov.src_stride = buffer_stride[p];
mov.dst += TDFX_VID_YUV_PLANE_SIZE;
if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnVPlane);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] AGP move failed on V plane.\n");
break;
}
break;
default:
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_UnknownFormat,mpi->imgfmt);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TDFXVID] unknown format: 0x%x.\n",mpi->imgfmt);
return VO_TRUE;
}
@@ -644,7 +644,7 @@ static uint32_t set_colorkey(mp_colorkey_t* colork) {
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -666,4 +666,3 @@ static int control(uint32_t request, void *data, ...)
}
return VO_NOTIMPL;
}
-
diff --git a/libvo/vo_tdfxfb.c b/libvo/vo_tdfxfb.c
index 03f0513076..343045dff3 100644
--- a/libvo/vo_tdfxfb.c
+++ b/libvo/vo_tdfxfb.c
@@ -111,12 +111,12 @@ static int preinit(const char *arg)
name = "/dev/fb0";
if((fd = open(name, O_RDWR)) == -1) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_CantOpen, name, strerror(errno));
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_TDFXFB] Can't open %s: %s.\n", name, strerror(errno));
return -1;
}
if(ioctl(fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_ProblemWithFbitgetFscreenInfo,
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_TDFXFB] Problem with FBITGET_FSCREENINFO ioctl: %s.\n",
strerror(errno));
close(fd);
fd = -1;
@@ -124,7 +124,7 @@ static int preinit(const char *arg)
}
if(ioctl(fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_ProblemWithFbitgetVscreenInfo,
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_TDFXFB] Problem with FBITGET_VSCREENINFO ioctl: %s.\n",
strerror(errno));
close(fd);
fd = -1;
@@ -133,7 +133,7 @@ static int preinit(const char *arg)
/* BANSHEE means any of the series aparently */
if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_ThisDriverOnlySupports);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_TDFXFB] This driver only supports the 3Dfx Banshee, Voodoo3 and Voodoo 5.\n");
close(fd);
fd = -1;
return -1;
@@ -146,7 +146,7 @@ static int preinit(const char *arg)
case 32:
break; // Ok
default:
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_OutputIsNotSupported, fb_vinfo.bits_per_pixel);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_TDFXFB] %d bpp output is not supported.\n", fb_vinfo.bits_per_pixel);
close(fd);
fd = -1;
return -1;
@@ -159,7 +159,7 @@ static int preinit(const char *arg)
MAP_SHARED, fd, fb_finfo.smem_len);
if((long)memBase0 == -1 || (long)memBase1 == -1) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_CouldntMapMemoryAreas, strerror(errno));
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_TDFXFB] Couldn't map memory areas: %s.\n", strerror(errno));
if((long)memBase0 != -1)
munmap(memBase0, fb_finfo.smem_len);
if((long)memBase1 != -1)
@@ -266,7 +266,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
break;
default:
- mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_TDFXFB_BppOutputIsNotSupported, fb_vinfo.bits_per_pixel);
+ mp_tmsg(MSGT_VO, MSGL_ERR, "[VO_TDFXFB] %d bpp output is not supported (This should never have happened).\n", fb_vinfo.bits_per_pixel);
return -1;
}
@@ -304,7 +304,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
break;
default:
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_SomethingIsWrongWithControl);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_TDFXFB] Eik! Something's wrong with control().\n");
return -1;
}
@@ -321,7 +321,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
inpageoffset = hidpageoffset + screenwidth * screenheight * screendepth;
if(inpageoffset + in_width * in_depth * in_height > fb_finfo.smem_len) {
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_NotEnoughVideoMemoryToPlay);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_TDFXFB] Not enough video memory to play this movie. Try at a lower resolution.\n");
return -1;
}
@@ -333,7 +333,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
memset(inpage, 0, in_width * in_height * in_depth);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXFB_ScreenIs,
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_TDFXFB] Screen is %dx%d at %d bpp, in is %dx%d at %d bpp, norm is %dx%d.\n",
screenwidth, screenheight, screendepth * 8,
in_width, in_height, in_depth * 8,
d_width, d_height);
@@ -496,7 +496,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch(request) {
case VOCTRL_GET_IMAGE:
diff --git a/libvo/vo_tga.c b/libvo/vo_tga.c
index 0b338f994c..707455b4ea 100644
--- a/libvo/vo_tga.c
+++ b/libvo/vo_tga.c
@@ -254,13 +254,13 @@ static void check_events(void)
static int preinit(const char *arg)
{
if(arg) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TGA_UnknownSubdevice,arg);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TGA] Unknown subdevice: %s.\n",arg);
return ENOSYS;
}
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_DRAW_IMAGE:
diff --git a/libvo/vo_v4l2.c b/libvo/vo_v4l2.c
index 62808f8291..c0362aa83c 100644
--- a/libvo/vo_v4l2.c
+++ b/libvo/vo_v4l2.c
@@ -69,7 +69,7 @@ static const vo_info_t info =
const LIBVO_EXTERN (v4l2)
int
-v4l2_write (unsigned char *data, int len)
+v4l2_write (const unsigned char *data, int len)
{
if (v4l2_fd < 0)
return 0;
@@ -253,7 +253,7 @@ query_format (uint32_t format)
}
static int
-control (uint32_t request, void *data, ...)
+control (uint32_t request, void *data)
{
switch (request)
{
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index fffb1b010e..31bfba4eae 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -553,7 +553,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
if (IMGFMT_IS_VDPAU(image_format) && !create_vdp_decoder(2))
return -1;
- int_pause = 0;
visible_buf = 0;
#ifdef CONFIG_GUI
@@ -1163,7 +1162,7 @@ static int set_equalizer(char *name, int value) {
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GET_DEINTERLACE:
@@ -1213,24 +1212,13 @@ static int control(uint32_t request, void *data, ...)
resize();
return VO_TRUE;
case VOCTRL_SET_EQUALIZER: {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
-
- va_end(ap);
- return set_equalizer(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return set_equalizer(args->name, args->value);
}
- case VOCTRL_GET_EQUALIZER: {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
-
- va_end(ap);
- return get_equalizer(data, value);
+ case VOCTRL_GET_EQUALIZER:
+ {
+ struct voctrl_get_equalizer_args *args = data;
+ return get_equalizer(args->name, args->valueptr);
}
case VOCTRL_ONTOP:
vo_x11_ontop();
diff --git a/libvo/vo_vesa.c b/libvo/vo_vesa.c
index 5f58f5ddeb..1ab3cdd184 100644
--- a/libvo/vo_vesa.c
+++ b/libvo/vo_vesa.c
@@ -194,7 +194,7 @@ static inline void vbeSwitchBank(unsigned long offset)
show_err:
vesa_term();
PRINT_VBE_ERR("vbeSetWindow",err);
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_FatalErrorOccurred);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] Fatal error occurred! Can't continue.\n");
abort();
}
win.low = new_offset * gran;
@@ -396,7 +396,7 @@ static void flip_page(void)
{
vesa_term();
PRINT_VBE_ERR("vbeSetDisplayStart",err);
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_FatalErrorOccurred);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] Fatal error occurred! Can't continue.\n");
abort();
}
multi_idx = multi_idx ? 0 : 1;
@@ -462,7 +462,7 @@ static uint32_t parseSubDevice(const char *sd)
else
if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */
#endif
- else { mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_UnknownSubdevice, sd); return 0xFFFFFFFFUL; }
+ else { mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] unknown subdevice: '%s'.\n", sd); return 0xFFFFFFFFUL; }
return flags;
}
@@ -550,7 +550,7 @@ unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs )
total = min(total,nbuffs);
while(i < total) { multi_buff[i++] = offset; offset += screen_size; }
if(!i)
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_YouHaveTooLittleVideoMemory, screen_size, vsize);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] You have too little video memory for this mode:\n[VO_VESA] Required: %08lX present: %08lX.\n", screen_size, vsize);
return i;
}
@@ -569,7 +569,7 @@ static int set_refresh(unsigned x, unsigned y, unsigned mode,struct VesaCRTCInfo
monitor_dotclock = str2range(monitor_dotclock_str);
if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_YouHaveToSpecifyTheCapabilitiesOfTheMonitor);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] You have to specify the capabilities of the monitor. Not changing refresh rate.\n");
return 0;
}
@@ -606,7 +606,7 @@ static int set_refresh(unsigned x, unsigned y, unsigned mode,struct VesaCRTCInfo
if (!in_range(monitor_vfreq,crtc_pass->RefreshRate/100)||
!in_range(monitor_hfreq,H_freq*1000)) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_UnableToFitTheMode);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] The mode does not fit the monitor limits. Not changing refresh rate.\n");
return 0;
}
@@ -637,13 +637,13 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
fs_mode = 0;
if(subdev_flags == 0xFFFFFFFEUL)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_DetectedInternalFatalError);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] Detected internal fatal error: init is called before preinit.\n");
return -1;
}
if(subdev_flags == 0xFFFFFFFFUL) return -1;
if(flags & VOFLAG_FLIPPING)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_SwitchFlipIsNotSupported);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] The -flip option is not supported.\n");
}
if(flags & VOFLAG_SWSCALE) use_scaler = 1;
if(flags & VOFLAG_FULLSCREEN)
@@ -656,30 +656,32 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
if(!vib_set && (err=vbeGetControllerInfo(&vib)) != VBE_OK)
{
PRINT_VBE_ERR("vbeGetControllerInfo",err);
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_PossibleReasonNoVbe2BiosFound);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] Possible reason: No VBE2 BIOS found.\n");
return -1;
}
vib_set = 1;
/* Print general info here */
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_FoundVesaVbeBiosVersion,
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] Found VESA VBE BIOS Version %x.%x Revision: %x.\n",
(int)(vib.VESAVersion >> 8) & 0xff,
(int)(vib.VESAVersion & 0xff),
(int)(vib.OemSoftwareRev & 0xffff));
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_VideoMemory,vib.TotalMemory*64);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_Capabilites
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] Video memory: %u Kb.\n",vib.TotalMemory*64);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] VESA Capabilities: %s %s %s %s %s.\n"
,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC,"
,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC,"
,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC,"
,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic,"
,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo");
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_BelowWillBePrintedOemInfo);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_YouShouldSee5OemRelatedLines);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_OemInfo,vib.OemStringPtr);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_OemRevision,vib.OemSoftwareRev);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_OemVendor,vib.OemVendorNamePtr);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_OemProductName,vib.OemProductNamePtr);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_OemProductRev,vib.OemProductRevPtr);
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_Hint);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] !!! OEM info will be printed below !!!\n");
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] You should see 5 OEM related lines below; If not, you've broken vm86.\n");
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] OEM info: %s.\n",vib.OemStringPtr);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] OEM Revision: %x.\n",vib.OemSoftwareRev);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] OEM vendor: %s.\n",vib.OemVendorNamePtr);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] OEM Product Name: %s.\n",vib.OemProductNamePtr);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] OEM Product Rev: %s.\n",vib.OemProductRevPtr);
+ mp_tmsg(MSGT_VO,MSGL_INFO,
+ "[VO_VESA] Hint: For working TV-Out you should have plugged in the TV connector\n"\
+ "[VO_VESA] before booting since VESA BIOS initializes itself only during POST.\n");
/* Find best mode here */
num_modes = 0;
mode_ptr = vib.VideoModePtr;
@@ -795,7 +797,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
return -1;
}
dstBpp = video_mode_info.BitsPerPixel;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_UsingVesaMode
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] Using VESA mode (%u) = %x [%ux%u@%u]\n"
,best_mode_idx,video_mode,video_mode_info.XResolution
,video_mode_info.YResolution,dstBpp);
if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0;
@@ -830,7 +832,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
sws = sws_getContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc);
if(!sws)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_CantInitializeSwscaler);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] Can't initialize software scaler.\n");
return -1;
}
else if( mp_msg_test(MSGT_VO,MSGL_V) ) {
@@ -850,7 +852,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
vsize = vib.TotalMemory*64*1024;
lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize);
if(lfb == NULL)
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_CantUseDga);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] Can't use DGA. Force bank switching mode. :(\n");
else
{
video_base = win.ptr = lfb;
@@ -858,7 +860,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
win.high = vsize;
win.idx = -1; /* HAS_DGA() is on */
video_mode |= VESA_MODE_USE_LINEAR;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_UsingDga
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] Using DGA (physical resources: %08lXh, %08lXh)"
,video_mode_info.PhysBasePtr
,vsize);
if( mp_msg_test(MSGT_VO,MSGL_V) ) {
@@ -866,30 +868,30 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
printf("\n");
if(!(multi_size = fillMultiBuffer(vsize,2))) return -1;
if(vo_doublebuffering && multi_size < 2)
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_CantUseDoubleBuffering);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] Can't use double buffering: not enough video memory.\n");
}
}
if(win.idx == -2)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_CantFindNeitherDga);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] Can find neither DGA nor relocatable window frame.\n");
return -1;
}
if(!HAS_DGA())
{
if(subdev_flags & SUBDEV_FORCEDGA)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_YouveForcedDga);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] You've forced DGA. Exiting\n");
return -1;
}
if(!(win_seg = win.idx == 0 ? video_mode_info.WinASegment:video_mode_info.WinBSegment))
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_CantFindValidWindowAddress);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] Can't find valid window address.\n");
return -1;
}
win.ptr = PhysToVirtSO(win_seg,0);
win.low = 0L;
win.high= video_mode_info.WinSize*1024;
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_UsingBankSwitchingMode
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] Using bank switching mode (physical resources: %08lXh, %08lXh).\n"
,(unsigned long)win.ptr,(unsigned long)win.high);
}
if(video_mode_info.XResolution > dstW)
@@ -919,7 +921,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
{
if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp)))
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_CantAllocateTemporaryBuffer);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] Can't allocate temporary buffer.\n");
return -1;
}
if( mp_msg_test(MSGT_VO,MSGL_V) ) {
@@ -955,10 +957,10 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
if (neomagic_tvout) {
err = vbeSetTV(video_mode,neomagic_tvnorm);
if (err!=0x4f) {
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_VESA_SorryUnsupportedMode);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_VESA] Sorry, unsupported mode -- try -x 640 -zoom.\n");
}
else {
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_OhYouReallyHavePictureOnTv);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] Oh you really have a picture on the TV!\n");
}
}
/* Now we are in video mode!!!*/
@@ -972,11 +974,11 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
{
if(vlvo_init(width,height,x_offset,y_offset,dstW,dstH,format,dstBpp) != 0)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_CantInitialozeLinuxVideoOverlay);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] Can't initialize Linux Video Overlay.\n");
vesa_term();
return -1;
}
- else mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_UsingVideoOverlay,lvo_name);
+ else mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] Using video overlay: %s.\n",lvo_name);
lvo_opened = 1;
}
#ifdef CONFIG_VIDIX
@@ -987,11 +989,11 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
dstH,format,dstBpp,
video_mode_info.XResolution,video_mode_info.YResolution) != 0)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_CantInitializeVidixDriver);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] Can't initialize VIDIX driver.\n");
vesa_term();
return -1;
}
- else mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_UsingVidix);
+ else mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] Using VIDIX.\n");
vidix_start();
/* set colorkey */
@@ -1017,12 +1019,12 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
}
else
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_VESA_CantFindModeFor,width,height,bpp);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_VESA] Can't find mode for: %ux%u@%u.\n",width,height,bpp);
return -1;
}
if( mp_msg_test(MSGT_VO,MSGL_V) )
{
- mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_VESA_InitializationComplete);
+ mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_VESA] VESA initialization complete.\n");
fflush(stdout);
}
if(HAS_DGA() && vo_doublebuffering)
@@ -1087,7 +1089,8 @@ static int preinit(const char *arg)
if(arg) subdev_flags = parseSubDevice(arg);
if(lvo_name) pre_init_err = vlvo_preinit(lvo_name);
#ifdef CONFIG_VIDIX
- else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_vesa);
+ else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,
+ video_out_vesa.old_functions);
#endif
// check if we can open /dev/mem (it will be opened later in config(), but if we
// detect now that we can't we can exit cleanly)
@@ -1101,7 +1104,7 @@ static int preinit(const char *arg)
return pre_init_err;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -1109,33 +1112,8 @@ static int control(uint32_t request, void *data, ...)
}
#ifdef CONFIG_VIDIX
- if (vidix_name) {
- switch (request) {
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vidix_control(request, data, (int *)value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
- }
+ if (vidix_name)
return vidix_control(request, data);
- }
#endif
return VO_NOTIMPL;
diff --git a/libvo/vo_wii.c b/libvo/vo_wii.c
index 030b19dd05..8999852d80 100644
--- a/libvo/vo_wii.c
+++ b/libvo/vo_wii.c
@@ -351,7 +351,7 @@ static uint32_t get_image(mp_image_t *mpi)
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
if (request == VOCTRL_GET_IMAGE)
return get_image(data);
diff --git a/libvo/vo_winvidix.c b/libvo/vo_winvidix.c
index ad4c5e2dd8..3c3f0419d8 100644
--- a/libvo/vo_winvidix.c
+++ b/libvo/vo_winvidix.c
@@ -57,6 +57,7 @@ LIBVO_EXTERN(winvidix)
/* VIDIX related */
static char *vidix_name;
+static int depthonscreen;
/* Image parameters */
static uint32_t image_width;
static uint32_t image_height;
@@ -129,7 +130,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
/*update vidix*/
/* FIXME: implement runtime resize/move if possible, this way is very ugly! */
vidix_stop();
- if(vidix_init(image_width, image_height, vo_dx, vo_dy, vo_dwidth, vo_dheight, image_format, vo_depthonscreen, vo_screenwidth, vo_screenheight) != 0)
+ if(vidix_init(image_width, image_height, vo_dx, vo_dy, vo_dwidth, vo_dheight, image_format, depthonscreen, vo_screenwidth, vo_screenheight) != 0)
mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s\n", strerror(errno));
/*set colorkey*/
vidix_start();
@@ -203,7 +204,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,uint32_t d_h
image_format = format;
vo_screenwidth = GetSystemMetrics(SM_CXSCREEN);
vo_screenheight = GetSystemMetrics(SM_CYSCREEN);
- vo_depthonscreen = GetDeviceCaps(GetDC(GetDesktopWindow()),BITSPIXEL);
+ depthonscreen = GetDeviceCaps(GetDC(GetDesktopWindow()),BITSPIXEL);
aspect_save_orig(width, height);
@@ -336,13 +337,13 @@ static int preinit(const char *arg){
vidix_name = NULL;
}
- if (vidix_preinit(vidix_name, &video_out_winvidix) != 0)
+ if (vidix_preinit(vidix_name, video_out_winvidix.old_functions) != 0)
return 1;
return 0;
}
-static int control(uint32_t request, void *data, ...){
+static int control(uint32_t request, void *data){
switch (request) {
case VOCTRL_FULLSCREEN:
if(!vo_fs){vo_fs=1;ShowWindow(hWndFS,SW_SHOW);SetForegroundWindow(hWndFS);}
@@ -350,28 +351,6 @@ static int control(uint32_t request, void *data, ...){
break;
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vidix_control(request, data, (int *)value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
}
return vidix_control(request, data);
// return VO_NOTIMPL;
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c
index 1d5b2b55a0..c890a312e6 100644
--- a/libvo/vo_x11.c
+++ b/libvo/vo_x11.c
@@ -330,7 +330,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
old_vo_dwidth = -1;
old_vo_dheight = -1;
- int_pause = 0;
if (!title)
title = "MPlayer X11 (XImage/Shm) render";
@@ -665,7 +664,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
@@ -685,25 +684,13 @@ static int control(uint32_t request, void *data, ...)
return VO_TRUE;
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
-
- va_end(ap);
- return vo_x11_set_equalizer(data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return vo_x11_set_equalizer(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
-
- va_end(ap);
- return vo_x11_get_equalizer(data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return vo_x11_get_equalizer(args->name, args->valueptr);
}
case VOCTRL_ONTOP:
vo_x11_ontop();
diff --git a/libvo/vo_xover.c b/libvo/vo_xover.c
index 06815f15cd..ac8b3e85a7 100644
--- a/libvo/vo_xover.c
+++ b/libvo/vo_xover.c
@@ -82,8 +82,8 @@ static uint32_t window_width, window_height;
static uint32_t drwX, drwY, drwWidth, drwHeight, drwBorderWidth,
drwDepth, drwcX, drwcY, dwidth, dheight;
-static const vo_functions_t* sub_vo = NULL;
-
+static const struct vo_old_functions *sub_vo = NULL;
+static const struct vo_info_s *sub_info;
static void set_window(int force_update)
{
@@ -224,7 +224,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
mp_colorkey_t colork;
char _title[255];
- sprintf(_title,"MPlayer %s X11 Overlay",sub_vo->info->name);
+ sprintf(_title,"MPlayer %s X11 Overlay", sub_info->name);
title = _title;
panscan_init();
@@ -378,10 +378,10 @@ static void uninit(void)
sub_vo = NULL;
vo_x11_uninit();
// Restore our callbacks
- video_out_xover.draw_frame = draw_frame;
- video_out_xover.draw_slice = draw_slice;
- video_out_xover.flip_page = flip_page;
- video_out_xover.draw_osd = draw_osd;
+ video_out_xover.old_functions->draw_frame = draw_frame;
+ video_out_xover.old_functions->draw_slice = draw_slice;
+ video_out_xover.old_functions->flip_page = flip_page;
+ video_out_xover.old_functions->draw_osd = draw_osd;
}
static int preinit(const char *arg)
@@ -393,35 +393,38 @@ static int preinit(const char *arg)
return 1;
}
- for(i = 0 ; video_out_drivers[i] != NULL ; i++) {
- if(!strcmp(video_out_drivers[i]->info->short_name,arg) &&
- strcmp(video_out_drivers[i]->info->short_name,"xover"))
+ const struct vo_driver *candidate;
+ for(i = 0; (candidate = video_out_drivers[i]) != NULL; i++)
+ if (!candidate->is_new && !strcmp(candidate->info->short_name,arg) &&
+ strcmp(candidate->info->short_name,"xover"))
break;
- }
- if(!video_out_drivers[i]) {
+ if (!candidate) {
mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: Subdriver %s not found\n", arg);
return 1;
}
- if(video_out_drivers[i]->control(VOCTRL_XOVERLAY_SUPPORT,NULL) != VO_TRUE) {
+
+ const struct vo_old_functions *functions = candidate->old_functions;
+ if (functions->control(VOCTRL_XOVERLAY_SUPPORT,NULL) != VO_TRUE) {
mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: %s doesn't support XOverlay\n", arg);
return 1;
}
// X11 init
if (!vo_init()) return VO_FALSE;
- if(video_out_drivers[i]->preinit(NULL)) {
+ if(functions->preinit(NULL)) {
mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: Subvo init failed\n");
return 1;
}
- sub_vo = video_out_drivers[i];
+ sub_vo = functions;
+ sub_info = candidate->info;
// Setup the sub vo callbacks
- video_out_xover.draw_frame = sub_vo->draw_frame;
- video_out_xover.draw_slice = sub_vo->draw_slice;
- video_out_xover.flip_page = sub_vo->flip_page;
- video_out_xover.draw_osd = sub_vo->draw_osd;
+ video_out_xover.old_functions->draw_frame = sub_vo->draw_frame;
+ video_out_xover.old_functions->draw_slice = sub_vo->draw_slice;
+ video_out_xover.old_functions->flip_page = sub_vo->flip_page;
+ video_out_xover.old_functions->draw_osd = sub_vo->draw_osd;
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
if(!sub_vo) return VO_ERROR;
switch (request) {
@@ -443,7 +446,6 @@ static int control(uint32_t request, void *data, ...)
}
return VO_TRUE;
default:
- // Safe atm bcs nothing use more than 1 arg
return sub_vo->control(request,data);
}
return VO_NOTIMPL;
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index b7e0e74b81..18519ec666 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -37,13 +37,18 @@ Buffer allocation:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
+#include <stdbool.h>
#include "config.h"
+#include "options.h"
+#include "talloc.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "video_out.h"
-#include "video_out_internal.h"
-
+#include "libmpcodecs/vfcap.h"
+#include "libmpcodecs/mp_image.h"
+#include "osd.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -58,6 +63,7 @@ Buffer allocation:
#include "subopt-helper.h"
#include "input/input.h"
+#include "mp_fifo.h"
#ifdef CONFIG_GUI
#include "gui/interface.h"
@@ -72,153 +78,166 @@ static const vo_info_t info = {
""
};
-const LIBVO_EXTERN(xv)
#ifdef HAVE_SHM
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
-
-static XShmSegmentInfo Shminfo[NUM_BUFFERS];
-static int Shmem_Flag;
#endif
// Note: depends on the inclusion of X11/extensions/XShm.h
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvlib.h>
-// FIXME: dynamically allocate this stuff
-static void allocate_xvimage(int);
-static unsigned int ver, rel, req, ev, err;
-static unsigned int formats, adaptors, xv_format;
-static XvAdaptorInfo *ai = NULL;
-static XvImageFormatValues *fo=NULL;
-
-static int current_buf = 0;
-static int current_ip_buf = 0;
-static int num_buffers = 1; // default
-static int visible_buf = -1; // -1 means: no buffer was drawn yet
-static XvImage *xvimage[NUM_BUFFERS];
-
-
-static uint32_t image_width;
-static uint32_t image_height;
-static uint32_t image_format;
-
-static int int_pause;
+struct xvctx {
+ XvAdaptorInfo *ai;
+ XvImageFormatValues *fo;
+ unsigned int formats, adaptors, xv_format;
+ int current_buf;
+ int current_ip_buf;
+ int num_buffers;
+ int total_buffers;
+ int have_visible_image_copy;
+ int have_next_image_copy;
+ int unchanged_visible_image;
+ int unchanged_next_image;
+ int visible_buf;
+ XvImage *xvimage[NUM_BUFFERS + 1];
+ uint32_t image_width;
+ uint32_t image_height;
+ uint32_t image_format;
+ int is_paused;
+ struct vo_rect src_rect;
+ struct vo_rect dst_rect;
+ uint32_t max_width, max_height; // zero means: not set
+ int event_fd_registered; // for uninit called from preinit
+ int mode_switched;
+ int osd_objects_drawn;
+ void (*draw_alpha_fnc)(void *ctx, int x0, int y0, int w, int h,
+ unsigned char *src, unsigned char *srca,
+ int stride);
+#ifdef HAVE_SHM
+ XShmSegmentInfo Shminfo[NUM_BUFFERS + 1];
+ int Shmem_Flag;
+#endif
+};
-static struct vo_rect src_rect;
-static struct vo_rect dst_rect;
-static uint32_t max_width = 0, max_height = 0; // zero means: not set
+static void allocate_xvimage(struct vo *, int);
-static void (*draw_alpha_fnc) (int x0, int y0, int w, int h,
- unsigned char *src, unsigned char *srca,
- int stride);
-static void draw_alpha_yv12(int x0, int y0, int w, int h,
+static void draw_alpha_yv12(void *p, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ struct vo *vo = p;
+ struct xvctx *ctx = vo->priv;
+ x0 += ctx->image_width * (vo->panscan_x >> 1)
+ / (vo->dwidth + vo->panscan_x);
vo_draw_alpha_yv12(w, h, src, srca, stride,
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y0 + x0,
- xvimage[current_buf]->pitches[0]);
+ ctx->xvimage[ctx->current_buf]->data +
+ ctx->xvimage[ctx->current_buf]->offsets[0] +
+ ctx->xvimage[ctx->current_buf]->pitches[0] * y0 + x0,
+ ctx->xvimage[ctx->current_buf]->pitches[0]);
+ ctx->osd_objects_drawn++;
}
-static void draw_alpha_yuy2(int x0, int y0, int w, int h,
+static void draw_alpha_yuy2(void *p, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ struct vo *vo = p;
+ struct xvctx *ctx = vo->priv;
+ x0 += ctx->image_width * (vo->panscan_x >> 1)
+ / (vo->dwidth + vo->panscan_x);
vo_draw_alpha_yuy2(w, h, src, srca, stride,
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y0 + 2 * x0,
- xvimage[current_buf]->pitches[0]);
+ ctx->xvimage[ctx->current_buf]->data +
+ ctx->xvimage[ctx->current_buf]->offsets[0] +
+ ctx->xvimage[ctx->current_buf]->pitches[0] * y0 + 2 * x0,
+ ctx->xvimage[ctx->current_buf]->pitches[0]);
+ ctx->osd_objects_drawn++;
}
-static void draw_alpha_uyvy(int x0, int y0, int w, int h,
+static void draw_alpha_uyvy(void *p, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ struct vo *vo = p;
+ struct xvctx *ctx = vo->priv;
+ x0 += ctx->image_width * (vo->panscan_x >> 1)
+ / (vo->dwidth + vo->panscan_x);
vo_draw_alpha_yuy2(w, h, src, srca, stride,
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y0 + 2 * x0 + 1,
- xvimage[current_buf]->pitches[0]);
+ ctx->xvimage[ctx->current_buf]->data +
+ ctx->xvimage[ctx->current_buf]->offsets[0] +
+ ctx->xvimage[ctx->current_buf]->pitches[0] * y0 + 2 * x0 + 1,
+ ctx->xvimage[ctx->current_buf]->pitches[0]);
+ ctx->osd_objects_drawn++;
}
-static void draw_alpha_null(int x0, int y0, int w, int h,
+static void draw_alpha_null(void *p, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
}
-static void deallocate_xvimage(int foo);
+static void deallocate_xvimage(struct vo *vo, int foo);
-static void resize(void)
+static void resize(struct vo *vo)
{
- calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL, NULL);
- vo_x11_clearwindow_part(mDisplay, vo_window, dst_rect.width, dst_rect.height, 1);
- vo_xv_draw_colorkey(dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height);
+ struct xvctx *ctx = vo->priv;
+
+ calc_src_dst_rects(vo, ctx->image_width, ctx->image_height, &ctx->src_rect,
+ &ctx->dst_rect, NULL, NULL);
+ struct vo_rect *dst = &ctx->dst_rect;
+ vo_x11_clearwindow_part(vo, vo->x11->window, dst->width, dst->height, 1);
+ vo_xv_draw_colorkey(vo, dst->left, dst->top, dst->width, dst->height);
}
/*
* connect to server, create and map window,
* allocate colors and (shared) memory
*/
-static int config(uint32_t width, uint32_t height, uint32_t d_width,
- uint32_t d_height, uint32_t flags, char *title,
- uint32_t format)
+static int config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height, uint32_t flags,
+ char *title, uint32_t format)
{
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
XVisualInfo vinfo;
XSetWindowAttributes xswa;
XWindowAttributes attribs;
unsigned long xswamask;
int depth;
+ struct xvctx *ctx = vo->priv;
+ int i;
-#ifdef CONFIG_XF86VM
- int vm = flags & VOFLAG_MODESWITCHING;
-#endif
-
- image_height = height;
- image_width = width;
- image_format = format;
+ ctx->image_height = height;
+ ctx->image_width = width;
+ ctx->image_format = format;
- if ((max_width != 0 && max_height != 0) &&
- (image_width > max_width || image_height > max_height))
- {
- mp_msg( MSGT_VO, MSGL_ERR, MSGTR_VO_XV_ImagedimTooHigh,
- image_width, image_height, max_width, max_height);
+ if ((ctx->max_width != 0 && ctx->max_height != 0)
+ && (ctx->image_width > ctx->max_width
+ || ctx->image_height > ctx->max_height)) {
+ mp_tmsg(MSGT_VO, MSGL_ERR, "Source image dimensions are too high: %ux%u (maximum is %ux%u)\n",
+ ctx->image_width, ctx->image_height, ctx->max_width,
+ ctx->max_height);
return -1;
}
- int_pause = 0;
- visible_buf = -1;
-
- num_buffers =
- vo_doublebuffering ? (vo_directrendering ? NUM_BUFFERS : 2) : 1;
+ ctx->visible_buf = -1;
+ ctx->have_visible_image_copy = false;
+ ctx->have_next_image_copy = false;
/* check image formats */
- {
- unsigned int i;
-
- xv_format = 0;
- for (i = 0; i < formats; i++)
- {
- mp_msg(MSGT_VO, MSGL_V,
- "Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,
- (char *) &fo[i].id,
- (fo[i].format == XvPacked) ? "packed" : "planar");
- if (fo[i].id == format)
- xv_format = fo[i].id;
- }
- if (!xv_format)
- return -1;
+ ctx->xv_format = 0;
+ for (i = 0; i < ctx->formats; i++) {
+ mp_msg(MSGT_VO, MSGL_V, "Xvideo image format: 0x%x (%4.4s) %s\n",
+ ctx->fo[i].id, (char *) &ctx->fo[i].id,
+ (ctx->fo[i].format == XvPacked) ? "packed" : "planar");
+ if (ctx->fo[i].id == format)
+ ctx->xv_format = ctx->fo[i].id;
}
+ if (!ctx->xv_format)
+ return -1;
#ifdef CONFIG_GUI
if (use_gui)
@@ -227,578 +246,627 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
#endif
{
#ifdef CONFIG_XF86VM
- if (vm)
- {
- vo_vm_switch();
+ int vm = flags & VOFLAG_MODESWITCHING;
+ if (vm) {
+ vo_vm_switch(vo);
+ ctx->mode_switched = 1;
}
#endif
- XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay),
+ XGetWindowAttributes(x11->display, DefaultRootWindow(x11->display),
&attribs);
depth = attribs.depth;
if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
depth = 24;
- XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo);
+ XMatchVisualInfo(x11->display, x11->screen, depth, TrueColor, &vinfo);
xswa.background_pixel = 0;
- if (xv_ck_info.method == CK_METHOD_BACKGROUND)
- {
- xswa.background_pixel = xv_colorkey;
- }
+ if (x11->xv_ck_info.method == CK_METHOD_BACKGROUND)
+ xswa.background_pixel = x11->xv_colorkey;
xswa.border_pixel = 0;
xswamask = CWBackPixel | CWBorderPixel;
- vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, vo_dwidth, vo_dheight,
- flags, CopyFromParent, "xv", title);
- XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
+ vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, vo->dwidth,
+ vo->dheight, flags, CopyFromParent, "xv",
+ title);
+ XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa);
#ifdef CONFIG_XF86VM
- if (vm)
- {
+ if (vm) {
/* Grab the mouse pointer in our window */
if (vo_grabpointer)
- XGrabPointer(mDisplay, vo_window, True, 0,
- GrabModeAsync, GrabModeAsync,
- vo_window, None, CurrentTime);
- XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime);
+ XGrabPointer(x11->display, x11->window, True, 0, GrabModeAsync,
+ GrabModeAsync, x11->window, None, CurrentTime);
+ XSetInputFocus(x11->display, x11->window, RevertToNone,
+ CurrentTime);
}
#endif
}
mp_msg(MSGT_VO, MSGL_V, "using Xvideo port %d for hw scaling\n",
- xv_port);
-
- switch (xv_format)
- {
- case IMGFMT_YV12:
- case IMGFMT_I420:
- case IMGFMT_IYUV:
- draw_alpha_fnc = draw_alpha_yv12;
- break;
- case IMGFMT_YUY2:
- case IMGFMT_YVYU:
- draw_alpha_fnc = draw_alpha_yuy2;
- break;
- case IMGFMT_UYVY:
- draw_alpha_fnc = draw_alpha_uyvy;
- break;
- default:
- draw_alpha_fnc = draw_alpha_null;
+ x11->xv_port);
+
+ switch (ctx->xv_format) {
+ case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ ctx->draw_alpha_fnc = draw_alpha_yv12;
+ break;
+ case IMGFMT_YUY2:
+ case IMGFMT_YVYU:
+ ctx->draw_alpha_fnc = draw_alpha_yuy2;
+ break;
+ case IMGFMT_UYVY:
+ ctx->draw_alpha_fnc = draw_alpha_uyvy;
+ break;
+ default:
+ ctx->draw_alpha_fnc = draw_alpha_null;
}
- if (vo_config_count)
- for (current_buf = 0; current_buf < num_buffers; ++current_buf)
- deallocate_xvimage(current_buf);
+ // In case config has been called before
+ for (i = 0; i < ctx->total_buffers; i++)
+ deallocate_xvimage(vo, i);
- for (current_buf = 0; current_buf < num_buffers; ++current_buf)
- allocate_xvimage(current_buf);
+ ctx->num_buffers =
+ vo_doublebuffering ? (vo_directrendering ? NUM_BUFFERS : 2) : 1;
+ ctx->total_buffers = ctx->num_buffers + 1;
+
+ for (i = 0; i < ctx->total_buffers; i++)
+ allocate_xvimage(vo, i);
- current_buf = 0;
- current_ip_buf = 0;
+ ctx->current_buf = 0;
+ ctx->current_ip_buf = 0;
- resize();
+
+ resize(vo);
return 0;
}
-static void allocate_xvimage(int foo)
+static void allocate_xvimage(struct vo *vo, int foo)
{
+ struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
/*
* allocate XvImages. FIXME: no error checking, without
* mit-shm this will bomb... trzing to fix ::atmos
*/
#ifdef HAVE_SHM
- if (mLocalDisplay && XShmQueryExtension(mDisplay))
- Shmem_Flag = 1;
- else
- {
- Shmem_Flag = 0;
- mp_msg(MSGT_VO, MSGL_INFO,
- MSGTR_LIBVO_XV_SharedMemoryNotSupported);
+ if (x11->display_is_local && XShmQueryExtension(x11->display))
+ ctx->Shmem_Flag = 1;
+ else {
+ ctx->Shmem_Flag = 0;
+ mp_tmsg(MSGT_VO, MSGL_INFO, "[VO_XV] Shared memory not supported\nReverting to normal Xv.\n");
}
- if (Shmem_Flag)
- {
- xvimage[foo] =
- (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format,
- NULL, image_width, image_height,
- &Shminfo[foo]);
-
- Shminfo[foo].shmid =
- shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
- Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0);
- Shminfo[foo].readOnly = False;
-
- xvimage[foo]->data = Shminfo[foo].shmaddr;
- XShmAttach(mDisplay, &Shminfo[foo]);
- XSync(mDisplay, False);
- shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
+ if (ctx->Shmem_Flag) {
+ ctx->xvimage[foo] =
+ (XvImage *) XvShmCreateImage(x11->display, x11->xv_port,
+ ctx->xv_format, NULL,
+ ctx->image_width, ctx->image_height,
+ &ctx->Shminfo[foo]);
+
+ ctx->Shminfo[foo].shmid = shmget(IPC_PRIVATE,
+ ctx->xvimage[foo]->data_size,
+ IPC_CREAT | 0777);
+ ctx->Shminfo[foo].shmaddr = (char *) shmat(ctx->Shminfo[foo].shmid, 0,
+ 0);
+ ctx->Shminfo[foo].readOnly = False;
+
+ ctx->xvimage[foo]->data = ctx->Shminfo[foo].shmaddr;
+ XShmAttach(x11->display, &ctx->Shminfo[foo]);
+ XSync(x11->display, False);
+ shmctl(ctx->Shminfo[foo].shmid, IPC_RMID, 0);
} else
#endif
{
- xvimage[foo] =
- (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL,
- image_width, image_height);
- xvimage[foo]->data = malloc(xvimage[foo]->data_size);
- XSync(mDisplay, False);
+ ctx->xvimage[foo] =
+ (XvImage *) XvCreateImage(x11->display, x11->xv_port,
+ ctx->xv_format, NULL, ctx->image_width,
+ ctx->image_height);
+ ctx->xvimage[foo]->data = malloc(ctx->xvimage[foo]->data_size);
+ XSync(x11->display, False);
}
- memset(xvimage[foo]->data, 128, xvimage[foo]->data_size);
+ memset(ctx->xvimage[foo]->data, 128, ctx->xvimage[foo]->data_size);
return;
}
-static void deallocate_xvimage(int foo)
+static void deallocate_xvimage(struct vo *vo, int foo)
{
+ struct xvctx *ctx = vo->priv;
#ifdef HAVE_SHM
- if (Shmem_Flag)
- {
- XShmDetach(mDisplay, &Shminfo[foo]);
- shmdt(Shminfo[foo].shmaddr);
+ if (ctx->Shmem_Flag) {
+ XShmDetach(vo->x11->display, &ctx->Shminfo[foo]);
+ shmdt(ctx->Shminfo[foo].shmaddr);
} else
#endif
{
- free(xvimage[foo]->data);
+ free(ctx->xvimage[foo]->data);
}
- XFree(xvimage[foo]);
+ XFree(ctx->xvimage[foo]);
- XSync(mDisplay, False);
+ XSync(vo->x11->display, False);
return;
}
-static inline void put_xvimage( XvImage * xvi )
+static inline void put_xvimage(struct vo *vo, XvImage *xvi)
{
+ struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
+ struct vo_rect *src = &ctx->src_rect;
+ struct vo_rect *dst = &ctx->dst_rect;
#ifdef HAVE_SHM
- if (Shmem_Flag)
- {
- XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc,
- xvi,
- src_rect.left, src_rect.top, src_rect.width, src_rect.height,
- dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height,
+ if (ctx->Shmem_Flag) {
+ XvShmPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, xvi,
+ src->left, src->top, src->width, src->height,
+ dst->left, dst->top, dst->width, dst->height,
False);
} else
#endif
{
- XvPutImage(mDisplay, xv_port, vo_window, vo_gc,
- xvi,
- src_rect.left, src_rect.top, src_rect.width, src_rect.height,
- dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height);
+ XvPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, xvi,
+ src->left, src->top, src->width, src->height,
+ dst->left, dst->top, dst->width, dst->height);
}
}
-static void check_events(void)
+// Only copies luma for planar formats as draw_alpha doesn't change others */
+void copy_backup_image(struct vo *vo, int dest, int src)
{
- int e = vo_x11_check_events(mDisplay);
+ struct xvctx *ctx = vo->priv;
+
+ XvImage *vb = ctx->xvimage[dest];
+ XvImage *cp = ctx->xvimage[src];
+ memcpy_pic(vb->data + vb->offsets[0], cp->data + cp->offsets[0],
+ vb->width, vb->height,
+ vb->pitches[0], cp->pitches[0]);
+}
+
+static void check_events(struct vo *vo)
+{
+ struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
+ int e = vo_x11_check_events(vo);
if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE)
- {
- resize();
- }
+ resize(vo);
- if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause)
- {
+ if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && ctx->is_paused) {
/* did we already draw a buffer */
- if ( visible_buf != -1 )
- {
- /* redraw the last visible buffer */
- put_xvimage( xvimage[visible_buf] );
+ if (ctx->visible_buf != -1) {
+ /* redraw the last visible buffer */
+ put_xvimage(vo, ctx->xvimage[ctx->visible_buf]);
}
}
}
-static void draw_osd(void)
+static void draw_osd(struct vo *vo, struct osd_state *osd)
{
- vo_draw_text(image_width -
- image_width * vo_panscan_x / (vo_dwidth + vo_panscan_x),
- image_height, draw_alpha_fnc);
+ struct xvctx *ctx = vo->priv;
+
+ ctx->osd_objects_drawn = 0;
+ osd_draw_text(osd,
+ ctx->image_width -
+ ctx->image_width * vo->panscan_x / (vo->dwidth +
+ vo->panscan_x),
+ ctx->image_height, ctx->draw_alpha_fnc, vo);
+ if (ctx->osd_objects_drawn)
+ ctx->unchanged_next_image = false;
+}
+
+static int redraw_osd(struct vo *vo, struct osd_state *osd)
+{
+ struct xvctx *ctx = vo->priv;
+
+ if (ctx->have_visible_image_copy)
+ copy_backup_image(vo, ctx->visible_buf, ctx->num_buffers);
+ else if (ctx->unchanged_visible_image) {
+ copy_backup_image(vo, ctx->num_buffers, ctx->visible_buf);
+ ctx->have_visible_image_copy = true;
+ }
+ else
+ return false;
+ int temp = ctx->current_buf;
+ ctx->current_buf = ctx->visible_buf;
+ draw_osd(vo, osd);
+ ctx->current_buf = temp;
+ put_xvimage(vo, ctx->xvimage[ctx->visible_buf]);
+ return true;
}
-static void flip_page(void)
+static void flip_page(struct vo *vo)
{
- put_xvimage( xvimage[current_buf] );
+ struct xvctx *ctx = vo->priv;
+ put_xvimage(vo, ctx->xvimage[ctx->current_buf]);
/* remember the currently visible buffer */
- visible_buf = current_buf;
+ ctx->visible_buf = ctx->current_buf;
- if (num_buffers > 1)
- {
- current_buf =
- vo_directrendering ? 0 : ((current_buf + 1) % num_buffers);
- XFlush(mDisplay);
+ ctx->have_visible_image_copy = ctx->have_next_image_copy;
+ ctx->have_next_image_copy = false;
+ ctx->unchanged_visible_image = ctx->unchanged_next_image;
+ ctx->unchanged_next_image = false;
+
+ if (ctx->num_buffers > 1) {
+ ctx->current_buf = vo_directrendering ? 0 : ((ctx->current_buf + 1) %
+ ctx->num_buffers);
+ XFlush(vo->x11->display);
} else
- XSync(mDisplay, False);
+ XSync(vo->x11->display, False);
return;
}
-static int draw_slice(uint8_t * image[], int stride[], int w, int h,
- int x, int y)
+static int draw_slice(struct vo *vo, uint8_t *image[], int stride[], int w,
+ int h, int x, int y)
{
+ struct xvctx *ctx = vo->priv;
uint8_t *dst;
+ XvImage *current_image = ctx->xvimage[ctx->current_buf];
- dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[0] +
- xvimage[current_buf]->pitches[0] * y + x;
- memcpy_pic(dst, image[0], w, h, xvimage[current_buf]->pitches[0],
- stride[0]);
+ dst = current_image->data + current_image->offsets[0]
+ + current_image->pitches[0] * y + x;
+ memcpy_pic(dst, image[0], w, h, current_image->pitches[0], stride[0]);
x /= 2;
y /= 2;
w /= 2;
h /= 2;
- dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] +
- xvimage[current_buf]->pitches[1] * y + x;
- if (image_format != IMGFMT_YV12)
- memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
- stride[1]);
+ dst = current_image->data + current_image->offsets[1]
+ + current_image->pitches[1] * y + x;
+ if (ctx->image_format != IMGFMT_YV12)
+ memcpy_pic(dst, image[1], w, h, current_image->pitches[1], stride[1]);
else
- memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
- stride[2]);
-
- dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] +
- xvimage[current_buf]->pitches[2] * y + x;
- if (image_format == IMGFMT_YV12)
- memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
- stride[1]);
+ memcpy_pic(dst, image[2], w, h, current_image->pitches[1], stride[2]);
+
+ dst = current_image->data + current_image->offsets[2]
+ + current_image->pitches[2] * y + x;
+ if (ctx->image_format == IMGFMT_YV12)
+ memcpy_pic(dst, image[1], w, h, current_image->pitches[1], stride[1]);
else
- memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
- stride[2]);
+ memcpy_pic(dst, image[2], w, h, current_image->pitches[1], stride[2]);
return 0;
}
-static int draw_frame(uint8_t * src[])
+static int draw_frame(struct vo *vo, uint8_t *src[])
{
return VO_ERROR;
}
-static uint32_t draw_image(mp_image_t * mpi)
+static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
{
+ struct xvctx *ctx = vo->priv;
+
+ ctx->have_next_image_copy = false;
+
if (mpi->flags & MP_IMGFLAG_DIRECT)
- {
// direct rendering:
- current_buf = (int) (mpi->priv); // hack!
- return VO_TRUE;
- }
- if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
- return VO_TRUE; // done
- if (mpi->flags & MP_IMGFLAG_PLANAR)
- {
- draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
- return VO_TRUE;
- }
- if (mpi->flags & MP_IMGFLAG_YUV)
- {
+ ctx->current_buf = (int) (mpi->priv); // hack!
+ else if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
+ ; // done
+ else if (mpi->flags & MP_IMGFLAG_PLANAR)
+ draw_slice(vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
+ else if (mpi->flags & MP_IMGFLAG_YUV)
// packed YUV:
- memcpy_pic(xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[0], mpi->planes[0],
+ memcpy_pic(ctx->xvimage[ctx->current_buf]->data +
+ ctx->xvimage[ctx->current_buf]->offsets[0], mpi->planes[0],
mpi->w * (mpi->bpp / 8), mpi->h,
- xvimage[current_buf]->pitches[0], mpi->stride[0]);
- return VO_TRUE;
+ ctx->xvimage[ctx->current_buf]->pitches[0], mpi->stride[0]);
+ else
+ return false;
+
+ if (ctx->is_paused) {
+ copy_backup_image(vo, ctx->num_buffers, ctx->current_buf);
+ ctx->have_next_image_copy = true;
}
- return VO_FALSE; // not (yet) supported
+ ctx->unchanged_next_image = true;
+ return true;
}
-static uint32_t get_image(mp_image_t * mpi)
+static uint32_t get_image(struct xvctx *ctx, mp_image_t *mpi)
{
- int buf = current_buf; // we shouldn't change current_buf unless we do DR!
+ // we shouldn't change current_buf unless we do DR!
+ int buf = ctx->current_buf;
- if (mpi->type == MP_IMGTYPE_STATIC && num_buffers > 1)
+ if (mpi->type == MP_IMGTYPE_STATIC && ctx->num_buffers > 1)
return VO_FALSE; // it is not static
- if (mpi->imgfmt != image_format)
+ if (mpi->imgfmt != ctx->image_format)
return VO_FALSE; // needs conversion :(
-// if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
- if (mpi->flags & MP_IMGFLAG_READABLE &&
- (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP))
- {
+ if (mpi->flags & MP_IMGFLAG_READABLE
+ && (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP)) {
// reference (I/P) frame of IP or IPB:
- if (num_buffers < 2)
+ if (ctx->num_buffers < 2)
return VO_FALSE; // not enough
- current_ip_buf ^= 1;
+ ctx->current_ip_buf ^= 1;
// for IPB with 2 buffers we can DR only one of the 2 P frames:
- if (mpi->type == MP_IMGTYPE_IPB && num_buffers < 3
- && current_ip_buf)
+ if (mpi->type == MP_IMGTYPE_IPB && ctx->num_buffers < 3
+ && ctx->current_ip_buf)
return VO_FALSE;
- buf = current_ip_buf;
+ buf = ctx->current_ip_buf;
if (mpi->type == MP_IMGTYPE_IPB)
++buf; // preserve space for B
}
- if (mpi->height > xvimage[buf]->height)
+ if (mpi->height > ctx->xvimage[buf]->height)
return VO_FALSE; //buffer to small
- if (mpi->width * (mpi->bpp / 8) > xvimage[buf]->pitches[0])
+ if (mpi->width * (mpi->bpp / 8) > ctx->xvimage[buf]->pitches[0])
return VO_FALSE; //buffer to small
if ((mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH))
- || (mpi->width * (mpi->bpp / 8) == xvimage[buf]->pitches[0]))
- {
- current_buf = buf;
- mpi->planes[0] =
- xvimage[current_buf]->data + xvimage[current_buf]->offsets[0];
- mpi->stride[0] = xvimage[current_buf]->pitches[0];
+ || (mpi->width * (mpi->bpp / 8) == ctx->xvimage[buf]->pitches[0])) {
+ ctx->current_buf = buf;
+ XvImage *current_image = ctx->xvimage[ctx->current_buf];
+ mpi->planes[0] = current_image->data + current_image->offsets[0];
+ mpi->stride[0] = current_image->pitches[0];
mpi->width = mpi->stride[0] / (mpi->bpp / 8);
- if (mpi->flags & MP_IMGFLAG_PLANAR)
- {
- if (mpi->flags & MP_IMGFLAG_SWAPPED)
- {
+ if (mpi->flags & MP_IMGFLAG_PLANAR) {
+ if (mpi->flags & MP_IMGFLAG_SWAPPED) {
// I420
- mpi->planes[1] =
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[1];
- mpi->planes[2] =
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[2];
- mpi->stride[1] = xvimage[current_buf]->pitches[1];
- mpi->stride[2] = xvimage[current_buf]->pitches[2];
- } else
- {
+ mpi->planes[1] = current_image->data
+ + current_image->offsets[1];
+ mpi->planes[2] = current_image->data
+ + current_image->offsets[2];
+ mpi->stride[1] = current_image->pitches[1];
+ mpi->stride[2] = current_image->pitches[2];
+ } else {
// YV12
- mpi->planes[1] =
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[2];
- mpi->planes[2] =
- xvimage[current_buf]->data +
- xvimage[current_buf]->offsets[1];
- mpi->stride[1] = xvimage[current_buf]->pitches[2];
- mpi->stride[2] = xvimage[current_buf]->pitches[1];
+ mpi->planes[1] = current_image->data
+ + current_image->offsets[2];
+ mpi->planes[2] = current_image->data
+ + current_image->offsets[1];
+ mpi->stride[1] = current_image->pitches[2];
+ mpi->stride[2] = current_image->pitches[1];
}
}
mpi->flags |= MP_IMGFLAG_DIRECT;
- mpi->priv = (void *) current_buf;
-// printf("mga: get_image() SUCCESS -> Direct Rendering ENABLED\n");
+ mpi->priv = (void *) ctx->current_buf;
return VO_TRUE;
}
return VO_FALSE;
}
-static int query_format(uint32_t format)
+static int query_format(struct xvctx *ctx, uint32_t format)
{
uint32_t i;
int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN
/* check image formats */
- for (i = 0; i < formats; i++)
- {
- if (fo[i].id == format)
+ for (i = 0; i < ctx->formats; i++) {
+ if (ctx->fo[i].id == format)
return flag; //xv_format = fo[i].id;
}
return 0;
}
-static void uninit(void)
+static void uninit(struct vo *vo)
{
+ struct xvctx *ctx = vo->priv;
int i;
- if (!vo_config_count)
- return;
- visible_buf = -1;
- XvFreeAdaptorInfo(ai);
- ai = NULL;
- if(fo){
- XFree(fo);
- fo=NULL;
+ ctx->visible_buf = -1;
+ if (ctx->ai)
+ XvFreeAdaptorInfo(ctx->ai);
+ ctx->ai = NULL;
+ if (ctx->fo) {
+ XFree(ctx->fo);
+ ctx->fo = NULL;
}
- for (i = 0; i < num_buffers; i++)
- deallocate_xvimage(i);
+ for (i = 0; i < ctx->total_buffers; i++)
+ deallocate_xvimage(vo, i);
#ifdef CONFIG_XF86VM
- vo_vm_close();
+ if (ctx->mode_switched)
+ vo_vm_close(vo);
#endif
- mp_input_rm_event_fd(ConnectionNumber(mDisplay));
- vo_x11_uninit();
+ if (ctx->event_fd_registered)
+ mp_input_rm_key_fd(vo->input_ctx, ConnectionNumber(vo->x11->display));
+ // uninit() shouldn't get called unless initialization went past vo_init()
+ vo_x11_uninit(vo);
+}
+
+static int x11_fd_callback(void *ctx, int fd)
+{
+ struct vo *vo = ctx;
+ check_events(vo);
+ return mplayer_get_key(vo->key_fifo, 0);
}
-static int preinit(const char *arg)
+static int preinit(struct vo *vo, const char *arg)
{
XvPortID xv_p;
int busy_ports = 0;
unsigned int i;
strarg_t ck_src_arg = { 0, NULL };
strarg_t ck_method_arg = { 0, NULL };
+ struct xvctx *ctx = talloc_zero(vo, struct xvctx);
+ vo->priv = ctx;
+ struct vo_x11_state *x11 = vo->x11;
int xv_adaptor = -1;
- const opt_t subopts[] =
- {
- /* name arg type arg var test */
- { "port", OPT_ARG_INT, &xv_port, (opt_test_f)int_pos },
- { "adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f)int_non_neg },
- { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck },
- { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm },
- { NULL }
+ const opt_t subopts[] = {
+ /* name arg type arg var test */
+ {"port", OPT_ARG_INT, &x11->xv_port, (opt_test_f) int_pos},
+ {"adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f) int_non_neg},
+ {"ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck},
+ {"ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm},
+ {NULL}
};
- xv_port = 0;
+ x11->xv_port = 0;
/* parse suboptions */
- if ( subopt_parse( arg, subopts ) != 0 )
- {
- return -1;
+ if (subopt_parse(arg, subopts) != 0) {
+ return -1;
}
/* modify colorkey settings according to the given options */
- xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str );
+ xv_setup_colorkeyhandling(vo, ck_method_arg.str, ck_src_arg.str);
- if (!vo_init())
+ if (!vo_init(vo))
return -1;
/* check for Xvideo extension */
- if (Success != XvQueryExtension(mDisplay, &ver, &rel, &req, &ev, &err))
- {
- mp_msg(MSGT_VO, MSGL_ERR,
- MSGTR_LIBVO_XV_XvNotSupportedByX11);
- return -1;
+ unsigned int ver, rel, req, ev, err;
+ if (Success != XvQueryExtension(x11->display, &ver, &rel, &req, &ev, &err)) {
+ mp_tmsg(MSGT_VO, MSGL_ERR, "[VO_XV] Sorry, Xv not supported by this X11 version/driver\n[VO_XV] ******** Try with -vo x11 or -vo sdl *********\n");
+ goto error;
}
/* check for Xvideo support */
if (Success !=
- XvQueryAdaptors(mDisplay, DefaultRootWindow(mDisplay), &adaptors,
- &ai))
- {
- mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_XV_XvQueryAdaptorsFailed);
- return -1;
+ XvQueryAdaptors(x11->display, DefaultRootWindow(x11->display),
+ &ctx->adaptors, &ctx->ai)) {
+ mp_tmsg(MSGT_VO, MSGL_ERR, "[VO_XV] XvQueryAdaptors failed.\n");
+ goto error;
}
/* check adaptors */
- if (xv_port)
- {
+ if (x11->xv_port) {
int port_found;
- for (port_found = 0, i = 0; !port_found && i < adaptors; i++)
- {
- if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask))
- {
- for (xv_p = ai[i].base_id;
- xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p)
- {
- if (xv_p == xv_port)
- {
+ for (port_found = 0, i = 0; !port_found && i < ctx->adaptors; i++) {
+ if ((ctx->ai[i].type & XvInputMask)
+ && (ctx->ai[i].type & XvImageMask)) {
+ for (xv_p = ctx->ai[i].base_id;
+ xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports;
+ ++xv_p) {
+ if (xv_p == x11->xv_port) {
port_found = 1;
break;
}
}
}
}
- if (port_found)
- {
- if (XvGrabPort(mDisplay, xv_port, CurrentTime))
- xv_port = 0;
- } else
- {
- mp_msg(MSGT_VO, MSGL_WARN,
- MSGTR_LIBVO_XV_InvalidPortParameter);
- xv_port = 0;
+ if (port_found) {
+ if (XvGrabPort(x11->display, x11->xv_port, CurrentTime))
+ x11->xv_port = 0;
+ } else {
+ mp_tmsg(MSGT_VO, MSGL_WARN, "[VO_XV] Invalid port parameter, overriding with port 0.\n");
+ x11->xv_port = 0;
}
}
- for (i = 0; i < adaptors && xv_port == 0; i++)
- {
+ for (i = 0; i < ctx->adaptors && x11->xv_port == 0; i++) {
/* check if adaptor number has been specified */
if (xv_adaptor != -1 && xv_adaptor != i)
- continue;
+ continue;
- if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask))
- {
- for (xv_p = ai[i].base_id;
- xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p)
- if (!XvGrabPort(mDisplay, xv_p, CurrentTime))
- {
- xv_port = xv_p;
+ if ((ctx->ai[i].type & XvInputMask) && (ctx->ai[i].type & XvImageMask)) {
+ for (xv_p = ctx->ai[i].base_id;
+ xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports; ++xv_p)
+ if (!XvGrabPort(x11->display, xv_p, CurrentTime)) {
+ x11->xv_port = xv_p;
mp_msg(MSGT_VO, MSGL_V,
"[VO_XV] Using Xv Adapter #%d (%s)\n",
- i, ai[i].name);
+ i, ctx->ai[i].name);
break;
- } else
- {
- mp_msg(MSGT_VO, MSGL_WARN,
- MSGTR_LIBVO_XV_CouldNotGrabPort, (int) xv_p);
+ } else {
+ mp_tmsg(MSGT_VO, MSGL_WARN, "[VO_XV] Could not grab port %i.\n",
+ (int) xv_p);
++busy_ports;
}
}
}
- if (!xv_port)
- {
+ if (!x11->xv_port) {
if (busy_ports)
- mp_msg(MSGT_VO, MSGL_ERR,
- MSGTR_LIBVO_XV_CouldNotFindFreePort);
+ mp_tmsg(MSGT_VO, MSGL_ERR,
+ "[VO_XV] Could not find free Xvideo port - maybe another process is already\n"\
+ "[VO_XV] using it. Close all video applications, and try again. If that does\n"\
+ "[VO_XV] not help, see 'mplayer -vo help' for other (non-xv) video out drivers.\n");
else
- mp_msg(MSGT_VO, MSGL_ERR,
- MSGTR_LIBVO_XV_NoXvideoSupport);
- return -1;
+ mp_tmsg(MSGT_VO, MSGL_ERR,
+ "[VO_XV] It seems there is no Xvideo support for your video card available.\n"\
+ "[VO_XV] Run 'xvinfo' to verify its Xv support and read\n"\
+ "[VO_XV] DOCS/HTML/en/video.html#xv!\n"\
+ "[VO_XV] See 'mplayer -vo help' for other (non-xv) video out drivers.\n"\
+ "[VO_XV] Try -vo x11.\n");
+ goto error;
}
- if ( !vo_xv_init_colorkey() )
- {
- return -1; // bail out, colorkey setup failed
+ if (!vo_xv_init_colorkey(vo)) {
+ goto error; // bail out, colorkey setup failed
}
- vo_xv_enable_vsync();
- vo_xv_get_max_img_dim( &max_width, &max_height );
+ vo_xv_enable_vsync(vo);
+ vo_xv_get_max_img_dim(vo, &ctx->max_width, &ctx->max_height);
- fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats);
+ ctx->fo = XvListImageFormats(x11->display, x11->xv_port,
+ (int *) &ctx->formats);
- mp_input_add_event_fd(ConnectionNumber(mDisplay), check_events);
+ mp_input_add_key_fd(vo->input_ctx, ConnectionNumber(x11->display), 1,
+ x11_fd_callback, NULL, vo);
+ ctx->event_fd_registered = 1;
return 0;
+
+ error:
+ uninit(vo); // free resources
+ return -1;
}
-static int control(uint32_t request, void *data, ...)
+static int control(struct vo *vo, uint32_t request, void *data)
{
- switch (request)
- {
- case VOCTRL_PAUSE:
- return int_pause = 1;
- case VOCTRL_RESUME:
- return int_pause = 0;
- case VOCTRL_QUERY_FORMAT:
- return query_format(*((uint32_t *) data));
- case VOCTRL_GET_IMAGE:
- return get_image(data);
- case VOCTRL_DRAW_IMAGE:
- return draw_image(data);
- case VOCTRL_GUISUPPORT:
- return VO_TRUE;
- case VOCTRL_GET_PANSCAN:
- if (!vo_config_count || !vo_fs)
- return VO_FALSE;
- return VO_TRUE;
- case VOCTRL_FULLSCREEN:
- vo_x11_fullscreen();
- /* indended, fallthrough to update panscan on fullscreen/windowed switch */
- case VOCTRL_SET_PANSCAN:
- if ((vo_fs && (vo_panscan != vo_panscan_amount))
- || (!vo_fs && vo_panscan_amount))
- {
- int old_y = vo_panscan_y;
-
- panscan_calc();
-
- if (old_y != vo_panscan_y)
- {
- resize();
- flip_page();
- }
- }
- return VO_TRUE;
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
-
- va_end(ap);
-
- return vo_xv_set_eq(xv_port, data, value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
-
- va_end(ap);
-
- return vo_xv_get_eq(xv_port, data, value);
+ struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
+ switch (request) {
+ case VOCTRL_PAUSE:
+ return (ctx->is_paused = 1);
+ case VOCTRL_RESUME:
+ return (ctx->is_paused = 0);
+ case VOCTRL_QUERY_FORMAT:
+ return query_format(ctx, *((uint32_t *) data));
+ case VOCTRL_GET_IMAGE:
+ return get_image(ctx, data);
+ case VOCTRL_DRAW_IMAGE:
+ return draw_image(vo, data);
+ case VOCTRL_GUISUPPORT:
+ return VO_TRUE;
+ case VOCTRL_GET_PANSCAN:
+ if (!vo->config_ok || !vo_fs)
+ return VO_FALSE;
+ return VO_TRUE;
+ case VOCTRL_FULLSCREEN:
+ vo_x11_fullscreen(vo);
+ /* indended, fallthrough to update panscan on fullscreen/windowed switch */
+ case VOCTRL_SET_PANSCAN:
+ if ((vo_fs && (vo_panscan != vo->panscan_amount))
+ || (!vo_fs && vo->panscan_amount)) {
+ int old_y = vo->panscan_y;
+
+ panscan_calc(vo);
+
+ if (old_y != vo->panscan_y) {
+ resize(vo);
+ flip_page(vo);
}
- case VOCTRL_ONTOP:
- vo_x11_ontop();
- return VO_TRUE;
- case VOCTRL_UPDATE_SCREENINFO:
- update_xinerama_info();
- return VO_TRUE;
+ }
+ return VO_TRUE;
+ case VOCTRL_SET_EQUALIZER:
+ {
+ struct voctrl_set_equalizer_args *args = data;
+ return vo_xv_set_eq(vo, x11->xv_port, args->name, args->value);
+ }
+ case VOCTRL_GET_EQUALIZER:
+ {
+ struct voctrl_get_equalizer_args *args = data;
+ return vo_xv_get_eq(vo, x11->xv_port, args->name, args->valueptr);
+ }
+ case VOCTRL_ONTOP:
+ vo_x11_ontop(vo);
+ return VO_TRUE;
+ case VOCTRL_UPDATE_SCREENINFO:
+ update_xinerama_info(vo);
+ return VO_TRUE;
+ case VOCTRL_REDRAW_OSD:
+ return redraw_osd(vo, data);
}
return VO_NOTIMPL;
}
+
+const struct vo_driver video_out_xv = {
+ .is_new = 1,
+ .info = &info,
+ .preinit = preinit,
+ .config = config,
+ .control = control,
+ .draw_frame = draw_frame,
+ .draw_slice = draw_slice,
+ .draw_osd = draw_osd,
+ .flip_page = flip_page,
+ .check_events = check_events,
+ .uninit = uninit
+};
diff --git a/libvo/vo_xvidix.c b/libvo/vo_xvidix.c
index b48168e6d5..620d6df3b5 100644
--- a/libvo/vo_xvidix.c
+++ b/libvo/vo_xvidix.c
@@ -409,13 +409,13 @@ static int preinit(const char *arg)
if (!vo_init())
return -1;
- if (vidix_preinit(vidix_name, &video_out_xvidix) != 0)
+ if (vidix_preinit(vidix_name, video_out_xvidix.old_functions) != 0)
return 1;
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request)
{
@@ -439,30 +439,6 @@ static int control(uint32_t request, void *data, ...)
set_window(0);
}
return VO_TRUE;
- case VOCTRL_SET_EQUALIZER:
- {
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
-
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
- case VOCTRL_GET_EQUALIZER:
- {
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int *);
-
- va_end(ap);
-
- return vidix_control(request, data, value);
- }
case VOCTRL_UPDATE_SCREENINFO:
aspect_save_screenres(vo_screenwidth, vo_screenheight);
return VO_TRUE;
diff --git a/libvo/vo_xvmc.c b/libvo/vo_xvmc.c
index 1673fa8774..aad00de687 100644
--- a/libvo/vo_xvmc.c
+++ b/libvo/vo_xvmc.c
@@ -1269,7 +1269,7 @@ assert(rndr->next_free_data_block_num == 0);
return VO_TRUE;
}
-static int control(uint32_t request, void *data, ... )
+static int control(uint32_t request, void *data)
{
switch (request){
case VOCTRL_GET_DEINTERLACE:
@@ -1311,26 +1311,14 @@ static int control(uint32_t request, void *data, ... )
return VO_TRUE;
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
-
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-
- return vo_xv_set_eq(xv_port, data, value);
+ struct voctrl_set_equalizer_args *args = data;
+ return vo_xv_set_eq(xv_port, args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
-
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
-
- return vo_xv_get_eq(xv_port, data, value);
+ struct voctrl_get_equalizer_args *args = data;
+ return vo_xv_get_eq(xv_port, args->name, args->valueptr);
}
case VOCTRL_UPDATE_SCREENINFO:
update_xinerama_info();
diff --git a/libvo/vo_xvr100.c b/libvo/vo_xvr100.c
index 476744729c..7a82c436fb 100644
--- a/libvo/vo_xvr100.c
+++ b/libvo/vo_xvr100.c
@@ -428,7 +428,7 @@ static int query_format(uint32_t format)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_GET_IMAGE:
diff --git a/libvo/vo_yuv4mpeg.c b/libvo/vo_yuv4mpeg.c
index f4cbfb1639..52e18f159e 100644
--- a/libvo/vo_yuv4mpeg.c
+++ b/libvo/vo_yuv4mpeg.c
@@ -122,28 +122,28 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
{
if (height % 4)
{
- mp_msg(MSGT_VO,MSGL_FATAL,
- MSGTR_VO_YUV4MPEG_InterlacedHeightDivisibleBy4);
+ mp_tmsg(MSGT_VO,MSGL_FATAL,
+ "Interlaced mode requires image height to be divisible by 4.");
return -1;
}
rgb_line_buffer = malloc(image_width * 3);
if (!rgb_line_buffer)
{
- mp_msg(MSGT_VO,MSGL_FATAL,
- MSGTR_VO_YUV4MPEG_InterlacedLineBufAllocFail);
+ mp_tmsg(MSGT_VO,MSGL_FATAL,
+ "Unable to allocate line buffer for interlaced mode.");
return -1;
}
if (using_format == IMGFMT_YV12)
- mp_msg(MSGT_VO,MSGL_WARN,
- MSGTR_VO_YUV4MPEG_InterlacedInputNotRGB);
+ mp_tmsg(MSGT_VO,MSGL_WARN,
+ "Input not RGB, can't separate chrominance by fields!");
}
if (width % 2)
{
- mp_msg(MSGT_VO,MSGL_FATAL,
- MSGTR_VO_YUV4MPEG_WidthDivisibleBy2);
+ mp_tmsg(MSGT_VO,MSGL_FATAL,
+ "Image width must be divisible by 2.");
return -1;
}
@@ -153,8 +153,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
rgb_buffer = malloc(image_width * image_height * 3);
if (!rgb_buffer)
{
- mp_msg(MSGT_VO,MSGL_FATAL,
- MSGTR_VO_YUV4MPEG_NoMemRGBFrameBuf);
+ mp_tmsg(MSGT_VO,MSGL_FATAL,
+ "Not enough memory to allocate RGB framebuffer.");
return -1;
}
}
@@ -165,8 +165,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
yuv_out = fopen(yuv_filename, "wb");
if (!yuv_out || image == 0)
{
- mp_msg(MSGT_VO,MSGL_FATAL,
- MSGTR_VO_YUV4MPEG_OutFileOpenError,
+ mp_tmsg(MSGT_VO,MSGL_FATAL,
+ "Can't get memory or file handle to write \"%s\"!",
yuv_filename);
return -1;
}
@@ -262,8 +262,8 @@ static void deinterleave_fields(uint8_t *ptr, const int stride,
static void vo_y4m_write(const void *ptr, const size_t num_bytes)
{
if (fwrite(ptr, 1, num_bytes, yuv_out) != num_bytes)
- mp_msg(MSGT_VO,MSGL_ERR,
- MSGTR_VO_YUV4MPEG_OutFileWriteError);
+ mp_tmsg(MSGT_VO,MSGL_ERR,
+ "Error writing image to output!");
}
static int write_last_frame(void)
@@ -524,7 +524,7 @@ static int preinit(const char *arg)
il_bf = 0;
yuv_filename = strdup("stream.yuv");
if (subopt_parse(arg, subopts) != 0) {
- mp_msg(MSGT_VO, MSGL_FATAL, MSGTR_VO_YUV4MPEG_UnknownSubDev, arg);
+ mp_tmsg(MSGT_VO, MSGL_FATAL, "Unknown subdevice: %s", arg);
return -1;
}
@@ -538,22 +538,22 @@ static int preinit(const char *arg)
switch (config_interlace)
{
case Y4M_ILACE_TOP_FIRST:
- mp_msg(MSGT_VO,MSGL_STATUS,
- MSGTR_VO_YUV4MPEG_InterlacedTFFMode);
+ mp_tmsg(MSGT_VO,MSGL_STATUS,
+ "Using interlaced output mode, top-field first.");
break;
case Y4M_ILACE_BOTTOM_FIRST:
- mp_msg(MSGT_VO,MSGL_STATUS,
- MSGTR_VO_YUV4MPEG_InterlacedBFFMode);
+ mp_tmsg(MSGT_VO,MSGL_STATUS,
+ "Using interlaced output mode, bottom-field first.");
break;
default:
- mp_msg(MSGT_VO,MSGL_STATUS,
- MSGTR_VO_YUV4MPEG_ProgressiveMode);
+ mp_tmsg(MSGT_VO,MSGL_STATUS,
+ "Using (default) progressive frame mode.");
break;
}
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_zr.c b/libvo/vo_zr.c
index e8d1f23e11..9b7968a6ba 100644
--- a/libvo/vo_zr.c
+++ b/libvo/vo_zr.c
@@ -830,7 +830,7 @@ static int preinit(const char *arg)
return 0;
}
-static int control(uint32_t request, void *data, ...)
+static int control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vo_zr2.c b/libvo/vo_zr2.c
index 21347cb1d7..2bad93a731 100644
--- a/libvo/vo_zr2.c
+++ b/libvo/vo_zr2.c
@@ -449,7 +449,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
return 0;
}
-static int control(uint32_t request, void *data, ...) {
+static int control(uint32_t request, void *data) {
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
diff --git a/libvo/vosub_vidix.c b/libvo/vosub_vidix.c
index a6f261130b..9b3c941c4d 100644
--- a/libvo/vosub_vidix.c
+++ b/libvo/vosub_vidix.c
@@ -44,6 +44,7 @@
#include "video_out.h"
#include "sub.h"
#include "vosub_vidix.h"
+#include "old_vo_wrapper.h"
#include "libmpcodecs/vfcap.h"
#include "libmpcodecs/mp_image.h"
@@ -59,7 +60,7 @@ static int video_on=0;
static vidix_capability_t vidix_cap;
static vidix_playback_t vidix_play;
static vidix_fourcc_t vidix_fourcc;
-static vo_functions_t * vo_server;
+static struct vo_old_functions *vo_server;
static vidix_yuv_t dstrides;
/*static uint32_t (*server_control)(uint32_t request, void *data, ...);*/
@@ -68,7 +69,7 @@ int vidix_start(void)
int err;
if((err=vdlPlaybackOn(vidix_handler))!=0)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantStartPlayback,strerror(err));
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] Can't start playback: %s\n",strerror(err));
return -1;
}
video_on=1;
@@ -80,7 +81,7 @@ int vidix_stop(void)
int err;
if((err=vdlPlaybackOff(vidix_handler))!=0)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantStopPlayback,strerror(err));
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] Can't stop playback: %s\n",strerror(err));
return -1;
}
video_on=0;
@@ -96,7 +97,7 @@ void vidix_term( void )
// vo_server->control=server_control;
}
-static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -160,7 +161,7 @@ static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h
return -1;
}
-static uint32_t vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -178,7 +179,7 @@ static uint32_t vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h
if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_InterleavedUvForYuv410pNotSupported);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SUB_VIDIX] Interleaved UV for YUV410P not supported.\n");
}
else
{
@@ -206,7 +207,7 @@ static uint32_t vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h
return -1;
}
-static uint32_t vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -223,7 +224,7 @@ static uint32_t vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,in
return 0;
}
-static uint32_t vidix_draw_slice_nv12(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice_nv12(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -251,9 +252,9 @@ static uint32_t vidix_draw_slice_nv12(uint8_t *image[], int stride[], int w,int
return 0;
}
-static uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
+static int vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawsliceWasCalled);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SUB_VIDIX] Dummy vidix_draw_slice() was called.\n");
return -1;
}
@@ -269,9 +270,9 @@ static uint32_t vidix_draw_image(mp_image_t *mpi){
return VO_TRUE;
}
-static uint32_t vidix_draw_frame(uint8_t *image[])
+static int vidix_draw_frame(uint8_t *image[])
{
- mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawframeWasCalled);
+ mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_SUB_VIDIX] Dummy vidix_draw_frame() was called.\n");
return -1;
}
@@ -391,7 +392,7 @@ int vidix_init(unsigned src_width,unsigned src_height,
if(vidix_query_fourcc(format) == 0)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_UnsupportedFourccForThisVidixDriver,
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] Unsupported FourCC for this VIDIX driver: %x (%s).\n",
format,vo_format_name(format));
return -1;
}
@@ -401,7 +402,7 @@ int vidix_init(unsigned src_width,unsigned src_height,
((vidix_cap.maxheight != -1) && (vid_h > vidix_cap.maxheight)) ||
((vidix_cap.minwidth != -1 ) && (vid_h < vidix_cap.minheight)))
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_VideoServerHasUnsupportedResolution,
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] Video server has unsupported resolution (%dx%d), supported: %dx%d-%dx%d.\n",
vid_w, vid_h, vidix_cap.minwidth, vidix_cap.minheight,
vidix_cap.maxwidth, vidix_cap.maxheight);
return -1;
@@ -423,19 +424,19 @@ int vidix_init(unsigned src_width,unsigned src_height,
}
if(err)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_VideoServerHasUnsupportedColorDepth
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] Video server has unsupported color depth by vidix (%d).\n"
,vidix_fourcc.depth);
return -1;
}
if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_UPSCALER) != FLAG_UPSCALER)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_DriverCantUpscaleImage,
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] VIDIX driver can't upscale image (%d%d -> %d%d).\n",
src_width, src_height, dst_width, dst_height);
return -1;
}
if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_DriverCantDownscaleImage,
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] VIDIX driver can't downscale image (%d%d -> %d%d).\n",
src_width, src_height, dst_width, dst_height);
return -1;
}
@@ -463,7 +464,7 @@ int vidix_init(unsigned src_width,unsigned src_height,
if((err=vdlConfigPlayback(vidix_handler,&vidix_play))!=0)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantConfigurePlayback,strerror(err));
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] Can't configure playback: %s.\n",strerror(err));
return -1;
}
if ( mp_msg_test(MSGT_VO,MSGL_V) ) {
@@ -576,7 +577,7 @@ static uint32_t vidix_get_image(mp_image_t *mpi)
return VO_FALSE;
}
-uint32_t vidix_control(uint32_t request, void *data, ...)
+uint32_t vidix_control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
@@ -596,36 +597,31 @@ uint32_t vidix_control(uint32_t request, void *data, ...)
return VO_TRUE;
case VOCTRL_SET_EQUALIZER:
{
- va_list ap;
- int value;
vidix_video_eq_t info;
if(!video_on) return VO_FALSE;
- va_start(ap, data);
- value = va_arg(ap, int);
- va_end(ap);
-// printf("vidix seteq %s -> %d \n",data,value);
+ struct voctrl_set_equalizer_args *args = data;
/* vidix eq ranges are -1000..1000 */
- if (!strcasecmp(data, "brightness"))
+ if (!strcasecmp(args->name, "brightness"))
{
- info.brightness = value*10;
+ info.brightness = args->value*10;
info.cap = VEQ_CAP_BRIGHTNESS;
}
- else if (!strcasecmp(data, "contrast"))
+ else if (!strcasecmp(args->name, "contrast"))
{
- info.contrast = value*10;
+ info.contrast = args->value*10;
info.cap = VEQ_CAP_CONTRAST;
}
- else if (!strcasecmp(data, "saturation"))
+ else if (!strcasecmp(args->name, "saturation"))
{
- info.saturation = value*10;
+ info.saturation = args->value*10;
info.cap = VEQ_CAP_SATURATION;
}
- else if (!strcasecmp(data, "hue"))
+ else if (!strcasecmp(args->name, "hue"))
{
- info.hue = value*10;
+ info.hue = args->value*10;
info.cap = VEQ_CAP_HUE;
}
@@ -635,38 +631,34 @@ uint32_t vidix_control(uint32_t request, void *data, ...)
}
case VOCTRL_GET_EQUALIZER:
{
- va_list ap;
- int *value;
vidix_video_eq_t info;
if(!video_on) return VO_FALSE;
if (vdlPlaybackGetEq(vidix_handler, &info) != 0)
return VO_FALSE;
- va_start(ap, data);
- value = va_arg(ap, int*);
- va_end(ap);
+ struct voctrl_get_equalizer_args *args = data;
/* vidix eq ranges are -1000..1000 */
- if (!strcasecmp(data, "brightness"))
+ if (!strcasecmp(args->name, "brightness"))
{
if (info.cap & VEQ_CAP_BRIGHTNESS)
- *value = info.brightness/10;
+ *args->valueptr = info.brightness/10;
}
- else if (!strcasecmp(data, "contrast"))
+ else if (!strcasecmp(args->name, "contrast"))
{
if (info.cap & VEQ_CAP_CONTRAST)
- *value = info.contrast/10;
+ *args->valueptr = info.contrast/10;
}
- else if (!strcasecmp(data, "saturation"))
+ else if (!strcasecmp(args->name, "saturation"))
{
if (info.cap & VEQ_CAP_SATURATION)
- *value = info.saturation/10;
+ *args->valueptr = info.saturation/10;
}
- else if (!strcasecmp(data, "hue"))
+ else if (!strcasecmp(args->name, "hue"))
{
if (info.cap & VEQ_CAP_HUE)
- *value = info.hue/10;
+ *args->valueptr = info.hue/10;
}
return VO_TRUE;
@@ -677,7 +669,7 @@ uint32_t vidix_control(uint32_t request, void *data, ...)
// return server_control(request,data); //VO_NOTIMPL;
}
-int vidix_preinit(const char *drvname,vo_functions_t *server)
+int vidix_preinit(const char *drvname, struct vo_old_functions *server)
{
int err;
if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
@@ -689,12 +681,12 @@ int vidix_preinit(const char *drvname,vo_functions_t *server)
if(vidix_handler == NULL)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CouldntFindWorkingVidixDriver);
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] Couldn't find working VIDIX driver.\n");
return -1;
}
if((err=vdlGetCapability(vidix_handler,&vidix_cap)) != 0)
{
- mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CouldntGetCapability,strerror(err));
+ mp_tmsg(MSGT_VO,MSGL_ERR, "[VO_SUB_VIDIX] Couldn't get capability: %s.\n",strerror(err));
return -1;
}
mp_msg(MSGT_VO,MSGL_V, "[VO_SUB_VIDIX] Description: %s.\n", vidix_cap.name);
diff --git a/libvo/vosub_vidix.h b/libvo/vosub_vidix.h
index 128409e95a..7b05607de6 100644
--- a/libvo/vosub_vidix.h
+++ b/libvo/vosub_vidix.h
@@ -27,7 +27,7 @@
#include "video_out.h"
/* drvname can be NULL */
-int vidix_preinit(const char *drvname,vo_functions_t *server);
+int vidix_preinit(const char *drvname, struct vo_old_functions *server);
int vidix_init(unsigned src_width,unsigned src_height,
unsigned dest_x,unsigned dest_y,unsigned dst_width,
unsigned dst_height,unsigned format,unsigned dest_bpp,
@@ -35,7 +35,7 @@ int vidix_init(unsigned src_width,unsigned src_height,
int vidix_start(void);
int vidix_stop(void);
void vidix_term( void );
-uint32_t vidix_control(uint32_t request, void *data, ...);
+uint32_t vidix_control(uint32_t request, void *data);
uint32_t vidix_query_fourcc(uint32_t fourcc);
#include "vidix/vidix.h"
diff --git a/libvo/w32_common.c b/libvo/w32_common.c
index 3125a56305..b78f8f1fc4 100644
--- a/libvo/w32_common.c
+++ b/libvo/w32_common.c
@@ -21,6 +21,8 @@
#include <windows.h>
#include <windowsx.h>
+// To get "#define vo_ontop global_vo->opts->vo_ontop" etc
+#include "old_vo_defines.h"
#include "osdep/keycodes.h"
#include "input/input.h"
#include "input/mouse.h"
@@ -39,6 +41,7 @@ extern int enable_mouse_movements;
static const char classname[] = "MPlayer - The Movie Player";
int vo_vm = 0;
+static int depthonscreen;
// last non-fullscreen extends
static int prev_width;
static int prev_height;
@@ -116,7 +119,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
xborder = (r.right - r.left) - wpos->cx;
yborder = (r.bottom - r.top) - wpos->cy;
wpos->cx -= xborder; wpos->cy -= yborder;
- aspect_fit(&wpos->cx, &wpos->cy, wpos->cx, wpos->cy);
+ aspect_fit(global_vo, &wpos->cx, &wpos->cy, wpos->cx, wpos->cy);
wpos->cx += xborder; wpos->cy += yborder;
}
return 0;
@@ -163,7 +166,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
char cmd_str[40];
snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i",
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
- mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
+ mp_input_queue_cmd(global_vo->input_ctx, mp_input_parse_cmd(cmd_str));
}
break;
case WM_MOUSEWHEEL:
@@ -283,7 +286,7 @@ static void updateScreenProperties(void) {
vo_screenwidth = dm.dmPelsWidth;
vo_screenheight = dm.dmPelsHeight;
- vo_depthonscreen = dm.dmBitsPerPel;
+ depthonscreen = dm.dmBitsPerPel;
w32_update_xinerama_info();
}
@@ -293,7 +296,7 @@ static void changeMode(void) {
dm.dmDriverExtra = 0;
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
- dm.dmBitsPerPel = vo_depthonscreen;
+ dm.dmBitsPerPel = depthonscreen;
dm.dmPelsWidth = vo_screenwidth;
dm.dmPelsHeight = vo_screenheight;
@@ -303,7 +306,7 @@ static void changeMode(void) {
int i;
for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) {
int score = (dm.dmPelsWidth - o_dwidth) * (dm.dmPelsHeight - o_dheight);
- if (dm.dmBitsPerPel != vo_depthonscreen) continue;
+ if (dm.dmBitsPerPel != depthonscreen) continue;
if (dm.dmPelsWidth < o_dwidth) continue;
if (dm.dmPelsHeight < o_dheight) continue;
@@ -393,7 +396,7 @@ static int createRenderingContext(void) {
SetPixelFormat(vo_hdc, pf, &pfd);
- mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen);
+ mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, depthonscreen);
ReleaseDC(vo_window, vo_hdc);
return 1;
@@ -563,7 +566,7 @@ void vo_w32_uninit(void) {
mp_msg(MSGT_VO, MSGL_V, "vo: win32: uninit\n");
resetMode();
ShowCursor(1);
- vo_depthonscreen = 0;
+ depthonscreen = 0;
DestroyWindow(vo_window);
vo_window = 0;
UnregisterClass(classname, 0);
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 883cae0e70..51c85bee9e 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -23,10 +23,12 @@
#include <limits.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "mp_fifo.h"
#include "libavutil/common.h"
#include "x11_common.h"
+#include "talloc.h"
#ifdef X11_FULLSCREEN
@@ -87,56 +89,26 @@
extern int enable_mouse_movements;
int fs_layer = WIN_LAYER_ABOVE_DOCK;
-static int orig_layer = 0;
-static int old_gravity = NorthWestGravity;
int stop_xscreensaver = 0;
static int dpms_disabled = 0;
char *mDisplayName = NULL;
-Display *mDisplay = NULL;
-Window mRootWin;
-int mScreen;
-int mLocalDisplay;
-
-/* output window id */
-int vo_mouse_autohide = 0;
-int vo_wm_type = 0;
-int vo_fs_type = 0; // needs to be accessible for GUI X11 code
-static int vo_fs_flip = 0;
+
char **vo_fstype_list;
/* 1 means that the WM is metacity (broken as hell) */
int metacity_hack = 0;
-static Atom XA_NET_SUPPORTED;
-static Atom XA_NET_WM_STATE;
-static Atom XA_NET_WM_STATE_FULLSCREEN;
-static Atom XA_NET_WM_STATE_ABOVE;
-static Atom XA_NET_WM_STATE_STAYS_ON_TOP;
-static Atom XA_NET_WM_STATE_BELOW;
-static Atom XA_NET_WM_PID;
-static Atom XA_WIN_PROTOCOLS;
-static Atom XA_WIN_LAYER;
-static Atom XA_WIN_HINTS;
-static Atom XAWM_PROTOCOLS;
-static Atom XAWM_DELETE_WINDOW;
-
-#define XA_INIT(x) XA##x = XInternAtom(mDisplay, #x, False)
-
-static int vo_old_x = 0;
-static int vo_old_y = 0;
-static int vo_old_width = 0;
-static int vo_old_height = 0;
-
#ifdef CONFIG_XF86VM
XF86VidModeModeInfo **vidmodes = NULL;
XF86VidModeModeLine modeline;
#endif
static int vo_x11_get_fs_type(int supported);
-
+static void saver_off(Display *);
+static void saver_on(Display *);
/*
* Sends the EWMH fullscreen state event.
@@ -145,12 +117,12 @@ static int vo_x11_get_fs_type(int supported);
* _NET_WM_STATE_ADD -- add state
* _NET_WM_STATE_TOGGLE -- toggle
*/
-void vo_x11_ewmh_fullscreen(int action)
+void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action)
{
assert(action == _NET_WM_STATE_REMOVE ||
action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE);
- if (vo_fs_type & vo_wm_FULLSCREEN)
+ if (x11->fs_type & vo_wm_FULLSCREEN)
{
XEvent xev;
@@ -158,32 +130,32 @@ void vo_x11_ewmh_fullscreen(int action)
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
- xev.xclient.message_type = XA_NET_WM_STATE;
- xev.xclient.window = vo_window;
+ xev.xclient.message_type = x11->XA_NET_WM_STATE;
+ xev.xclient.window = x11->window;
xev.xclient.format = 32;
xev.xclient.data.l[0] = action;
- xev.xclient.data.l[1] = XA_NET_WM_STATE_FULLSCREEN;
+ xev.xclient.data.l[1] = x11->XA_NET_WM_STATE_FULLSCREEN;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
/* finally send that damn thing */
- if (!XSendEvent(mDisplay, DefaultRootWindow(mDisplay), False,
+ if (!XSendEvent(x11->display, DefaultRootWindow(x11->display), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev))
{
- mp_msg(MSGT_VO, MSGL_ERR, MSGTR_EwmhFullscreenStateFailed);
+ mp_tmsg(MSGT_VO, MSGL_ERR, "\nX11: Couldn't send EWMH fullscreen event!\n");
}
}
}
-void vo_hidecursor(Display * disp, Window win)
+static void vo_hidecursor(Display * disp, Window win)
{
Cursor no_ptr;
Pixmap bm_no;
XColor black, dummy;
Colormap colormap;
- static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ const char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
if (WinID == 0)
return; // do not hide if playing on the root window
@@ -202,7 +174,7 @@ void vo_hidecursor(Display * disp, Window win)
XFreeColors(disp,colormap,&black.pixel,1,0);
}
-void vo_showcursor(Display * disp, Window win)
+static void vo_showcursor(Display * disp, Window win)
{
if (WinID == 0)
return;
@@ -233,7 +205,7 @@ static int x11_errorhandler(Display * display, XErrorEvent * event)
void fstype_help(void)
{
- mp_msg(MSGT_VO, MSGL_INFO, MSGTR_AvailableFsType);
+ mp_tmsg(MSGT_VO, MSGL_INFO, "Available fullscreen layer change modes:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FULL_SCREEN_TYPES\n");
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "none",
@@ -278,9 +250,9 @@ static void fstype_dump(int fstype)
"[x11] Current fstype setting doesn't honour any X atoms\n");
}
-static int net_wm_support_state_test(Atom atom)
+static int net_wm_support_state_test(struct vo_x11_state *x11, Atom atom)
{
-#define NET_WM_STATE_TEST(x) { if (atom == XA_NET_WM_STATE_##x) { mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); return vo_wm_##x; } }
+#define NET_WM_STATE_TEST(x) { if (atom == x11->XA_NET_WM_STATE_##x) { mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); return vo_wm_##x; } }
NET_WM_STATE_TEST(FULLSCREEN);
NET_WM_STATE_TEST(ABOVE);
@@ -289,20 +261,22 @@ static int net_wm_support_state_test(Atom atom)
return 0;
}
-static int x11_get_property(Atom type, Atom ** args, unsigned long *nitems)
+static int x11_get_property(struct vo_x11_state *x11, Atom type, Atom ** args,
+ unsigned long *nitems)
{
int format;
unsigned long bytesafter;
return Success ==
- XGetWindowProperty(mDisplay, mRootWin, type, 0, 16384, False,
+ XGetWindowProperty(x11->display, x11->rootwin, type, 0, 16384, False,
AnyPropertyType, &type, &format, nitems,
&bytesafter, (unsigned char **) args)
&& *nitems > 0;
}
-static int vo_wm_detect(void)
+static int vo_wm_detect(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
int i;
int wm = 0;
unsigned long nitems;
@@ -312,12 +286,12 @@ static int vo_wm_detect(void)
return 0;
// -- supports layers
- if (x11_get_property(XA_WIN_PROTOCOLS, &args, &nitems))
+ if (x11_get_property(x11, x11->XA_WIN_PROTOCOLS, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports layers.\n");
for (i = 0; i < nitems; i++)
{
- if (args[i] == XA_WIN_LAYER)
+ if (args[i] == x11->XA_WIN_LAYER)
{
wm |= vo_wm_LAYER;
metacity_hack |= 1;
@@ -337,11 +311,11 @@ static int vo_wm_detect(void)
}
}
// --- netwm
- if (x11_get_property(XA_NET_SUPPORTED, &args, &nitems))
+ if (x11_get_property(x11, x11->XA_NET_SUPPORTED, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports NetWM.\n");
for (i = 0; i < nitems; i++)
- wm |= net_wm_support_state_test(args[i]);
+ wm |= net_wm_support_state_test(vo->x11, args[i]);
XFree(args);
}
@@ -350,7 +324,8 @@ static int vo_wm_detect(void)
return wm;
}
-static void init_atoms(void)
+#define XA_INIT(x) x11->XA##x = XInternAtom(x11->display, #x, False)
+static void init_atoms(struct vo_x11_state *x11)
{
XA_INIT(_NET_SUPPORTED);
XA_INIT(_NET_WM_STATE);
@@ -366,21 +341,22 @@ static void init_atoms(void)
XA_INIT(WM_DELETE_WINDOW);
}
-void update_xinerama_info(void) {
+void update_xinerama_info(struct vo *vo) {
+ struct MPOpts *opts = vo->opts;
int screen = xinerama_screen;
xinerama_x = xinerama_y = 0;
#ifdef CONFIG_XINERAMA
- if (screen >= -1 && XineramaIsActive(mDisplay))
+ if (screen >= -1 && XineramaIsActive(vo->x11->display))
{
XineramaScreenInfo *screens;
int num_screens;
- screens = XineramaQueryScreens(mDisplay, &num_screens);
+ screens = XineramaQueryScreens(vo->x11->display, &num_screens);
if (screen >= num_screens)
screen = num_screens - 1;
if (screen == -1) {
- int x = vo_dx + vo_dwidth / 2;
- int y = vo_dy + vo_dheight / 2;
+ int x = vo->dx + vo->dwidth / 2;
+ int y = vo->dy + vo->dheight / 2;
for (screen = num_screens - 1; screen > 0; screen--) {
int left = screens[screen].x_org;
int right = left + screens[screen].width;
@@ -392,19 +368,21 @@ void update_xinerama_info(void) {
}
if (screen < 0)
screen = 0;
- vo_screenwidth = screens[screen].width;
- vo_screenheight = screens[screen].height;
+ opts->vo_screenwidth = screens[screen].width;
+ opts->vo_screenheight = screens[screen].height;
xinerama_x = screens[screen].x_org;
xinerama_y = screens[screen].y_org;
XFree(screens);
}
#endif
- aspect_save_screenres(vo_screenwidth, vo_screenheight);
+ aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight);
}
-int vo_init(void)
+int vo_init(struct vo *vo)
{
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
// int mScreen;
int depth, bpp;
unsigned int mask;
@@ -420,9 +398,9 @@ int vo_init(void)
if (vo_rootwin)
WinID = 0; // use root window
- if (vo_depthonscreen)
+ if (x11->depthonscreen)
{
- saver_off(mDisplay);
+ saver_off(x11->display);
return 1; // already called
}
@@ -438,52 +416,52 @@ int vo_init(void)
mp_msg(MSGT_VO, MSGL_V, "X11 opening display: %s\n", dispName);
- mDisplay = XOpenDisplay(dispName);
- if (!mDisplay)
+ x11->display = XOpenDisplay(dispName);
+ if (!x11->display)
{
mp_msg(MSGT_VO, MSGL_ERR,
"vo: couldn't open the X11 display (%s)!\n", dispName);
return 0;
}
- mScreen = DefaultScreen(mDisplay); // screen ID
- mRootWin = RootWindow(mDisplay, mScreen); // root window ID
+ x11->screen = DefaultScreen(x11->display); // screen ID
+ x11->rootwin = RootWindow(x11->display, x11->screen); // root window ID
- init_atoms();
+ init_atoms(vo->x11);
#ifdef CONFIG_XF86VM
{
int clock;
- XF86VidModeGetModeLine(mDisplay, mScreen, &clock, &modeline);
- if (!vo_screenwidth)
- vo_screenwidth = modeline.hdisplay;
- if (!vo_screenheight)
- vo_screenheight = modeline.vdisplay;
+ XF86VidModeGetModeLine(x11->display, x11->screen, &clock, &modeline);
+ if (!opts->vo_screenwidth)
+ opts->vo_screenwidth = modeline.hdisplay;
+ if (!opts->vo_screenheight)
+ opts->vo_screenheight = modeline.vdisplay;
}
#endif
{
- if (!vo_screenwidth)
- vo_screenwidth = DisplayWidth(mDisplay, mScreen);
- if (!vo_screenheight)
- vo_screenheight = DisplayHeight(mDisplay, mScreen);
+ if (!opts->vo_screenwidth)
+ opts->vo_screenwidth = DisplayWidth(x11->display, x11->screen);
+ if (!opts->vo_screenheight)
+ opts->vo_screenheight = DisplayHeight(x11->display, x11->screen);
}
// get color depth (from root window, or the best visual):
- XGetWindowAttributes(mDisplay, mRootWin, &attribs);
+ XGetWindowAttributes(x11->display, x11->rootwin, &attribs);
depth = attribs.depth;
if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
{
Visual *visual;
- depth = vo_find_depth_from_visuals(mDisplay, mScreen, &visual);
+ depth = vo_find_depth_from_visuals(x11->display, x11->screen, &visual);
if (depth != -1)
- mXImage = XCreateImage(mDisplay, visual, depth, ZPixmap,
+ mXImage = XCreateImage(x11->display, visual, depth, ZPixmap,
0, NULL, 1, 1, 8, 1);
} else
mXImage =
- XGetImage(mDisplay, mRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap);
+ XGetImage(x11->display, x11->rootwin, 0, 0, 1, 1, AllPlanes, ZPixmap);
- vo_depthonscreen = depth; // display depth on screen
+ x11->depthonscreen = depth; // display depth on screen
// get bits/pixel from XImage structure:
if (mXImage == NULL)
@@ -493,15 +471,15 @@ int vo_init(void)
{
/*
* for the depth==24 case, the XImage structures might use
- * 24 or 32 bits of data per pixel. The global variable
- * vo_depthonscreen stores the amount of data per pixel in the
+ * 24 or 32 bits of data per pixel. The x11->depthonscreen
+ * field stores the amount of data per pixel in the
* XImage structure!
*
* Maybe we should rename vo_depthonscreen to (or add) vo_bpp?
*/
bpp = mXImage->bits_per_pixel;
- if ((vo_depthonscreen + 7) / 8 != (bpp + 7) / 8)
- vo_depthonscreen = bpp; // by A'rpi
+ if ((x11->depthonscreen + 7) / 8 != (bpp + 7) / 8)
+ x11->depthonscreen = bpp; // by A'rpi
mask =
mXImage->red_mask | mXImage->green_mask | mXImage->blue_mask;
mp_msg(MSGT_VO, MSGL_V,
@@ -509,12 +487,12 @@ int vo_init(void)
mXImage->red_mask, mXImage->green_mask, mXImage->blue_mask);
XDestroyImage(mXImage);
}
- if (((vo_depthonscreen + 7) / 8) == 2)
+ if (((x11->depthonscreen + 7) / 8) == 2)
{
if (mask == 0x7FFF)
- vo_depthonscreen = 15;
+ x11->depthonscreen = 15;
else if (mask == 0xFFFF)
- vo_depthonscreen = 16;
+ x11->depthonscreen = 16;
}
// XCloseDisplay( mDisplay );
/* slightly improved local display detection AST */
@@ -523,27 +501,27 @@ int vo_init(void)
else if (strncmp(dispName, "localhost:", 10) == 0)
dispName += 9;
if (*dispName == ':' && atoi(dispName + 1) < 10)
- mLocalDisplay = 1;
+ x11->display_is_local = 1;
else
- mLocalDisplay = 0;
+ x11->display_is_local = 0;
mp_msg(MSGT_VO, MSGL_V,
"vo: X11 running at %dx%d with depth %d and %d bpp (\"%s\" => %s display)\n",
- vo_screenwidth, vo_screenheight, depth, vo_depthonscreen,
- dispName, mLocalDisplay ? "local" : "remote");
+ opts->vo_screenwidth, opts->vo_screenheight, depth, x11->depthonscreen,
+ dispName, x11->display_is_local ? "local" : "remote");
- vo_wm_type = vo_wm_detect();
+ x11->wm_type = vo_wm_detect(vo);
- vo_fs_type = vo_x11_get_fs_type(vo_wm_type);
+ x11->fs_type = vo_x11_get_fs_type(x11->wm_type);
- fstype_dump(vo_fs_type);
+ fstype_dump(x11->fs_type);
- saver_off(mDisplay);
+ saver_off(x11->display);
return 1;
}
-void vo_uninit(void)
+void vo_uninit(struct vo_x11_state *x11)
{
- if (!mDisplay)
+ if (!x11->display)
{
mp_msg(MSGT_VO, MSGL_V,
"vo: x11 uninit called but X11 not initialized..\n");
@@ -552,9 +530,10 @@ void vo_uninit(void)
// if( !vo_depthonscreen ) return;
mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n");
XSetErrorHandler(NULL);
- XCloseDisplay(mDisplay);
- vo_depthonscreen = 0;
- mDisplay = NULL;
+ XCloseDisplay(x11->display);
+ x11->depthonscreen = 0;
+ x11->display = NULL;
+ talloc_free(x11);
}
#include "osdep/keycodes.h"
@@ -569,11 +548,12 @@ static const struct keymap keysym_map[] = {
{0, 0}
};
-static void vo_x11_putkey_ext(int keysym)
+static void vo_x11_putkey_ext(struct vo *vo, int keysym)
{
+ struct mp_fifo *f = vo->key_fifo;
int mpkey = lookup_keymap_table(keysym_map, keysym);
if (mpkey)
- mplayer_put_key(mpkey);
+ mplayer_put_key(f, mpkey);
}
#endif
@@ -612,7 +592,7 @@ static const struct keymap keymap[] = {
{0, 0}
};
-void vo_x11_putkey(int key)
+void vo_x11_putkey(struct vo *vo, int key)
{
static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
int mpkey = 0;
@@ -626,7 +606,7 @@ void vo_x11_putkey(int key)
mpkey = lookup_keymap_table(keymap, key);
if (mpkey)
- mplayer_put_key(mpkey);
+ mplayer_put_key(vo->key_fifo, mpkey);
}
@@ -672,12 +652,9 @@ typedef struct
static MotifWmHints vo_MotifWmHints;
static Atom vo_MotifHints = None;
-void vo_x11_decoration(Display * vo_Display, Window w, int d)
+void vo_x11_decoration(struct vo *vo, int d)
{
- static unsigned int olddecor = MWM_DECOR_ALL;
- static unsigned int oldfuncs =
- MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE |
- MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE;
+ struct vo_x11_state *x11 = vo->x11;
Atom mtype;
int mformat;
unsigned long mn, mb;
@@ -687,26 +664,27 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
if (vo_fsmode & 8)
{
- XSetTransientForHint(vo_Display, w,
- RootWindow(vo_Display, mScreen));
+ XSetTransientForHint(x11->display, x11->window,
+ RootWindow(x11->display, x11->screen));
}
- vo_MotifHints = XInternAtom(vo_Display, "_MOTIF_WM_HINTS", 0);
+ vo_MotifHints = XInternAtom(x11->display, "_MOTIF_WM_HINTS", 0);
if (vo_MotifHints != None)
{
if (!d)
{
MotifWmHints *mhints = NULL;
- XGetWindowProperty(vo_Display, w, vo_MotifHints, 0, 20, False,
+ XGetWindowProperty(x11->display, x11->window,
+ vo_MotifHints, 0, 20, False,
vo_MotifHints, &mtype, &mformat, &mn,
&mb, (unsigned char **) &mhints);
if (mhints)
{
if (mhints->flags & MWM_HINTS_DECORATIONS)
- olddecor = mhints->decorations;
+ x11->olddecor = mhints->decorations;
if (mhints->flags & MWM_HINTS_FUNCTIONS)
- oldfuncs = mhints->functions;
+ x11->oldfuncs = mhints->functions;
XFree(mhints);
}
}
@@ -716,8 +694,8 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
if (d)
{
- vo_MotifWmHints.functions = oldfuncs;
- d = olddecor;
+ vo_MotifWmHints.functions = x11->oldfuncs;
+ d = x11->olddecor;
}
#if 0
vo_MotifWmHints.decorations =
@@ -726,110 +704,99 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
vo_MotifWmHints.decorations =
d | ((vo_fsmode & 2) ? MWM_DECOR_MENU : 0);
#endif
- XChangeProperty(vo_Display, w, vo_MotifHints, vo_MotifHints, 32,
+ XChangeProperty(x11->display, x11->window, vo_MotifHints,
+ vo_MotifHints, 32,
PropModeReplace,
(unsigned char *) &vo_MotifWmHints,
(vo_fsmode & 4) ? 4 : 5);
}
}
-void vo_x11_classhint(Display * display, Window window, char *name)
+void vo_x11_classhint(struct vo *vo, Window window, char *name)
{
+ struct vo_x11_state *x11 = vo->x11;
XClassHint wmClass;
pid_t pid = getpid();
wmClass.res_name = name;
wmClass.res_class = "MPlayer";
- XSetClassHint(display, window, &wmClass);
- XChangeProperty(display, window, XA_NET_WM_PID, XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *) &pid, 1);
-}
-
-Window vo_window = None;
-GC vo_gc = NULL;
-GC f_gc = NULL;
-XSizeHints vo_hint;
-
-#ifdef CONFIG_GUI
-void vo_setwindow(Window w, GC g)
-{
- vo_window = w;
- vo_gc = g;
+ XSetClassHint(x11->display, window, &wmClass);
+ XChangeProperty(x11->display, window, x11->XA_NET_WM_PID, XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *) &pid, 1);
}
-#endif
-void vo_x11_uninit(void)
+void vo_x11_uninit(struct vo *vo)
{
- saver_on(mDisplay);
- if (vo_window != None)
- vo_showcursor(mDisplay, vo_window);
+ struct vo_x11_state *x11 = vo->x11;
+ saver_on(x11->display);
+ if (x11->window != None)
+ vo_showcursor(x11->display, x11->window);
- if (f_gc)
+ if (x11->f_gc)
{
- XFreeGC(mDisplay, f_gc);
- f_gc = NULL;
+ XFreeGC(vo->x11->display, x11->f_gc);
+ x11->f_gc = NULL;
}
#ifdef CONFIG_GUI
/* destroy window only if it's not controlled by the GUI */
if (!use_gui)
#endif
{
- if (vo_gc)
+ if (x11->vo_gc)
{
- XSetBackground(mDisplay, vo_gc, 0);
- XFreeGC(mDisplay, vo_gc);
- vo_gc = NULL;
+ XSetBackground(vo->x11->display, x11->vo_gc, 0);
+ XFreeGC(vo->x11->display, x11->vo_gc);
+ x11->vo_gc = NULL;
}
- if (vo_window != None)
+ if (x11->window != None)
{
- XClearWindow(mDisplay, vo_window);
+ XClearWindow(x11->display, x11->window);
if (WinID < 0)
{
XEvent xev;
- XUnmapWindow(mDisplay, vo_window);
- XDestroyWindow(mDisplay, vo_window);
+ XUnmapWindow(x11->display, x11->window);
+ XDestroyWindow(x11->display, x11->window);
do
{
- XNextEvent(mDisplay, &xev);
+ XNextEvent(x11->display, &xev);
}
while (xev.type != DestroyNotify
- || xev.xdestroywindow.event != vo_window);
+ || xev.xdestroywindow.event != x11->window);
}
- vo_window = None;
+ x11->window = None;
}
vo_fs = 0;
- vo_old_width = vo_old_height = 0;
+ x11->vo_old_width = x11->vo_old_height = 0;
}
}
-static unsigned int mouse_timer;
-static int mouse_waiting_hide;
-
-int vo_x11_check_events(Display * mydisplay)
+int vo_x11_check_events(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
+ Display *display = vo->x11->display;
int ret = 0;
XEvent Event;
char buf[100];
KeySym keySym;
- static XComposeStatus stat;
// unsigned long vo_KeyTable[512];
- if ((vo_mouse_autohide) && mouse_waiting_hide &&
- (GetTimerMS() - mouse_timer >= 1000)) {
- vo_hidecursor(mydisplay, vo_window);
- mouse_waiting_hide = 0;
+ if ((x11->vo_mouse_autohide) && x11->mouse_waiting_hide &&
+ (GetTimerMS() - x11->mouse_timer >= 1000)) {
+ vo_hidecursor(display, x11->window);
+ x11->mouse_waiting_hide = 0;
}
- while (XPending(mydisplay))
+ while (XPending(display))
{
- XNextEvent(mydisplay, &Event);
+ XNextEvent(display, &Event);
#ifdef CONFIG_GUI
if (use_gui)
{
guiGetEvent(0, (char *) &Event);
- if (vo_window != Event.xany.window)
+ if (x11->window != Event.xany.window)
continue;
}
#endif
@@ -840,14 +807,14 @@ int vo_x11_check_events(Display * mydisplay)
ret |= VO_EVENT_EXPOSE;
break;
case ConfigureNotify:
-// if (!vo_fs && (Event.xconfigure.width == vo_screenwidth || Event.xconfigure.height == vo_screenheight)) break;
-// if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break;
- if (vo_window == None)
+// if (!vo_fs && (Event.xconfigure.width == opts->vo_screenwidth || Event.xconfigure.height == opts->vo_screenheight)) break;
+// if (vo_fs && Event.xconfigure.width != opts->vo_screenwidth && Event.xconfigure.height != opts->vo_screenheight) break;
+ if (x11->window == None)
break;
{
- int old_w = vo_dwidth, old_h = vo_dheight;
- vo_x11_update_geometry();
- if (vo_dwidth != old_w || vo_dheight != old_h)
+ int old_w = vo->dwidth, old_h = vo->dheight;
+ vo_x11_update_geometry(vo);
+ if (vo->dwidth != old_w || vo->dheight != old_h)
ret |= VO_EVENT_RESIZE;
}
break;
@@ -860,14 +827,14 @@ int vo_x11_check_events(Display * mydisplay)
#endif
XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
- &stat);
+ &x11->compose_status);
#ifdef XF86XK_AudioPause
- vo_x11_putkey_ext(keySym);
+ vo_x11_putkey_ext(vo, keySym);
#endif
key =
((keySym & 0xff00) !=
0 ? ((keySym & 0x00ff) + 256) : (keySym));
- vo_x11_putkey(key);
+ vo_x11_putkey(vo, key);
ret |= VO_EVENT_KEYPRESS;
}
break;
@@ -876,22 +843,23 @@ int vo_x11_check_events(Display * mydisplay)
{
char cmd_str[40];
sprintf(cmd_str,"set_mouse_pos %i %i",Event.xmotion.x, Event.xmotion.y);
- mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
+ mp_input_queue_cmd(vo->input_ctx,
+ mp_input_parse_cmd(cmd_str));
}
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
break;
case ButtonPress:
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
#ifdef CONFIG_GUI
// Ignore mouse button 1-3 under GUI.
@@ -899,15 +867,16 @@ int vo_x11_check_events(Display * mydisplay)
&& (Event.xbutton.button <= 3))
break;
#endif
- mplayer_put_key((MOUSE_BTN0 + Event.xbutton.button -
- 1) | MP_KEY_DOWN);
+ mplayer_put_key(vo->key_fifo,
+ (MOUSE_BTN0 + Event.xbutton.button - 1)
+ | MP_KEY_DOWN);
break;
case ButtonRelease:
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
#ifdef CONFIG_GUI
// Ignore mouse button 1-3 under GUI.
@@ -915,12 +884,13 @@ int vo_x11_check_events(Display * mydisplay)
&& (Event.xbutton.button <= 3))
break;
#endif
- mplayer_put_key(MOUSE_BTN0 + Event.xbutton.button - 1);
+ mplayer_put_key(vo->key_fifo,
+ MOUSE_BTN0 + Event.xbutton.button - 1);
break;
case PropertyNotify:
{
char *name =
- XGetAtomName(mydisplay, Event.xproperty.atom);
+ XGetAtomName(display, Event.xproperty.atom);
if (!name)
break;
@@ -931,14 +901,14 @@ int vo_x11_check_events(Display * mydisplay)
}
break;
case MapNotify:
- vo_hint.win_gravity = old_gravity;
- XSetWMNormalHints(mDisplay, vo_window, &vo_hint);
- vo_fs_flip = 0;
+ x11->vo_hint.win_gravity = x11->old_gravity;
+ XSetWMNormalHints(display, x11->window, &x11->vo_hint);
+ x11->fs_flip = 0;
break;
case ClientMessage:
- if (Event.xclient.message_type == XAWM_PROTOCOLS &&
- Event.xclient.data.l[0] == XAWM_DELETE_WINDOW)
- mplayer_put_key(KEY_CLOSE_WIN);
+ if (Event.xclient.message_type == x11->XAWM_PROTOCOLS &&
+ Event.xclient.data.l[0] == x11->XAWM_DELETE_WINDOW)
+ mplayer_put_key(vo->key_fifo, KEY_CLOSE_WIN);
break;
}
}
@@ -948,69 +918,76 @@ int vo_x11_check_events(Display * mydisplay)
/**
* \brief sets the size and position of the non-fullscreen window.
*/
-void vo_x11_nofs_sizepos(int x, int y, int width, int height)
+static void vo_x11_nofs_sizepos(struct vo *vo, int x, int y,
+ int width, int height)
{
- vo_x11_sizehint(x, y, width, height, 0);
+ struct vo_x11_state *x11 = vo->x11;
+ vo_x11_sizehint(vo, x, y, width, height, 0);
if (vo_fs) {
- vo_old_x = x;
- vo_old_y = y;
- vo_old_width = width;
- vo_old_height = height;
+ x11->vo_old_x = x;
+ x11->vo_old_y = y;
+ x11->vo_old_width = width;
+ x11->vo_old_height = height;
}
else
{
- vo_dwidth = width;
- vo_dheight = height;
- XMoveResizeWindow(mDisplay, vo_window, x, y, width, height);
+ vo->dwidth = width;
+ vo->dheight = height;
+ if (vo->opts->force_window_position)
+ XMoveResizeWindow(vo->x11->display, vo->x11->window, x, y, width,
+ height);
+ else
+ XResizeWindow(vo->x11->display, vo->x11->window, width, height);
}
}
-void vo_x11_sizehint(int x, int y, int width, int height, int max)
+void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height, int max)
{
- vo_hint.flags = 0;
+ struct vo_x11_state *x11 = vo->x11;
+ x11->vo_hint.flags = 0;
if (vo_keepaspect)
{
- vo_hint.flags |= PAspect;
- vo_hint.min_aspect.x = width;
- vo_hint.min_aspect.y = height;
- vo_hint.max_aspect.x = width;
- vo_hint.max_aspect.y = height;
+ x11->vo_hint.flags |= PAspect;
+ x11->vo_hint.min_aspect.x = width;
+ x11->vo_hint.min_aspect.y = height;
+ x11->vo_hint.max_aspect.x = width;
+ x11->vo_hint.max_aspect.y = height;
}
- vo_hint.flags |= PPosition | PSize;
- vo_hint.x = x;
- vo_hint.y = y;
- vo_hint.width = width;
- vo_hint.height = height;
+ x11->vo_hint.flags |= PPosition | PSize;
+ x11->vo_hint.x = x;
+ x11->vo_hint.y = y;
+ x11->vo_hint.width = width;
+ x11->vo_hint.height = height;
if (max)
{
- vo_hint.flags |= PMaxSize;
- vo_hint.max_width = width;
- vo_hint.max_height = height;
+ x11->vo_hint.flags |= PMaxSize;
+ x11->vo_hint.max_width = width;
+ x11->vo_hint.max_height = height;
} else
{
- vo_hint.max_width = 0;
- vo_hint.max_height = 0;
+ x11->vo_hint.max_width = 0;
+ x11->vo_hint.max_height = 0;
}
// Set minimum height/width to 4 to avoid off-by-one errors
// and because mga_vid requires a minimal size of 4 pixels.
- vo_hint.flags |= PMinSize;
- vo_hint.min_width = vo_hint.min_height = 4;
+ x11->vo_hint.flags |= PMinSize;
+ x11->vo_hint.min_width = x11->vo_hint.min_height = 4;
// Set the base size. A window manager might display the window
// size to the user relative to this.
// Setting these to width/height might be nice, but e.g. fluxbox can't handle it.
- vo_hint.flags |= PBaseSize;
- vo_hint.base_width = 0 /*width*/;
- vo_hint.base_height = 0 /*height*/;
+ x11->vo_hint.flags |= PBaseSize;
+ x11->vo_hint.base_width = 0 /*width*/;
+ x11->vo_hint.base_height = 0 /*height*/;
- vo_hint.flags |= PWinGravity;
- vo_hint.win_gravity = StaticGravity;
- XSetWMNormalHints(mDisplay, vo_window, &vo_hint);
+ x11->vo_hint.flags |= PWinGravity;
+ x11->vo_hint.win_gravity = StaticGravity;
+ XSetWMNormalHints(x11->display, x11->window, &x11->vo_hint);
}
-static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
+static int vo_x11_get_gnome_layer(struct vo_x11_state *x11, Window win)
{
Atom type;
int format;
@@ -1018,7 +995,7 @@ static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
unsigned long bytesafter;
unsigned short *args = NULL;
- if (XGetWindowProperty(mDisplay, win, XA_WIN_LAYER, 0, 16384,
+ if (XGetWindowProperty(x11->display, win, x11->XA_WIN_LAYER, 0, 16384,
False, AnyPropertyType, &type, &format, &nitems,
&bytesafter,
(unsigned char **) &args) == Success
@@ -1032,7 +1009,7 @@ static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
}
//
-Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
+static Window vo_x11_create_smooth_window(struct vo_x11_state *x11, Window mRoot,
Visual * vis, int x, int y,
unsigned int width, unsigned int height,
int depth, Colormap col_map)
@@ -1052,12 +1029,12 @@ Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
xswa.bit_gravity = StaticGravity;
ret_win =
- XCreateWindow(mDisplay, mRootWin, x, y, width, height, 0, depth,
+ XCreateWindow(x11->display, x11->rootwin, x, y, width, height, 0, depth,
CopyFromParent, vis, xswamask, &xswa);
- XSetWMProtocols(mDisplay, ret_win, &XAWM_DELETE_WINDOW, 1);
- if (!f_gc)
- f_gc = XCreateGC(mDisplay, ret_win, 0, 0);
- XSetForeground(mDisplay, f_gc, 0);
+ XSetWMProtocols(x11->display, ret_win, &x11->XAWM_DELETE_WINDOW, 1);
+ if (!x11->f_gc)
+ x11->f_gc = XCreateGC(x11->display, ret_win, 0, 0);
+ XSetForeground(x11->display, x11->f_gc, 0);
return ret_win;
}
@@ -1078,171 +1055,180 @@ Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
* This also does the grunt-work like setting Window Manager hints etc.
* If vo_window is already set it just moves and resizes it.
*/
-void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
+void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
unsigned int width, unsigned int height, int flags,
Colormap col_map,
const char *classname, const char *title)
{
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
+ Display *mDisplay = vo->x11->display;
XGCValues xgcv;
if (WinID >= 0) {
- vo_window = WinID ? (Window)WinID : mRootWin;
+ x11->window = WinID ? (Window)WinID : x11->rootwin;
if (col_map != CopyFromParent) {
unsigned long xswamask = CWColormap;
XSetWindowAttributes xswa;
xswa.colormap = col_map;
- XUnmapWindow(mDisplay, vo_window);
- XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
- XMapWindow(mDisplay, vo_window);
+ XUnmapWindow(mDisplay, x11->window);
+ XChangeWindowAttributes(mDisplay, x11->window, xswamask, &xswa);
+ XMapWindow(mDisplay, x11->window);
}
- if (WinID) vo_x11_update_geometry();
- vo_x11_selectinput_witherr(mDisplay, vo_window,
+ if (WinID) vo_x11_update_geometry(vo);
+ vo_x11_selectinput_witherr(mDisplay, x11->window,
StructureNotifyMask | KeyPressMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | ExposureMask);
goto final;
}
- if (vo_window == None) {
+ if (x11->window == None) {
XSizeHints hint;
XEvent xev;
vo_fs = 0;
- vo_dwidth = width;
- vo_dheight = height;
- vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vis->visual,
+ vo->dwidth = width;
+ vo->dheight = height;
+ x11->window = vo_x11_create_smooth_window(x11, x11->rootwin, vis->visual,
x, y, width, height, vis->depth, col_map);
- vo_x11_classhint(mDisplay, vo_window, classname);
- XStoreName(mDisplay, vo_window, title);
- vo_hidecursor(mDisplay, vo_window);
- XSelectInput(mDisplay, vo_window, StructureNotifyMask);
+ vo_x11_classhint(vo, x11->window, classname);
+ XStoreName(mDisplay, x11->window, title);
+ vo_hidecursor(mDisplay, x11->window);
+ XSelectInput(mDisplay, x11->window, StructureNotifyMask);
hint.x = x; hint.y = y;
hint.width = width; hint.height = height;
hint.flags = PPosition | PSize;
- XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
- vo_x11_sizehint(x, y, width, height, 0);
- if (!vo_border) vo_x11_decoration(mDisplay, vo_window, 0);
+ XSetStandardProperties(mDisplay, x11->window, title, title, None, NULL, 0, &hint);
+ vo_x11_sizehint(vo, x, y, width, height, 0);
+ if (!vo_border) vo_x11_decoration(vo, 0);
// map window
- XMapWindow(mDisplay, vo_window);
- XClearWindow(mDisplay, vo_window);
+ XMapWindow(mDisplay, x11->window);
+ XClearWindow(mDisplay, x11->window);
// wait for map
do {
XNextEvent(mDisplay, &xev);
- } while (xev.type != MapNotify || xev.xmap.event != vo_window);
- XSelectInput(mDisplay, vo_window, NoEventMask);
+ } while (xev.type != MapNotify || xev.xmap.event != x11->window);
+ XSelectInput(mDisplay, x11->window, NoEventMask);
XSync(mDisplay, False);
- vo_x11_selectinput_witherr(mDisplay, vo_window,
+ vo_x11_selectinput_witherr(mDisplay, x11->window,
StructureNotifyMask | KeyPressMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | ExposureMask);
}
- if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
- vo_x11_nofs_sizepos(vo_dx, vo_dy, width, height);
+ if (opts->vo_ontop) vo_x11_setlayer(vo, x11->window, opts->vo_ontop);
+ vo_x11_nofs_sizepos(vo, vo->dx, vo->dy, width, height);
if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
- vo_x11_fullscreen();
+ vo_x11_fullscreen(vo);
else if (vo_fs) {
// if we are already in fullscreen do not switch back and forth, just
// set the size values right.
- vo_dwidth = vo_screenwidth;
- vo_dheight = vo_screenheight;
+ vo->dwidth = vo->opts->vo_screenwidth;
+ vo->dheight = vo->opts->vo_screenheight;
}
final:
- if (vo_gc != None)
- XFreeGC(mDisplay, vo_gc);
- vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &xgcv);
+ if (x11->vo_gc != None)
+ XFreeGC(mDisplay, x11->vo_gc);
+ x11->vo_gc = XCreateGC(mDisplay, x11->window, GCForeground, &xgcv);
XSync(mDisplay, False);
- vo_mouse_autohide = 1;
+ x11->vo_mouse_autohide = 1;
}
-void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window,
+void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
int img_width, int img_height, int use_fs)
{
+ struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
+ Display *mDisplay = vo->x11->display;
int u_dheight, u_dwidth, left_ov, left_ov2;
- if (!f_gc)
+ if (!x11->f_gc)
return;
- u_dheight = use_fs ? vo_screenheight : vo_dheight;
- u_dwidth = use_fs ? vo_screenwidth : vo_dwidth;
+ u_dheight = use_fs ? opts->vo_screenheight : vo->dheight;
+ u_dwidth = use_fs ? opts->vo_screenwidth : vo->dwidth;
if ((u_dheight <= img_height) && (u_dwidth <= img_width))
return;
left_ov = (u_dheight - img_height) / 2;
left_ov2 = (u_dwidth - img_width) / 2;
- XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, u_dwidth, left_ov);
- XFillRectangle(mDisplay, vo_window, f_gc, 0, u_dheight - left_ov - 1,
+ XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, 0, u_dwidth, left_ov);
+ XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, u_dheight - left_ov - 1,
u_dwidth, left_ov + 1);
if (u_dwidth > img_width)
{
- XFillRectangle(mDisplay, vo_window, f_gc, 0, left_ov, left_ov2,
+ XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, left_ov, left_ov2,
img_height);
- XFillRectangle(mDisplay, vo_window, f_gc, u_dwidth - left_ov2 - 1,
+ XFillRectangle(mDisplay, vo_window, x11->f_gc, u_dwidth - left_ov2 - 1,
left_ov, left_ov2 + 1, img_height);
}
XFlush(mDisplay);
}
-void vo_x11_clearwindow(Display * mDisplay, Window vo_window)
+void vo_x11_clearwindow(struct vo *vo, Window vo_window)
{
- if (!f_gc)
+ struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
+ if (!x11->f_gc)
return;
- XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, vo_screenwidth,
- vo_screenheight);
+ XFillRectangle(x11->display, vo_window, x11->f_gc, 0, 0,
+ opts->vo_screenwidth, opts->vo_screenheight);
//
- XFlush(mDisplay);
+ XFlush(x11->display);
}
-void vo_x11_setlayer(Display * mDisplay, Window vo_window, int layer)
+void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer)
{
+ struct vo_x11_state *x11 = vo->x11;
if (WinID >= 0)
return;
- if (vo_fs_type & vo_wm_LAYER)
+ if (x11->fs_type & vo_wm_LAYER)
{
XClientMessageEvent xev;
- if (!orig_layer)
- orig_layer = vo_x11_get_gnome_layer(mDisplay, vo_window);
+ if (!x11->orig_layer)
+ x11->orig_layer = vo_x11_get_gnome_layer(x11, vo_window);
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
- xev.display = mDisplay;
+ xev.display = x11->display;
xev.window = vo_window;
- xev.message_type = XA_WIN_LAYER;
+ xev.message_type = x11->XA_WIN_LAYER;
xev.format = 32;
- xev.data.l[0] = layer ? fs_layer : orig_layer; // if not fullscreen, stay on default layer
+ xev.data.l[0] = layer ? fs_layer : x11->orig_layer; // if not fullscreen, stay on default layer
xev.data.l[1] = CurrentTime;
mp_msg(MSGT_VO, MSGL_V,
"[x11] Layered style stay on top (layer %ld).\n",
xev.data.l[0]);
- XSendEvent(mDisplay, mRootWin, False, SubstructureNotifyMask,
+ XSendEvent(x11->display, x11->rootwin, False, SubstructureNotifyMask,
(XEvent *) & xev);
- } else if (vo_fs_type & vo_wm_NETWM)
+ } else if (x11->fs_type & vo_wm_NETWM)
{
XClientMessageEvent xev;
char *state;
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
- xev.message_type = XA_NET_WM_STATE;
- xev.display = mDisplay;
+ xev.message_type = x11->XA_NET_WM_STATE;
+ xev.display = x11->display;
xev.window = vo_window;
xev.format = 32;
xev.data.l[0] = layer;
- if (vo_fs_type & vo_wm_STAYS_ON_TOP)
- xev.data.l[1] = XA_NET_WM_STATE_STAYS_ON_TOP;
- else if (vo_fs_type & vo_wm_ABOVE)
- xev.data.l[1] = XA_NET_WM_STATE_ABOVE;
- else if (vo_fs_type & vo_wm_FULLSCREEN)
- xev.data.l[1] = XA_NET_WM_STATE_FULLSCREEN;
- else if (vo_fs_type & vo_wm_BELOW)
+ if (x11->fs_type & vo_wm_STAYS_ON_TOP)
+ xev.data.l[1] = x11->XA_NET_WM_STATE_STAYS_ON_TOP;
+ else if (x11->fs_type & vo_wm_ABOVE)
+ xev.data.l[1] = x11->XA_NET_WM_STATE_ABOVE;
+ else if (x11->fs_type & vo_wm_FULLSCREEN)
+ xev.data.l[1] = x11->XA_NET_WM_STATE_FULLSCREEN;
+ else if (x11->fs_type & vo_wm_BELOW)
// This is not fallback. We can safely assume that the situation
// where only NETWM_STATE_BELOW is supported doesn't exist.
- xev.data.l[1] = XA_NET_WM_STATE_BELOW;
+ xev.data.l[1] = x11->XA_NET_WM_STATE_BELOW;
- XSendEvent(mDisplay, mRootWin, False, SubstructureRedirectMask,
+ XSendEvent(x11->display, x11->rootwin, False, SubstructureRedirectMask,
(XEvent *) & xev);
- state = XGetAtomName(mDisplay, xev.data.l[1]);
+ state = XGetAtomName(x11->display, xev.data.l[1]);
mp_msg(MSGT_VO, MSGL_V,
"[x11] NET style stay on top (layer %d). Using state %s.\n",
layer, state);
@@ -1323,107 +1309,115 @@ static int vo_x11_get_fs_type(int supported)
}
/**
- * \brief update vo_dx, vo_dy, vo_dwidth and vo_dheight with current values of vo_window
- * \return returns current color depth of vo_window
+ * \brief update vo->dx, vo->dy, vo->dwidth and vo->dheight with current values of vo->x11->window
+ * \return returns current color depth of vo->x11->window
*/
-int vo_x11_update_geometry(void) {
+int vo_x11_update_geometry(struct vo *vo)
+{
+ struct vo_x11_state *x11 = vo->x11;
unsigned depth, w, h;
int dummy_int;
Window dummy_win;
- XGetGeometry(mDisplay, vo_window, &dummy_win, &dummy_int, &dummy_int,
+ XGetGeometry(x11->display, x11->window, &dummy_win, &dummy_int, &dummy_int,
&w, &h, &dummy_int, &depth);
- if (w <= INT_MAX && h <= INT_MAX) { vo_dwidth = w; vo_dheight = h; }
- XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy,
- &dummy_win);
+ if (w <= INT_MAX && h <= INT_MAX) {
+ vo->dwidth = w;
+ vo->dheight = h;
+ }
+ XTranslateCoordinates(x11->display, x11->window, x11->rootwin, 0, 0,
+ &vo->dx, &vo->dy, &dummy_win);
return depth <= INT_MAX ? depth : 0;
}
-void vo_x11_fullscreen(void)
+void vo_x11_fullscreen(struct vo *vo)
{
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
int x, y, w, h;
- if (WinID >= 0 || vo_fs_flip)
+ if (WinID >= 0 || x11->fs_flip)
return;
if (vo_fs)
{
// fs->win
- if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
+ if ( ! (x11->fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
{
- x = vo_old_x;
- y = vo_old_y;
- w = vo_old_width;
- h = vo_old_height;
+ x = x11->vo_old_x;
+ y = x11->vo_old_y;
+ w = x11->vo_old_width;
+ h = x11->vo_old_height;
}
- vo_x11_ewmh_fullscreen(_NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
+ vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
vo_fs = VO_FALSE;
} else
{
// win->fs
- vo_x11_ewmh_fullscreen(_NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
+ vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
vo_fs = VO_TRUE;
- if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
+ if ( ! (x11->fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
{
- vo_old_x = vo_dx;
- vo_old_y = vo_dy;
- vo_old_width = vo_dwidth;
- vo_old_height = vo_dheight;
+ x11->vo_old_x = vo->dx;
+ x11->vo_old_y = vo->dy;
+ x11->vo_old_width = vo->dwidth;
+ x11->vo_old_height = vo->dheight;
}
- update_xinerama_info();
+ update_xinerama_info(vo);
x = xinerama_x;
y = xinerama_y;
- w = vo_screenwidth;
- h = vo_screenheight;
+ w = opts->vo_screenwidth;
+ h = opts->vo_screenheight;
}
{
long dummy;
- XGetWMNormalHints(mDisplay, vo_window, &vo_hint, &dummy);
- if (!(vo_hint.flags & PWinGravity))
- old_gravity = NorthWestGravity;
+ XGetWMNormalHints(x11->display, x11->window, &x11->vo_hint, &dummy);
+ if (!(x11->vo_hint.flags & PWinGravity))
+ x11->old_gravity = NorthWestGravity;
else
- old_gravity = vo_hint.win_gravity;
+ x11->old_gravity = x11->vo_hint.win_gravity;
}
- if (vo_wm_type == 0 && !(vo_fsmode & 16))
+ if (x11->wm_type == 0 && !(vo_fsmode & 16))
{
- XUnmapWindow(mDisplay, vo_window); // required for MWM
- XWithdrawWindow(mDisplay, vo_window, mScreen);
- vo_fs_flip = 1;
+ XUnmapWindow(x11->display, x11->window); // required for MWM
+ XWithdrawWindow(x11->display, x11->window, x11->screen);
+ x11->fs_flip = 1;
}
- if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
+ if ( ! (x11->fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
{
- vo_x11_decoration(mDisplay, vo_window, vo_border && !vo_fs);
- vo_x11_sizehint(x, y, w, h, 0);
- vo_x11_setlayer(mDisplay, vo_window, vo_fs);
+ vo_x11_decoration(vo, vo_border && !vo_fs);
+ vo_x11_sizehint(vo, x, y, w, h, 0);
+ vo_x11_setlayer(vo, x11->window, vo_fs);
- XMoveResizeWindow(mDisplay, vo_window, x, y, w, h);
+ XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
}
/* some WMs lose ontop after fullscreen */
- if ((!(vo_fs)) & vo_ontop)
- vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
-
- XMapRaised(mDisplay, vo_window);
- if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // some WMs change window pos on map
- XMoveResizeWindow(mDisplay, vo_window, x, y, w, h);
- XRaiseWindow(mDisplay, vo_window);
- XFlush(mDisplay);
+ if ((!(vo_fs)) & opts->vo_ontop)
+ vo_x11_setlayer(vo, x11->window, opts->vo_ontop);
+
+ XMapRaised(x11->display, x11->window);
+ if ( ! (x11->fs_type & vo_wm_FULLSCREEN) ) // some WMs change window pos on map
+ XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
+ XRaiseWindow(x11->display, x11->window);
+ XFlush(x11->display);
}
-void vo_x11_ontop(void)
+void vo_x11_ontop(struct vo *vo)
{
- vo_ontop = (!(vo_ontop));
+ struct MPOpts *opts = vo->opts;
+ opts->vo_ontop = !opts->vo_ontop;
- vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
+ vo_x11_setlayer(vo, vo->x11->window, opts->vo_ontop);
}
-void vo_x11_border(void)
+void vo_x11_border(struct vo *vo)
{
vo_border = !vo_border;
- vo_x11_decoration(mDisplay, vo_window, vo_border && !vo_fs);
+ vo_x11_decoration(vo, vo_border && !vo_fs);
}
/*
@@ -1433,19 +1427,19 @@ void vo_x11_border(void)
static int screensaver_off;
static unsigned int time_last;
-void xscreensaver_heartbeat(void)
+void xscreensaver_heartbeat(struct vo_x11_state *x11)
{
unsigned int time = GetTimerMS();
- if (mDisplay && screensaver_off && (time - time_last) > 30000)
+ if (x11->display && screensaver_off && (time - time_last) > 30000)
{
time_last = time;
- XResetScreenSaver(mDisplay);
+ XResetScreenSaver(x11->display);
}
}
-static int xss_suspend(Bool suspend)
+static int xss_suspend(Display *mDisplay, Bool suspend)
{
#ifndef CONFIG_XSS
return 0;
@@ -1465,13 +1459,13 @@ static int xss_suspend(Bool suspend)
* End of XScreensaver stuff
*/
-void saver_on(Display * mDisplay)
+static void saver_on(Display * mDisplay)
{
if (!screensaver_off)
return;
screensaver_off = 0;
- if (xss_suspend(False))
+ if (xss_suspend(mDisplay, False))
return;
#ifdef CONFIG_XDPMS
if (dpms_disabled)
@@ -1505,14 +1499,14 @@ void saver_on(Display * mDisplay)
#endif
}
-void saver_off(Display * mDisplay)
+static void saver_off(Display * mDisplay)
{
int nothing;
if (screensaver_off)
return;
screensaver_off = 1;
- if (xss_suspend(True))
+ if (xss_suspend(mDisplay, True))
return;
#ifdef CONFIG_XDPMS
if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
@@ -1587,12 +1581,15 @@ void vo_x11_selectinput_witherr(Display * display, Window w,
}
#ifdef CONFIG_XF86VM
-void vo_vm_switch(void)
+void vo_vm_switch(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
+ Display *mDisplay = x11->display;
int vm_event, vm_error;
int vm_ver, vm_rev;
int i, j, have_vm = 0;
- int X = vo_dwidth, Y = vo_dheight;
+ int X = vo->dwidth, Y = vo->dheight;
int modeline_width, modeline_height;
int modecount;
@@ -1611,7 +1608,7 @@ void vo_vm_switch(void)
if (have_vm)
{
if (vidmodes == NULL)
- XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount,
+ XF86VidModeGetAllModeLines(mDisplay, x11->screen, &modecount,
&vidmodes);
j = 0;
modeline_width = vidmodes[0]->hdisplay;
@@ -1628,28 +1625,30 @@ void vo_vm_switch(void)
j = i;
}
- mp_msg(MSGT_VO, MSGL_INFO, MSGTR_SelectedVideoMode,
+ mp_tmsg(MSGT_VO, MSGL_INFO, "XF86VM: Selected video mode %dx%d for image size %dx%d.\n",
modeline_width, modeline_height, X, Y);
- XF86VidModeLockModeSwitch(mDisplay, mScreen, 0);
- XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]);
- XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]);
+ XF86VidModeLockModeSwitch(mDisplay, x11->screen, 0);
+ XF86VidModeSwitchToMode(mDisplay, x11->screen, vidmodes[j]);
+ XF86VidModeSwitchToMode(mDisplay, x11->screen, vidmodes[j]);
// FIXME: all this is more of a hack than proper solution
- X = (vo_screenwidth - modeline_width) / 2;
- Y = (vo_screenheight - modeline_height) / 2;
- XF86VidModeSetViewPort(mDisplay, mScreen, X, Y);
- vo_dx = X;
- vo_dy = Y;
- vo_dwidth = modeline_width;
- vo_dheight = modeline_height;
- aspect_save_screenres(modeline_width, modeline_height);
+ X = (opts->vo_screenwidth - modeline_width) / 2;
+ Y = (opts->vo_screenheight - modeline_height) / 2;
+ XF86VidModeSetViewPort(mDisplay, x11->screen, X, Y);
+ vo->dx = X;
+ vo->dy = Y;
+ vo->dwidth = modeline_width;
+ vo->dheight = modeline_height;
+ aspect_save_screenres(vo, modeline_width, modeline_height);
}
}
-void vo_vm_close(void)
+void vo_vm_close(struct vo *vo)
{
+ Display *dpy = vo->x11->display;
+ struct MPOpts *opts = vo->opts;
#ifdef CONFIG_GUI
- if (vidmodes != NULL && vo_window != None)
+ if (vidmodes != NULL && vo->x11->vo_window != None)
#else
if (vidmodes != NULL)
#endif
@@ -1658,20 +1657,20 @@ void vo_vm_close(void)
free(vidmodes);
vidmodes = NULL;
- XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount,
+ XF86VidModeGetAllModeLines(dpy, vo->x11->screen, &modecount,
&vidmodes);
for (i = 0; i < modecount; i++)
- if ((vidmodes[i]->hdisplay == vo_screenwidth)
- && (vidmodes[i]->vdisplay == vo_screenheight))
+ if ((vidmodes[i]->hdisplay == opts->vo_screenwidth)
+ && (vidmodes[i]->vdisplay == opts->vo_screenheight))
{
mp_msg(MSGT_VO, MSGL_INFO,
"Returning to original mode %dx%d\n",
- vo_screenwidth, vo_screenheight);
+ opts->vo_screenwidth, opts->vo_screenheight);
break;
}
- XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[i]);
- XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[i]);
+ XF86VidModeSwitchToMode(dpy, vo->x11->screen, vidmodes[i]);
+ XF86VidModeSwitchToMode(dpy, vo->x11->screen, vidmodes[i]);
free(vidmodes);
vidmodes = NULL;
}
@@ -1739,12 +1738,13 @@ static XColor cols[256];
static int cm_size, red_mask, green_mask, blue_mask;
-Colormap vo_x11_create_colormap(XVisualInfo * vinfo)
+Colormap vo_x11_create_colormap(struct vo *vo, XVisualInfo *vinfo)
{
+ struct vo_x11_state *x11 = vo->x11;
unsigned k, r, g, b, ru, gu, bu, m, rv, gv, bv, rvu, gvu, bvu;
if (vinfo->class != DirectColor)
- return XCreateColormap(mDisplay, mRootWin, vinfo->visual,
+ return XCreateColormap(x11->display, x11->rootwin, vinfo->visual,
AllocNone);
/* can this function get called twice or more? */
@@ -1788,8 +1788,8 @@ Colormap vo_x11_create_colormap(XVisualInfo * vinfo)
gv += gvu;
bv += bvu;
}
- cmap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocAll);
- XStoreColors(mDisplay, cmap, cols, cm_size);
+ cmap = XCreateColormap(x11->display, x11->rootwin, vinfo->visual, AllocAll);
+ XStoreColors(x11->display, cmap, cols, cm_size);
return cmap;
}
@@ -1816,7 +1816,7 @@ static int transform_color(float val,
return (unsigned short) (s * 65535);
}
-uint32_t vo_x11_set_equalizer(char *name, int value)
+uint32_t vo_x11_set_equalizer(struct vo *vo, char *name, int value)
{
float gamma, brightness, contrast;
float rf, gf, bf;
@@ -1862,8 +1862,8 @@ uint32_t vo_x11_set_equalizer(char *name, int value)
cols[k].blue = transform_color(bf * k, brightness, contrast, gamma);
}
- XStoreColors(mDisplay, cmap, cols, cm_size);
- XFlush(mDisplay);
+ XStoreColors(vo->x11->display, cmap, cols, cm_size);
+ XFlush(vo->x11->display);
return VO_TRUE;
}
@@ -1883,7 +1883,7 @@ uint32_t vo_x11_get_equalizer(char *name, int *value)
}
#ifdef CONFIG_XV
-int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
+int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char *name, int value)
{
XvAttribute *attributes;
int i, howmany, xv_atom;
@@ -1891,11 +1891,11 @@ int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
mp_dbg(MSGT_VO, MSGL_V, "xv_set_eq called! (%s, %d)\n", name, value);
/* get available attributes */
- attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany);
+ attributes = XvQueryPortAttributes(vo->x11->display, xv_port, &howmany);
for (i = 0; i < howmany && attributes; i++)
if (attributes[i].flags & XvSettable)
{
- xv_atom = XInternAtom(mDisplay, attributes[i].name, True);
+ xv_atom = XInternAtom(vo->x11->display, attributes[i].name, True);
/* since we have SET_DEFAULTS first in our list, we can check if it's available
then trigger it if it's ok so that the other values are at default upon query */
if (xv_atom != None)
@@ -1946,32 +1946,32 @@ int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
port_value =
(port_value + 100) * (port_max - port_min) / 200 +
port_min;
- XvSetPortAttribute(mDisplay, xv_port, xv_atom, port_value);
+ XvSetPortAttribute(vo->x11->display, xv_port, xv_atom, port_value);
return VO_TRUE;
}
}
return VO_FALSE;
}
-int vo_xv_get_eq(uint32_t xv_port, char *name, int *value)
+int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char *name, int *value)
{
XvAttribute *attributes;
int i, howmany, xv_atom;
/* get available attributes */
- attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany);
+ attributes = XvQueryPortAttributes(vo->x11->display, xv_port, &howmany);
for (i = 0; i < howmany && attributes; i++)
if (attributes[i].flags & XvGettable)
{
- xv_atom = XInternAtom(mDisplay, attributes[i].name, True);
+ xv_atom = XInternAtom(vo->x11->display, attributes[i].name, True);
/* since we have SET_DEFAULTS first in our list, we can check if it's available
then trigger it if it's ok so that the other values are at default upon query */
if (xv_atom != None)
{
int val, port_value = 0, port_min, port_max;
- XvGetPortAttribute(mDisplay, xv_port, xv_atom,
+ XvGetPortAttribute(vo->x11->display, xv_port, xv_atom,
&port_value);
port_min = attributes[i].min_value;
@@ -2019,11 +2019,6 @@ int vo_xv_get_eq(uint32_t xv_port, char *name, int *value)
return VO_FALSE;
}
-/** \brief contains flags changing the execution of the colorkeying code */
-xv_ck_info_t xv_ck_info = { CK_METHOD_MANUALFILL, CK_SRC_CUR };
-unsigned long xv_colorkey; ///< The color used for manual colorkeying.
-unsigned int xv_port; ///< The selected Xv port.
-
/**
* \brief Interns the requested atom if it is available.
*
@@ -2032,20 +2027,21 @@ unsigned int xv_port; ///< The selected Xv port.
* \return Returns the atom if available, else None is returned.
*
*/
-static Atom xv_intern_atom_if_exists( char const * atom_name )
+static Atom xv_intern_atom_if_exists(struct vo_x11_state *x11,
+ char const *atom_name)
{
XvAttribute * attributes;
int attrib_count,i;
Atom xv_atom = None;
- attributes = XvQueryPortAttributes( mDisplay, xv_port, &attrib_count );
+ attributes = XvQueryPortAttributes(x11->display, x11->xv_port, &attrib_count );
if( attributes!=NULL )
{
for ( i = 0; i < attrib_count; ++i )
{
if ( strcmp(attributes[i].name, atom_name ) == 0 )
{
- xv_atom = XInternAtom( mDisplay, atom_name, False );
+ xv_atom = XInternAtom(x11->display, atom_name, False );
break; // found what we want, break out
}
}
@@ -2059,12 +2055,13 @@ static Atom xv_intern_atom_if_exists( char const * atom_name )
* \brief Try to enable vsync for xv.
* \return Returns -1 if not available, 0 on failure and 1 on success.
*/
-int vo_xv_enable_vsync(void)
+int vo_xv_enable_vsync(struct vo *vo)
{
- Atom xv_atom = xv_intern_atom_if_exists("XV_SYNC_TO_VBLANK");
+ struct vo_x11_state *x11 = vo->x11;
+ Atom xv_atom = xv_intern_atom_if_exists(x11, "XV_SYNC_TO_VBLANK");
if (xv_atom == None)
return -1;
- return XvSetPortAttribute(mDisplay, xv_port, xv_atom, 1) == Success;
+ return XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 1) == Success;
}
/**
@@ -2078,13 +2075,14 @@ int vo_xv_enable_vsync(void)
* \param height [out] The maximum height gets stored here.
*
*/
-void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height )
+void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height)
{
+ struct vo_x11_state *x11 = vo->x11;
XvEncodingInfo * encodings;
//unsigned long num_encodings, idx; to int or too long?!
unsigned int num_encodings, idx;
- XvQueryEncodings( mDisplay, xv_port, &num_encodings, &encodings);
+ XvQueryEncodings(x11->display, x11->xv_port, &num_encodings, &encodings);
if ( encodings )
{
@@ -2115,11 +2113,11 @@ void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height )
* Outputs the content of |ck_handling| as a readable message.
*
*/
-void vo_xv_print_ck_info(void)
+static void vo_xv_print_ck_info(struct vo_x11_state *x11)
{
mp_msg( MSGT_VO, MSGL_V, "[xv common] " );
- switch ( xv_ck_info.method )
+ switch ( x11->xv_ck_info.method )
{
case CK_METHOD_NONE:
mp_msg( MSGT_VO, MSGL_V, "Drawing no colorkey.\n" ); return;
@@ -2133,32 +2131,32 @@ void vo_xv_print_ck_info(void)
mp_msg( MSGT_VO, MSGL_V, "\n[xv common] " );
- switch ( xv_ck_info.source )
+ switch ( x11->xv_ck_info.source )
{
case CK_SRC_CUR:
mp_msg( MSGT_VO, MSGL_V, "Using colorkey from Xv (0x%06lx).\n",
- xv_colorkey );
+ x11->xv_colorkey );
break;
case CK_SRC_USE:
- if ( xv_ck_info.method == CK_METHOD_AUTOPAINT )
+ if ( x11->xv_ck_info.method == CK_METHOD_AUTOPAINT )
{
mp_msg( MSGT_VO, MSGL_V,
"Ignoring colorkey from MPlayer (0x%06lx).\n",
- xv_colorkey );
+ x11->xv_colorkey );
}
else
{
mp_msg( MSGT_VO, MSGL_V,
"Using colorkey from MPlayer (0x%06lx)."
" Use -colorkey to change.\n",
- xv_colorkey );
+ x11->xv_colorkey );
}
break;
case CK_SRC_SET:
mp_msg( MSGT_VO, MSGL_V,
"Setting and using colorkey from MPlayer (0x%06lx)."
" Use -colorkey to change.\n",
- xv_colorkey );
+ x11->xv_colorkey );
break;
}
}
@@ -2183,28 +2181,29 @@ void vo_xv_print_ck_info(void)
* NOTE: If vo_colorkey has bits set after the first 3 low order bytes
* we don't draw anything as this means it was forced to off.
*/
-int vo_xv_init_colorkey(void)
+int vo_xv_init_colorkey(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
Atom xv_atom;
int rez;
/* check if colorkeying is needed */
- xv_atom = xv_intern_atom_if_exists( "XV_COLORKEY" );
+ xv_atom = xv_intern_atom_if_exists(vo->x11, "XV_COLORKEY");
/* if we have to deal with colorkeying ... */
if( xv_atom != None && !(vo_colorkey & 0xFF000000) )
{
/* check if we should use the colorkey specified in vo_colorkey */
- if ( xv_ck_info.source != CK_SRC_CUR )
+ if ( x11->xv_ck_info.source != CK_SRC_CUR )
{
- xv_colorkey = vo_colorkey;
+ x11->xv_colorkey = vo_colorkey;
/* check if we have to set the colorkey too */
- if ( xv_ck_info.source == CK_SRC_SET )
+ if ( x11->xv_ck_info.source == CK_SRC_SET )
{
- xv_atom = XInternAtom(mDisplay, "XV_COLORKEY",False);
+ xv_atom = XInternAtom(x11->display, "XV_COLORKEY",False);
- rez = XvSetPortAttribute( mDisplay, xv_port, xv_atom, vo_colorkey );
+ rez = XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, vo_colorkey);
if ( rez != Success )
{
mp_msg( MSGT_VO, MSGL_FATAL,
@@ -2217,10 +2216,10 @@ int vo_xv_init_colorkey(void)
{
int colorkey_ret;
- rez=XvGetPortAttribute(mDisplay,xv_port, xv_atom, &colorkey_ret);
+ rez=XvGetPortAttribute(x11->display,x11->xv_port, xv_atom, &colorkey_ret);
if ( rez == Success )
{
- xv_colorkey = colorkey_ret;
+ x11->xv_colorkey = colorkey_ret;
}
else
{
@@ -2231,39 +2230,39 @@ int vo_xv_init_colorkey(void)
}
}
- xv_atom = xv_intern_atom_if_exists( "XV_AUTOPAINT_COLORKEY" );
+ xv_atom = xv_intern_atom_if_exists(vo->x11, "XV_AUTOPAINT_COLORKEY");
/* should we draw the colorkey ourselves or activate autopainting? */
- if ( xv_ck_info.method == CK_METHOD_AUTOPAINT )
+ if ( x11->xv_ck_info.method == CK_METHOD_AUTOPAINT )
{
rez = !Success; // reset rez to something different than Success
if ( xv_atom != None ) // autopaint is supported
{
- rez = XvSetPortAttribute( mDisplay, xv_port, xv_atom, 1 );
+ rez = XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 1);
}
if ( rez != Success )
{
// fallback to manual colorkey drawing
- xv_ck_info.method = CK_METHOD_MANUALFILL;
+ x11->xv_ck_info.method = CK_METHOD_MANUALFILL;
}
}
else // disable colorkey autopainting if supported
{
if ( xv_atom != None ) // we have autopaint attribute
{
- XvSetPortAttribute( mDisplay, xv_port, xv_atom, 0 );
+ XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 0);
}
}
}
else // do no colorkey drawing at all
{
- xv_ck_info.method = CK_METHOD_NONE;
+ x11->xv_ck_info.method = CK_METHOD_NONE;
} /* end: should we draw colorkey */
/* output information about the current colorkey settings */
- vo_xv_print_ck_info();
+ vo_xv_print_ck_info(x11);
return 1; // success
}
@@ -2278,14 +2277,16 @@ int vo_xv_init_colorkey(void)
* It doesn't call XFlush.
*
*/
-void vo_xv_draw_colorkey( int32_t x, int32_t y,
- int32_t w, int32_t h )
+void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y,
+ int32_t w, int32_t h)
{
- if( xv_ck_info.method == CK_METHOD_MANUALFILL ||
- xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow()
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
+ if( x11->xv_ck_info.method == CK_METHOD_MANUALFILL ||
+ x11->xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow()
{
- XSetForeground( mDisplay, vo_gc, xv_colorkey );
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ XSetForeground(x11->display, x11->vo_gc, x11->xv_colorkey );
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
x, y,
w, h );
}
@@ -2294,24 +2295,24 @@ void vo_xv_draw_colorkey( int32_t x, int32_t y,
/* TODO! move this to vo_x11_clearwindow_part() */
if ( vo_fs )
{
- XSetForeground( mDisplay, vo_gc, 0 );
+ XSetForeground(x11->display, x11->vo_gc, 0 );
/* making non-overlap fills, requires 8 checks instead of 4 */
if ( y > 0 )
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
0, 0,
- vo_screenwidth, y);
+ opts->vo_screenwidth, y);
if (x > 0)
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
0, 0,
- x, vo_screenheight);
- if (x + w < vo_screenwidth)
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ x, opts->vo_screenheight);
+ if (x + w < opts->vo_screenwidth)
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
x + w, 0,
- vo_screenwidth, vo_screenheight);
- if (y + h < vo_screenheight)
- XFillRectangle( mDisplay, vo_window, vo_gc,
+ opts->vo_screenwidth, opts->vo_screenheight);
+ if (y + h < opts->vo_screenheight)
+ XFillRectangle(x11->display, x11->window, x11->vo_gc,
0, y + h,
- vo_screenwidth, vo_screenheight);
+ opts->vo_screenwidth, opts->vo_screenheight);
}
}
@@ -2356,19 +2357,20 @@ int xv_test_ckm( void * arg )
* \param str Pointer to the string or NULL
*
*/
-void xv_setup_colorkeyhandling( char const * ck_method_str,
- char const * ck_str )
+void xv_setup_colorkeyhandling(struct vo *vo, const char *ck_method_str,
+ const char *ck_str)
{
+ struct vo_x11_state *x11 = vo->x11;
/* check if a valid pointer to the string was passed */
if ( ck_str )
{
if ( strncmp( ck_str, "use", 3 ) == 0 )
{
- xv_ck_info.source = CK_SRC_USE;
+ x11->xv_ck_info.source = CK_SRC_USE;
}
else if ( strncmp( ck_str, "set", 3 ) == 0 )
{
- xv_ck_info.source = CK_SRC_SET;
+ x11->xv_ck_info.source = CK_SRC_SET;
}
}
/* check if a valid pointer to the string was passed */
@@ -2376,17 +2378,30 @@ void xv_setup_colorkeyhandling( char const * ck_method_str,
{
if ( strncmp( ck_method_str, "bg", 2 ) == 0 )
{
- xv_ck_info.method = CK_METHOD_BACKGROUND;
+ x11->xv_ck_info.method = CK_METHOD_BACKGROUND;
}
else if ( strncmp( ck_method_str, "man", 3 ) == 0 )
{
- xv_ck_info.method = CK_METHOD_MANUALFILL;
+ x11->xv_ck_info.method = CK_METHOD_MANUALFILL;
}
else if ( strncmp( ck_method_str, "auto", 4 ) == 0 )
{
- xv_ck_info.method = CK_METHOD_AUTOPAINT;
+ x11->xv_ck_info.method = CK_METHOD_AUTOPAINT;
}
}
}
#endif
+
+struct vo_x11_state *vo_x11_init_state(void)
+{
+ struct vo_x11_state *s = talloc_ptrtype(NULL, s);
+ *s = (struct vo_x11_state){
+ .xv_ck_info = { CK_METHOD_MANUALFILL, CK_SRC_CUR },
+ .olddecor = MWM_DECOR_ALL,
+ .oldfuncs = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE |
+ MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE,
+ .old_gravity = NorthWestGravity,
+ };
+ return s;
+}
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index c7221d2577..a610f813bb 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -24,6 +24,60 @@
#include "config.h"
+struct vo;
+
+struct vo_x11_state {
+ Display *display;
+ Window window;
+ Window rootwin;
+ int screen;
+ int display_is_local;
+ int depthonscreen;
+
+ GC vo_gc;
+
+ struct xv_ck_info_s {
+ int method; ///< CK_METHOD_* constants
+ int source; ///< CK_SRC_* constants
+ } xv_ck_info;
+ unsigned long xv_colorkey;
+ unsigned int xv_port;
+
+ int vo_mouse_autohide;
+ int wm_type;
+ int fs_type;
+ int fs_flip;
+
+ GC f_gc;
+ XSizeHints vo_hint;
+ unsigned int mouse_timer;
+ int mouse_waiting_hide;
+ int orig_layer;
+ int old_gravity;
+ int vo_old_x;
+ int vo_old_y;
+ int vo_old_width;
+ int vo_old_height;
+
+
+ unsigned int olddecor;
+ unsigned int oldfuncs;
+ XComposeStatus compose_status;
+
+ Atom XA_NET_SUPPORTED;
+ Atom XA_NET_WM_STATE;
+ Atom XA_NET_WM_STATE_FULLSCREEN;
+ Atom XA_NET_WM_STATE_ABOVE;
+ Atom XA_NET_WM_STATE_STAYS_ON_TOP;
+ Atom XA_NET_WM_STATE_BELOW;
+ Atom XA_NET_WM_PID;
+ Atom XA_WIN_PROTOCOLS;
+ Atom XA_WIN_LAYER;
+ Atom XA_WIN_HINTS;
+ Atom XAWM_PROTOCOLS;
+ Atom XAWM_DELETE_WINDOW;
+};
+
#if defined(CONFIG_GL) || defined(CONFIG_X11) || defined(CONFIG_XV)
#define X11_FULLSCREEN 1
#endif
@@ -51,67 +105,43 @@ extern int vo_fs_type;
extern char** vo_fstype_list;
extern char *mDisplayName;
-extern Display *mDisplay;
-extern Window mRootWin;
-extern int mScreen;
-extern int mLocalDisplay;
-
-extern int vo_mouse_autohide;
-
-int vo_init( void );
-void vo_uninit( void );
-void vo_hidecursor ( Display* , Window );
-void vo_showcursor( Display *disp, Window win );
-void vo_x11_decoration( Display * vo_Display,Window w,int d );
-void vo_x11_classhint( Display * display,Window window,char *name );
-void vo_x11_nofs_sizepos(int x, int y, int width, int height);
-void vo_x11_sizehint( int x, int y, int width, int height, int max );
-int vo_x11_check_events(Display *mydisplay);
+
+struct vo_x11_state *vo_x11_init_state(void);
+int vo_init(struct vo *vo);
+void vo_uninit(struct vo_x11_state *x11);
+void vo_x11_decoration(struct vo *vo, int d );
+void vo_x11_classhint(struct vo *vo, Window window, char *name);
+void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height, int max);
+int vo_x11_check_events(struct vo *vo);
void vo_x11_selectinput_witherr(Display *display, Window w, long event_mask);
-int vo_x11_update_geometry(void);
-void vo_x11_fullscreen( void );
-void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer );
-void vo_x11_uninit(void);
-Colormap vo_x11_create_colormap(XVisualInfo *vinfo);
-uint32_t vo_x11_set_equalizer(char *name, int value);
+void vo_x11_fullscreen(struct vo *vo);
+int vo_x11_update_geometry(struct vo *vo);
+void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer);
+void vo_x11_uninit(struct vo *vo);
+Colormap vo_x11_create_colormap(struct vo *vo, XVisualInfo *vinfo);
+uint32_t vo_x11_set_equalizer(struct vo *vo, char *name, int value);
uint32_t vo_x11_get_equalizer(char *name, int *value);
void fstype_help(void);
-Window vo_x11_create_smooth_window( Display *mDisplay, Window mRoot,
- Visual *vis, int x, int y, unsigned int width, unsigned int height,
- int depth, Colormap col_map);
-void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
- unsigned int width, unsigned int height, int flags,
+void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
+ int x, int y, unsigned int width, unsigned int height, int flags,
Colormap col_map, const char *classname, const char *title);
-void vo_x11_clearwindow_part(Display *mDisplay, Window vo_window,
+void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
int img_width, int img_height, int use_fs);
-void vo_x11_clearwindow( Display *mDisplay, Window vo_window );
-void vo_x11_ontop(void);
-void vo_x11_border(void);
-void vo_x11_ewmh_fullscreen( int action );
+void vo_x11_clearwindow(struct vo *vo, Window vo_window);
+void vo_x11_ontop(struct vo *vo);
+void vo_x11_border(struct vo *vo);
+void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action);
#endif
-extern Window vo_window;
-extern GC vo_gc;
-extern XSizeHints vo_hint;
-
-#ifdef CONFIG_XV
-//XvPortID xv_port;
-extern unsigned int xv_port;
-
-int vo_xv_set_eq(uint32_t xv_port, char * name, int value);
-int vo_xv_get_eq(uint32_t xv_port, char * name, int *value);
+int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char * name, int value);
+int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char * name, int *value);
-int vo_xv_enable_vsync(void);
+int vo_xv_enable_vsync(struct vo *vo);
-void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height );
+void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height);
/*** colorkey handling ***/
-typedef struct xv_ck_info_s
-{
- int method; ///< CK_METHOD_* constants
- int source; ///< CK_SRC_* constants
-} xv_ck_info_t;
#define CK_METHOD_NONE 0 ///< no colorkey drawing
#define CK_METHOD_BACKGROUND 1 ///< set colorkey as window background
@@ -121,31 +151,66 @@ typedef struct xv_ck_info_s
#define CK_SRC_SET 1 ///< use and set specified / default colorkey
#define CK_SRC_CUR 2 ///< use current colorkey ( get it from xv )
-extern xv_ck_info_t xv_ck_info;
-extern unsigned long xv_colorkey;
-
-int vo_xv_init_colorkey(void);
-void vo_xv_draw_colorkey(int32_t x, int32_t y, int32_t w, int32_t h);
-void xv_setup_colorkeyhandling(char const * ck_method_str, char const * ck_str);
+int vo_xv_init_colorkey(struct vo *vo);
+void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y, int32_t w, int32_t h);
+void xv_setup_colorkeyhandling(struct vo *vo, const char *ck_method_str, const char *ck_str);
/*** test functions for common suboptions ***/
int xv_test_ck( void * arg );
int xv_test_ckm( void * arg );
-#endif
-void vo_setwindow( Window w,GC g );
-void vo_x11_putkey(int key);
-
-void saver_off( Display * );
-void saver_on( Display * );
+void vo_x11_putkey(struct vo *vo, int key);
#ifdef CONFIG_XF86VM
-void vo_vm_switch(void);
-void vo_vm_close(void);
+void vo_vm_switch(struct vo *vo);
+void vo_vm_close(struct vo *vo);
#endif
-void update_xinerama_info(void);
+void update_xinerama_info(struct vo *vo);
int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return);
+void xscreensaver_heartbeat(struct vo_x11_state *x11);
+
+// Old VOs use incompatible function calls, translate them to new
+// prototypes
+#ifdef IS_OLD_VO
+#define vo_x11_create_vo_window(...) vo_x11_create_vo_window(global_vo, __VA_ARGS__)
+#define vo_x11_fullscreen() vo_x11_fullscreen(global_vo)
+#define vo_x11_update_geometry() vo_x11_update_geometry(global_vo)
+#define vo_x11_ontop() vo_x11_ontop(global_vo)
+#define vo_init() vo_init(global_vo)
+#define vo_x11_ewmh_fullscreen(action) vo_x11_ewmh_fullscreen(global_vo->x11->display, action)
+#define update_xinerama_info() update_xinerama_info(global_vo)
+#define vo_x11_uninit() vo_x11_uninit(global_vo)
+#define vo_x11_check_events(display) vo_x11_check_events(global_vo)
+#define vo_x11_sizehint(...) vo_x11_sizehint(global_vo, __VA_ARGS__)
+#define vo_vm_switch() vo_vm_switch(global_vo)
+#define vo_x11_create_colormap(vinfo) vo_x11_create_colormap(global_vo, vinfo)
+#define vo_x11_set_equalizer(...) vo_x11_set_equalizer(global_vo, __VA_ARGS__)
+#define vo_xv_set_eq(...) vo_xv_set_eq(global_vo, __VA_ARGS__)
+#define vo_xv_get_eq(...) vo_xv_get_eq(global_vo, __VA_ARGS__)
+#define vo_xv_enable_vsync() vo_xv_enable_vsync(global_vo)
+#define vo_xv_get_max_img_dim(...) vo_xv_get_max_img_dim(global_vo, __VA_ARGS__)
+#define vo_xv_init_colorkey() vo_xv_init_colorkey(global_vo)
+#define vo_xv_draw_colorkey(...) vo_xv_draw_colorkey(global_vo, __VA_ARGS__)
+#define vo_x11_clearwindow_part(display, ...) vo_x11_clearwindow_part(global_vo, __VA_ARGS__)
+#define vo_vm_close() vo_vm_close(global_vo)
+#define vo_x11_clearwindow(display, window) vo_x11_clearwindow(global_vo, window)
+#define vo_x11_classhint(display, window, name) vo_x11_classhint(global_vo, window, name)
+#define vo_x11_setlayer(display, window, layer) vo_x11_setlayer(global_vo, window, layer)
+#define xv_setup_colorkeyhandling(a, b) xv_setup_colorkeyhandling(global_vo, a, b)
+#define vo_x11_border() vo_x11_border(global_vo)
+
+#define mDisplay global_vo->x11->display
+#define vo_depthonscreen global_vo->x11->depthonscreen
+#define vo_window global_vo->x11->window
+#define xv_ck_info global_vo->x11->xv_ck_info
+#define xv_colorkey global_vo->x11->xv_colorkey
+#define xv_port global_vo->x11->xv_port
+#define vo_gc global_vo->x11->vo_gc
+#define mRootWin global_vo->x11->rootwin
+#define mScreen global_vo->x11->screen
+#define mLocalDisplay global_vo->x11->display_is_local
+#endif
#endif /* MPLAYER_X11_COMMON_H */
diff --git a/loader/dmo/DMO_VideoDecoder.c b/loader/dmo/DMO_VideoDecoder.c
index 334acacedf..d5a56ebefd 100644
--- a/loader/dmo/DMO_VideoDecoder.c
+++ b/loader/dmo/DMO_VideoDecoder.c
@@ -552,4 +552,3 @@ int DMO_VideoDecoder_SetDirection(DMO_VideoDecoder *this, int d)
this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight;
return 0;
}
-
diff --git a/loader/dshow/DS_VideoDecoder.c b/loader/dshow/DS_VideoDecoder.c
index 7f5c8994ad..e691bb5dc5 100644
--- a/loader/dshow/DS_VideoDecoder.c
+++ b/loader/dshow/DS_VideoDecoder.c
@@ -917,7 +917,3 @@ int DS_SetAttr_DivX(char* attribute, int value){
printf("Unknown attribute!\n");
return -200;
}
-
-
-
-
diff --git a/loader/ldt_keeper.c b/loader/ldt_keeper.c
index 8bffa6e958..732d254a28 100644
--- a/loader/ldt_keeper.c
+++ b/loader/ldt_keeper.c
@@ -209,7 +209,7 @@ ldt_fs_t* Setup_LDT_Keeper(void)
#ifdef __APPLE__
if (getenv("DYLD_BIND_AT_LAUNCH") == NULL)
- mp_msg(MSGT_LOADER, MSGL_WARN, MSGTR_LOADER_DYLD_Warning);
+ mp_tmsg(MSGT_LOADER, MSGL_WARN, "WARNING: Attempting to use DLL codecs but environment variable\n DYLD_BIND_AT_LAUNCH not set. This will likely crash.\n");
#endif /* __APPLE__ */
fs_seg=
diff --git a/loader/qtx/qtxsdk/components.h b/loader/qtx/qtxsdk/components.h
index 0856e279f4..08b883099c 100644
--- a/loader/qtx/qtxsdk/components.h
+++ b/loader/qtx/qtxsdk/components.h
@@ -656,6 +656,7 @@ static inline void dump_ImageDescription(void* xxx){
printf("=========================================================\n");
}
+#if 0
static inline void dump_Rect(char* title,Rect *r){
printf("%s: %d;%d - %d;%d\n",title,
(int)r->top,(int)r->left,(int)r->bottom,(int)r->right);
@@ -743,5 +744,6 @@ static inline void dump_CodecDecompressParams(void* xxx){
}
+#endif
#endif /* MPLAYER_COMPONENTS_H */
diff --git a/loader/vfl.c b/loader/vfl.c
index b0ce80acfd..e5d0445b92 100644
--- a/loader/vfl.c
+++ b/loader/vfl.c
@@ -227,4 +227,3 @@ int VFWAPI ICDoSomething(void)
{
return 0;
}
-
diff --git a/loader/wrapper.S b/loader/wrapper.S
index 7656a00f92..f21001f392 100644
--- a/loader/wrapper.S
+++ b/loader/wrapper.S
@@ -80,4 +80,3 @@ wrapper:
popf
popa
ret
-
diff --git a/loader/wrapper.h b/loader/wrapper.h
index 64fbe94217..a7c7da224e 100644
--- a/loader/wrapper.h
+++ b/loader/wrapper.h
@@ -17,4 +17,3 @@ int wrapper(void);
int null_call(void);
#endif /* MPLAYER_WRAPPER_H */
-
diff --git a/m_config.c b/m_config.c
index 7d85f547e3..3f7d32407d 100644
--- a/m_config.c
+++ b/m_config.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
+#include "talloc.h"
#ifdef MP_DEBUG
#include <assert.h>
#endif
@@ -34,12 +35,33 @@ m_config_add_option(m_config_t *config, const m_option_t *arg, const char* prefi
static int
list_options(m_option_t *opt, char* name, char *param);
-m_config_t*
-m_config_new(void) {
+static void m_option_save(const m_config_t *config, const m_option_t *opt,
+ void *dst)
+{
+ if (opt->type->save) {
+ void *src = opt->new ? (char*)config->optstruct + opt->offset : opt->p;
+ opt->type->save(opt, dst, src);
+ }
+}
+
+static void m_option_set(const m_config_t *config, const m_option_t *opt,
+ void *src)
+{
+ if (opt->type->set) {
+ void *dst = opt->new ? (char*)config->optstruct + opt->offset : opt->p;
+ opt->type->set(opt, dst, src);
+ }
+}
+
+
+
+m_config_t *m_config_new(void *optstruct,
+ int includefunc(m_option_t *conf, char *filename))
+{
m_config_t* config;
static int initialized = 0;
static m_option_type_t profile_opt_type;
- static m_option_t ref_opts[] = {
+ static const m_option_t ref_opts[] = {
{ "profile", NULL, &profile_opt_type, CONF_NOSAVE, 0, 0, NULL },
{ "show-profile", show_profile, CONF_TYPE_PRINT_FUNC, CONF_NOCFG, 0, 0, NULL },
{ "list-options", list_options, CONF_TYPE_PRINT_FUNC, CONF_NOCFG, 0, 0, NULL },
@@ -47,7 +69,7 @@ m_config_new(void) {
};
int i;
- config = calloc(1,sizeof(m_config_t));
+ config = talloc_zero(NULL, m_config_t);
config->lvl = 1; // 0 Is the defaults
if(!initialized) {
initialized = 1;
@@ -55,56 +77,32 @@ m_config_new(void) {
profile_opt_type.parse = parse_profile;
profile_opt_type.set = set_profile;
}
- config->self_opts = malloc(sizeof(ref_opts));
- memcpy(config->self_opts,ref_opts,sizeof(ref_opts));
- for(i = 0 ; config->self_opts[i].name ; i++)
- config->self_opts[i].priv = config;
- m_config_register_options(config,config->self_opts);
+ m_option_t *self_opts = talloc_memdup(config, ref_opts, sizeof(ref_opts));
+ for (i = 0; self_opts[i].name; i++)
+ self_opts[i].priv = config;
+ m_config_register_options(config, self_opts);
+ if (includefunc) {
+ struct m_option *p = talloc_ptrtype(config, p);
+ *p = (struct m_option){"include", includefunc, CONF_TYPE_FUNC_PARAM,
+ CONF_NOSAVE, 0, 0, config};
+ m_config_add_option(config, p, NULL);
+ }
+ config->optstruct = optstruct;
return config;
}
-void
-m_config_free(m_config_t* config) {
- m_config_option_t *i = config->opts, *ct;
- m_config_save_slot_t *sl,*st;
- m_profile_t *p,*pn;
- int j;
-
-#ifdef MP_DEBUG
- assert(config != NULL);
-#endif
-
- while(i) {
- if (i->flags & M_CFG_OPT_ALIAS)
- sl = NULL;
- else
- sl = i->slots;
- while(sl) {
- m_option_free(i->opt,sl->data);
- st = sl->prev;
- free(sl);
- sl = st;
- }
- if(i->name != i->opt->name)
- free(i->name);
- ct = i->next;
- free(i);
- i = ct;
- }
- for(p = config->profiles ; p ; p = pn) {
- pn = p->next;
- free(p->name);
- if(p->desc) free(p->desc);
- for(j = 0 ; j < p->num_opts ; j++) {
- free(p->opts[2*j]);
- if(p->opts[2*j+1]) free(p->opts[2*j+1]);
+void m_config_free(m_config_t* config)
+{
+ m_config_option_t *opt;
+ for (opt = config->opts; opt; opt = opt->next) {
+ if (opt->flags & M_CFG_OPT_ALIAS)
+ continue;
+ m_config_save_slot_t *sl;
+ for (sl = opt->slots; sl; sl = sl->prev)
+ m_option_free(opt->opt, sl->data);
}
- free(p->opts);
- free(p);
- }
- free(config->self_opts);
- free(config);
+ talloc_free(config);
}
void
@@ -130,10 +128,11 @@ m_config_push(m_config_t* config) {
continue;
// Update the current status
- m_option_save(co->opt,co->slots->data,co->opt->p);
+ m_option_save(config, co->opt, co->slots->data);
// Allocate a new slot
- slot = calloc(1,sizeof(m_config_save_slot_t) + co->opt->type->size);
+ slot = talloc_zero_size(co, sizeof(m_config_save_slot_t) +
+ co->opt->type->size);
slot->lvl = config->lvl;
slot->prev = co->slots;
co->slots = slot;
@@ -164,17 +163,17 @@ m_config_pop(m_config_t* config) {
if(co->flags & M_CFG_OPT_ALIAS)
continue;
if(co->slots->lvl > config->lvl)
- mp_msg(MSGT_CFGPARSER, MSGL_WARN,MSGTR_SaveSlotTooOld,config->lvl,co->slots->lvl);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_WARN,"Save slot found from lvl %d is too old: %d !!!\n",config->lvl,co->slots->lvl);
while(co->slots->lvl >= config->lvl) {
m_option_free(co->opt,co->slots->data);
slot = co->slots;
co->slots = slot->prev;
- free(slot);
+ talloc_free(slot);
pop++;
}
if(pop) // We removed some ctx -> set the previous value
- m_option_set(co->opt,co->opt->p,co->slots->data);
+ m_option_set(config, co->opt, co->slots->data);
}
config->lvl--;
@@ -193,14 +192,12 @@ m_config_add_option(m_config_t *config, const m_option_t *arg, const char* prefi
#endif
// Allocate a new entry for this option
- co = calloc(1,sizeof(m_config_option_t) + arg->type->size);
+ co = talloc_zero_size(config, sizeof(m_config_option_t) + arg->type->size);
co->opt = arg;
// Fill in the full name
if(prefix && strlen(prefix) > 0) {
- int l = strlen(prefix) + 1 + strlen(arg->name) + 1;
- co->name = malloc(l);
- sprintf(co->name,"%s:%s",prefix,arg->name);
+ co->name = talloc_asprintf(co, "%s:%s", prefix, arg->name);
} else
co->name = arg->name;
@@ -214,9 +211,11 @@ m_config_add_option(m_config_t *config, const m_option_t *arg, const char* prefi
} else {
m_config_option_t *i;
// Check if there is already an option pointing to this address
- if(arg->p) {
+ if(arg->p || arg->new && arg->offset >= 0) {
for(i = config->opts ; i ; i = i->next ) {
- if(i->opt->p == arg->p) { // So we don't save the same vars more than 1 time
+ if (arg->new ? (i->opt->new && i->opt->offset == arg->offset)
+ : (!i->opt->new && i->opt->p == arg->p)) {
+ // So we don't save the same vars more than 1 time
co->slots = i->slots;
co->flags |= M_CFG_OPT_ALIAS;
break;
@@ -224,22 +223,28 @@ m_config_add_option(m_config_t *config, const m_option_t *arg, const char* prefi
}
}
if(!(co->flags & M_CFG_OPT_ALIAS)) {
- // Allocate a slot for the defaults
- sl = calloc(1,sizeof(m_config_save_slot_t) + arg->type->size);
- m_option_save(arg,sl->data,(void**)arg->p);
- // Hack to avoid too much trouble with dynamically allocated data :
- // We always use a dynamic version
- if((arg->type->flags & M_OPT_TYPE_DYNAMIC) && arg->p && (*(void**)arg->p)) {
- *(void**)arg->p = NULL;
- m_option_set(arg,arg->p,sl->data);
+ // Allocate a slot for the defaults
+ sl = talloc_zero_size(co, sizeof(m_config_save_slot_t) +
+ arg->type->size);
+ m_option_save(config, arg, sl->data);
+ // Hack to avoid too much trouble with dynamically allocated data :
+ // We always use a dynamic version
+ if ((arg->type->flags & M_OPT_TYPE_DYNAMIC)) {
+ char **hackptr = arg->new ? (char*)config->optstruct + arg->offset
+ : arg->p;
+ if (hackptr && *hackptr) {
+ *hackptr = NULL;
+ m_option_set(config, arg, sl->data);
+ }
+ }
+ sl->lvl = 0;
+ sl->prev = NULL;
+ co->slots = talloc_zero_size(co, sizeof(m_config_save_slot_t) +
+ arg->type->size);
+ co->slots->prev = sl;
+ co->slots->lvl = config->lvl;
+ m_option_copy(co->opt, co->slots->data, sl->data);
}
- sl->lvl = 0;
- sl->prev = NULL;
- co->slots = calloc(1,sizeof(m_config_save_slot_t) + arg->type->size);
- co->slots->prev = sl;
- co->slots->lvl = config->lvl;
- m_option_copy(co->opt,co->slots->data,sl->data);
- } // !M_OPT_ALIAS
}
co->next = config->opts;
config->opts = co;
@@ -301,11 +306,11 @@ m_config_parse_option(m_config_t *config, char* arg, char* param,int set) {
// Check if this option isn't forbidden in the current mode
if((config->mode == M_CONFIG_FILE) && (co->opt->flags & M_OPT_NOCFG)) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_InvalidCfgfileOption,arg);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR,"The %s option can't be used in a config file.\n",arg);
return M_OPT_INVALID;
}
if((config->mode == M_COMMAND_LINE) && (co->opt->flags & M_OPT_NOCMD)) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_InvalidCmdlineOption,arg);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR,"The %s option can't be used on the command line.\n",arg);
return M_OPT_INVALID;
}
// During command line preparse set only pre-parse options
@@ -333,11 +338,11 @@ m_config_parse_option(m_config_t *config, char* arg, char* param,int set) {
sr = m_config_parse_option(config,n,lst[2*i+1],set);
if(sr < 0){
if(sr == M_OPT_UNKNOWN){
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_InvalidSuboption,co->name,lst[2*i]);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR,"Error: option '%s' has no suboption '%s'.\n",co->name,lst[2*i]);
r = M_OPT_INVALID;
} else
if(sr == M_OPT_MISSING_PARAM){
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_MissingSuboptionParameter,lst[2*i],co->name);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR,"Error: suboption '%s' of '%s' must have a parameter!\n",lst[2*i],co->name);
r = M_OPT_INVALID;
} else
r = sr;
@@ -355,7 +360,7 @@ m_config_parse_option(m_config_t *config, char* arg, char* param,int set) {
return r;
// Set the option
if(set) {
- m_option_set(co->opt,co->opt->p,co->slots->data);
+ m_option_set(config, co->opt, co->slots->data);
co->flags |= M_CFG_OPT_SET;
}
@@ -374,7 +379,7 @@ m_config_check_option(m_config_t *config, char* arg, char* param) {
mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Checking %s=%s\n",arg,param);
r=m_config_parse_option(config,arg,param,0);
if(r==M_OPT_MISSING_PARAM){
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_MissingOptionParameter,arg);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR,"Error: option '%s' must have a parameter!\n",arg);
return M_OPT_INVALID;
}
return r;
@@ -398,20 +403,6 @@ m_config_get_option(m_config_t *config, char* arg) {
return NULL;
}
-const void*
-m_config_get_option_ptr(m_config_t *config, char* arg) {
- const m_option_t* conf;
-
-#ifdef MP_DEBUG
- assert(config != NULL);
- assert(arg != NULL);
-#endif
-
- conf = m_config_get_option(config,arg);
- if(!conf) return NULL;
- return conf->p;
-}
-
void
m_config_print_option_list(m_config_t *config) {
char min[50],max[50];
@@ -420,7 +411,7 @@ m_config_print_option_list(m_config_t *config) {
if(!config->opts) return;
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_OptionListHeader);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "\n Name Type Min Max Global CL Cfg\n\n");
for(co = config->opts ; co ; co = co->next) {
const m_option_t* opt = co->opt;
if(opt->type->flags & M_OPT_TYPE_HAS_CHILD) continue;
@@ -442,7 +433,7 @@ m_config_print_option_list(m_config_t *config) {
opt->flags & CONF_NOCFG ? "No" : "Yes");
count++;
}
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_TotalOptions,count);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "\nTotal: %d options\n",count);
}
m_profile_t*
@@ -457,8 +448,8 @@ m_profile_t*
m_config_add_profile(m_config_t* config, char* name) {
m_profile_t* p = m_config_get_profile(config,name);
if(p) return p;
- p = calloc(1,sizeof(m_profile_t));
- p->name = strdup(name);
+ p = talloc_zero(config, m_profile_t);
+ p->name = talloc_strdup(p, name);
p->next = config->profiles;
config->profiles = p;
return p;
@@ -466,8 +457,8 @@ m_config_add_profile(m_config_t* config, char* name) {
void
m_profile_set_desc(m_profile_t* p, char* desc) {
- if(p->desc) free(p->desc);
- p->desc = desc ? strdup(desc) : NULL;
+ talloc_free(p->desc);
+ p->desc = talloc_strdup(p, desc);
}
int
@@ -475,10 +466,9 @@ m_config_set_profile_option(m_config_t* config, m_profile_t* p,
char* name, char* val) {
int i = m_config_check_option(config,name,val);
if(i < 0) return i;
- if(p->opts) p->opts = realloc(p->opts,2*(p->num_opts+2)*sizeof(char*));
- else p->opts = malloc(2*(p->num_opts+2)*sizeof(char*));
- p->opts[p->num_opts*2] = strdup(name);
- p->opts[p->num_opts*2+1] = val ? strdup(val) : NULL;
+ p->opts = talloc_realloc(p, p->opts, char *, 2*(p->num_opts+2));
+ p->opts[p->num_opts*2] = talloc_strdup(p, name);
+ p->opts[p->num_opts*2+1] = talloc_strdup(p, val);
p->num_opts++;
p->opts[p->num_opts*2] = p->opts[p->num_opts*2+1] = NULL;
return 1;
@@ -488,7 +478,7 @@ void
m_config_set_profile(m_config_t* config, m_profile_t* p) {
int i;
if(config->profile_depth > MAX_PROFILE_DEPTH) {
- mp_msg(MSGT_CFGPARSER, MSGL_WARN, MSGTR_ProfileInclusionTooDeep);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_WARN, "WARNING: Profile inclusion too deep.\n");
return;
}
config->profile_depth++;
@@ -506,10 +496,10 @@ parse_profile(const m_option_t *opt, const char *name, char *param, void *dst, i
if(param && !strcmp(param,"help")) {
m_profile_t* p;
if(!config->profiles) {
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_NoProfileDefined);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "No profiles have been defined.\n");
return M_OPT_EXIT-1;
}
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_AvailableProfiles);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "Available profiles:\n");
for(p = config->profiles ; p ; p = p->next)
mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\t%s\t%s\n",p->name,
p->desc ? p->desc : "");
@@ -522,7 +512,7 @@ parse_profile(const m_option_t *opt, const char *name, char *param, void *dst, i
if(!list || !list[0]) return M_OPT_INVALID;
for(i = 0 ; list[i] ; i++)
if(!m_config_get_profile(config,list[i])) {
- mp_msg(MSGT_CFGPARSER, MSGL_WARN, MSGTR_UnknownProfile,
+ mp_tmsg(MSGT_CFGPARSER, MSGL_WARN, "Unknown profile '%s'.\n",
list[i]);
r = M_OPT_INVALID;
}
@@ -556,11 +546,11 @@ show_profile(m_option_t *opt, char* name, char *param) {
int i,j;
if(!param) return M_OPT_MISSING_PARAM;
if(!(p = m_config_get_profile(config,param))) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_UnknownProfile, param);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Unknown profile '%s'.\n", param);
return M_OPT_EXIT-1;
}
if(!config->profile_depth)
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_Profile, param,
+ mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "Profile %s: %s\n", param,
p->desc ? p->desc : "");
config->profile_depth++;
for(i = 0 ; i < p->num_opts ; i++) {
diff --git a/m_config.h b/m_config.h
index 8a666ecec1..0c84b87569 100644
--- a/m_config.h
+++ b/m_config.h
@@ -76,8 +76,8 @@ typedef struct m_config {
m_profile_t* profiles;
/// Depth when recursively including profiles.
int profile_depth;
- /// Options defined by the config itself.
- struct m_option* self_opts;
+
+ void *optstruct; // struct mpopts or other
} m_config_t;
/// \defgroup ConfigOptionFlags Config option flags
@@ -96,7 +96,8 @@ typedef struct m_config {
/** \ingroup Config
*/
m_config_t*
-m_config_new(void);
+m_config_new(void *optstruct,
+ int includefunc(struct m_option *conf, char *filename));
/// Free a config object.
void
diff --git a/m_option.c b/m_option.c
index b04ee772bf..2b7491ca4d 100644
--- a/m_option.c
+++ b/m_option.c
@@ -781,8 +781,6 @@ static void set_func_param(const m_option_t* opt, void* dst, void* src) {
if(!s) return;
- // Revert if needed
- if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,opt->name);
for( ; s != NULL ; s = s->next)
((m_opt_func_param_t) opt->p)(opt,s->param);
}
@@ -830,18 +828,12 @@ const m_option_type_t m_option_type_func_full = {
/////////////// Func
#undef VAL
-#define VAL(x) (*(int*)(x))
static int parse_func(const m_option_t* opt,const char *name, char *param, void* dst, int src) {
- if(dst)
- VAL(dst) += 1;
return 0;
}
static void set_func(const m_option_t* opt,void* dst, void* src) {
- int i;
- if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,opt->name);
- for(i = 0 ; i < VAL(src) ; i++)
((m_opt_func_t) opt->p)(opt);
}
diff --git a/m_option.h b/m_option.h
index 9417fb562e..3387193db4 100644
--- a/m_option.h
+++ b/m_option.h
@@ -2,6 +2,7 @@
#define MPLAYER_M_OPTION_H
#include <string.h>
+#include <stddef.h>
/// \defgroup Options
/// m_option allows to parse, print and copy data of various types.
@@ -284,6 +285,10 @@ struct m_option {
* Passing a 'default func' is still valid for all func based option types.
*/
void* priv;
+
+ int new;
+
+ int offset;
};
@@ -478,20 +483,6 @@ m_option_print(const m_option_t* opt, const void* val_ptr) {
return (char*)-1;
}
-/// Helper around \ref m_option_type::save.
-inline static void
-m_option_save(const m_option_t* opt,void* dst, void* src) {
- if(opt->type->save)
- opt->type->save(opt,dst,src);
-}
-
-/// Helper around \ref m_option_type::set.
-inline static void
-m_option_set(const m_option_t* opt,void* dst, void* src) {
- if(opt->type->set)
- opt->type->set(opt,dst,src);
-}
-
/// Helper around \ref m_option_type::copy.
inline static void
m_option_copy(const m_option_t* opt,void* dst, void* src) {
@@ -510,4 +501,14 @@ m_option_free(const m_option_t* opt,void* dst) {
/*@}*/
+#define OPT_FLAG_ON(optname, varname, flags) {optname, NULL, &m_option_type_flag, flags, 0, 1, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_FLAG_OFF(optname, varname, flags) {optname, NULL, &m_option_type_flag, flags, 1, 0, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_FLAG_CONSTANTS(optname, varname, flags, offvalue, value) {optname, NULL, &m_option_type_flag, flags, offvalue, value, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_STRINGLIST(optname, varname, flags) {optname, NULL, &m_option_type_string_list, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_INT(optname, varname, flags) {optname, NULL, &m_option_type_int, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_INTRANGE(optname, varname, flags, min, max) {optname, NULL, &m_option_type_int, (flags)|CONF_RANGE, min, max, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_FLOATRANGE(optname, varname, flags, min, max) {optname, NULL, &m_option_type_float, (flags)|CONF_RANGE, min, max, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_STRING(optname, varname, flags) {optname, NULL, &m_option_type_string, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_SETTINGSLIST(optname, varname, flags, objlist) {optname, NULL, &m_option_type_obj_settings_list, flags, 0, 0, objlist, 1, offsetof(struct MPOpts, varname)}
+
#endif /* MPLAYER_M_OPTION_H */
diff --git a/m_property.c b/m_property.c
index c81fced8a5..72d2491a87 100644
--- a/m_property.c
+++ b/m_property.c
@@ -181,7 +181,7 @@ void m_properties_print_help_list(const m_option_t* list) {
char min[50],max[50];
int i,count = 0;
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_PropertyListHeader);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "\n Name Type Min Max\n\n");
for(i = 0 ; list[i].name ; i++) {
const m_option_t* opt = &list[i];
if(opt->flags & M_OPT_MIN)
@@ -199,7 +199,7 @@ void m_properties_print_help_list(const m_option_t* list) {
max);
count++;
}
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_TotalProperties, count);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "\nTotal: %d properties\n", count);
}
// Some generic property implementations
@@ -250,7 +250,7 @@ int m_property_flag_ro(const m_option_t* prop,int action,
switch(action) {
case M_PROPERTY_PRINT:
if(!arg) return 0;
- *(char**)arg = strdup((var > prop->min) ? MSGTR_Enabled : MSGTR_Disabled);
+ *(char**)arg = strdup((var > prop->min) ? _("enabled") : _("disabled"));
return 1;
}
return m_property_int_ro(prop,action,arg,var);
diff --git a/mencoder.c b/mencoder.c
index d082ecd141..6627332c17 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -86,9 +86,15 @@
#endif
#include "libmpcodecs/ae.h"
+#include "options.h"
+#include "defaultopts.h"
+
+MPOpts opts;
+struct osd_state *osd;
+
+const int under_mencoder = 1;
int vo_doublebuffering=0;
int vo_directrendering=0;
-int vo_config_count=1;
int forced_subs_only=0;
//--------------------------
@@ -104,9 +110,6 @@ float stream_cache_seek_min_percent=50.0;
#define cache_fill_status 0
#endif
-int audio_id=-1;
-int video_id=-1;
-int dvdsub_id=-2;
int vobsub_id=-1;
char* audio_lang=NULL;
char* dvdsub_lang=NULL;
@@ -156,7 +159,6 @@ static int audio_density=2;
double force_fps=0;
static double force_ofps=0; // set to 24 for inverse telecine
static int skip_limit=-1;
-float playback_speed=1.0;
static int force_srate=0;
static int audio_output_format=0;
@@ -203,18 +205,19 @@ char *info_sourceform=NULL;
char *info_comment=NULL;
// Needed by libmpcodecs vf_vo.c
-int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
- uint32_t d_width, uint32_t d_height, uint32_t flags,
- char *title, uint32_t format) {
- return 1;
-}
-// Needed by libmpdemux.
-int mp_input_check_interrupt(int time) {
- usec_sleep(time);
- return 0;
-}
+int vo_config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height, uint32_t flags,
+ char *title, uint32_t format) { abort(); }
+int vo_control(struct vo *vo, uint32_t request, void *data) { abort(); }
+int vo_draw_frame(struct vo *vo, uint8_t *src[]) { abort(); }
+int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y) { abort(); }
+void vo_draw_osd(struct vo *vo, struct osd_state *osd) { abort(); }
+void vo_flip_page(struct vo *vo) { abort(); }
+void vo_check_events(struct vo *vo) { abort(); }
+
// Needed by getch2
-void mplayer_put_key(int code)
+struct mp_fifo;
+void mplayer_put_key(struct mp_fifo *fifo, int code)
{
}
@@ -293,9 +296,9 @@ static int edl_seek(edl_record_ptr next_edl_record, demuxer_t* demuxer, demux_st
static void mencoder_exit(int level, const char *how)
{
if (how)
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ExitingHow, how);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "\nExiting... (%s)\n", how);
else
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_Exiting);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "\nExiting...\n");
exit(level);
}
@@ -305,14 +308,14 @@ static void parse_cfgfiles( m_config_t* conf )
char *conffile;
if (!disable_system_conf &&
m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mencoder.conf") < 0)
- mencoder_exit(1,MSGTR_ConfigFileError);
+ mencoder_exit(1,_("config file error"));
if (!disable_user_conf) {
if ((conffile = get_path("mencoder.conf")) == NULL) {
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"get_path(\"config\") problem\n");
} else {
if (m_config_parse_config_file(conf, conffile) < 0)
- mencoder_exit(1,MSGTR_ConfigFileError);
+ mencoder_exit(1,_("config file error"));
free(conffile);
}
}
@@ -402,12 +405,11 @@ ao_data_t ao_data = {0,0,0,0,OUTBURST,-1,0};
audio_encoding_params_t aparams;
audio_encoder_t *aencoder = NULL;
-user_correct_pts = 0;
-
mp_msg_init();
// Create the config context and register the options
- mconfig = m_config_new();
+ set_default_mencoder_options(&opts);
+ mconfig = m_config_new(&opts, cfg_include);
m_config_register_options(mconfig,mencoder_opts);
// Preparse the command line
@@ -428,19 +430,19 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
if(!parse_codec_cfg(NULL)){
mencoder_exit(1,NULL);
}
- mp_msg(MSGT_MENCODER,MSGL_V,MSGTR_BuiltinCodecsConf);
+ mp_tmsg(MSGT_MENCODER,MSGL_V,"Using built-in default codecs.conf.\n");
}
}
}
parse_cfgfiles(mconfig);
filelist = m_config_parse_me_command_line(mconfig, argc, argv);
- if(!filelist) mencoder_exit(1, MSGTR_ErrorParsingCommandLine);
+ if(!filelist) mencoder_exit(1, _("error parsing command line"));
{
char *extension;
- if (!out_filename) mencoder_exit(1,MSGTR_MissingOutputFilename);
+ if (!out_filename) mencoder_exit(1,_("No output file specified, please see the -o option."));
extension=strrchr(out_filename,'.');
if (extension != NULL && strlen(extension) > 3 && strlen(extension) < 6)
{
@@ -450,14 +452,14 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
{
case MUXER_TYPE_AVI:
if (strcasecmp(extension,"avi"))
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_MencoderWrongFormatAVI);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "\nWARNING: OUTPUT FILE FORMAT IS _AVI_. See -of help.\n");
break;
case MUXER_TYPE_MPEG:
if (strcasecmp(extension,"mpg") &&
strcasecmp(extension,"mpeg") &&
strcasecmp(extension,"vob"))
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_MencoderWrongFormatMPG);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "\nWARNING: OUTPUT FILE FORMAT IS _MPEG_. See -of help.\n");
break;
}
}
@@ -465,13 +467,16 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
/* Display what configure line was used */
mp_msg(MSGT_MENCODER, MSGL_V, "Configuration: " CONFIGURATION "\n");
+#define FormatNotRecognized _("============ Sorry, this file format is not recognized/supported =============\n"\
+"=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n")
+
if (frameno_filename) {
stream2=open_stream(frameno_filename,0,&i);
if(stream2){
- demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2,NULL);
- if(demuxer2) mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_UsingPass3ControlFile, frameno_filename);
- else mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
+ demuxer2=demux_open(&opts, stream2,DEMUXER_TYPE_AVI,-1,-1,-2,NULL);
+ if(demuxer2) mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Using pass3 control file: %s\n", frameno_filename);
+ else mp_tmsg(MSGT_DEMUXER,MSGL_ERR, FormatNotRecognized);
}
}
@@ -490,7 +495,7 @@ if (frameno_filename) {
#ifdef CONFIG_BITMAP_FONT
if(font_name){
vo_font=read_font_desc(font_name,font_factor,verbose>1);
- if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+ if(!vo_font) mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Cannot load bitmap font: %s\n",font_name);
} else {
// try default:
vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1);
@@ -502,7 +507,7 @@ if (frameno_filename) {
}
#endif
- vo_init_osd();
+ osd = osd_create();
/* HACK, for some weird reason, push() has to be called twice,
otherwise options are not saved correctly */
@@ -513,29 +518,29 @@ play_next_file:
filename = filelist[curfile].name;
if(!filename){
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_MissingFilename);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "\nFilename missing.\n\n");
mencoder_exit(1,NULL);
}
stream=open_stream(filename,0,&file_format);
if(!stream){
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_CannotOpenFile_Device);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Cannot open file/device.\n");
mencoder_exit(1,NULL);
}
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_OpenedStream, file_format, (int)(stream->start_pos), (int)(stream->end_pos));
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "success: format: %d data: 0x%X - 0x%x\n", file_format, (int)(stream->start_pos), (int)(stream->end_pos));
#ifdef CONFIG_DVDREAD
if(stream->type==STREAMTYPE_DVD){
- if(audio_lang && audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang);
- if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang);
+ if(audio_lang && opts.audio_id==-1) opts.audio_id=dvd_aid_from_lang(stream,audio_lang);
+ if(dvdsub_lang && opts.sub_id==-2) opts.sub_id=dvd_sid_from_lang(stream,dvdsub_lang);
}
#endif
#ifdef CONFIG_DVDNAV
if(stream->type==STREAMTYPE_DVDNAV){
- if(audio_lang && audio_id==-1) audio_id=mp_dvdnav_aid_from_lang(stream,audio_lang);
- if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=mp_dvdnav_sid_from_lang(stream,dvdsub_lang);
+ if(audio_lang && opts.audio_id==-1) opts.audio_id=mp_dvdnav_aid_from_lang(stream,audio_lang);
+ if(dvdsub_lang && opts.sub_id==-2) opts.sub_id=mp_dvdnav_sid_from_lang(stream,dvdsub_lang);
}
#endif
@@ -543,27 +548,27 @@ if(stream->type==STREAMTYPE_DVDNAV){
if(stream_cache_size>0) stream_enable_cache(stream,stream_cache_size*1024,0,0);
- if(demuxer2) audio_id=-2; /* do NOT read audio packets... */
+ if(demuxer2) opts.audio_id=-2; /* do NOT read audio packets... */
- //demuxer=demux_open(stream,file_format,video_id,audio_id,dvdsub_id);
- demuxer=demux_open(stream,file_format,audio_id,video_id,dvdsub_id,filename);
+ //demuxer=demux_open(stream,file_format,opts.video_id,opts.audio_id,opts.sub_id);
+ demuxer=demux_open(&opts, stream,file_format,opts.audio_id,opts.video_id,opts.sub_id,filename);
if(!demuxer){
- mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_FormatNotRecognized);
- mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_CannotOpenDemuxer);
+ mp_tmsg(MSGT_DEMUXER, MSGL_FATAL, FormatNotRecognized);
+ mp_tmsg(MSGT_DEMUXER, MSGL_FATAL, "Cannot open demuxer.\n");
mencoder_exit(1,NULL);
}
- select_audio(demuxer, audio_id, audio_lang);
+ select_audio(demuxer, opts.audio_id, audio_lang);
- if (dvdsub_id < 0 && dvdsub_lang)
- dvdsub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
+ if (opts.sub_id < 0 && dvdsub_lang)
+ opts.sub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
- if (dvdsub_id < 0)
- dvdsub_id = demuxer_default_sub_track(demuxer);
+ if (opts.sub_id < 0)
+ opts.sub_id = demuxer_default_sub_track(demuxer);
for (i = 0; i < MAX_S_STREAMS; i++) {
sh_sub_t *sh = demuxer->s_streams[i];
- if (sh && sh->sid == dvdsub_id) {
+ if (sh && sh->sid == opts.sub_id) {
demuxer->sub->id = i;
demuxer->sub->sh = sh;
break;
@@ -571,8 +576,8 @@ if(stream->type==STREAMTYPE_DVDNAV){
}
if(dvd_chapter>1) {
- float pts;
- if (demuxer_seek_chapter(demuxer, dvd_chapter-1, 1, &pts, NULL, NULL) >= 0 && pts > -1.0)
+ double pts;
+ if (demuxer_seek_chapter(demuxer, dvd_chapter-1, &pts, NULL) >= 0 && pts > -1.0)
seek_to_sec = pts;
}
@@ -584,16 +589,16 @@ sh_video=d_video->sh;
if(!sh_video)
{
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_VideoStreamRequired);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Video stream is mandatory!\n");
mencoder_exit(1,NULL);
}
if(!video_read_properties(sh_video)){
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_CannotReadVideoProperties);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Video: Cannot read properties.\n");
mencoder_exit(1,NULL);
}
- mp_msg(MSGT_MENCODER,MSGL_INFO, MSGTR_FilefmtFourccSizeFpsFtime,
+ mp_tmsg(MSGT_MENCODER,MSGL_INFO, "[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.3f ftime:=%6.4f\n",
demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h,
sh_video->fps,sh_video->frametime
);
@@ -601,21 +606,21 @@ sh_video=d_video->sh;
if(force_fps){
sh_video->fps=force_fps;
sh_video->frametime=1.0f/sh_video->fps;
- mp_msg(MSGT_MENCODER,MSGL_INFO,MSGTR_ForcingInputFPS, sh_video->fps);
+ mp_tmsg(MSGT_MENCODER,MSGL_INFO,"Input fps will be interpreted as %5.3f instead.\n", sh_video->fps);
}
if(sh_audio && out_audio_codec<0){
- if(audio_id==-2)
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_DemuxerDoesntSupportNosound);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoAudioEncoderSelected);
+ if(opts.audio_id==-2)
+ mp_tmsg(MSGT_MENCODER,MSGL_ERR,"This demuxer doesn't support -nosound yet.\n");
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nNo audio encoder (-oac) selected. Select one (see -oac help) or use -nosound.\n");
mencoder_exit(1,NULL);
}
if(sh_video && out_video_codec<0){
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoVideoEncoderSelected);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nNo video encoder (-ovc) selected. Select one (see -ovc help).\n");
mencoder_exit(1,NULL);
}
-if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf || playback_speed != 1.0)){
+if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf || opts.playback_speed != 1.0)){
// Go through the codec.conf and find the best codec...
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
if(!init_best_audio_codec(sh_audio,audio_codec_list,audio_fm_list)){
@@ -626,12 +631,12 @@ if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf || playback_spee
if (sh_audio) {
new_srate = sh_audio->samplerate;
- if (playback_speed != 1.0) {
- new_srate *= playback_speed;
+ if (opts.playback_speed != 1.0) {
+ new_srate *= opts.playback_speed;
// limits are taken from libaf/af_resample.c
if (new_srate < 8000) new_srate = 8000;
if (new_srate > 192000) new_srate = 192000;
- playback_speed = (float)new_srate / (float)sh_audio->samplerate;
+ opts.playback_speed = (float)new_srate / (float)sh_audio->samplerate;
}
}
@@ -641,7 +646,7 @@ if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf || playback_spee
// current_module="read_subtitles_file";
if(sub_name && sub_name[0]){
subdata=sub_read_file(sub_name[0], sh_video->fps);
- if(!subdata) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name[0]);
+ if(!subdata) mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Cannot load subtitles: %s\n",sub_name[0]);
} else
if(sub_auto && filename) { // auto load sub file ...
char **tmp = NULL;
@@ -661,7 +666,7 @@ if (!curfile) { // curfile is non zero when a second file is opened
if (vobsub_out) {
unsigned int palette[16], width, height;
unsigned char tmp[3] = { 0, 0, 0 };
- if (spudec_ifo && vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, dvdsub_id, tmp) >= 0)
+ if (spudec_ifo && vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, opts.sub_id, tmp) >= 0)
vobsub_writer = vobsub_out_open(vobsub_out, palette, sh_video->disp_w, sh_video->disp_h,
vobsub_out_id?vobsub_out_id:(char *)tmp, vobsub_out_index);
#ifdef CONFIG_DVDREAD
@@ -671,7 +676,7 @@ if (vobsub_out) {
int i;
dvd_priv_t *dvd = (dvd_priv_t*)stream->priv;
for (i = 0; i < dvd->nr_of_subtitles; ++i)
- if (dvd->subtitles[i].id == dvdsub_id) {
+ if (dvd->subtitles[i].id == opts.sub_id) {
tmp[0] = (dvd->subtitles[i].language >> 8) & 0xff;
tmp[1] = dvd->subtitles[i].language & 0xff;
tmp[2] = 0;
@@ -702,13 +707,13 @@ if (vo_spudec)
ostream = open_output_stream(out_filename, 0);
if(!ostream) {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CannotOpenOutputFile, out_filename);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Cannot open output file '%s'.\n", out_filename);
mencoder_exit(1,NULL);
}
muxer=muxer_new_muxer(out_file_format,ostream);
if(!muxer) {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CannotInitializeMuxer);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Cannot initialize muxer.");
mencoder_exit(1,NULL);
}
#if 0
@@ -730,14 +735,14 @@ mux_v->source=sh_video;
mux_v->h.dwSampleSize=0; // VBR
#ifdef CONFIG_LIBAVCODEC
{
- double fps = force_ofps?force_ofps:sh_video->fps*playback_speed;
+ double fps = force_ofps?force_ofps:sh_video->fps*opts.playback_speed;
AVRational q= av_d2q(fps, fps*1001+2);
mux_v->h.dwScale= q.den;
mux_v->h.dwRate = q.num;
}
#else
mux_v->h.dwScale=10000;
-mux_v->h.dwRate=mux_v->h.dwScale*(force_ofps?force_ofps:sh_video->fps*playback_speed);
+mux_v->h.dwRate=mux_v->h.dwScale*(force_ofps?force_ofps:sh_video->fps*opts.playback_speed);
#endif
mux_v->codec=out_video_codec;
@@ -766,7 +771,7 @@ case VCODEC_COPY:
mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
}
}
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_VCodecFramecopy,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "videocodec: framecopy (%dx%d %dbpp fourcc=%x)\n",
mux_v->bih->biWidth, mux_v->bih->biHeight,
mux_v->bih->biBitCount, mux_v->bih->biCompression);
@@ -775,10 +780,10 @@ case VCODEC_COPY:
if ((mux_v->bih->biSize != sh_video->bih->biSize) ||
memcmp(mux_v->bih, sh_video->bih, sh_video->bih->biSize))
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_VCodecFramecopy,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "videocodec: framecopy (%dx%d %dbpp fourcc=%x)\n",
sh_video->bih->biWidth, sh_video->bih->biHeight,
sh_video->bih->biBitCount, sh_video->bih->biCompression);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_FrameCopyFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nAll video files must have identical fps, resolution, and codec for -ovc copy.\n");
mencoder_exit(1,NULL);
}
}
@@ -786,9 +791,9 @@ case VCODEC_COPY:
if ((mux_v->bih->biWidth != sh_video->disp_w) ||
(mux_v->bih->biHeight != sh_video->disp_h) ||
(mux_v->bih->biCompression != sh_video->format)) {
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_VCodecFramecopy,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "videocodec: framecopy (%dx%d %dbpp fourcc=%x)\n",
sh_video->disp_w, sh_video->disp_w, 24, sh_video->format);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_FrameCopyFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nAll video files must have identical fps, resolution, and codec for -ovc copy.\n");
mencoder_exit(1,NULL);
}
}
@@ -811,24 +816,24 @@ default: {
if (!ve) {
switch(mux_v->codec){
case VCODEC_LIBAVCODEC:
- sh_video->vfilter=vf_open_encoder(NULL,"lavc",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"lavc",(char *)mux_v); break;
case VCODEC_RAW:
- sh_video->vfilter=vf_open_encoder(NULL,"raw",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"raw",(char *)mux_v); break;
case VCODEC_VFW:
- sh_video->vfilter=vf_open_encoder(NULL,"vfw",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"vfw",(char *)mux_v); break;
case VCODEC_LIBDV:
- sh_video->vfilter=vf_open_encoder(NULL,"libdv",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"libdv",(char *)mux_v); break;
case VCODEC_XVID:
- sh_video->vfilter=vf_open_encoder(NULL,"xvid",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"xvid",(char *)mux_v); break;
case VCODEC_QTVIDEO:
- sh_video->vfilter=vf_open_encoder(NULL,"qtvideo",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"qtvideo",(char *)mux_v); break;
case VCODEC_NUV:
- sh_video->vfilter=vf_open_encoder(NULL,"nuv",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"nuv",(char *)mux_v); break;
case VCODEC_X264:
- sh_video->vfilter=vf_open_encoder(NULL,"x264",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"x264",(char *)mux_v); break;
}
if(!mux_v->bih || !sh_video->vfilter){
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_EncoderOpenFailed);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"Failed to open the encoder.\n");
mencoder_exit(1,NULL);
}
ve = sh_video->vfilter;
@@ -836,9 +841,9 @@ default: {
// append 'expand' filter, it fixes stride problems and renders osd:
if (auto_expand) {
char* vf_args[] = { "osd", "1", NULL };
- sh_video->vfilter=vf_open_filter(sh_video->vfilter,"expand",vf_args);
+ sh_video->vfilter=vf_open_filter(&opts, sh_video->vfilter,"expand",vf_args);
}
- sh_video->vfilter=append_filters(sh_video->vfilter);
+ sh_video->vfilter=append_filters(sh_video->vfilter, opts.vf_settings);
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
init_best_video_codec(sh_video,video_codec_list,video_fm_list);
@@ -853,7 +858,7 @@ if ((force_fourcc != NULL) && (strlen(force_fourcc) >= 4))
{
mux_v->bih->biCompression = mmioFOURCC(force_fourcc[0], force_fourcc[1],
force_fourcc[2], force_fourcc[3]);
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ForcingOutputFourcc,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Forcing output FourCC to %x [%.4s].\n",
mux_v->bih->biCompression, (char *)&mux_v->bih->biCompression);
}
@@ -870,7 +875,7 @@ if (force_audiofmttag != -1) {
if (sh_audio->wf) {
sh_audio->wf->wFormatTag = sh_audio->format;
}
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ForcingOutputAudiofmtTag,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Forcing output audio format tag to 0x%x.\n",
force_audiofmttag);
}
@@ -879,7 +884,7 @@ mux_a=muxer_new_stream(muxer,MUXER_TYPE_AUDIO);
mux_a->buffer_size=0x100000; //16384;
mux_a->buffer=malloc(mux_a->buffer_size);
if (!mux_a->buffer)
- mencoder_exit(1,MSGTR_MemAllocFailed);
+ mencoder_exit(1,_("Memory allocation failed.\n"));
mux_a->source=sh_audio;
@@ -893,7 +898,7 @@ if(!init_audio_filters(sh_audio,
new_srate,
// output:
&ao_data.samplerate, &ao_data.channels, &ao_data.format)) {
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_AudioFilterChainPreinitError);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Error at audio filter chain pre-init!\n");
mencoder_exit(1, NULL);
}
@@ -907,15 +912,19 @@ if(mux_a->codec != ACODEC_COPY) {
if(!init_audio_filters(sh_audio,
new_srate,
&aparams.sample_rate, &aparams.channels, &aencoder->input_format)) {
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_NoMatchingFilter);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Couldn't find matching filter/ao format!\n");
mencoder_exit(1,NULL);
}
}
+
+#define NoSpeedWithFrameCopy _("WARNING: -speed is not guaranteed to work correctly with -oac copy!\n"\
+"Your encode might be broken!\n")
+
switch(mux_a->codec){
case ACODEC_COPY:
- if (playback_speed != 1.0) mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_NoSpeedWithFrameCopy);
+ if (opts.playback_speed != 1.0) mp_tmsg(MSGT_CPLAYER, MSGL_WARN, NoSpeedWithFrameCopy);
if (sh_audio->format >= 0x10000) {
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantCopyAudioFormat, sh_audio->format);
+ mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Audio format 0x%x is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it.\n", sh_audio->format);
mencoder_exit(1,NULL);
}
if (sh_audio->wf){
@@ -941,9 +950,9 @@ case ACODEC_COPY:
mux_a->h.dwScale=mux_a->h.dwSampleSize;
mux_a->h.dwRate=mux_a->wf->nAvgBytesPerSec;
}
- mux_a->h.dwRate *= playback_speed;
- mux_a->wf->nSamplesPerSec *= playback_speed;
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ACodecFramecopy,
+ mux_a->h.dwRate *= opts.playback_speed;
+ mux_a->wf->nSamplesPerSec *= opts.playback_speed;
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "audiocodec: framecopy (format=%x chans=%d rate=%d bits=%d B/s=%d sample-%d)\n",
mux_a->wf->wFormatTag, mux_a->wf->nChannels, mux_a->wf->nSamplesPerSec,
mux_a->wf->wBitsPerSample, mux_a->wf->nAvgBytesPerSec, mux_a->h.dwSampleSize);
break;
@@ -968,34 +977,34 @@ timer_start=GetTimerMS();
} // if (!curfile) // if this was the first file.
else {
if (!mux_a != !sh_audio) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoAudioFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nCannot mix video-only files with audio and video files. Try -nosound.\n");
mencoder_exit(1,NULL);
}
if (sh_audio && mux_a->codec == ACODEC_COPY) {
- if (playback_speed != 1.0) mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_NoSpeedWithFrameCopy);
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ACodecFramecopy,
+ if (opts.playback_speed != 1.0) mp_tmsg(MSGT_CPLAYER, MSGL_WARN, NoSpeedWithFrameCopy);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "audiocodec: framecopy (format=%x chans=%d rate=%d bits=%d B/s=%d sample-%d)\n",
mux_a->wf->wFormatTag, mux_a->wf->nChannels, mux_a->wf->nSamplesPerSec,
mux_a->wf->wBitsPerSample, mux_a->wf->nAvgBytesPerSec, mux_a->h.dwSampleSize);
if (sh_audio->wf) {
if ((mux_a->wf->wFormatTag != sh_audio->wf->wFormatTag) ||
(mux_a->wf->nChannels != sh_audio->wf->nChannels) ||
- (mux_a->wf->nSamplesPerSec != sh_audio->wf->nSamplesPerSec * playback_speed))
+ (mux_a->wf->nSamplesPerSec != sh_audio->wf->nSamplesPerSec * opts.playback_speed))
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ACodecFramecopy,
- sh_audio->wf->wFormatTag, sh_audio->wf->nChannels, (int)(sh_audio->wf->nSamplesPerSec * playback_speed),
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "audiocodec: framecopy (format=%x chans=%d rate=%d bits=%d B/s=%d sample-%d)\n",
+ sh_audio->wf->wFormatTag, sh_audio->wf->nChannels, (int)(sh_audio->wf->nSamplesPerSec * opts.playback_speed),
sh_audio->wf->wBitsPerSample, sh_audio->wf->nAvgBytesPerSec, 0);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_AudioCopyFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nAll files must have identical audio codec and format for -oac copy.\n");
mencoder_exit(1,NULL);
}
} else {
if ((mux_a->wf->wFormatTag != sh_audio->format) ||
(mux_a->wf->nChannels != sh_audio->channels) ||
- (mux_a->wf->nSamplesPerSec != sh_audio->samplerate * playback_speed))
+ (mux_a->wf->nSamplesPerSec != sh_audio->samplerate * opts.playback_speed))
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ACodecFramecopy,
- sh_audio->wf->wFormatTag, sh_audio->wf->nChannels, (int)(sh_audio->wf->nSamplesPerSec * playback_speed),
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "audiocodec: framecopy (format=%x chans=%d rate=%d bits=%d B/s=%d sample-%d)\n",
+ sh_audio->wf->wFormatTag, sh_audio->wf->nChannels, (int)(sh_audio->wf->nSamplesPerSec * opts.playback_speed),
sh_audio->wf->wBitsPerSample, sh_audio->wf->nAvgBytesPerSec, 0);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_AudioCopyFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nAll files must have identical audio codec and format for -oac copy.\n");
mencoder_exit(1,NULL);
}
}
@@ -1006,7 +1015,7 @@ else {
if (!init_audio_filters(sh_audio, new_srate,
&out_srate, &out_channels,
&out_format)) {
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_NoMatchingFilter);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Couldn't find matching filter/ao format!\n");
mencoder_exit(1, NULL);
}
mux_a->wf->nSamplesPerSec = out_srate;
@@ -1026,18 +1035,18 @@ if (seek_to_sec) {
if (out_file_format == MUXER_TYPE_MPEG)
{
if (audio_preload > 0.4) {
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_LimitingAudioPreload);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "Limiting audio preload to 0.4s.\n");
audio_preload = 0.4;
}
if (audio_density < 4) {
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_IncreasingAudioDensity);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "Increasing audio density to 4.\n");
audio_density = 4;
}
}
if(file_format == DEMUXER_TYPE_TV)
{
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_ZeroingAudioPreloadAndMaxPtsCorrection);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "Forcing audio preload to 0, max pts correction to 0.\n");
audio_preload = 0.0;
default_max_pts_correction = 0;
}
@@ -1220,7 +1229,7 @@ if(sh_audio){
frame_data.in_size=video_read_frame(sh_video,&frame_data.frame_time,&frame_data.start,force_fps);
sh_video->timer+=frame_data.frame_time;
}
- frame_data.frame_time /= playback_speed;
+ frame_data.frame_time /= opts.playback_speed;
if(frame_data.in_size<0){ at_eof=1; break; }
++decoded_frameno;
@@ -1293,9 +1302,16 @@ case VCODEC_FRAMENO:
break;
default:
// decode_video will callback down to ve_*.c encoders, through the video filters
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SET_OSD_OBJ, osd);
{void *decoded_frame = decode_video(sh_video,frame_data.start,frame_data.in_size,
- skip_flag>0 && (!sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE), MP_NOPTS_VALUE);
- blit_frame = decoded_frame && filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE);}
+ skip_flag>0 && (!sh_video->vfilter || sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE), MP_NOPTS_VALUE);
+ blit_frame = decoded_frame && filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE);
+ if (blit_frame) {
+ struct vf_instance *vf = sh_video->vfilter;
+ vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
+ vf->control(vf, VFCTRL_DRAW_OSD, osd);
+ }
+ }
if (sh_video->vf_initialized < 0) mencoder_exit(1, NULL);
@@ -1314,7 +1330,7 @@ default:
// Eventually this entire block should probably be removed.
if(skip_limit==0){
// skipping not allowed -> write empty frame:
- if (!encode_duplicates || !sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
+ if (!encode_duplicates || !sh_video->vfilter || sh_video->vfilter->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
muxer_write_chunk(mux_v,0,0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
} else {
// skipping allowed -> skip it and distriubute timer error:
@@ -1330,17 +1346,17 @@ videorate+=(GetTimerMS() - ptimer_start);
if(skip_flag<0){
// duplicate frame
- if(!quiet) mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_DuplicateFrames,-skip_flag);
+ if(!quiet) mp_tmsg(MSGT_MENCODER, MSGL_WARN, "\n%d duplicate frame(s)!\n",-skip_flag);
while(skip_flag<0){
duplicatedframes++;
- if (!encode_duplicates || !sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
+ if (!encode_duplicates || !sh_video->vfilter || sh_video->vfilter->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
muxer_write_chunk(mux_v,0,0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
++skip_flag;
}
} else
if(skip_flag>0){
// skip frame
- if(!quiet) mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_SkipFrame);
+ if(!quiet) mp_tmsg(MSGT_MENCODER, MSGL_WARN, "\nSkipping frame!\n");
skippedframes++;
--skip_flag;
}
@@ -1369,7 +1385,7 @@ if(sh_audio && !demuxer2){
// av = compensated (with out buffering delay) A-V diff
AV_delay=(a_pts-v_pts);
AV_delay-=audio_delay;
- AV_delay /= playback_speed;
+ AV_delay /= opts.playback_speed;
AV_delay-=mux_a->timer-(mux_v->timer-(v_timer_corr+v_pts_corr));
// adjust for encoder delays
AV_delay -= (float) mux_a->encoder_delay * mux_a->h.dwScale/mux_a->h.dwRate;
@@ -1379,9 +1395,9 @@ if(sh_audio && !demuxer2){
if(x<-max_pts_correction) x=-max_pts_correction; else
if(x> max_pts_correction) x= max_pts_correction;
if(default_max_pts_correction>=0)
- max_pts_correction=default_max_pts_correction*playback_speed;
+ max_pts_correction=default_max_pts_correction*opts.playback_speed;
else
- max_pts_correction=sh_video->frametime*0.10 *playback_speed; // +-10% of time
+ max_pts_correction=sh_video->frametime*0.10 *opts.playback_speed; // +-10% of time
// sh_video->timer-=x;
c_total+=x;
v_pts_corr+=x;
@@ -1460,13 +1476,13 @@ if(sh_audio && !demuxer2){
}
else
#endif
- update_subtitles(sh_video, d_dvdsub, 0);
+ update_subtitles(sh_video, d_dvdsub, 0, 0);
frame_data = (s_frame_data){ .start = NULL, .in_size = 0, .frame_time = 0., .already_read = 0 };
#if 0
if(ferror(muxer_f)) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"%s: Error writing file.\n", out_filename);
mencoder_exit(1, NULL);
}
#endif
@@ -1496,11 +1512,11 @@ if (!interrupted && filelist[++curfile].name != 0) {
/* Emit the remaining frames in the video system */
/*TODO emit frmaes delayed by decoder lag*/
if(sh_video && sh_video->vfilter){
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_FlushingVideoFrames);
- if (!((vf_instance_t *)sh_video->vfilter)->fmt.have_configured)
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_FiltersHaveNotBeenConfiguredEmptyFile);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "\nFlushing video frames.\n");
+ if (!sh_video->vfilter->fmt.have_configured)
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "Filters have not been configured! Empty file?\n");
else
- ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter,
+ sh_video->vfilter->control(sh_video->vfilter,
VFCTRL_FLUSH_FRAMES, 0);
}
@@ -1514,7 +1530,7 @@ stream_seek(muxer->stream,0);
if (muxer->cont_write_header) muxer_write_header(muxer); // update header
#if 0
if(ferror(muxer_f) || fclose(muxer_f) != 0) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"%s: Error writing file.\n", out_filename);
mencoder_exit(1, NULL);
}
#endif
@@ -1522,18 +1538,18 @@ if(vobsub_writer)
vobsub_out_close(vobsub_writer);
if(out_video_codec==VCODEC_FRAMENO && mux_v->timer>100){
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_RecommendedVideoBitrate,"650MB",(int)((650*1024*1024-muxer_f_size)/mux_v->timer/125));
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_RecommendedVideoBitrate,"700MB",(int)((700*1024*1024-muxer_f_size)/mux_v->timer/125));
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_RecommendedVideoBitrate,"800MB",(int)((800*1024*1024-muxer_f_size)/mux_v->timer/125));
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_RecommendedVideoBitrate,"2 x 650MB",(int)((2*650*1024*1024-muxer_f_size)/mux_v->timer/125));
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_RecommendedVideoBitrate,"2 x 700MB",(int)((2*700*1024*1024-muxer_f_size)/mux_v->timer/125));
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_RecommendedVideoBitrate,"2 x 800MB",(int)((2*800*1024*1024-muxer_f_size)/mux_v->timer/125));
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Recommended video bitrate for %s CD: %d\n","650MB",(int)((650*1024*1024-muxer_f_size)/mux_v->timer/125));
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Recommended video bitrate for %s CD: %d\n","700MB",(int)((700*1024*1024-muxer_f_size)/mux_v->timer/125));
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Recommended video bitrate for %s CD: %d\n","800MB",(int)((800*1024*1024-muxer_f_size)/mux_v->timer/125));
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Recommended video bitrate for %s CD: %d\n","2 x 650MB",(int)((2*650*1024*1024-muxer_f_size)/mux_v->timer/125));
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Recommended video bitrate for %s CD: %d\n","2 x 700MB",(int)((2*700*1024*1024-muxer_f_size)/mux_v->timer/125));
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Recommended video bitrate for %s CD: %d\n","2 x 800MB",(int)((2*800*1024*1024-muxer_f_size)/mux_v->timer/125));
}
-mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_VideoStreamResult,
+mp_tmsg(MSGT_MENCODER, MSGL_INFO, "\nVideo stream: %8.3f kbit/s (%d B/s) size: %"PRIu64" bytes %5.3f secs %d frames\n",
(float)(mux_v->size/mux_v->timer*8.0f/1000.0f), (int)(mux_v->size/mux_v->timer), (uint64_t)mux_v->size, (float)mux_v->timer, decoded_frameno);
if(sh_audio)
-mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_AudioStreamResult,
+mp_tmsg(MSGT_MENCODER, MSGL_INFO, "\nAudio stream: %8.3f kbit/s (%d B/s) size: %"PRIu64" bytes %5.3f secs\n",
(float)(mux_a->size/mux_a->timer*8.0f/1000.0f), (int)(mux_a->size/mux_a->timer), (uint64_t)mux_a->size, (float)mux_a->timer);
if(sh_audio){ uninit_audio(sh_audio);sh_audio=NULL; }
@@ -1655,14 +1671,20 @@ static int slowseek(float end_pts, demux_stream_t *d_video, demux_stream_t *d_au
if (sh_video->pts >= end_pts) done = 1;
if (vfilter) {
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SET_OSD_OBJ,
+ osd);
int softskip = (vfilter->control(vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) == CONTROL_TRUE);
void *decoded_frame = decode_video(sh_video, frame_data->start, frame_data->in_size, !softskip, MP_NOPTS_VALUE);
if (decoded_frame)
- filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE);
+ if (filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE)) {
+ struct vf_instance *vf = sh_video->vfilter;
+ vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
+ vf->control(vf, VFCTRL_DRAW_OSD, osd);
+ }
}
- if (print_info) mp_msg(MSGT_MENCODER, MSGL_STATUS,
- MSGTR_EdlSkipStartEndCurrent,
+ if (print_info) mp_tmsg(MSGT_MENCODER, MSGL_STATUS,
+ "EDL SKIP: Start: %.2f End: %.2f Current: V: %.2f A: %.2f \r",
next_edl_record->start_sec, next_edl_record->stop_sec,
sh_video->pts, a_pts);
}
diff --git a/metadata.h b/metadata.h
index 6a31d75f4b..06c3822d81 100644
--- a/metadata.h
+++ b/metadata.h
@@ -48,7 +48,8 @@ enum metadata_s {
META_INFO_GENRE
};
-char *get_metadata (metadata_t type);
+struct MPContext;
-#endif /* MPLAYER_METADATA_H */
+char *get_metadata(struct MPContext *mpctx, metadata_t type);
+#endif /* MPLAYER_METADATA_H */
diff --git a/mixer.c b/mixer.c
index 3e66b78cfc..26b4ff665e 100644
--- a/mixer.c
+++ b/mixer.c
@@ -64,11 +64,11 @@ void mixer_setvolume(mixer_t *mixer, float l, float r)
af_to_dB (AF_NCH, db_vals, db_vals, 20.0);
if (!af_control_any_rev(mixer->afilter,
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) {
- mp_msg(MSGT_GLOBAL, MSGL_INFO, MSGTR_InsertingAfVolume);
+ mp_tmsg(MSGT_GLOBAL, MSGL_INFO, "[Mixer] No hardware mixing, inserting volume filter.\n");
if (af_add(mixer->afilter, "volume")) {
if (!af_control_any_rev(mixer->afilter,
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) {
- mp_msg(MSGT_GLOBAL, MSGL_ERR, MSGTR_NoVolume);
+ mp_tmsg(MSGT_GLOBAL, MSGL_ERR, "[Mixer] No volume control available.\n");
return;
}
}
@@ -142,7 +142,7 @@ void mixer_setbalance(mixer_t *mixer, float val)
return;
if (!(af_pan_balance = af_add(mixer->afilter, "pan"))) {
- mp_msg(MSGT_GLOBAL, MSGL_ERR, MSGTR_NoBalance);
+ mp_tmsg(MSGT_GLOBAL, MSGL_ERR, "[Mixer] No balance control available.\n");
return;
}
@@ -160,4 +160,3 @@ void mixer_setbalance(mixer_t *mixer, float val)
af_pan_balance->control(af_pan_balance,
AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val);
}
-
diff --git a/mp3lib/dct36.c b/mp3lib/dct36.c
index 753c2f25d5..b884bb949d 100644
--- a/mp3lib/dct36.c
+++ b/mp3lib/dct36.c
@@ -267,4 +267,3 @@ static void dct36(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf)
}
}
-
diff --git a/mp3lib/huffman.h b/mp3lib/huffman.h
index aa9e7b91fa..63cb978c7e 100644
--- a/mp3lib/huffman.h
+++ b/mp3lib/huffman.h
@@ -328,5 +328,3 @@ static struct newhuff htc[] =
{ /* 1 , 1 , */ 0 , tab_c0 } ,
{ /* 1 , 1 , */ 0 , tab_c1 }
};
-
-
diff --git a/mp3lib/l2tables.h b/mp3lib/l2tables.h
index f62a546088..5f08a4f5a7 100644
--- a/mp3lib/l2tables.h
+++ b/mp3lib/l2tables.h
@@ -157,4 +157,3 @@ static struct al_table alloc_4[] = {
{2,0},{5,3},{7,5},{10,9},
{2,0},{5,3},{7,5},{10,9},
{2,0},{5,3},{7,5},{10,9} };
-
diff --git a/mp3lib/layer1.c b/mp3lib/layer1.c
index 9a50b5df47..3b560ec24b 100644
--- a/mp3lib/layer1.c
+++ b/mp3lib/layer1.c
@@ -163,5 +163,3 @@ static int do_layer1(struct frame *fr,int single)
return clip;
}
-
-
diff --git a/mp3lib/layer3.c b/mp3lib/layer3.c
index 398e631913..b89bc9844d 100644
--- a/mp3lib/layer3.c
+++ b/mp3lib/layer3.c
@@ -1345,5 +1345,3 @@ static int do_layer3(struct frame *fr,int single){
return clip;
}
-
-
diff --git a/mp_core.h b/mp_core.h
index 2fa98e57d4..5b3f954366 100644
--- a/mp_core.h
+++ b/mp_core.h
@@ -1,14 +1,10 @@
#ifndef MPLAYER_MP_CORE_H
#define MPLAYER_MP_CORE_H
-#include "mp_osd.h"
-#include "libao2/audio_out.h"
-#include "playtree.h"
-#include "stream/stream.h"
-#include "libmpdemux/demuxer.h"
-#include "libmpdemux/stheader.h"
+#include <stdbool.h>
+
+#include "options.h"
#include "mixer.h"
-#include "libvo/video_out.h"
#include "subreader.h"
// definitions used internally by the core player code
@@ -19,7 +15,6 @@
#define INITIALIZED_GETCH2 8
#define INITIALIZED_SPUDEC 32
#define INITIALIZED_STREAM 64
-#define INITIALIZED_INPUT 128
#define INITIALIZED_VOBSUB 256
#define INITIALIZED_DEMUXER 512
#define INITIALIZED_ACODEC 1024
@@ -33,13 +28,17 @@
#define SUB_SOURCES 3
-#define PT_NEXT_ENTRY 1
-#define PT_PREV_ENTRY -1
-#define PT_NEXT_SRC 2
-#define PT_PREV_SRC -2
-#define PT_UP_NEXT 3
-#define PT_UP_PREV -3
-#define PT_STOP 4
+enum stop_play_reason {
+ KEEP_PLAYING = 0, // must be 0, numeric values of others do not matter
+ AT_END_OF_FILE,
+ PT_NEXT_ENTRY,
+ PT_PREV_ENTRY,
+ PT_NEXT_SRC,
+ PT_PREV_SRC,
+ PT_UP_NEXT,
+ PT_UP_PREV,
+ PT_STOP,
+};
typedef enum {
EXIT_NONE,
@@ -48,36 +47,98 @@ typedef enum {
EXIT_ERROR
} exit_reason_t;
+struct content_source {
+ struct stream *stream;
+ struct demuxer *demuxer;
+};
+
+struct timeline_part {
+ double start;
+ double source_start;
+ struct content_source *source;
+};
+
+struct chapter {
+ double start;
+ char *name;
+};
+
typedef struct MPContext {
- int osd_show_percentage;
+ struct MPOpts opts;
+ struct m_config *mconfig;
+ struct vo_x11_state *x11_state;
+ struct mp_fifo *key_fifo;
+ struct input_ctx *input;
+ struct osd_state *osd;
+
+ bool add_osd_seek_info;
+ // if nonzero, hide current OSD contents when GetTimerMS() reaches this
+ unsigned int osd_show_percentage_until;
+ unsigned int osd_visible;
+
int osd_function;
const ao_functions_t *audio_out;
- play_tree_t *playtree;
- play_tree_iter_t *playtree_iter;
- int eof;
+ struct play_tree *playtree;
+ struct play_tree_iter *playtree_iter;
+ char *filename; // currently playing file
+ enum stop_play_reason stop_play;
int play_tree_step;
- int loop_times;
-
- stream_t *stream;
- demuxer_t *demuxer;
- sh_audio_t *sh_audio;
- sh_video_t *sh_video;
- demux_stream_t *d_audio;
- demux_stream_t *d_video;
- demux_stream_t *d_sub;
+ unsigned int initialized_flags; // which subsystems have been initialized
+
+ struct content_source *sources;
+ int num_sources;
+ struct timeline_part *timeline;
+ int num_timeline_parts;
+ int timeline_part;
+ struct chapter *chapters;
+ int num_chapters;
+ double video_offset;
+
+ struct stream *stream;
+ struct demuxer *demuxer;
+ struct sh_audio *sh_audio;
+ struct sh_video *sh_video;
+ struct demux_stream *d_audio;
+ struct demux_stream *d_video;
+ struct demux_stream *d_sub;
mixer_t mixer;
- const vo_functions_t *video_out;
+ struct vo *video_out;
// Frames buffered in the vo ready to flip. Currently always 0 or 1.
// This is really a vo variable but currently there's no suitable vo
// struct.
int num_buffered_frames;
+ // Show a video frame as quickly as possible without trying to adjust
+ // for AV sync. Used when starting a file or after seeking.
+ bool update_video_immediately;
// AV sync: the next frame should be shown when the audio out has this
// much (in seconds) buffered data left. Increased when more data is
// written to the ao, decreased when moving to the next frame.
// In the audio-only case used as a timer since the last seek
// by the audio CPU usage meter.
double delay;
+ // AV sync: time until next frame should be shown
+ float time_frame;
+ // How long the last vo flip() call took. Used to adjust timing with
+ // the goal of making flip() calls finish (rather than start) at the
+ // specified time.
+ float last_vo_flip_duration;
+ // How much video timing has been changed to make it match the audio
+ // timeline. Used for status line information only.
+ double total_avsync_change;
+ // A-V sync difference when last frame was displayed. Kept to display
+ // the same value if the status line is updated at a time where no new
+ // video frame is shown.
+ double last_av_difference;
+
+ // Timestamp from the last time some timing functions read the
+ // current time, in (occasionally wrapping) microseconds. Used
+ // to turn a new time value to a delta from last time.
+ unsigned int last_time;
+
+ // Used to communicate the parameters of a seek between parts
+ double rel_seek_secs;
+ int abs_seek_pos;
float begin_skip; ///< start time of the current skip while on edlout mode
// audio is muted if either EDL or user activates mute
@@ -89,24 +150,26 @@ typedef struct MPContext {
int set_of_sub_pos;
int set_of_sub_size;
int global_sub_indices[SUB_SOURCES];
-#ifdef CONFIG_ASS
// set_of_ass_tracks[i] contains subtitles from set_of_subtitles[i]
// parsed by libass or NULL if format unsupported
- ass_track_t* set_of_ass_tracks[MAX_SUBTITLE_FILES];
-#endif
+ struct ass_track_s *set_of_ass_tracks[MAX_SUBTITLE_FILES];
sub_data* set_of_subtitles[MAX_SUBTITLE_FILES];
int file_format;
-#ifdef CONFIG_DVBIN
int last_dvb_step;
int dvbin_reopen;
-#endif
- int was_paused;
+ int paused;
+ // step this many frames, then pause
+ int step_frames;
+
+ // Set after showing warning about decoding being too slow for realtime
+ // playback rate. Used to avoid showing it multiple times.
+ bool drop_message_shown;
#ifdef CONFIG_DVDNAV
- struct mp_image_s *nav_smpi; ///< last decoded dvdnav video image
+ struct mp_image *nav_smpi; ///< last decoded dvdnav video image
unsigned char *nav_buffer; ///< last read dvdnav video frame
unsigned char *nav_start; ///< pointer to last read video buffer
int nav_in_size; ///< last read size
@@ -115,24 +178,26 @@ typedef struct MPContext {
// Most of these should not be globals
-extern int abs_seek_pos;
-extern float rel_seek_secs;
extern FILE *edl_fd;
extern int file_filter;
// These appear in options list
-extern float playback_speed;
-extern int fixed_vo;
extern int forced_subs_only;
-
-int build_afilter_chain(sh_audio_t *sh_audio, ao_data_t *ao_data);
-void uninit_player(unsigned int mask);
-void reinit_audio_chain(void);
-void init_vo_spudec(void);
-double playing_audio_pts(sh_audio_t *sh_audio, demux_stream_t *d_audio,
- const ao_functions_t *audio_out);
-void exit_player_with_rc(exit_reason_t how, int rc);
-void add_subtitles(char *filename, float fps, int noerr);
-int reinit_video_chain(void);
+struct ao_data;
+int build_afilter_chain(struct MPContext *mpctx, struct sh_audio *sh_audio, struct ao_data *ao_data);
+void uninit_player(struct MPContext *mpctx, unsigned int mask);
+void reinit_audio_chain(struct MPContext *mpctx);
+void init_vo_spudec(struct MPContext *mpctx);
+double playing_audio_pts(struct MPContext *mpctx);
+void exit_player_with_rc(struct MPContext *mpctx, exit_reason_t how, int rc);
+void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr);
+int reinit_video_chain(struct MPContext *mpctx);
+void pause_player(struct MPContext *mpctx);
+void unpause_player(struct MPContext *mpctx);
+void add_step_frame(struct MPContext *mpctx);
+int seek_chapter(struct MPContext *mpctx, int chapter, double *seek_pts,
+ char **chapter_name);
+int get_current_chapter(struct MPContext *mpctx);
+char *chapter_display_name(struct MPContext *mpctx, int chapter);
#endif /* MPLAYER_MP_CORE_H */
diff --git a/mp_fifo.c b/mp_fifo.c
index 5d0159dfd8..62228e8558 100644
--- a/mp_fifo.c
+++ b/mp_fifo.c
@@ -2,69 +2,82 @@
#include "osdep/timer.h"
#include "input/input.h"
#include "input/mouse.h"
+#include "mp_fifo.h"
+#include "talloc.h"
+#include "options.h"
-int key_fifo_size = 7;
-static int *key_fifo_data = NULL;
-static int key_fifo_read=0;
-static int key_fifo_write=0;
+struct mp_fifo {
+ struct MPOpts *opts;
+ int *data;
+ int readpos;
+ int writepos;
+ int size;
+ unsigned last_key_time[2];
+ int last_key[2];
+};
-static void mplayer_put_key_internal(int code){
- int fifo_free = key_fifo_read - key_fifo_write - 1;
- if (fifo_free < 0) fifo_free += key_fifo_size;
-// printf("mplayer_put_key(%d)\n",code);
- if (key_fifo_data == NULL)
- key_fifo_data = malloc(key_fifo_size * sizeof(int));
- if(!fifo_free) return; // FIFO FULL!!
- // reserve some space for key release events to avoid stuck keys
- if((code & MP_KEY_DOWN) && fifo_free < (key_fifo_size >> 1))
- return;
- key_fifo_data[key_fifo_write]=code;
- key_fifo_write=(key_fifo_write+1)%key_fifo_size;
+struct mp_fifo *mp_fifo_create(struct MPOpts *opts)
+{
+ struct mp_fifo *fifo = talloc_zero(NULL, struct mp_fifo);
+ fifo->opts = opts;
+ fifo->size = opts->key_fifo_size;
+ fifo->data = talloc_array_ptrtype(fifo, fifo->data, fifo->size);
+ return fifo;
}
-int mplayer_get_key(int fd){
- int key;
-// printf("mplayer_get_key(%d)\n",fd);
- if (key_fifo_data == NULL)
- return MP_INPUT_NOTHING;
- if(key_fifo_write==key_fifo_read) return MP_INPUT_NOTHING;
- key=key_fifo_data[key_fifo_read];
- key_fifo_read=(key_fifo_read+1)%key_fifo_size;
-// printf("mplayer_get_key => %d\n",key);
- return key;
+static void mplayer_put_key_internal(struct mp_fifo *fifo, int code)
+{
+ int fifo_free = fifo->readpos - fifo->writepos - 1;
+ if (fifo_free < 0)
+ fifo_free += fifo->size;
+ if (!fifo_free)
+ return; // FIFO FULL!!
+ // reserve some space for key release events to avoid stuck keys
+ if((code & MP_KEY_DOWN) && fifo_free < (fifo->size >> 1))
+ return;
+ fifo->data[fifo->writepos++] = code;
+ fifo->writepos %= fifo->size;
}
+int mplayer_get_key(void *ctx, int fd)
+{
+ struct mp_fifo *fifo = ctx;
+ if (fifo->writepos == fifo->readpos)
+ return MP_INPUT_NOTHING;
+ int key = fifo->data[fifo->readpos++];
+ fifo->readpos %= fifo->size;
+ return key;
+}
-unsigned doubleclick_time = 300;
-
-static void put_double(int code) {
+static void put_double(struct mp_fifo *fifo, int code)
+{
if (code >= MOUSE_BTN0 && code <= MOUSE_BTN9)
- mplayer_put_key_internal(code - MOUSE_BTN0 + MOUSE_BTN0_DBL);
+ mplayer_put_key_internal(fifo, code - MOUSE_BTN0 + MOUSE_BTN0_DBL);
}
-void mplayer_put_key(int code) {
- static unsigned last_key_time[2];
- static int last_key[2];
- unsigned now = GetTimerMS();
- // ignore system-doubleclick if we generate these events ourselves
- if (doubleclick_time &&
- (code & ~MP_KEY_DOWN) >= MOUSE_BTN0_DBL &&
- (code & ~MP_KEY_DOWN) <= MOUSE_BTN9_DBL)
- return;
- mplayer_put_key_internal(code);
- if (code & MP_KEY_DOWN) {
- code &= ~MP_KEY_DOWN;
- last_key[1] = last_key[0];
- last_key[0] = code;
- last_key_time[1] = last_key_time[0];
- last_key_time[0] = now;
- if (last_key[1] == code &&
- now - last_key_time[1] < doubleclick_time)
- put_double(code);
- return;
- }
- if (last_key[0] == code && last_key[1] == code &&
- now - last_key_time[1] < doubleclick_time)
- put_double(code);
+void mplayer_put_key(struct mp_fifo *fifo, int code)
+{
+ unsigned now = GetTimerMS();
+ int doubleclick_time = fifo->opts->doubleclick_time;
+ // ignore system-doubleclick if we generate these events ourselves
+ if (doubleclick_time
+ && (code & ~MP_KEY_DOWN) >= MOUSE_BTN0_DBL
+ && (code & ~MP_KEY_DOWN) <= MOUSE_BTN9_DBL)
+ return;
+ mplayer_put_key_internal(fifo, code);
+ if (code & MP_KEY_DOWN) {
+ code &= ~MP_KEY_DOWN;
+ fifo->last_key[1] = fifo->last_key[0];
+ fifo->last_key[0] = code;
+ fifo->last_key_time[1] = fifo->last_key_time[0];
+ fifo->last_key_time[0] = now;
+ if (fifo->last_key[1] == code
+ && now - fifo->last_key_time[1] < doubleclick_time)
+ put_double(fifo, code);
+ return;
+ }
+ if (fifo->last_key[0] == code && fifo->last_key[1] == code
+ && now - fifo->last_key_time[1] < doubleclick_time)
+ put_double(fifo, code);
}
diff --git a/mp_fifo.h b/mp_fifo.h
index 5a5c925462..751de324b6 100644
--- a/mp_fifo.h
+++ b/mp_fifo.h
@@ -1,7 +1,16 @@
#ifndef MPLAYER_MP_FIFO_H
#define MPLAYER_MP_FIFO_H
-int mplayer_get_key(int fd);
-void mplayer_put_key(int code);
+struct mp_fifo;
+int mplayer_get_key(void *ctx, int fd);
+void mplayer_put_key(struct mp_fifo *fifo, int code);
+// Can be freed with talloc_free()
+struct MPOpts;
+struct mp_fifo *mp_fifo_create(struct MPOpts *opts);
+
+
+#ifdef IS_OLD_VO
+#define mplayer_put_key(key) mplayer_put_key(global_vo->key_fifo, key)
+#endif
#endif /* MPLAYER_MP_FIFO_H */
diff --git a/mp_msg.c b/mp_msg.c
index 85e792408d..8099305d6f 100644
--- a/mp_msg.c
+++ b/mp_msg.c
@@ -230,3 +230,8 @@ void mp_msg(int mod, int lev, const char *format, ... ){
fprintf(stream, "%s", tmp);
fflush(stream);
}
+
+char *mp_gtext(const char *string)
+{
+ return string;
+}
diff --git a/mp_msg.h b/mp_msg.h
index 0f2776f922..3a81603992 100644
--- a/mp_msg.h
+++ b/mp_msg.h
@@ -4,6 +4,9 @@
// defined in mplayer.c and mencoder.c
extern int verbose;
+/* No-op macro to mark translated strings in the sources */
+#define _(x) x
+
// verbosity elevel:
/* Only messages level MSGL_FATAL-MSGL_STATUS should be translated,
@@ -111,6 +114,9 @@ int mp_msg_test(int mod, int lev);
#include "config.h"
+char *mp_gtext(const char *string);
+#define mp_tmsg mp_msg
+
#ifdef __GNUC__
void mp_msg(int mod, int lev, const char *format, ... ) __attribute__ ((format (printf, 3, 4)));
# ifdef MP_DEBUG
diff --git a/mp_osd.h b/mp_osd.h
index f3b2a69561..6a1b3b94fe 100644
--- a/mp_osd.h
+++ b/mp_osd.h
@@ -16,10 +16,11 @@
#define MAX_TERM_OSD_LEVEL 1
// These appear in options list
-extern int osd_duration;
extern int term_osd;
-void set_osd_bar(int type,const char* name,double min,double max,double val);
+struct MPContext;
+
+void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,double max,double val);
void set_osd_msg(int id, int level, int time, const char* fmt, ...);
void rm_osd_msg(int id);
diff --git a/mpcommon.c b/mpcommon.c
index 248e609151..836ed8e44c 100644
--- a/mpcommon.c
+++ b/mpcommon.c
@@ -1,4 +1,6 @@
#include <stdlib.h>
+#include "mpcommon.h"
+#include "options.h"
#include "stream/stream.h"
#include "libmpdemux/demuxer.h"
#include "libmpdemux/stheader.h"
@@ -42,9 +44,9 @@ void print_version(const char* name)
gCpuCaps.has3DNow, gCpuCaps.has3DNowExt,
gCpuCaps.hasSSE, gCpuCaps.hasSSE2, gCpuCaps.hasSSSE3);
#if CONFIG_RUNTIME_CPUDETECT
- mp_msg(MSGT_CPLAYER,MSGL_V, MSGTR_CompiledWithRuntimeDetection);
+ mp_tmsg(MSGT_CPLAYER,MSGL_V, "Compiled with runtime CPU detection.\n");
#else
- mp_msg(MSGT_CPLAYER,MSGL_V, MSGTR_CompiledWithCPUExtensions);
+ mp_tmsg(MSGT_CPLAYER,MSGL_V, "Compiled for x86 CPU with extensions:");
if (HAVE_MMX)
mp_msg(MSGT_CPLAYER,MSGL_V," MMX");
if (HAVE_MMX2)
@@ -67,8 +69,10 @@ if (HAVE_CMOV)
}
-void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
+void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub,
+ double video_offset, int reset)
{
+ struct MPOpts *opts = sh_video->opts;
unsigned char *packet=NULL;
int len;
char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v';
@@ -99,8 +103,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
}
// DVD sub:
- if (vo_config_count && vo_spudec &&
- (vobsub_id >= 0 || (dvdsub_id >= 0 && type == 'v'))) {
+ if (vo_spudec && (vobsub_id >= 0 || (opts->sub_id >= 0 && type == 'v'))) {
int timestamp;
current_module = "spudec";
spudec_heartbeat(vo_spudec, 90000*sh_video->timer);
@@ -144,15 +147,16 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
if (spudec_changed(vo_spudec))
vo_osd_changed(OSDTYPE_SPU);
- } else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a')) {
+ } else if (opts->sub_id >= 0
+ && (type == 't' || type == 'm' || type == 'a')) {
double curpts = sh_video->pts + sub_delay;
double endpts;
vo_sub = &subs;
while (d_dvdsub->first) {
- double pts = ds_get_next_pts(d_dvdsub);
+ double pts = ds_get_next_pts(d_dvdsub) + video_offset;
if (pts > curpts)
break;
- endpts = d_dvdsub->first->endpts;
+ endpts = d_dvdsub->first->endpts + video_offset;
len = ds_get_packet_sub(d_dvdsub, &packet);
if (type == 'm') {
if (len < 2) continue;
diff --git a/mpcommon.h b/mpcommon.h
index a0c6fb8ff8..c9bfd92122 100644
--- a/mpcommon.h
+++ b/mpcommon.h
@@ -10,7 +10,8 @@ extern struct ass_track_s *ass_track;
extern subtitle *vo_sub_last;
void print_version(const char* name);
-void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset);
+void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub,
+ double video_offset, int reset);
void update_teletext(sh_video_t *sh_video, demuxer_t *demuxer, int reset);
int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang);
diff --git a/mplayer.c b/mplayer.c
index d64f5268e2..505bd41d8d 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -4,7 +4,9 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include "config.h"
+#include "talloc.h"
#if defined(__MINGW32__) || defined(__CYGWIN__)
#define _UWIN 1 /*disable Non-underscored versions of non-ANSI functions as otherwise int eof would conflict with eof()*/
@@ -43,6 +45,8 @@
#include "m_option.h"
#include "m_config.h"
+#include "mplayer.h"
+#include "access_mpcontext.h"
#include "m_property.h"
#include "cfg-mplayer-def.h"
@@ -51,6 +55,7 @@
#include "subreader.h"
+#include "mp_osd.h"
#include "libvo/video_out.h"
#include "libvo/font_load.h"
@@ -71,6 +76,7 @@
#include "osdep/getch2.h"
#include "osdep/timer.h"
+#include "osdep/findfiles.h"
#ifdef CONFIG_GUI
#include "gui/interface.h"
@@ -78,6 +84,7 @@
#include "input/input.h"
+const int under_mencoder = 0;
int slave_mode=0;
int player_idle_mode=0;
int quiet=0;
@@ -127,27 +134,15 @@ int import_initial_playtree_into_gui(play_tree_t* my_playtree, m_config_t* confi
#include "parser-cfg.h"
#include "parser-mpcmd.h"
-m_config_t* mconfig;
-
//**************************************************************************//
// Config file
//**************************************************************************//
static int cfg_inc_verbose(m_option_t *conf){ ++verbose; return 0;}
-static int cfg_include(m_option_t *conf, char *filename){
- return m_config_parse_config_file(mconfig, filename);
-}
-
#include "get_path.h"
//**************************************************************************//
-// XScreensaver
-//**************************************************************************//
-
-void xscreensaver_heartbeat(void);
-
-//**************************************************************************//
//**************************************************************************//
// Input media streaming & demultiplexer:
//**************************************************************************//
@@ -175,6 +170,54 @@ static int max_framesize=0;
#include "mixer.h"
#include "mp_core.h"
+#include "options.h"
+#include "defaultopts.h"
+
+#define Exit_SIGILL_RTCpuSel _(\
+"- MPlayer crashed by an 'Illegal Instruction'.\n"\
+" It may be a bug in our new runtime CPU-detection code...\n"\
+" Please read DOCS/HTML/en/bugreports.html.\n")
+
+#define Exit_SIGILL _(\
+"- MPlayer crashed by an 'Illegal Instruction'.\n"\
+" It usually happens when you run it on a CPU different than the one it was\n"\
+" compiled/optimized for.\n"\
+" Verify this!\n")
+
+#define Exit_SIGSEGV_SIGFPE _(\
+"- MPlayer crashed by bad usage of CPU/FPU/RAM.\n"\
+" Recompile MPlayer with --enable-debug and make a 'gdb' backtrace and\n"\
+" disassembly. Details in DOCS/HTML/en/bugreports_what.html#bugreports_crash.\n")
+
+#define Exit_SIGCRASH _(\
+"- MPlayer crashed. This shouldn't happen.\n"\
+" It can be a bug in the MPlayer code _or_ in your drivers _or_ in your\n"\
+" gcc version. If you think it's MPlayer's fault, please read\n"\
+" DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and\n"\
+" won't help unless you provide this information when reporting a possible bug.\n")
+
+#define SystemTooSlow _("\n\n"\
+" ************************************************\n"\
+" **** Your system is too SLOW to play this! ****\n"\
+" ************************************************\n\n"\
+"Possible reasons, problems, workarounds:\n"\
+"- Most common: broken/buggy _audio_ driver\n"\
+" - Try -ao sdl or use the OSS emulation of ALSA.\n"\
+" - Experiment with different values for -autosync, 30 is a good start.\n"\
+"- Slow video output\n"\
+" - Try a different -vo driver (-vo help for a list) or try -framedrop!\n"\
+"- Slow CPU\n"\
+" - Don't try to play a big DVD/DivX on a slow CPU! Try some of the lavdopts,\n"\
+" e.g. -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all.\n"\
+"- Broken file\n"\
+" - Try various combinations of -nobps -ni -forceidx -mc 0.\n"\
+"- Slow media (NFS/SMB mounts, DVD, VCD etc)\n"\
+" - Try -cache 8192.\n"\
+"- Are you using -cache to play a non-interleaved AVI file?\n"\
+" - Try -nocache.\n"\
+"Read DOCS/HTML/en/video.html for tuning/speedup tips.\n"\
+"If none of this helps you, read DOCS/HTML/en/bugreports.html.\n\n")
+
//**************************************************************************//
//**************************************************************************//
@@ -184,24 +227,6 @@ static int max_framesize=0;
int noconsolecontrols=0;
//**************************************************************************//
-// Not all functions in mplayer.c take the context as an argument yet
-static MPContext mpctx_s = {
- .osd_function = OSD_PLAY,
- .begin_skip = MP_NOPTS_VALUE,
- .play_tree_step = 1,
- .global_sub_pos = -1,
- .set_of_sub_pos = -1,
- .file_format = DEMUXER_TYPE_UNKNOWN,
- .loop_times = -1,
-#ifdef CONFIG_DVBIN
- .last_dvb_step = 1,
-#endif
-};
-
-static MPContext *mpctx = &mpctx_s;
-
-int fixed_vo=0;
-
// benchmark:
double video_time_usage=0;
double vout_time_usage=0;
@@ -215,8 +240,6 @@ int benchmark=0;
int auto_quality=0;
static int output_quality=0;
-float playback_speed=1.0;
-
int use_gui=0;
#ifdef CONFIG_GUI
@@ -225,11 +248,6 @@ int enqueue=0;
static int list_properties = 0;
-int osd_level=1;
-// if nonzero, hide current OSD contents when GetTimerMS() reaches this
-unsigned int osd_visible;
-int osd_duration = 1000;
-
int term_osd = 1;
static char* term_osd_esc = "\x1b[A\r\x1b[K";
static char* playing_msg = NULL;
@@ -237,17 +255,12 @@ static char* playing_msg = NULL;
static double seek_to_sec;
static off_t seek_to_byte=0;
static off_t step_sec=0;
-static int loop_seek=0;
static m_time_size_t end_at = { .type = END_AT_NONE, .pos = 0 };
// A/V sync:
int autosync=0; // 30 might be a good default value.
-// may be changed by GUI: (FIXME!)
-float rel_seek_secs=0;
-int abs_seek_pos=0;
-
// codecs:
char **audio_codec_list=NULL; // override audio codec
char **video_codec_list=NULL; // override video codec
@@ -259,15 +272,10 @@ extern char *demuxer_name; // override demuxer
extern char *audio_demuxer_name; // override audio demuxer
extern char *sub_demuxer_name; // override sub demuxer
-// streaming:
-int audio_id=-1;
-int video_id=-1;
-int dvdsub_id=-2;
int vobsub_id=-1;
char* audio_lang=NULL;
char* dvdsub_lang=NULL;
static char* spudec_ifo=NULL;
-char* filename=NULL; //"MI2-Trailer.avi";
int forced_subs_only=0;
int file_filter=1;
@@ -288,8 +296,6 @@ static char *stream_dump_name="stream.dump";
// A-V sync:
static float default_max_pts_correction=-1;//0.01f;
-static float max_pts_correction=0;//default_max_pts_correction;
-static float c_total=0;
float audio_delay=0;
static int ignore_start=0;
@@ -302,10 +308,6 @@ static int audio_output_format=-1; // AF_FORMAT_UNKNOWN
static int play_n_frames=-1;
static int play_n_frames_mf=-1;
-// screen info:
-char** video_driver_list=NULL;
-char** audio_driver_list=NULL;
-
// sub:
char *font_name=NULL;
char *sub_font_name=NULL;
@@ -333,9 +335,9 @@ char* current_module=NULL; // for debugging
#ifdef CONFIG_MENU
#include "m_struct.h"
#include "libmenu/menu.h"
-void vf_menu_pause_update(struct vf_instance_s* vf);
+void vf_menu_pause_update(struct vf_instance* vf);
extern vf_info_t vf_info_menu;
-static vf_info_t* libmenu_vfs[] = {
+static const vf_info_t* const libmenu_vfs[] = {
&vf_info_menu,
NULL
};
@@ -353,11 +355,9 @@ static char* rtc_device;
edl_record_ptr edl_records = NULL; ///< EDL entries memory area
edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records
-short edl_decision = 0; ///< 1 when an EDL operation has been made.
FILE* edl_fd = NULL; ///< fd to write to when in -edlout mode.
int use_filedir_conf;
-static unsigned int initialized_flags=0;
#include "mpcommon.h"
#include "command.h"
@@ -400,7 +400,15 @@ int mpctx_get_osd_function(MPContext *mpctx)
return mpctx->osd_function;
}
-static int is_valid_metadata_type (metadata_t type) {
+static float get_relative_time(struct MPContext *mpctx)
+{
+ unsigned int new_time = GetTimer();
+ unsigned int delta = new_time - mpctx->last_time;
+ mpctx->last_time = new_time;
+ return delta * 0.000001;
+}
+
+static int is_valid_metadata_type(struct MPContext *mpctx, metadata_t type) {
switch (type)
{
/* check for valid video stream */
@@ -444,7 +452,7 @@ static int is_valid_metadata_type (metadata_t type) {
return 1;
}
-static char *get_demuxer_info (char *tag) {
+static char *get_demuxer_info(struct MPContext *mpctx, char *tag) {
char **info = mpctx->demuxer->info;
int n;
@@ -458,19 +466,20 @@ static char *get_demuxer_info (char *tag) {
return info[2*n+1] ? strdup (info[2*n+1]) : NULL;
}
-char *get_metadata (metadata_t type) {
+char *get_metadata(struct MPContext *mpctx, metadata_t type)
+{
char *meta = NULL;
sh_audio_t * const sh_audio = mpctx->sh_audio;
sh_video_t * const sh_video = mpctx->sh_video;
- if (!is_valid_metadata_type (type))
+ if (!is_valid_metadata_type(mpctx, type))
return NULL;
switch (type)
{
case META_NAME:
{
- return strdup (mp_basename2 (filename));
+ return strdup (mp_basename2 (mpctx->filename));
}
case META_VIDEO_CODEC:
@@ -533,25 +542,25 @@ char *get_metadata (metadata_t type) {
/* check for valid demuxer */
case META_INFO_TITLE:
- return get_demuxer_info ("Title");
+ return get_demuxer_info(mpctx, "Title");
case META_INFO_ARTIST:
- return get_demuxer_info ("Artist");
+ return get_demuxer_info(mpctx, "Artist");
case META_INFO_ALBUM:
- return get_demuxer_info ("Album");
+ return get_demuxer_info(mpctx, "Album");
case META_INFO_YEAR:
- return get_demuxer_info ("Year");
+ return get_demuxer_info(mpctx, "Year");
case META_INFO_COMMENT:
- return get_demuxer_info ("Comment");
+ return get_demuxer_info(mpctx, "Comment");
case META_INFO_TRACK:
- return get_demuxer_info ("Track");
+ return get_demuxer_info(mpctx, "Track");
case META_INFO_GENRE:
- return get_demuxer_info ("Genre");
+ return get_demuxer_info(mpctx, "Genre");
default:
break;
@@ -574,13 +583,13 @@ static void mp_dvdnav_context_free(MPContext *ctx){
}
#endif
-void uninit_player(unsigned int mask){
- mask=initialized_flags&mask;
+void uninit_player(struct MPContext *mpctx, unsigned int mask){
+ mask=mpctx->initialized_flags&mask;
mp_msg(MSGT_CPLAYER,MSGL_DBG2,"\n*** uninit(0x%X)\n",mask);
if(mask&INITIALIZED_ACODEC){
- initialized_flags&=~INITIALIZED_ACODEC;
+ mpctx->initialized_flags&=~INITIALIZED_ACODEC;
current_module="uninit_acodec";
if(mpctx->sh_audio) uninit_audio(mpctx->sh_audio);
#ifdef CONFIG_GUI
@@ -591,7 +600,7 @@ void uninit_player(unsigned int mask){
}
if(mask&INITIALIZED_VCODEC){
- initialized_flags&=~INITIALIZED_VCODEC;
+ mpctx->initialized_flags&=~INITIALIZED_VCODEC;
current_module="uninit_vcodec";
if(mpctx->sh_video) uninit_video(mpctx->sh_video);
mpctx->sh_video=NULL;
@@ -601,8 +610,25 @@ void uninit_player(unsigned int mask){
}
if(mask&INITIALIZED_DEMUXER){
- initialized_flags&=~INITIALIZED_DEMUXER;
+ mpctx->initialized_flags&=~INITIALIZED_DEMUXER;
current_module="free_demuxer";
+ if (mpctx->num_sources) {
+ mpctx->demuxer = mpctx->sources[0].demuxer;
+ for (int i = 1; i < mpctx->num_sources; i++) {
+ free_stream(mpctx->sources[i].stream);
+ free_demuxer(mpctx->sources[i].demuxer);
+ }
+ }
+ talloc_free(mpctx->sources);
+ mpctx->sources = NULL;
+ mpctx->num_sources = 0;
+ talloc_free(mpctx->timeline);
+ mpctx->timeline = NULL;
+ mpctx->num_timeline_parts = 0;
+ talloc_free(mpctx->chapters);
+ mpctx->chapters = NULL;
+ mpctx->num_chapters = 0;
+ mpctx->video_offset = 0;
if(mpctx->demuxer){
mpctx->stream=mpctx->demuxer->stream;
free_demuxer(mpctx->demuxer);
@@ -612,16 +638,16 @@ void uninit_player(unsigned int mask){
// kill the cache process:
if(mask&INITIALIZED_STREAM){
- initialized_flags&=~INITIALIZED_STREAM;
+ mpctx->initialized_flags&=~INITIALIZED_STREAM;
current_module="uninit_stream";
if(mpctx->stream) free_stream(mpctx->stream);
mpctx->stream=NULL;
}
if(mask&INITIALIZED_VO){
- initialized_flags&=~INITIALIZED_VO;
+ mpctx->initialized_flags&=~INITIALIZED_VO;
current_module="uninit_vo";
- mpctx->video_out->uninit();
+ vo_destroy(mpctx->video_out);
mpctx->video_out=NULL;
#ifdef CONFIG_DVDNAV
mp_dvdnav_context_free(mpctx);
@@ -630,7 +656,7 @@ void uninit_player(unsigned int mask){
// Must be after libvo uninit, as few vo drivers (svgalib) have tty code.
if(mask&INITIALIZED_GETCH2){
- initialized_flags&=~INITIALIZED_GETCH2;
+ mpctx->initialized_flags&=~INITIALIZED_GETCH2;
current_module="uninit_getch2";
mp_msg(MSGT_CPLAYER,MSGL_DBG2,"\n[[[uninit getch2]]]\n");
// restore terminal:
@@ -638,51 +664,42 @@ void uninit_player(unsigned int mask){
}
if(mask&INITIALIZED_VOBSUB){
- initialized_flags&=~INITIALIZED_VOBSUB;
+ mpctx->initialized_flags&=~INITIALIZED_VOBSUB;
current_module="uninit_vobsub";
if(vo_vobsub) vobsub_close(vo_vobsub);
vo_vobsub=NULL;
}
if (mask&INITIALIZED_SPUDEC){
- initialized_flags&=~INITIALIZED_SPUDEC;
+ mpctx->initialized_flags&=~INITIALIZED_SPUDEC;
current_module="uninit_spudec";
spudec_free(vo_spudec);
vo_spudec=NULL;
}
if(mask&INITIALIZED_AO){
- initialized_flags&=~INITIALIZED_AO;
+ mpctx->initialized_flags&=~INITIALIZED_AO;
current_module="uninit_ao";
if (mpctx->edl_muted) mixer_mute(&mpctx->mixer);
- mpctx->audio_out->uninit(mpctx->eof?0:1); mpctx->audio_out=NULL;
+ mpctx->audio_out->uninit(mpctx->stop_play != AT_END_OF_FILE);
+ mpctx->audio_out=NULL;
}
#ifdef CONFIG_GUI
if(mask&INITIALIZED_GUI){
- initialized_flags&=~INITIALIZED_GUI;
+ mpctx->initialized_flags&=~INITIALIZED_GUI;
current_module="uninit_gui";
guiDone();
}
#endif
- if(mask&INITIALIZED_INPUT){
- initialized_flags&=~INITIALIZED_INPUT;
- current_module="uninit_input";
- mp_input_uninit();
-#ifdef CONFIG_MENU
- if (use_menu)
- menu_uninit();
-#endif
- }
-
current_module=NULL;
}
-void exit_player_with_rc(exit_reason_t how, int rc){
-
+void exit_player_with_rc(struct MPContext *mpctx, exit_reason_t how, int rc)
+{
if (mpctx->user_muted && !mpctx->edl_muted) mixer_mute(&mpctx->mixer);
- uninit_player(INITIALIZED_ALL);
+ uninit_player(mpctx, INITIALIZED_ALL);
#if defined(__MINGW32__) || defined(__CYGWIN__)
timeEndPeriod(1);
#endif
@@ -690,18 +707,25 @@ void exit_player_with_rc(exit_reason_t how, int rc){
#ifdef CONFIG_GUI
if ( !use_gui )
#endif
- vo_uninit(); // Close the X11 connection (if any is open).
+ vo_uninit(mpctx->x11_state); // Close the X11 connection (if any is open).
+#endif
+
+ current_module="uninit_input";
+ mp_input_uninit(mpctx->input);
+#ifdef CONFIG_MENU
+ if (use_menu)
+ menu_uninit();
#endif
#ifdef CONFIG_FREETYPE
current_module="uninit_font";
- if (sub_font && sub_font != vo_font) free_font_desc(sub_font);
- sub_font = NULL;
- if (vo_font) free_font_desc(vo_font);
+ if (mpctx->osd && mpctx->osd->sub_font != vo_font)
+ free_font_desc(mpctx->osd->sub_font);
+ free_font_desc(vo_font);
vo_font = NULL;
done_freetype();
#endif
- free_osd_list();
+ osd_free(mpctx->osd);
#ifdef CONFIG_ASS
ass_library_done(ass_library);
@@ -710,25 +734,26 @@ void exit_player_with_rc(exit_reason_t how, int rc){
current_module="exit_player";
// free mplayer config
- if(mconfig)
- m_config_free(mconfig);
+ if(mpctx->mconfig)
+ m_config_free(mpctx->mconfig);
if(mpctx->playtree)
play_tree_free(mpctx->playtree, 1);
+ talloc_free(mpctx->key_fifo);
if(edl_records != NULL) free(edl_records); // free mem allocated for EDL
switch(how) {
case EXIT_QUIT:
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_ExitingHow,MSGTR_Exit_quit);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"\nExiting... (%s)\n","Quit");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=QUIT\n");
break;
case EXIT_EOF:
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_ExitingHow,MSGTR_Exit_eof);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"\nExiting... (%s)\n","End of file");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=EOF\n");
break;
case EXIT_ERROR:
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_ExitingHow,MSGTR_Exit_error);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"\nExiting... (%s)\n","Fatal error");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=ERROR\n");
break;
default:
@@ -739,8 +764,9 @@ void exit_player_with_rc(exit_reason_t how, int rc){
exit(rc);
}
-void exit_player(exit_reason_t how){
- exit_player_with_rc(how, 1);
+static void exit_player(struct MPContext *mpctx, exit_reason_t how)
+{
+ exit_player_with_rc(mpctx, how, 1);
}
#ifndef __MINGW32__
@@ -761,7 +787,6 @@ static void exit_sighandler(int x){
if (!crash_debug || x != SIGTRAP)
#endif
++sig_count;
- if(initialized_flags==0 && sig_count>1) exit(1);
if(sig_count==5)
{
/* We're crashing bad and can't uninit cleanly :(
@@ -778,7 +803,7 @@ static void exit_sighandler(int x){
kill(getpid(),SIGKILL);
#endif
}
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,"\n" MSGTR_IntBySignal,x,
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"\n" "\nMPlayer interrupted by signal %d in module: %s\n",x,
current_module?current_module:"unknown"
);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SIGNAL=%d\n", x);
@@ -792,15 +817,15 @@ static void exit_sighandler(int x){
return; // killed from keyboard (^C) or killed [-9]
case SIGILL:
#if CONFIG_RUNTIME_CPUDETECT
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGILL_RTCpuSel);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,Exit_SIGILL_RTCpuSel);
#else
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGILL);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,Exit_SIGILL);
#endif
case SIGFPE:
case SIGSEGV:
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGSEGV_SIGFPE);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,Exit_SIGSEGV_SIGFPE);
default:
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGCRASH);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,Exit_SIGCRASH);
#ifdef CONFIG_CRASH_DEBUG
if (crash_debug) {
int gdb_pid;
@@ -826,19 +851,22 @@ static void exit_sighandler(int x){
exit(1);
}
-void mp_input_register_options(m_config_t* cfg);
-
#include "cfg-mplayer.h"
-static void parse_cfgfiles( m_config_t* conf )
+static int cfg_include(m_option_t *conf, char *filename)
+{
+ return m_config_parse_config_file(conf->priv, filename);
+}
+
+static void parse_cfgfiles(struct MPContext *mpctx, m_config_t* conf)
{
char *conffile;
int conffile_fd;
if (!disable_system_conf &&
m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mplayer.conf") < 0)
- exit_player(EXIT_NONE);
+ exit_player(mpctx, EXIT_NONE);
if ((conffile = get_path("")) == NULL) {
- mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoHomeDir);
+ mp_tmsg(MSGT_CPLAYER,MSGL_WARN,"Cannot find HOME directory.\n");
} else {
#ifdef __MINGW32__
mkdir(conffile);
@@ -847,16 +875,16 @@ if ((conffile = get_path("")) == NULL) {
#endif
free(conffile);
if ((conffile = get_path("config")) == NULL) {
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"get_path(\"config\") problem\n");
} else {
if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) {
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CreatingCfgFile, conffile);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Creating config file: %s\n", conffile);
write(conffile_fd, default_config, strlen(default_config));
close(conffile_fd);
}
if (!disable_user_conf &&
m_config_parse_config_file(conf, conffile) < 0)
- exit_player(EXIT_NONE);
+ exit_player(mpctx, EXIT_NONE);
free(conffile);
}
}
@@ -880,7 +908,7 @@ static void load_per_protocol_config (m_config_t* conf, const char *const file)
p = m_config_get_profile (conf, protocol);
if (p)
{
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingProtocolProfile, protocol);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Loading protocol-related profile '%s'\n", protocol);
m_config_set_profile(conf,p);
}
}
@@ -894,7 +922,7 @@ static void load_per_extension_config (m_config_t* conf, const char *const file)
m_profile_t *p;
/* does filename actually have an extension ? */
- str = strrchr (filename, '.');
+ str = strrchr (file, '.');
if (!str)
return;
@@ -903,7 +931,7 @@ static void load_per_extension_config (m_config_t* conf, const char *const file)
p = m_config_get_profile (conf, extension);
if (p)
{
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingExtensionProfile, extension);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Loading extension-related profile '%s'\n", extension);
m_config_set_profile(conf,p);
}
}
@@ -920,7 +948,7 @@ static void load_per_output_config (m_config_t* conf, char *cfg, char *out)
p = m_config_get_profile (conf, profile);
if (p)
{
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingExtensionProfile, profile);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Loading extension-related profile '%s'\n", profile);
m_config_set_profile(conf,p);
}
}
@@ -936,7 +964,7 @@ static void load_per_file_config (m_config_t* conf, const char *const file)
if (use_filedir_conf && !stat (cfg, &st))
{
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingConfig, cfg);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Loading config '%s'\n", cfg);
m_config_parse_config_file (conf, cfg);
return;
}
@@ -950,7 +978,7 @@ static void load_per_file_config (m_config_t* conf, const char *const file)
{
if (!stat (confpath, &st))
{
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingConfig, confpath);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Loading config '%s'\n", confpath);
m_config_parse_config_file (conf, confpath);
}
@@ -962,38 +990,39 @@ static void load_per_file_config (m_config_t* conf, const char *const file)
* cache filling) if the operation fails we use this function to check
* if it was interrupted by the user.
* The function returns a new value for eof. */
-static int libmpdemux_was_interrupted(int eof) {
+static int libmpdemux_was_interrupted(struct MPContext *mpctx, int stop_play)
+{
mp_cmd_t* cmd;
- if((cmd = mp_input_get_cmd(0,0,0)) != NULL) {
+ if((cmd = mp_input_get_cmd(mpctx->input, 0,0,0)) != NULL) {
switch(cmd->id) {
case MP_CMD_QUIT:
- exit_player_with_rc(EXIT_QUIT, (cmd->nargs > 0)? cmd->args[0].v.i : 0);
+ exit_player_with_rc(mpctx, EXIT_QUIT, (cmd->nargs > 0)? cmd->args[0].v.i : 0);
case MP_CMD_PLAY_TREE_STEP: {
- eof = (cmd->args[0].v.i > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
+ stop_play = (cmd->args[0].v.i > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
mpctx->play_tree_step = (cmd->args[0].v.i == 0) ? 1 : cmd->args[0].v.i;
} break;
case MP_CMD_PLAY_TREE_UP_STEP: {
- eof = (cmd->args[0].v.i > 0) ? PT_UP_NEXT : PT_UP_PREV;
+ stop_play = (cmd->args[0].v.i > 0) ? PT_UP_NEXT : PT_UP_PREV;
} break;
case MP_CMD_PLAY_ALT_SRC_STEP: {
- eof = (cmd->args[0].v.i > 0) ? PT_NEXT_SRC : PT_PREV_SRC;
+ stop_play = (cmd->args[0].v.i > 0) ? PT_NEXT_SRC : PT_PREV_SRC;
} break;
}
mp_cmd_free(cmd);
}
- return eof;
+ return stop_play;
}
#define mp_basename(s) (strrchr(s,'\\')==NULL?(mp_basename2(s)):(strrchr(s,'\\')+1))
-static int playtree_add_playlist(play_tree_t* entry)
+static int playtree_add_playlist(struct MPContext *mpctx, play_tree_t* entry)
{
- play_tree_add_bpf(entry,filename);
+ play_tree_add_bpf(entry,mpctx->filename);
#ifdef CONFIG_GUI
if (use_gui) {
if (entry) {
- import_playtree_playlist_into_gui(entry, mconfig);
+ import_playtree_playlist_into_gui(entry, mpctx->mconfig);
play_tree_free_list(entry,1);
}
} else
@@ -1023,7 +1052,7 @@ static int playtree_add_playlist(play_tree_t* entry)
return PT_NEXT_SRC;
}
-void add_subtitles(char *filename, float fps, int noerr)
+void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr)
{
sub_data *subd;
#ifdef CONFIG_ASS
@@ -1049,7 +1078,7 @@ void add_subtitles(char *filename, float fps, int noerr)
#else
if(!subd)
#endif
- mp_msg(MSGT_CPLAYER, noerr ? MSGL_WARN : MSGL_ERR, MSGTR_CantLoadSub,
+ mp_tmsg(MSGT_CPLAYER, noerr ? MSGL_WARN : MSGL_ERR, "Cannot load subtitles: %s\n",
filename_recode(filename));
#ifdef CONFIG_ASS
@@ -1063,12 +1092,12 @@ void add_subtitles(char *filename, float fps, int noerr)
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n",
filename_recode(filename));
++mpctx->set_of_sub_size;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AddedSubtitleFile, mpctx->set_of_sub_size,
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "SUB: Added subtitle file (%d): %s\n", mpctx->set_of_sub_size,
filename_recode(filename));
}
// FIXME: if/when the GUI calls this, global sub numbering gets (potentially) broken.
-void update_set_of_subtitles(void)
+void update_set_of_subtitles(struct MPContext *mpctx)
// subdata was changed, set_of_sub... have to be updated.
{
sub_data ** const set_of_subtitles = mpctx->set_of_subtitles;
@@ -1089,10 +1118,11 @@ void update_set_of_subtitles(void)
}
}
-void init_vo_spudec(void) {
+void init_vo_spudec(struct MPContext *mpctx)
+{
if (vo_spudec)
spudec_free(vo_spudec);
- initialized_flags &= ~INITIALIZED_SPUDEC;
+ mpctx->initialized_flags &= ~INITIALIZED_SPUDEC;
vo_spudec = NULL;
if (spudec_ifo) {
unsigned int palette[16], width, height;
@@ -1126,7 +1156,7 @@ void init_vo_spudec(void) {
}
if (vo_spudec!=NULL) {
- initialized_flags|=INITIALIZED_SPUDEC;
+ mpctx->initialized_flags|=INITIALIZED_SPUDEC;
mp_property_do("sub_forced_only", M_PROPERTY_SET, &forced_subs_only, mpctx);
}
}
@@ -1183,15 +1213,25 @@ static void sadd_hhmmssf(char *buf, unsigned *pos, int len, float time) {
saddf(buf, pos, len, "%02d.%1d", ss, f1);
}
-/**
- * \brief print the status line
- * \param a_pos audio position
- * \param a_v A-V desynchronization
- * \param corr amount out A-V synchronization
- */
-static void print_status(float a_pos, float a_v, float corr)
+static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame)
{
+ struct MPOpts *opts = &mpctx->opts;
sh_video_t * const sh_video = mpctx->sh_video;
+
+ if (mpctx->sh_audio && a_pos == MP_NOPTS_VALUE)
+ a_pos = playing_audio_pts(mpctx);
+ if (mpctx->sh_audio && sh_video && at_frame) {
+ mpctx->last_av_difference = a_pos - sh_video->pts - audio_delay;
+ if (mpctx->last_av_difference > 0.5 && drop_frame_cnt > 50
+ && !mpctx->drop_message_shown) {
+ mp_tmsg(MSGT_AVSYNC,MSGL_WARN,SystemTooSlow);
+ mpctx->drop_message_shown = true;
+ }
+ }
+ if (quiet)
+ return;
+
+
int width;
char *line;
unsigned pos = 0;
@@ -1226,7 +1266,8 @@ static void print_status(float a_pos, float a_v, float corr)
// A-V sync
if (mpctx->sh_audio && sh_video)
- saddf(line, &pos, width, "A-V:%7.3f ct:%7.3f ", a_v, corr);
+ saddf(line, &pos, width, "A-V:%7.3f ct:%7.3f ",
+ mpctx->last_av_difference, mpctx->total_avsync_change);
// Video stats
if (sh_video)
@@ -1238,9 +1279,9 @@ static void print_status(float a_pos, float a_v, float corr)
if (sh_video) {
if (sh_video->timer > 0.5)
saddf(line, &pos, width, "%2d%% %2d%% %4.1f%% ",
- (int)(100.0*video_time_usage*playback_speed/(double)sh_video->timer),
- (int)(100.0*vout_time_usage*playback_speed/(double)sh_video->timer),
- (100.0*audio_time_usage*playback_speed/(double)sh_video->timer));
+ (int)(100.0*video_time_usage*opts->playback_speed/(double)sh_video->timer),
+ (int)(100.0*vout_time_usage*opts->playback_speed/(double)sh_video->timer),
+ (100.0*audio_time_usage*opts->playback_speed/(double)sh_video->timer));
else
saddf(line, &pos, width, "??%% ??%% ??,?%% ");
} else if (mpctx->sh_audio) {
@@ -1262,8 +1303,8 @@ static void print_status(float a_pos, float a_v, float corr)
#endif
// other
- if (playback_speed != 1)
- saddf(line, &pos, width, "%4.2fx ", playback_speed);
+ if (opts->playback_speed != 1)
+ saddf(line, &pos, width, "%4.2fx ", opts->playback_speed);
// end
if (erase_to_end_of_line) {
@@ -1283,8 +1324,9 @@ static void print_status(float a_pos, float a_v, float corr)
* \param sh_audio describes the requested input format of the chain.
* \param ao_data describes the requested output format of the chain.
*/
-int build_afilter_chain(sh_audio_t *sh_audio, ao_data_t *ao_data)
+int build_afilter_chain(struct MPContext *mpctx, sh_audio_t *sh_audio, ao_data_t *ao_data)
{
+ struct MPOpts *opts = &mpctx->opts;
int new_srate;
int result;
if (!sh_audio)
@@ -1297,17 +1339,17 @@ int build_afilter_chain(sh_audio_t *sh_audio, ao_data_t *ao_data)
}
if(af_control_any_rev(sh_audio->afilter,
AF_CONTROL_PLAYBACK_SPEED | AF_CONTROL_SET,
- &playback_speed)) {
+ &opts->playback_speed)) {
new_srate = sh_audio->samplerate;
} else {
- new_srate = sh_audio->samplerate * playback_speed;
+ new_srate = sh_audio->samplerate * opts->playback_speed;
if (new_srate != ao_data->samplerate) {
// limits are taken from libaf/af_resample.c
if (new_srate < 8000)
new_srate = 8000;
if (new_srate > 192000)
new_srate = 192000;
- playback_speed = (float)new_srate / (float)sh_audio->samplerate;
+ opts->playback_speed = (float)new_srate / (float)sh_audio->samplerate;
}
}
result = init_audio_filters(sh_audio, new_srate,
@@ -1418,24 +1460,27 @@ static void clear_osd_msgs(void) {
*
*/
-static mp_osd_msg_t* get_osd_msg(void) {
+static mp_osd_msg_t* get_osd_msg(struct MPContext *mpctx)
+{
+ struct MPOpts *opts = &mpctx->opts;
mp_osd_msg_t *msg,*prev,*last = NULL;
static unsigned last_update = 0;
unsigned now = GetTimerMS();
unsigned diff;
char hidden_dec_done = 0;
- if (osd_visible) {
+ if (mpctx->osd_visible) {
// 36000000 means max timed visibility is 1 hour into the future, if
// the difference is greater assume it's wrapped around from below 0
- if (osd_visible - now > 36000000) {
- osd_visible = 0;
+ if (mpctx->osd_visible - now > 36000000) {
+ mpctx->osd_visible = 0;
vo_osd_progbar_type = -1; // disable
vo_osd_changed(OSDTYPE_PROGBAR);
- if (mpctx->osd_function != OSD_PAUSE)
- mpctx->osd_function = OSD_PLAY;
+ mpctx->osd_function = mpctx->paused ? OSD_PAUSE : OSD_PLAY;
}
}
+ if (mpctx->osd_show_percentage_until - now > 36000000)
+ mpctx->osd_show_percentage_until = 0;
if(!last_update) last_update = now;
diff = now >= last_update ? now - last_update : 0;
@@ -1445,14 +1490,16 @@ static mp_osd_msg_t* get_osd_msg(void) {
// Look for the first message in the stack with high enough level.
for(msg = osd_msg_stack ; msg ; last = msg, msg = prev) {
prev = msg->prev;
- if(msg->level > osd_level && hidden_dec_done) continue;
+ if (msg->level > opts->osd_level && hidden_dec_done)
+ continue;
// The message has a high enough level or it is the first hidden one
// in both cases we decrement the timer or kill it.
if(!msg->started || msg->time > diff) {
if(msg->started) msg->time -= diff;
else msg->started = 1;
// display it
- if(msg->level <= osd_level) return msg;
+ if (msg->level <= opts->osd_level)
+ return msg;
hidden_dec_done = 1;
continue;
}
@@ -1477,20 +1524,21 @@ static mp_osd_msg_t* get_osd_msg(void) {
*
*/
-void set_osd_bar(int type,const char* name,double min,double max,double val) {
-
- if(osd_level < 1) return;
+void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,double max,double val) {
+ struct MPOpts *opts = &mpctx->opts;
+ if (opts->osd_level < 1)
+ return;
if(mpctx->sh_video) {
- osd_visible = (GetTimerMS() + 1000) | 1;
+ mpctx->osd_visible = (GetTimerMS() + 1000) | 1;
vo_osd_progbar_type = type;
vo_osd_progbar_value = 256*(val-min)/(max-min);
vo_osd_changed(OSDTYPE_PROGBAR);
return;
}
- set_osd_msg(OSD_MSG_BAR,1,osd_duration,"%s: %d %%",
- name,ROUND(100*(val-min)/(max-min)));
+ set_osd_msg(OSD_MSG_BAR, 1, opts->osd_duration, "%s: %d %%",
+ name, ROUND(100*(val-min)/(max-min)));
}
@@ -1503,18 +1551,30 @@ void set_osd_bar(int type,const char* name,double min,double max,double val) {
*
*/
-static void update_osd_msg(void) {
+static void update_osd_msg(struct MPContext *mpctx)
+{
+ struct MPOpts *opts = &mpctx->opts;
mp_osd_msg_t *msg;
- static char osd_text[128] = "";
- static char osd_text_timer[128];
-
- // we need some mem for vo_osd_text
- vo_osd_text = (unsigned char*)osd_text;
+ struct osd_state *osd = mpctx->osd;
+ char osd_text_timer[128];
+
+ if (mpctx->add_osd_seek_info) {
+ double percentage;
+ if (mpctx->timeline && mpctx->sh_video)
+ percentage = mpctx->sh_video->pts * 100 /
+ mpctx->timeline[mpctx->num_timeline_parts].start;
+ else
+ percentage = demuxer_get_percent_pos(mpctx->demuxer);
+ set_osd_bar(mpctx, 0, "Position", 0, 100, percentage);
+ if (mpctx->sh_video)
+ mpctx->osd_show_percentage_until = (GetTimerMS() + 1000) | 1;
+ mpctx->add_osd_seek_info = false;
+ }
// Look if we have a msg
- if((msg = get_osd_msg())) {
- if(strcmp(osd_text,msg->msg)) {
- strncpy((char*)osd_text, msg->msg, 127);
+ if((msg = get_osd_msg(mpctx))) {
+ if (strcmp(osd->osd_text, msg->msg)) {
+ strncpy(osd->osd_text, msg->msg, 127);
if(mpctx->sh_video) vo_osd_changed(OSDTYPE_OSD); else
if(term_osd) mp_msg(MSGT_CPLAYER,MSGL_STATUS,"%s%s\n",term_osd_esc,msg->msg);
}
@@ -1523,21 +1583,29 @@ static void update_osd_msg(void) {
if(mpctx->sh_video) {
// fallback on the timer
- if(osd_level>=2) {
- int len = demuxer_get_time_length(mpctx->demuxer);
+ if (opts->osd_level >= 2) {
+ int len;
+ if (mpctx->timeline)
+ len = mpctx->timeline[mpctx->num_timeline_parts].start;
+ else
+ len = demuxer_get_time_length(mpctx->demuxer);
int percentage = -1;
char percentage_text[10];
int pts = demuxer_get_current_time(mpctx->demuxer);
- if (mpctx->osd_show_percentage)
- percentage = demuxer_get_percent_pos(mpctx->demuxer);
+ if (mpctx->osd_show_percentage_until)
+ if (mpctx->timeline)
+ percentage = mpctx->sh_video->pts * 100 /
+ mpctx->timeline[mpctx->num_timeline_parts].start;
+ else
+ percentage = demuxer_get_percent_pos(mpctx->demuxer);
if (percentage >= 0)
snprintf(percentage_text, 9, " (%d%%)", percentage);
else
percentage_text[0] = 0;
- if (osd_level == 3)
+ if (opts->osd_level == 3)
snprintf(osd_text_timer, 63,
"%c %02d:%02d:%02d / %02d:%02d:%02d%s",
mpctx->osd_function,pts/3600,(pts/60)%60,pts%60,
@@ -1549,20 +1617,16 @@ static void update_osd_msg(void) {
} else
osd_text_timer[0]=0;
- // always decrement the percentage timer
- if(mpctx->osd_show_percentage)
- mpctx->osd_show_percentage--;
-
- if(strcmp(osd_text,osd_text_timer)) {
- strncpy(osd_text, osd_text_timer, 63);
+ if (strcmp(osd->osd_text, osd_text_timer)) {
+ strncpy(osd->osd_text, osd_text_timer, 63);
vo_osd_changed(OSDTYPE_OSD);
}
return;
}
// Clear the term osd line
- if(term_osd && osd_text[0]) {
- osd_text[0] = 0;
+ if (term_osd && osd->osd_text[0]) {
+ osd->osd_text[0] = 0;
printf("%s\n",term_osd_esc);
}
}
@@ -1571,7 +1635,9 @@ static void update_osd_msg(void) {
// OSDMsgStack
-void reinit_audio_chain(void) {
+void reinit_audio_chain(struct MPContext *mpctx)
+{
+ struct MPOpts *opts = &mpctx->opts;
if(mpctx->sh_audio){
current_module="init_audio_codec";
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
@@ -1580,7 +1646,7 @@ if(mpctx->sh_audio){
mpctx->d_audio->id = -2;
return;
} else
- initialized_flags|=INITIALIZED_ACODEC;
+ mpctx->initialized_flags|=INITIALIZED_ACODEC;
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
@@ -1596,25 +1662,25 @@ if(mpctx->sh_audio){
mpctx->sh_audio->samplerate,
// output:
&ao_data.samplerate, &ao_data.channels, &ao_data.format)){
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_AudioFilterChainPreinitError);
- exit_player(EXIT_ERROR);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Error at audio filter chain pre-init!\n");
+ exit_player(mpctx, EXIT_ERROR);
}
#endif
current_module="ao2_init";
- if(!(mpctx->audio_out=init_best_audio_out(audio_driver_list,
+ if(!(mpctx->audio_out=init_best_audio_out(opts->audio_driver_list,
0, // plugin flag
ao_data.samplerate,
ao_data.channels,
ao_data.format,0))){
// FAILED:
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO);
- uninit_player(INITIALIZED_ACODEC); // close codec
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Could not open/initialize audio device -> no sound.\n");
+ uninit_player(mpctx, INITIALIZED_ACODEC); // close codec
mpctx->sh_audio=mpctx->d_audio->sh=NULL; // -> nosound
mpctx->d_audio->id = -2;
return;
} else {
// SUCCESS:
- initialized_flags|=INITIALIZED_AO;
+ mpctx->initialized_flags|=INITIALIZED_AO;
mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %dHz %dch %s (%d bytes per sample)\n",
mpctx->audio_out->info->short_name,
ao_data.samplerate, ao_data.channels,
@@ -1627,10 +1693,10 @@ if(mpctx->sh_audio){
// init audio filters:
#if 1
current_module="af_init";
- if(!build_afilter_chain(mpctx->sh_audio, &ao_data)) {
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_NoMatchingFilter);
+ if(!build_afilter_chain(mpctx, mpctx->sh_audio, &ao_data)) {
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter/ao format!\n");
// mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format! -> NOSOUND\n");
-// uninit_player(INITIALIZED_ACODEC|INITIALIZED_AO); // close codec & ao
+// uninit_player(mpctx, INITIALIZED_ACODEC|INITIALIZED_AO); // close codec & ao
// sh_audio=mpctx->d_audio->sh=NULL; // -> nosound
}
#endif
@@ -1647,8 +1713,10 @@ if(mpctx->sh_audio){
// Return pts value corresponding to the end point of audio written to the
// ao so far.
-static double written_audio_pts(sh_audio_t *sh_audio, demux_stream_t *d_audio)
+static double written_audio_pts(struct MPContext *mpctx)
{
+ sh_audio_t *sh_audio = mpctx->sh_audio;
+ demux_stream_t *d_audio = mpctx->d_audio;
double buffered_output;
// first calculate the end pts of audio that has been output by decoder
double a_pts = sh_audio->pts;
@@ -1691,31 +1759,31 @@ static double written_audio_pts(sh_audio_t *sh_audio, demux_stream_t *d_audio)
// Filters divide audio length by playback_speed, so multiply by it
// to get the length in original units without speedup or slowdown
- a_pts -= buffered_output * playback_speed / ao_data.bps;
+ a_pts -= buffered_output * mpctx->opts.playback_speed / ao_data.bps;
- return a_pts;
+ return a_pts + mpctx->video_offset;
}
// Return pts value corresponding to currently playing audio.
-double playing_audio_pts(sh_audio_t *sh_audio, demux_stream_t *d_audio,
- const ao_functions_t *audio_out)
+double playing_audio_pts(struct MPContext *mpctx)
{
- return written_audio_pts(sh_audio, d_audio) - playback_speed *
- audio_out->get_delay();
+ return written_audio_pts(mpctx) - mpctx->opts.playback_speed *
+ mpctx->audio_out->get_delay();
}
-static int check_framedrop(double frame_time) {
+static int check_framedrop(struct MPContext *mpctx, double frame_time) {
+ struct MPOpts *opts = &mpctx->opts;
// check for frame-drop:
current_module = "check_framedrop";
if (mpctx->sh_audio && !mpctx->d_audio->eof) {
static int dropped_frames;
- float delay = playback_speed*mpctx->audio_out->get_delay();
+ float delay = opts->playback_speed*mpctx->audio_out->get_delay();
float d = delay-mpctx->delay;
++total_frame_cnt;
// we should avoid dropping too many frames in sequence unless we
// are too late. and we allow 100ms A-V delay here:
- if (d < -dropped_frames*frame_time-0.100 &&
- mpctx->osd_function != OSD_PAUSE) {
+ if (d < -dropped_frames*frame_time-0.100 && !mpctx->paused
+ && !mpctx->update_video_immediately) {
++drop_frame_cnt;
++dropped_frames;
return frame_dropping;
@@ -1725,53 +1793,12 @@ static int check_framedrop(double frame_time) {
return 0;
}
-static int generate_video_frame(sh_video_t *sh_video, demux_stream_t *d_video)
-{
- unsigned char *start;
- int in_size;
- int hit_eof=0;
- double pts;
-
- while (1) {
- int drop_frame = check_framedrop(sh_video->frametime);
- void *decoded_frame;
- current_module = "decode video";
- // XXX Time used in this call is not counted in any performance
- // timer now, OSD is not updated correctly for filter-added frames
- if (vf_output_queued_frame(sh_video->vfilter))
- break;
- current_module = "video_read_frame";
- in_size = ds_get_packet_pts(d_video, &start, &pts);
- if (in_size < 0) {
- // try to extract last frames in case of decoder lag
- in_size = 0;
- pts = 1e300;
- hit_eof = 1;
- }
- if (in_size > max_framesize)
- max_framesize = in_size;
- current_module = "decode video";
- decoded_frame = decode_video(sh_video, start, in_size, drop_frame, pts);
- if (decoded_frame) {
- update_subtitles(sh_video, mpctx->d_sub, 0);
- update_teletext(sh_video, mpctx->demuxer, 0);
- update_osd_msg();
- current_module = "filter video";
- if (filter_video(sh_video, decoded_frame, sh_video->pts))
- break;
- } else if (drop_frame)
- return -1;
- if (hit_eof)
- return 0;
- }
- return 1;
-}
#ifdef HAVE_RTC
int rtc_fd = -1;
#endif
-static float timing_sleep(float time_frame)
+static float timing_sleep(struct MPContext *mpctx, float time_frame)
{
#ifdef HAVE_RTC
if (rtc_fd >= 0){
@@ -1780,8 +1807,8 @@ static float timing_sleep(float time_frame)
while (time_frame > 0.000) {
unsigned long rtc_ts;
if (read(rtc_fd, &rtc_ts, sizeof(rtc_ts)) <= 0)
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_LinuxRTCReadError, strerror(errno));
- time_frame -= GetRelativeTime();
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Linux RTC read error: %s\n", strerror(errno));
+ time_frame -= get_relative_time(mpctx);
}
} else
#endif
@@ -1792,14 +1819,14 @@ static float timing_sleep(float time_frame)
current_module = "sleep_timer";
while (time_frame > margin) {
usec_sleep(1000000 * (time_frame - margin));
- time_frame -= GetRelativeTime();
+ time_frame -= get_relative_time(mpctx);
}
if (softsleep){
current_module = "sleep_soft";
if (time_frame < 0)
- mp_msg(MSGT_AVSYNC, MSGL_WARN, MSGTR_SoftsleepUnderflow);
+ mp_tmsg(MSGT_AVSYNC, MSGL_WARN, "Warning! Softsleep underflow!\n");
while (time_frame > 0)
- time_frame-=GetRelativeTime(); // burn the CPU
+ time_frame -= get_relative_time(mpctx); // burn the CPU
}
}
return time_frame;
@@ -1836,6 +1863,7 @@ static mp_image_t * mp_dvdnav_copy_mpi(mp_image_t *to_mpi,
}
static void mp_dvdnav_reset_stream (MPContext *ctx) {
+ struct MPOpts *opts = &ctx->opts;
if (ctx->sh_video) {
/// clear video pts
ctx->d_video->pts = 0.0f;
@@ -1860,7 +1888,7 @@ static void mp_dvdnav_reset_stream (MPContext *ctx) {
resync_audio_stream(ctx->sh_audio);
}
- if (ctx->d_sub) dvdsub_id = -2;
+ if (ctx->d_sub) opts->sub_id = -2;
audio_delay = 0.0f;
@@ -1869,7 +1897,8 @@ static void mp_dvdnav_reset_stream (MPContext *ctx) {
}
/// Restore last decoded DVDNAV (still frame)
-static mp_image_t *mp_dvdnav_restore_smpi(int *in_size,
+static mp_image_t *mp_dvdnav_restore_smpi(struct MPContext *mpctx,
+ int *in_size,
unsigned char **start,
mp_image_t *decoded_frame)
{
@@ -1913,7 +1942,7 @@ static mp_image_t *mp_dvdnav_restore_smpi(int *in_size,
}
/// Save last decoded DVDNAV (still frame)
-static void mp_dvdnav_save_smpi(int in_size,
+static void mp_dvdnav_save_smpi(struct MPContext *mpctx, int in_size,
unsigned char *start,
mp_image_t *decoded_frame)
{
@@ -1934,72 +1963,44 @@ static void mp_dvdnav_save_smpi(int in_size,
}
#endif /* CONFIG_DVDNAV */
-static void adjust_sync_and_print_status(int between_frames, float timing_error)
+/* Modify video timing to match the audio timeline. There are two main
+ * reasons this is needed. First, video and audio can start from different
+ * positions at beginning of file or after a seek (MPlayer starts both
+ * immediately even if they have different pts). Second, the file can have
+ * audio timestamps that are inconsistent with the duration of the audio
+ * packets, for example two consecutive timestamp values differing by
+ * one second but only a packet with enough samples for half a second
+ * of playback between them.
+ */
+static void adjust_sync(struct MPContext *mpctx, double frame_time)
{
- current_module="av_sync";
-
- if(mpctx->sh_audio){
- double a_pts, v_pts;
-
- if (autosync)
- /*
- * If autosync is enabled, the value for delay must be calculated
- * a bit differently. It is set only to the difference between
- * the audio and video timers. Any attempt to include the real
- * or corrected delay causes the pts_correction code below to
- * try to correct for the changes in delay which autosync is
- * trying to measure. This keeps the two from competing, but still
- * allows the code to correct for PTS drift *only*. (Using a delay
- * value here, even a "corrected" one, would be incompatible with
- * autosync mode.)
- */
- a_pts = written_audio_pts(mpctx->sh_audio, mpctx->d_audio) - mpctx->delay;
- else
- a_pts = playing_audio_pts(mpctx->sh_audio, mpctx->d_audio, mpctx->audio_out);
+ struct MPOpts *opts = &mpctx->opts;
+ current_module = "av_sync";
- v_pts = mpctx->sh_video->pts;
-
- {
- static int drop_message=0;
- double AV_delay = a_pts - audio_delay - v_pts;
- double x;
- if (AV_delay>0.5 && drop_frame_cnt>50 && drop_message==0){
- ++drop_message;
- mp_msg(MSGT_AVSYNC,MSGL_WARN,MSGTR_SystemTooSlow);
- }
- if (autosync)
- x = AV_delay*0.1f;
- else
- /* Do not correct target time for the next frame if this frame
- * was late not because of wrong target time but because the
- * target time could not be met */
- x = (AV_delay + timing_error * playback_speed) * 0.1f;
- if (x < -max_pts_correction)
- x = -max_pts_correction;
- else if (x> max_pts_correction)
- x = max_pts_correction;
- if (default_max_pts_correction >= 0)
- max_pts_correction = default_max_pts_correction;
- else
- max_pts_correction = mpctx->sh_video->frametime*0.10; // +-10% of time
- if (!between_frames) {
- mpctx->delay+=x;
- c_total+=x;
- }
- if(!quiet)
- print_status(a_pts - audio_delay, AV_delay, c_total);
- }
-
- } else {
- // No audio:
+ if (!mpctx->sh_audio)
+ return;
- if (!quiet)
- print_status(0, 0, 0);
- }
+ double a_pts = written_audio_pts(mpctx) - mpctx->delay;
+ double v_pts = mpctx->sh_video->pts;
+ double av_delay = a_pts - v_pts;
+ // Try to sync vo_flip() so it will *finish* at given time
+ av_delay += mpctx->last_vo_flip_duration;
+ av_delay -= audio_delay; // This much pts difference is desired
+
+ double change = av_delay * 0.1;
+ double max_change = default_max_pts_correction >= 0 ?
+ default_max_pts_correction : frame_time * 0.1;
+ if (change < -max_change)
+ change = -max_change;
+ else if (change > max_change)
+ change = max_change;
+ mpctx->delay += change;
+ mpctx->total_avsync_change += change;
}
-static int fill_audio_out_buffers(void)
+static int fill_audio_out_buffers(struct MPContext *mpctx)
{
+ struct MPOpts *opts = &mpctx->opts;
unsigned int t;
double tt;
int playsize;
@@ -2066,7 +2067,7 @@ static int fill_audio_out_buffers(void)
sh_audio->a_out_buffer_len -= playsize;
memmove(sh_audio->a_out_buffer, &sh_audio->a_out_buffer[playsize],
sh_audio->a_out_buffer_len);
- mpctx->delay += playback_speed*playsize/(double)ao_data.bps;
+ mpctx->delay += opts->playback_speed*playsize/(double)ao_data.bps;
}
else if (audio_eof && mpctx->audio_out->get_delay() < .04) {
// Sanity check to avoid hanging in case current ao doesn't output
@@ -2078,12 +2079,14 @@ static int fill_audio_out_buffers(void)
return 1;
}
-static int sleep_until_update(float *time_frame, float *aq_sleep_time)
+static int sleep_until_update(struct MPContext *mpctx, float *time_frame,
+ float *aq_sleep_time)
{
+ struct MPOpts *opts = &mpctx->opts;
int frame_time_remaining = 0;
current_module="calc_sleep_time";
- *time_frame -= GetRelativeTime(); // reset timer
+ *time_frame -= get_relative_time(mpctx); // reset timer
if (mpctx->sh_audio && !mpctx->d_audio->eof) {
float delay = mpctx->audio_out->get_delay();
@@ -2099,12 +2102,12 @@ static int sleep_until_update(float *time_frame, float *aq_sleep_time)
* sync to settle at the right value (but it eventually will.)
* This settling time is very short for values below 100.
*/
- float predicted = mpctx->delay / playback_speed + *time_frame;
+ float predicted = mpctx->delay / opts->playback_speed + *time_frame;
float difference = delay - predicted;
delay = predicted + difference / (float)autosync;
}
- *time_frame = delay - mpctx->delay / playback_speed;
+ *time_frame = delay - mpctx->delay / opts->playback_speed;
// delay = amount of audio buffered in soundcard/driver
if (delay > 0.25) delay=0.25; else
@@ -2129,26 +2132,27 @@ static int sleep_until_update(float *time_frame, float *aq_sleep_time)
//============================== SLEEP: ===================================
// flag 256 means: libvo driver does its timing (dvb card)
- if (*time_frame > 0.001 && !(vo_flags&256))
- *time_frame = timing_sleep(*time_frame);
+ if (*time_frame > 0.001 && !(mpctx->sh_video->output_flags&256))
+ *time_frame = timing_sleep(mpctx, *time_frame);
return frame_time_remaining;
}
-int reinit_video_chain(void) {
+int reinit_video_chain(struct MPContext *mpctx)
+{
+ struct MPOpts *opts = &mpctx->opts;
sh_video_t * const sh_video = mpctx->sh_video;
double ar=-1.0;
//================== Init VIDEO (codec & libvo) ==========================
- if(!fixed_vo || !(initialized_flags&INITIALIZED_VO)){
+ if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) {
current_module="preinit_libvo";
//shouldn't we set dvideo->id=-2 when we fail?
- vo_config_count=0;
//if((mpctx->video_out->preinit(vo_subdevice))!=0){
- if(!(mpctx->video_out=init_best_video_out(video_driver_list))){
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_ErrorInitializingVODevice);
+ if(!(mpctx->video_out=init_best_video_out(opts, mpctx->x11_state, mpctx->key_fifo, mpctx->input))){
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Error opening/initializing the selected video_out (-vo) device.\n");
goto err_out;
}
- initialized_flags|=INITIALIZED_VO;
+ mpctx->initialized_flags|=INITIALIZED_VO;
}
if(stream_control(mpctx->demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar) != STREAM_UNSUPPORTED)
@@ -2156,28 +2160,28 @@ int reinit_video_chain(void) {
current_module="init_video_filters";
{
char* vf_arg[] = { "_oldargs_", (char*)mpctx->video_out , NULL };
- sh_video->vfilter=(void*)vf_open_filter(NULL,"vo",vf_arg);
+ sh_video->vfilter = vf_open_filter(opts, NULL,"vo",vf_arg);
}
#ifdef CONFIG_MENU
if(use_menu) {
char* vf_arg[] = { "_oldargs_", menu_root, NULL };
- vf_menu = vf_open_plugin(libmenu_vfs,sh_video->vfilter,"menu",vf_arg);
+ vf_menu = vf_open_plugin(opts,libmenu_vfs,sh_video->vfilter,"menu",vf_arg);
if(!vf_menu) {
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantOpenLibmenuFilterWithThisRootMenu,menu_root);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Can't open libmenu video filter with root menu %s.\n",menu_root);
use_menu = 0;
}
}
if(vf_menu)
- sh_video->vfilter=(void*)vf_menu;
+ sh_video->vfilter = vf_menu;
#endif
#ifdef CONFIG_ASS
if(ass_enabled) {
int i;
int insert = 1;
- if (vf_settings)
- for (i = 0; vf_settings[i].name; ++i)
- if (strcmp(vf_settings[i].name, "ass") == 0) {
+ if (opts->vf_settings)
+ for (i = 0; opts->vf_settings[i].name; ++i)
+ if (strcmp(opts->vf_settings[i].name, "ass") == 0) {
insert = 0;
break;
}
@@ -2185,20 +2189,20 @@ int reinit_video_chain(void) {
extern vf_info_t vf_info_ass;
const vf_info_t* libass_vfs[] = {&vf_info_ass, NULL};
char* vf_arg[] = {"auto", "1", NULL};
- vf_instance_t* vf_ass = vf_open_plugin(libass_vfs,sh_video->vfilter,"ass",vf_arg);
+ vf_instance_t* vf_ass = vf_open_plugin(opts, libass_vfs,sh_video->vfilter,"ass",vf_arg);
if (vf_ass)
- sh_video->vfilter=(void*)vf_ass;
+ sh_video->vfilter = vf_ass;
else
mp_msg(MSGT_CPLAYER,MSGL_ERR, "ASS: cannot add video filter\n");
}
}
#endif
- sh_video->vfilter=(void*)append_filters(sh_video->vfilter);
+ sh_video->vfilter = append_filters(sh_video->vfilter, opts->vf_settings);
#ifdef CONFIG_ASS
if (ass_enabled)
- ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_INIT_EOSD, ass_library);
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_INIT_EOSD, ass_library);
#endif
current_module="init_video_codec";
@@ -2208,11 +2212,11 @@ int reinit_video_chain(void) {
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
if(!sh_video->initialized){
- if(!fixed_vo) uninit_player(INITIALIZED_VO);
+ if(!opts->fixed_vo) uninit_player(mpctx, INITIALIZED_VO);
goto err_out;
}
- initialized_flags|=INITIALIZED_VCODEC;
+ mpctx->initialized_flags|=INITIALIZED_VCODEC;
if (sh_video->codec)
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_CODEC=%s\n", sh_video->codec->name);
@@ -2241,87 +2245,189 @@ err_out:
return 0;
}
-static double update_video(int *blit_frame)
+static double update_video_nocorrect_pts(struct MPContext *mpctx,
+ int *blit_frame)
{
- sh_video_t * const sh_video = mpctx->sh_video;
- //-------------------- Decode a frame: -----------------------
- double frame_time;
- *blit_frame = 0; // Don't blit if we hit EOF
- if (!correct_pts) {
- unsigned char* start=NULL;
- void *decoded_frame = NULL;
- int drop_frame=0;
- int in_size;
-
- current_module = "video_read_frame";
- frame_time = sh_video->next_frame_time;
- in_size = video_read_frame(sh_video, &sh_video->next_frame_time,
- &start, force_fps);
+ struct sh_video *sh_video = mpctx->sh_video;
+ *blit_frame = 0;
+ double frame_time = 0;
+ while (1) {
+ current_module = "filter_video";
+ // In nocorrect-pts mode there is no way to properly time these frames
+ if (vf_output_queued_frame(sh_video->vfilter))
+ break;
+ unsigned char *packet = NULL;
+ frame_time = sh_video->next_frame_time;
+ if (mpctx->update_video_immediately)
+ frame_time = 0;
+ int in_size = video_read_frame(sh_video, &sh_video->next_frame_time,
+ &packet, force_fps);
+ if (in_size < 0) {
#ifdef CONFIG_DVDNAV
- /// wait, still frame or EOF
- if (mpctx->stream->type == STREAMTYPE_DVDNAV && in_size < 0) {
- if (mp_dvdnav_is_eof(mpctx->stream)) return -1;
- if (mpctx->d_video) mpctx->d_video->eof = 0;
- if (mpctx->d_audio) mpctx->d_audio->eof = 0;
- mpctx->stream->eof = 0;
- } else
+ if (mpctx->stream->type == STREAMTYPE_DVDNAV) {
+ if (mp_dvdnav_is_eof(mpctx->stream))
+ return -1;
+ if (mpctx->d_video)
+ mpctx->d_video->eof = 0;
+ if (mpctx->d_audio)
+ mpctx->d_audio->eof = 0;
+ mpctx->stream->eof = 0;
+ } else
#endif
- if (in_size < 0)
- return -1;
- if (in_size > max_framesize)
- max_framesize = in_size; // stats
- sh_video->timer += frame_time;
- if (mpctx->sh_audio)
- mpctx->delay -= frame_time;
- // video_read_frame can change fps (e.g. for ASF video)
- vo_fps = sh_video->fps;
- drop_frame = check_framedrop(frame_time);
- update_subtitles(sh_video, mpctx->d_sub, 0);
- update_teletext(sh_video, mpctx->demuxer, 0);
- update_osd_msg();
- current_module = "decode_video";
+ return -1;
+ }
+ if (in_size > max_framesize)
+ max_framesize = in_size;
+ sh_video->timer += frame_time;
+ if (mpctx->sh_audio)
+ mpctx->delay -= frame_time;
+ // video_read_frame can change fps (e.g. for ASF video)
+ vo_fps = sh_video->fps;
+ int framedrop_type = check_framedrop(mpctx, frame_time);
+ current_module = "decode video";
+
+ void *decoded_frame;
#ifdef CONFIG_DVDNAV
- decoded_frame = mp_dvdnav_restore_smpi(&in_size,&start,decoded_frame);
- /// still frame has been reached, no need to decode
- if (in_size > 0 && !decoded_frame)
+ decoded_frame = mp_dvdnav_restore_smpi(mpctx, &in_size, &packet, NULL);
+ if (in_size >= 0 && !decoded_frame)
#endif
- decoded_frame = decode_video(sh_video, start, in_size, drop_frame,
- sh_video->pts);
+ decoded_frame = decode_video(sh_video, packet, in_size, framedrop_type,
+ sh_video->pts);
#ifdef CONFIG_DVDNAV
- /// save back last still frame for future display
- mp_dvdnav_save_smpi(in_size,start,decoded_frame);
+ // Save last still frame for future display
+ mp_dvdnav_save_smpi(mpctx, in_size, packet, decoded_frame);
#endif
- current_module = "filter_video";
- *blit_frame = (decoded_frame && filter_video(sh_video, decoded_frame,
- sh_video->pts));
+ if (decoded_frame) {
+ // These updates are done here for vf_expand OSD/subtitles
+ update_subtitles(sh_video, mpctx->d_sub, mpctx->video_offset, 0);
+ update_teletext(sh_video, mpctx->demuxer, 0);
+ update_osd_msg(mpctx);
+ current_module = "filter video";
+ if (filter_video(sh_video, decoded_frame, sh_video->pts))
+ break;
+ }
}
- else {
- int res = generate_video_frame(sh_video, mpctx->d_video);
- if (!res)
- return -1;
- ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter,
- VFCTRL_GET_PTS, &sh_video->pts);
- if (sh_video->pts == MP_NOPTS_VALUE) {
- mp_msg(MSGT_CPLAYER, MSGL_ERR, "pts after filters MISSING\n");
- sh_video->pts = sh_video->last_pts;
- }
- if (sh_video->last_pts == MP_NOPTS_VALUE)
- sh_video->last_pts= sh_video->pts;
- else if (sh_video->last_pts > sh_video->pts) {
- sh_video->last_pts = sh_video->pts;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "pts value < previous\n");
- }
- frame_time = sh_video->pts - sh_video->last_pts;
- sh_video->last_pts = sh_video->pts;
- sh_video->timer += frame_time;
- if(mpctx->sh_audio)
- mpctx->delay -= frame_time;
- *blit_frame = res > 0;
+ *blit_frame = 1;
+ return frame_time;
+}
+
+static double update_video(struct MPContext *mpctx, int *blit_frame)
+{
+ struct sh_video *sh_video = mpctx->sh_video;
+ *blit_frame = 0;
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SET_OSD_OBJ,
+ mpctx->osd); // hack for vf_expand
+ if (!mpctx->opts.correct_pts)
+ return update_video_nocorrect_pts(mpctx, blit_frame);
+
+ double pts;
+
+ while (1) {
+ current_module = "filter_video";
+ // XXX Time used in this call is not counted in any performance
+ // timer now, OSD time is not updated correctly for filter-added frames
+ if (vf_output_queued_frame(sh_video->vfilter))
+ break;
+ unsigned char *packet = NULL;
+ bool hit_eof = false;
+ int in_size = ds_get_packet_pts(mpctx->d_video, &packet, &pts);
+ if (pts != MP_NOPTS_VALUE)
+ pts += mpctx->video_offset;
+ if (in_size < 0) {
+ // try to extract last frames in case of decoder lag
+ in_size = 0;
+ pts = 1e300;
+ hit_eof = true;
+ }
+ if (in_size > max_framesize)
+ max_framesize = in_size;
+ current_module = "decode video";
+ int framedrop_type = check_framedrop(mpctx, sh_video->frametime);
+ void *decoded_frame = decode_video(sh_video, packet, in_size,
+ framedrop_type, pts);
+ if (decoded_frame) {
+ // These updates are done here for vf_expand OSD/subtitles
+ update_subtitles(sh_video, mpctx->d_sub, mpctx->video_offset, 0);
+ update_teletext(sh_video, mpctx->demuxer, 0);
+ update_osd_msg(mpctx);
+ current_module = "filter video";
+ if (filter_video(sh_video, decoded_frame, sh_video->pts))
+ break;
+ } else if (hit_eof)
+ return -1;
+ }
+
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_GET_PTS, &pts);
+ if (pts == MP_NOPTS_VALUE) {
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, "Video pts after filters MISSING\n");
+ // Try to use decoder pts from before filters
+ pts = sh_video->pts;
+ if (pts == MP_NOPTS_VALUE)
+ pts = sh_video->last_pts;
}
+ sh_video->pts = pts;
+ if (sh_video->last_pts == MP_NOPTS_VALUE)
+ sh_video->last_pts = sh_video->pts;
+ else if (sh_video->last_pts > sh_video->pts) {
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "Decreasing video pts: %f < %f\n",
+ sh_video->pts, sh_video->last_pts);
+ /* If the difference in pts is small treat it as jitter around the
+ * right value (possibly caused by incorrect timestamp ordering) and
+ * just show this frame immediately after the last one.
+ * Treat bigger differences as timestamp resets and start counting
+ * timing of later frames from the position of this one. */
+ if (sh_video->last_pts - sh_video->pts > 0.5)
+ sh_video->last_pts = sh_video->pts;
+ else
+ sh_video->pts = sh_video->last_pts;
+ }
+ double frame_time = sh_video->pts - sh_video->last_pts;
+ sh_video->last_pts = sh_video->pts;
+ sh_video->timer += frame_time;
+ if (mpctx->sh_audio)
+ mpctx->delay -= frame_time;
+ *blit_frame = 1;
return frame_time;
}
-static void pause_loop(void)
+void pause_player(struct MPContext *mpctx)
+{
+ if (mpctx->paused)
+ return;
+ mpctx->paused = 1;
+ mpctx->step_frames = 0;
+ mpctx->time_frame -= get_relative_time(mpctx);
+
+ if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
+ vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL);
+
+ if (mpctx->audio_out && mpctx->sh_audio)
+ mpctx->audio_out->pause(); // pause audio, keep data if possible
+}
+
+void unpause_player(struct MPContext *mpctx)
+{
+ if (!mpctx->paused)
+ return;
+ mpctx->paused = 0;
+
+ if (mpctx->audio_out && mpctx->sh_audio)
+ mpctx->audio_out->resume(); // resume audio
+ if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok
+ && !mpctx->step_frames)
+ vo_control(mpctx->video_out, VOCTRL_RESUME, NULL); // resume video
+ (void)get_relative_time(mpctx); // ignore time that passed during pause
+}
+
+void add_step_frame(struct MPContext *mpctx)
+{
+ mpctx->step_frames++;
+ if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
+ vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL);
+ unpause_player(mpctx);
+}
+
+static void pause_loop(struct MPContext *mpctx)
{
mp_cmd_t* cmd;
if (!quiet) {
@@ -2329,39 +2435,35 @@ static void pause_loop(void)
// The pause string is: "\n == PAUSE == \r" so we need to
// take the first and the last char out
if (term_osd && !mpctx->sh_video) {
- char msg[128] = MSGTR_Paused;
+ char msg[128] = _("\n ===== PAUSE =====\r");
int mlen = strlen(msg);
msg[mlen-1] = '\0';
set_osd_msg(OSD_MSG_PAUSE, 1, 0, "%s", msg+1);
- update_osd_msg();
+ update_osd_msg(mpctx);
} else
- mp_msg(MSGT_CPLAYER,MSGL_STATUS,MSGTR_Paused);
+ mp_tmsg(MSGT_CPLAYER,MSGL_STATUS,"\n ===== PAUSE =====\r");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_PAUSED\n");
}
#ifdef CONFIG_GUI
if (use_gui)
guiGetEvent(guiCEvent, (char *)guiSetPause);
#endif
- if (mpctx->video_out && mpctx->sh_video && vo_config_count)
- mpctx->video_out->control(VOCTRL_PAUSE, NULL);
- if (mpctx->audio_out && mpctx->sh_audio)
- mpctx->audio_out->pause(); // pause audio, keep data if possible
-
- while ( (cmd = mp_input_get_cmd(20, 1, 1)) == NULL || cmd->pausing == 4) {
+ while ( (cmd = mp_input_get_cmd(mpctx->input, 20, 1, 1)) == NULL
+ || cmd->id == MP_CMD_SET_MOUSE_POS || cmd->pausing == 4) {
if (cmd) {
- cmd = mp_input_get_cmd(0,1,0);
+ cmd = mp_input_get_cmd(mpctx->input, 0,1,0);
run_command(mpctx, cmd);
mp_cmd_free(cmd);
continue;
}
- if (mpctx->sh_video && mpctx->video_out && vo_config_count)
- mpctx->video_out->check_events();
+ if (mpctx->sh_video && mpctx->video_out)
+ vo_check_events(mpctx->video_out);
#ifdef CONFIG_GUI
if (use_gui) {
guiEventHandling();
guiGetEvent(guiReDraw, NULL);
- if (guiIntfStruct.Playing!=2 || (rel_seek_secs || abs_seek_pos))
+ if (guiIntfStruct.Playing!=2 || (mpctx->rel_seek_secs || mpctx->abs_seek_pos))
break;
}
#endif
@@ -2370,17 +2472,12 @@ static void pause_loop(void)
vf_menu_pause_update(vf_menu);
#endif
usec_sleep(20000);
+ update_osd_msg(mpctx);
+ int hack = vo_osd_changed(0);
+ vo_osd_changed(hack);
+ if (hack)
+ break;
}
- if (cmd && cmd->id == MP_CMD_PAUSE) {
- cmd = mp_input_get_cmd(0,1,0);
- mp_cmd_free(cmd);
- }
- mpctx->osd_function=OSD_PLAY;
- if (mpctx->audio_out && mpctx->sh_audio)
- mpctx->audio_out->resume(); // resume audio
- if (mpctx->video_out && mpctx->sh_video && vo_config_count)
- mpctx->video_out->control(VOCTRL_RESUME, NULL); // resume video
- (void)GetRelativeTime(); // ignore time that passed during pause
#ifdef CONFIG_GUI
if (use_gui) {
if (guiIntfStruct.Playing == guiSetStop)
@@ -2418,7 +2515,7 @@ static void edl_update(MPContext *mpctx)
return;
if (!mpctx->sh_video) {
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlNOsh_video);
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Cannot use EDL without video, disabling.\n");
free_edl(edl_records);
next_edl_record = NULL;
edl_records = NULL;
@@ -2428,12 +2525,11 @@ static void edl_update(MPContext *mpctx)
if (mpctx->sh_video->pts >= next_edl_record->start_sec) {
if (next_edl_record->action == EDL_SKIP) {
mpctx->osd_function = OSD_FFW;
- abs_seek_pos = 0;
- rel_seek_secs = next_edl_record->length_sec;
+ mpctx->abs_seek_pos = 0;
+ mpctx->rel_seek_secs = next_edl_record->length_sec;
mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_SKIP: start [%f], stop "
"[%f], length [%f]\n", next_edl_record->start_sec,
next_edl_record->stop_sec, next_edl_record->length_sec);
- edl_decision = 1;
}
else if (next_edl_record->action == EDL_MUTE) {
mpctx->edl_muted = !mpctx->edl_muted;
@@ -2446,6 +2542,48 @@ static void edl_update(MPContext *mpctx)
}
}
+static void reinit_decoders(struct MPContext *mpctx)
+{
+ reinit_video_chain(mpctx);
+ reinit_audio_chain(mpctx);
+ mp_property_do("sub", M_PROPERTY_SET, &mpctx->global_sub_pos, mpctx);
+}
+
+static bool timeline_set_part(struct MPContext *mpctx, int i)
+{
+ struct timeline_part *p = mpctx->timeline + mpctx->timeline_part;
+ struct timeline_part *n = mpctx->timeline + i;
+ mpctx->timeline_part = i;
+ mpctx->video_offset = n->start - n->source_start;
+ if (n->source == p->source)
+ return false;
+ uninit_player(mpctx, INITIALIZED_VCODEC | (mpctx->opts.fixed_vo && mpctx->opts.video_id != -2 ? 0 : INITIALIZED_VO) | INITIALIZED_AO | INITIALIZED_ACODEC);
+ mpctx->demuxer = n->source->demuxer;
+ mpctx->d_video = mpctx->demuxer->video;
+ mpctx->d_audio = mpctx->demuxer->audio;
+ mpctx->d_sub = mpctx->demuxer->sub;
+ mpctx->sh_video = mpctx->d_video->sh;
+ mpctx->sh_audio = mpctx->d_audio->sh;
+ return true;
+}
+
+// Given pts, switch playback to the corresponding part.
+// Return offset within that part.
+static double timeline_set_from_time(struct MPContext *mpctx, double pts,
+ bool *need_reset)
+{
+ if (pts < 0)
+ pts = 0;
+ for (int i = 0; i < mpctx->num_timeline_parts; i++) {
+ struct timeline_part *p = mpctx->timeline + i;
+ if (pts < (p+1)->start) {
+ *need_reset = timeline_set_part(mpctx, i);
+ return pts - p->start + p->source_start;
+ }
+ }
+ return -1;
+}
+
// style & SEEK_ABSOLUTE == 0 means seek relative to current position, == 1 means absolute
// style & SEEK_FACTOR == 0 means amount in seconds, == 2 means fraction of file length
@@ -2453,23 +2591,61 @@ static void edl_update(MPContext *mpctx)
static int seek(MPContext *mpctx, double amount, int style)
{
current_module = "seek";
- if (demux_seek(mpctx->demuxer, amount, audio_delay, style) == 0)
+ if (mpctx->stop_play == AT_END_OF_FILE)
+ mpctx->stop_play = KEEP_PLAYING;
+ if (mpctx->timeline && style & SEEK_FACTOR) {
+ amount *= mpctx->timeline[mpctx->num_timeline_parts].start;
+ style &= ~SEEK_FACTOR;
+ }
+ if ((mpctx->demuxer->accurate_seek || mpctx->timeline) && mpctx->sh_video
+ && !(style & (SEEK_ABSOLUTE | SEEK_FACTOR))) {
+ style |= SEEK_ABSOLUTE;
+ if (amount > 0)
+ style |= SEEK_FORWARD;
+ else
+ style |= SEEK_BACKWARD;
+ amount += mpctx->sh_video->pts;
+ }
+
+ /* At least the liba52 decoder wants to read from the input stream
+ * during initialization, so reinit must be done after the demux_seek()
+ * call that clears possible stream EOF. */
+ bool need_reset = false;
+ if (mpctx->timeline) {
+ amount = timeline_set_from_time(mpctx, amount, &need_reset);
+ if (amount == -1) {
+ mpctx->stop_play = AT_END_OF_FILE;
+ // Clear audio from current position
+ if (mpctx->sh_audio) {
+ mpctx->audio_out->reset();
+ mpctx->sh_audio->a_buffer_len = 0;
+ mpctx->sh_audio->a_out_buffer_len = 0;
+ }
+ return -1;
+ }
+ }
+ int seekresult = demux_seek(mpctx->demuxer, amount, audio_delay, style);
+ if (need_reset)
+ reinit_decoders(mpctx);
+ if (seekresult == 0)
return -1;
if (mpctx->sh_video) {
current_module = "seek_video_reset";
resync_video_stream(mpctx->sh_video);
- if (vo_config_count)
- mpctx->video_out->control(VOCTRL_RESET, NULL);
+ if (mpctx->video_out->config_ok)
+ vo_control(mpctx->video_out, VOCTRL_RESET, NULL);
mpctx->sh_video->num_buffered_pts = 0;
mpctx->sh_video->last_pts = MP_NOPTS_VALUE;
mpctx->num_buffered_frames = 0;
mpctx->delay = 0;
+ mpctx->time_frame = 0;
+ mpctx->update_video_immediately = true;
// Not all demuxers set d_video->pts during seek, so this value
// (which is used by at least vobsub and edl code below) may
// be completely wrong (probably 0).
- mpctx->sh_video->pts = mpctx->d_video->pts;
- update_subtitles(mpctx->sh_video, mpctx->d_sub, 1);
+ mpctx->sh_video->pts = mpctx->d_video->pts + mpctx->video_offset;
+ update_subtitles(mpctx->sh_video, mpctx->d_sub, mpctx->video_offset, 1);
update_teletext(mpctx->sh_video, mpctx->demuxer, 1);
}
@@ -2487,8 +2663,7 @@ static int seek(MPContext *mpctx, double amount, int style)
edl_seek_reset(mpctx);
- c_total = 0;
- max_pts_correction = 0.1;
+ mpctx->total_avsync_change = 0;
audio_time_usage = 0; video_time_usage = 0; vout_time_usage = 0;
drop_frame_cnt = 0;
@@ -2496,6 +2671,241 @@ static int seek(MPContext *mpctx, double amount, int style)
return 0;
}
+int get_current_chapter(struct MPContext *mpctx)
+{
+ if (!mpctx->chapters || !mpctx->sh_video)
+ return demuxer_get_current_chapter(mpctx->demuxer);
+
+ int i;
+ double current_pts = mpctx->sh_video->pts;
+ for (i = 1; i < mpctx->num_chapters; i++)
+ if (current_pts < mpctx->chapters[i].start)
+ break;
+ return i - 1;
+}
+
+// currently returns a string allocated with malloc, not talloc
+char *chapter_display_name(struct MPContext *mpctx, int chapter)
+{
+ if (!mpctx->chapters || !mpctx->sh_video)
+ return demuxer_chapter_display_name(mpctx->demuxer, chapter);
+ return strdup(mpctx->chapters[chapter].name);
+}
+
+int seek_chapter(struct MPContext *mpctx, int chapter, double *seek_pts,
+ char **chapter_name)
+{
+ if (!mpctx->chapters || !mpctx->sh_video)
+ return demuxer_seek_chapter(mpctx->demuxer, chapter, seek_pts,
+ chapter_name);
+ if (chapter >= mpctx->num_chapters)
+ return -1;
+ if (chapter < 0)
+ chapter = 0;
+ *seek_pts = mpctx->chapters[chapter].start;
+ if (chapter_name)
+ *chapter_name = talloc_strdup(NULL, mpctx->chapters[chapter].name);
+ return chapter;
+}
+
+static int find_ordered_chapter_sources(struct MPContext *mpctx,
+ struct content_source *sources,
+ int num_sources,
+ unsigned char uid_map[][16])
+{
+ int num_filenames = 0;
+ char **filenames = NULL;
+ if (num_sources > 1) {
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "This file references data from "
+ "other sources.\n");
+ if (mpctx->stream->type != STREAMTYPE_FILE) {
+ mp_msg(MSGT_CPLAYER, MSGL_WARN, "Playback source is not a "
+ "normal disk file. Will not search for related files.\n");
+ } else {
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "Will scan other files in the "
+ "same directory to find referenced sources.\n");
+ filenames = find_files(mpctx->demuxer->filename, ".mkv",
+ &num_filenames);
+ }
+ }
+
+ int num_left = num_sources - 1;
+ for (int i = 0; i < num_filenames && num_left > 0; i++) {
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "Checking file %s\n",
+ filename_recode(filenames[i]));
+ int format;
+ struct stream *s = open_stream(filenames[i], &mpctx->opts, &format);
+ if (!s)
+ continue;
+ struct demuxer *d = demux_open(&mpctx->opts, s, DEMUXER_TYPE_MATROSKA,
+ mpctx->opts.audio_id,
+ mpctx->opts.video_id,
+ mpctx->opts.sub_id, filenames[i]);
+ if (!d) {
+ free_stream(s);
+ continue;
+ }
+ if (d->file_format == DEMUXER_TYPE_MATROSKA) {
+ for (int i = 1; i < num_sources; i++) {
+ if (sources[i].demuxer)
+ continue;
+ if (!memcmp(uid_map[i], d->matroska_data.segment_uid, 16)) {
+ mp_msg(MSGT_CPLAYER, MSGL_INFO,"Match for source %d: %s\n",
+ i, filename_recode(d->filename));
+ sources[i].stream = s;
+ sources[i].demuxer = d;
+ num_left--;
+ goto match;
+ }
+ }
+ }
+ free_demuxer(d);
+ free_stream(s);
+ continue;
+ match:
+ ;
+ }
+ talloc_free(filenames);
+ if (num_left) {
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, "Failed to find ordered chapter part!\n"
+ "There will be parts MISSING from the video!\n");
+ for (int i = 1, j = 1; i < num_sources; i++)
+ if (sources[i].demuxer) {
+ sources[j] = sources[i];
+ memcpy(uid_map[j], uid_map[i], 16);
+ j++;
+ }
+ }
+ return num_sources - num_left;
+}
+
+static void build_ordered_chapter_timeline(struct MPContext *mpctx)
+{
+ if (!mpctx->opts.ordered_chapters) {
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "File uses ordered chapters, but "
+ "you have disabled support for them. Ignoring.\n");
+ return;
+ }
+
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "File uses ordered chapters, will build "
+ "edit timeline.\n");
+
+ struct demuxer *demuxer = mpctx->demuxer;
+ struct matroska_data *m = &demuxer->matroska_data;
+
+ struct content_source *sources = talloc_array_ptrtype(NULL, sources,
+ m->num_ordered_chapters);
+ sources[0].stream = mpctx->stream;
+ sources[0].demuxer = mpctx->demuxer;
+ unsigned char uid_map[m->num_ordered_chapters][16];
+ int num_sources = 1;
+ memcpy(uid_map[0], m->segment_uid, 16);
+
+ for (int i = 0; i < m->num_ordered_chapters; i++) {
+ struct matroska_chapter *c = m->ordered_chapters + i;
+ if (!c->has_segment_uid)
+ memcpy(c->segment_uid, m->segment_uid, 16);
+
+ for (int j = 0; j < num_sources; j++)
+ if (!memcmp(c->segment_uid, uid_map[j], 16))
+ goto found1;
+ memcpy(uid_map[num_sources], c->segment_uid, 16);
+ sources[num_sources] = (struct content_source){};
+ num_sources++;
+ found1:
+ ;
+ }
+
+ num_sources = find_ordered_chapter_sources(mpctx, sources, num_sources,
+ uid_map);
+
+
+ struct timeline_part *timeline = talloc_array_ptrtype(NULL, timeline,
+ m->num_ordered_chapters + 1);
+ struct chapter *chapters = talloc_array_ptrtype(NULL, chapters,
+ m->num_ordered_chapters);
+ uint64_t starttime = 0;
+ uint64_t missing_time = 0;
+ int part_count = 0;
+ int num_chapters = 0;
+ uint64_t prev_part_offset;
+ for (int i = 0; i < m->num_ordered_chapters; i++) {
+ struct matroska_chapter *c = m->ordered_chapters + i;
+
+ int j;
+ for (j = 0; j < num_sources; j++) {
+ if (!memcmp(c->segment_uid, uid_map[j], 16))
+ goto found2;
+ }
+ missing_time += c->end - c->start;
+ continue;
+ found2:;
+ chapters[num_chapters].start = starttime / 1000.;
+ chapters[num_chapters].name = talloc_strdup(chapters, c->name);
+ /* Only add a separate part if the time or file actually changes.
+ * Matroska files have chapter divisions that are redundant from
+ * timeline point of view because the same chapter structure is used
+ * both to specify the timeline and for normal chapter information.
+ * Removing a missing inserted external chapter can also cause this. */
+ if (part_count == 0 || c->start != starttime + prev_part_offset
+ || sources + j != timeline[part_count - 1].source) {
+ timeline[part_count].source = sources + j;
+ timeline[part_count].start = chapters[num_chapters].start;
+ timeline[part_count].source_start = c->start / 1000.;
+ prev_part_offset = c->start - starttime;
+ part_count++;
+ }
+ starttime += c->end - c->start;
+ num_chapters++;
+ }
+ timeline[part_count].start = starttime / 1000.;
+
+ if (!part_count) {
+ // None of the parts come from the file itself???
+ talloc_free(sources);
+ talloc_free(timeline);
+ talloc_free(chapters);
+ return;
+ }
+
+ mp_msg(MSGT_CPLAYER, MSGL_V, "Timeline contains %d parts from %d "
+ "sources. Total length %.3f seconds.\n", part_count, num_sources,
+ timeline[part_count].start);
+ if (missing_time)
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, "There are %.3f seconds missing "
+ "from the timeline!\n", missing_time / 1000.);
+ mp_msg(MSGT_CPLAYER, MSGL_V, "Source files:\n");
+ for (int i = 0; i < num_sources; i++)
+ mp_msg(MSGT_CPLAYER, MSGL_V, "%d: %s\n", i,
+ filename_recode(sources[i].demuxer->filename));
+ mp_msg(MSGT_CPLAYER, MSGL_V, "Timeline parts: (number, start, "
+ "source_start, source):\n");
+ for (int i = 0; i < part_count; i++) {
+ struct timeline_part *p = timeline + i;
+ mp_msg(MSGT_CPLAYER, MSGL_V, "%3d %9.3f %9.3f %3td\n", i, p->start,
+ p->source_start, p->source - sources);
+ }
+ mp_msg(MSGT_CPLAYER, MSGL_V, "END %9.3f\n", timeline[part_count].start);
+ mpctx->sources = sources;
+ mpctx->num_sources = num_sources;
+ mpctx->timeline = timeline;
+ mpctx->num_timeline_parts = part_count;
+ mpctx->num_chapters = num_chapters;
+ mpctx->chapters = chapters;
+
+ mpctx->timeline_part = 0;
+ mpctx->video_offset = timeline[0].source_start;
+ mpctx->demuxer = timeline[0].source->demuxer;
+}
+
+
+static int read_keys(void *ctx, int fd)
+{
+ getch2(ctx);
+ return mplayer_get_key(ctx, 0);
+}
+
+
/* This preprocessor directive is a hack to generate a mplayer-nomain.o object
* file for some tools to link against. */
#ifndef DISABLE_MAIN
@@ -2515,18 +2925,33 @@ int i;
int gui_no_filename=0;
+ struct MPContext *mpctx = &(struct MPContext){
+ .osd_function = OSD_PLAY,
+ .begin_skip = MP_NOPTS_VALUE,
+ .play_tree_step = 1,
+ .global_sub_pos = -1,
+ .set_of_sub_pos = -1,
+ .file_format = DEMUXER_TYPE_UNKNOWN,
+ .last_dvb_step = 1,
+ };
+
InitTimer();
srand(GetTimerMS());
mp_msg_init();
+#ifdef CONFIG_X11
+ mpctx->x11_state = vo_x11_init_state();
+#endif
+ struct MPOpts *opts = &mpctx->opts;
+ set_default_mplayer_options(opts);
// Create the config context and register the options
- mconfig = m_config_new();
- m_config_register_options(mconfig,mplayer_opts);
- mp_input_register_options(mconfig);
+ mpctx->mconfig = m_config_new(opts, cfg_include);
+ m_config_register_options(mpctx->mconfig,mplayer_opts);
+ mp_input_register_options(mpctx->mconfig);
// Preparse the command line
- m_config_preparse_command_line(mconfig,argc,argv);
+ m_config_preparse_command_line(mpctx->mconfig,argc,argv);
#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL)
set_path_env();
@@ -2551,38 +2976,39 @@ int gui_no_filename=0;
use_gui=1;
}
- parse_cfgfiles(mconfig);
+ parse_cfgfiles(mpctx, mpctx->mconfig);
#ifdef CONFIG_GUI
if ( use_gui ) cfg_read();
#endif
- mpctx->playtree = m_config_parse_mp_command_line(mconfig, argc, argv);
+ mpctx->playtree = m_config_parse_mp_command_line(mpctx->mconfig, argc, argv);
if(mpctx->playtree == NULL)
opt_exit = 1;
else {
mpctx->playtree = play_tree_cleanup(mpctx->playtree);
if(mpctx->playtree) {
- mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree,mconfig);
+ mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree,mpctx->mconfig);
if(mpctx->playtree_iter) {
if(play_tree_iter_step(mpctx->playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) {
play_tree_iter_free(mpctx->playtree_iter);
mpctx->playtree_iter = NULL;
}
- filename = play_tree_iter_get_file(mpctx->playtree_iter,1);
+ mpctx->filename = play_tree_iter_get_file(mpctx->playtree_iter,1);
}
}
}
+ mpctx->key_fifo = mp_fifo_create(opts);
print_version("MPlayer");
#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_GUI)
void *runningmplayer = FindWindow("MPlayer GUI for Windows", "MPlayer for Windows");
- if(runningmplayer && filename && use_gui){
+ if(runningmplayer && mpctx->filename && use_gui){
COPYDATASTRUCT csData;
char file[MAX_PATH];
- char *filepart = filename;
- if(GetFullPathName(filename, MAX_PATH, file, &filepart)){
+ char *filepart = mpctx->filename;
+ if(GetFullPathName(mpctx->filename, MAX_PATH, file, &filepart)){
csData.dwData = 0;
csData.cbData = strlen(file)*2;
csData.lpData = file;
@@ -2604,13 +3030,13 @@ int gui_no_filename=0;
#ifndef CONFIG_GUI
if(use_gui){
- mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoGui);
+ mp_tmsg(MSGT_CPLAYER,MSGL_WARN,"MPlayer was compiled WITHOUT GUI support.\n");
use_gui=0;
}
#else
#if !defined(__MINGW32__) && !defined(__CYGWIN__)
if(use_gui && !vo_init()){
- mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_GuiNeedsX);
+ mp_tmsg(MSGT_CPLAYER,MSGL_WARN,"MPlayer GUI requires X11.\n");
use_gui=0;
}
#endif
@@ -2627,16 +3053,16 @@ int gui_no_filename=0;
play_tree_add_bpf(mpctx->playtree, cwd);
}
// Import initital playtree into GUI.
- import_initial_playtree_into_gui(mpctx->playtree, mconfig, enqueue);
+ import_initial_playtree_into_gui(mpctx->playtree, mpctx->mconfig, enqueue);
}
#endif /* CONFIG_GUI */
- if(video_driver_list && strcmp(video_driver_list[0],"help")==0){
+ if(opts->video_driver_list && strcmp(opts->video_driver_list[0],"help")==0){
list_video_out();
opt_exit = 1;
}
- if(audio_driver_list && strcmp(audio_driver_list[0],"help")==0){
+ if(opts->audio_driver_list && strcmp(opts->audio_driver_list[0],"help")==0){
list_audio_out();
opt_exit = 1;
}
@@ -2646,9 +3072,9 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
if(!parse_codec_cfg(mem_ptr=get_path("codecs.conf"))){
if(!parse_codec_cfg(MPLAYER_CONFDIR "/codecs.conf")){
if(!parse_codec_cfg(NULL)){
- exit_player_with_rc(EXIT_NONE, 0);
+ exit_player_with_rc(mpctx, EXIT_NONE, 0);
}
- mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_BuiltinCodecsConf);
+ mp_tmsg(MSGT_CPLAYER,MSGL_V,"Using built-in default codecs.conf.\n");
}
}
free( mem_ptr ); // release the buffer created by get_path()
@@ -2663,14 +3089,14 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
}
#endif
if(audio_codec_list && strcmp(audio_codec_list[0],"help")==0){
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableAudioCodecs);
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available audio codecs:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_CODECS\n");
list_codecs(1);
mp_msg(MSGT_FIXME, MSGL_FIXME, "\n");
opt_exit = 1;
}
if(video_codec_list && strcmp(video_codec_list[0],"help")==0){
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoCodecs);
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available video codecs:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_CODECS\n");
list_codecs(0);
mp_msg(MSGT_FIXME, MSGL_FIXME, "\n");
@@ -2711,18 +3137,18 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
}
if(opt_exit)
- exit_player(EXIT_NONE);
+ exit_player(mpctx, EXIT_NONE);
if (player_idle_mode && use_gui) {
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_NoIdleAndGui);
- exit_player_with_rc(EXIT_NONE, 1);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "The -idle option cannot be used with GMPlayer.\n");
+ exit_player_with_rc(mpctx, EXIT_NONE, 1);
}
- if(!filename && !player_idle_mode){
+ if(!mpctx->filename && !player_idle_mode){
if(!use_gui){
// no file/vcd/dvd -> show HELP:
mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text);
- exit_player_with_rc(EXIT_NONE, 0);
+ exit_player_with_rc(mpctx, EXIT_NONE, 0);
} else gui_no_filename=1;
}
@@ -2731,13 +3157,15 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
// Many users forget to include command line in bugreports...
if( mp_msg_test(MSGT_CPLAYER,MSGL_V) ){
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_CommandLine);
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "CommandLine:");
for(i=1;i<argc;i++)mp_msg(MSGT_CPLAYER, MSGL_INFO," '%s'",argv[i]);
mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n");
}
//------ load global data first ------
+ mpctx->osd = osd_create();
+
// check font
#ifdef CONFIG_FREETYPE
init_freetype();
@@ -2749,7 +3177,7 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
#ifdef CONFIG_BITMAP_FONT
if(font_name){
vo_font=read_font_desc(font_name,font_factor,verbose>1);
- if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,
+ if(!vo_font) mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Cannot load bitmap font: %s\n",
filename_recode(font_name));
} else {
// try default:
@@ -2759,16 +3187,14 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1);
}
if (sub_font_name)
- sub_font = read_font_desc(sub_font_name, font_factor, verbose>1);
+ mpctx->osd->sub_font = read_font_desc(sub_font_name, font_factor, verbose>1);
else
- sub_font = vo_font;
+ mpctx->osd->sub_font = vo_font;
#endif
#ifdef CONFIG_FONTCONFIG
}
#endif
- vo_init_osd();
-
#ifdef CONFIG_ASS
ass_library = ass_init();
#endif
@@ -2778,23 +3204,23 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
{
// seteuid(0); /* Can't hurt to try to get root here */
if ((rtc_fd = open(rtc_device ? rtc_device : "/dev/rtc", O_RDONLY)) < 0)
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_RTCDeviceNotOpenable,
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Failed to open %s: %s (it should be readable by the user.)\n",
rtc_device ? rtc_device : "/dev/rtc", strerror(errno));
else {
unsigned long irqp = 1024; /* 512 seemed OK. 128 is jerky. */
if (ioctl(rtc_fd, RTC_IRQP_SET, irqp) < 0) {
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_LinuxRTCInitErrorIrqpSet, irqp, strerror(errno));
- mp_msg(MSGT_CPLAYER, MSGL_HINT, MSGTR_IncreaseRTCMaxUserFreq, irqp);
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Linux RTC init error in ioctl (rtc_irqp_set %lu): %s\n", irqp, strerror(errno));
+ mp_tmsg(MSGT_CPLAYER, MSGL_HINT, "Try adding \"echo %lu > /proc/sys/dev/rtc/max-user-freq\" to your system startup scripts.\n", irqp);
close (rtc_fd);
rtc_fd = -1;
} else if (ioctl(rtc_fd, RTC_PIE_ON, 0) < 0) {
/* variable only by the root */
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_LinuxRTCInitErrorPieOn, strerror(errno));
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Linux RTC init error in ioctl (rtc_pie_on): %s\n", strerror(errno));
close (rtc_fd);
rtc_fd = -1;
} else
- mp_msg(MSGT_CPLAYER, MSGL_V, MSGTR_UsingRTCTiming, irqp);
+ mp_tmsg(MSGT_CPLAYER, MSGL_V, "Using Linux hardware RTC timing (%ldHz).\n", irqp);
}
}
#ifdef CONFIG_GUI
@@ -2815,28 +3241,29 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
// Init input system
current_module = "init_input";
-mp_input_init(use_gui);
- mp_input_add_key_fd(-1,0,mplayer_get_key,NULL);
+ mpctx->input = mp_input_init(&opts->input, use_gui);
+ mp_input_add_key_fd(mpctx->input, -1,0,mplayer_get_key,NULL, mpctx->key_fifo);
if(slave_mode)
- mp_input_add_cmd_fd(0,USE_SELECT,MP_INPUT_SLAVE_CMD_FUNC,NULL);
+ mp_input_add_cmd_fd(mpctx->input, 0,USE_SELECT,MP_INPUT_SLAVE_CMD_FUNC,NULL);
else if(!noconsolecontrols)
- mp_input_add_event_fd(0, getch2);
+ mp_input_add_key_fd(mpctx->input, 0, 1, read_keys, NULL, mpctx->key_fifo);
// Set the libstream interrupt callback
-stream_set_interrupt_callback(mp_input_check_interrupt);
+stream_set_interrupt_callback(mp_input_check_interrupt, mpctx->input);
#ifdef CONFIG_MENU
if(use_menu) {
- if(menu_cfg && menu_init(mpctx, menu_cfg))
- mp_msg(MSGT_CPLAYER, MSGL_V, MSGTR_MenuInitialized, menu_cfg);
+ if(menu_cfg && menu_init(mpctx, mpctx->mconfig, mpctx->input, menu_cfg))
+ mp_tmsg(MSGT_CPLAYER, MSGL_V, "Menu initialized: %s\n", menu_cfg);
else {
menu_cfg = get_path("menu.conf");
- if(menu_init(mpctx, menu_cfg))
- mp_msg(MSGT_CPLAYER, MSGL_V, MSGTR_MenuInitialized, menu_cfg);
+ if(menu_init(mpctx, mpctx->mconfig, mpctx->input, menu_cfg))
+ mp_tmsg(MSGT_CPLAYER, MSGL_V, "Menu initialized: %s\n", menu_cfg);
else {
- if(menu_init(mpctx, MPLAYER_CONFDIR "/menu.conf"))
- mp_msg(MSGT_CPLAYER, MSGL_V, MSGTR_MenuInitialized, MPLAYER_CONFDIR"/menu.conf");
+ if(menu_init(mpctx, mpctx->mconfig, mpctx->input,
+ MPLAYER_CONFDIR "/menu.conf"))
+ mp_tmsg(MSGT_CPLAYER, MSGL_V, "Menu initialized: %s\n", MPLAYER_CONFDIR"/menu.conf");
else {
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_MenuInitFailed);
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Menu init failed.\n");
use_menu = 0;
}
}
@@ -2844,7 +3271,6 @@ stream_set_interrupt_callback(mp_input_check_interrupt);
}
#endif
-initialized_flags|=INITIALIZED_INPUT;
current_module = NULL;
/// Catch signals
@@ -2881,7 +3307,7 @@ current_module = NULL;
if(use_gui){
guiInit();
guiGetEvent(guiSetContext, mpctx);
- initialized_flags|=INITIALIZED_GUI;
+ mpctx->initialized_flags|=INITIALIZED_GUI;
guiGetEvent( guiCEvent,(char *)((gui_no_filename) ? 0 : 1) );
}
#endif
@@ -2894,25 +3320,25 @@ play_next_file:
mpctx->global_sub_size = 0;
{ int i; for (i = 0; i < SUB_SOURCES; i++) mpctx->global_sub_indices[i] = -1; }
- if (filename) {
- load_per_protocol_config (mconfig, filename);
- load_per_extension_config (mconfig, filename);
- load_per_file_config (mconfig, filename);
+ if (mpctx->filename) {
+ load_per_protocol_config (mpctx->mconfig, mpctx->filename);
+ load_per_extension_config (mpctx->mconfig, mpctx->filename);
+ load_per_file_config (mpctx->mconfig, mpctx->filename);
}
- if (video_driver_list)
- load_per_output_config (mconfig, PROFILE_CFG_VO, video_driver_list[0]);
- if (audio_driver_list)
- load_per_output_config (mconfig, PROFILE_CFG_AO, audio_driver_list[0]);
+ if (opts->video_driver_list)
+ load_per_output_config (mpctx->mconfig, PROFILE_CFG_VO, opts->video_driver_list[0]);
+ if (opts->audio_driver_list)
+ load_per_output_config (mpctx->mconfig, PROFILE_CFG_AO, opts->audio_driver_list[0]);
// We must enable getch2 here to be able to interrupt network connection
// or cache filling
if(!noconsolecontrols && !slave_mode){
- if(initialized_flags&INITIALIZED_GETCH2)
- mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_Getch2InitializedTwice);
+ if(mpctx->initialized_flags&INITIALIZED_GETCH2)
+ mp_tmsg(MSGT_CPLAYER,MSGL_WARN,"WARNING: getch2_init called twice!\n");
else
getch2_enable(); // prepare stdin for hotkeys...
- initialized_flags|=INITIALIZED_GETCH2;
+ mpctx->initialized_flags|=INITIALIZED_GETCH2;
mp_msg(MSGT_CPLAYER,MSGL_DBG2,"\n[[[init getch2]]]\n");
}
@@ -2927,7 +3353,7 @@ if(!noconsolecontrols && !slave_mode){
usec_sleep(20000);
guiEventHandling();
guiGetEvent( guiReDraw,NULL );
- if ( (cmd = mp_input_get_cmd(0,0,0)) != NULL) {
+ if ( (cmd = mp_input_get_cmd(mpctx->input, 0,0,0)) != NULL) {
guiGetEvent(guiIEvent, (char *)cmd->id);
mp_cmd_free(cmd);
}
@@ -2942,7 +3368,7 @@ if(!noconsolecontrols && !slave_mode){
play_tree_set_child( mpctx->playtree,entry );
if(mpctx->playtree)
{
- mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree,mconfig);
+ mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree,mpctx->mconfig);
if(mpctx->playtree_iter)
{
if(play_tree_iter_step(mpctx->playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY)
@@ -2950,18 +3376,19 @@ if(!noconsolecontrols && !slave_mode){
play_tree_iter_free(mpctx->playtree_iter);
mpctx->playtree_iter = NULL;
}
- filename = play_tree_iter_get_file(mpctx->playtree_iter,1);
+ mpctx->filename = play_tree_iter_get_file(mpctx->playtree_iter,1);
}
}
}
}
#endif /* CONFIG_GUI */
-while (player_idle_mode && !filename) {
+while (player_idle_mode && !mpctx->filename) {
play_tree_t * entry = NULL;
mp_cmd_t * cmd;
- while (!(cmd = mp_input_get_cmd(0,1,0))) { // wait for command
- if (mpctx->video_out && vo_config_count) mpctx->video_out->check_events();
+ while (!(cmd = mp_input_get_cmd(mpctx->input, 0,1,0))) { // wait for command
+ if (mpctx->video_out)
+ vo_check_events(mpctx->video_out);
usec_sleep(20000);
}
switch (cmd->id) {
@@ -2972,10 +3399,10 @@ while (player_idle_mode && !filename) {
// The entry is added to the main playtree after the switch().
break;
case MP_CMD_LOADLIST:
- entry = parse_playlist_file(cmd->args[0].v.s);
+ entry = parse_playlist_file(mpctx->mconfig, cmd->args[0].v.s);
break;
case MP_CMD_QUIT:
- exit_player_with_rc(EXIT_QUIT, (cmd->nargs > 0)? cmd->args[0].v.i : 0);
+ exit_player_with_rc(mpctx, EXIT_QUIT, (cmd->nargs > 0)? cmd->args[0].v.i : 0);
break;
case MP_CMD_GET_PROPERTY:
case MP_CMD_SET_PROPERTY:
@@ -2996,7 +3423,7 @@ while (player_idle_mode && !filename) {
play_tree_set_child(mpctx->playtree, entry);
/* Make iterator start at the top the of tree. */
- mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree, mconfig);
+ mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree, mpctx->mconfig);
if (!mpctx->playtree_iter) continue;
// find the first real item in the tree
@@ -3006,14 +3433,14 @@ while (player_idle_mode && !filename) {
mpctx->playtree_iter = NULL;
continue; // wait for next command
}
- filename = play_tree_iter_get_file(mpctx->playtree_iter, 1);
+ mpctx->filename = play_tree_iter_get_file(mpctx->playtree_iter, 1);
}
}
//---------------------------------------------------------------------------
- if(filename)
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing,
- filename_recode(filename));
+ if(mpctx->filename)
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"\nPlaying %s.\n",
+ filename_recode(mpctx->filename));
if (edl_filename) {
if (edl_records) free_edl(edl_records);
@@ -3023,7 +3450,7 @@ if (edl_output_filename) {
if (edl_fd) fclose(edl_fd);
if ((edl_fd = fopen(edl_output_filename, "w")) == NULL)
{
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantOpenForWrite,
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Can't open EDL file [%s] for writing.\n",
filename_recode(edl_output_filename));
}
}
@@ -3034,11 +3461,11 @@ if (edl_output_filename) {
if (vobsub_name){
vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec);
if(vo_vobsub==NULL)
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Cannot load subtitles: %s\n",
filename_recode(vobsub_name));
- } else if (sub_auto && filename){
+ } else if (sub_auto && mpctx->filename){
/* try to autodetect vobsub from movie filename ::atmos */
- char *buf = strdup(filename), *psub;
+ char *buf = strdup(mpctx->filename), *psub;
char *pdot = strrchr(buf, '.');
char *pslash = strrchr(buf, '/');
#if defined(__MINGW32__) || defined(__CYGWIN__)
@@ -3066,7 +3493,7 @@ if (edl_output_filename) {
free(buf);
}
if(vo_vobsub){
- initialized_flags|=INITIALIZED_VOBSUB;
+ mpctx->initialized_flags|=INITIALIZED_VOBSUB;
vobsub_set_from_lang(vo_vobsub, dvdsub_lang);
mp_property_do("sub_forced_only", M_PROPERTY_SET, &forced_subs_only, mpctx);
@@ -3091,26 +3518,32 @@ if (edl_output_filename) {
mpctx->sh_video=NULL;
current_module="open_stream";
- mpctx->stream=open_stream(filename,0,&mpctx->file_format);
+ mpctx->stream = open_stream(mpctx->filename, opts, &mpctx->file_format);
if(!mpctx->stream) { // error...
- mpctx->eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY);
+ mpctx->stop_play = libmpdemux_was_interrupted(mpctx, PT_NEXT_ENTRY);
goto goto_next_file;
}
- initialized_flags|=INITIALIZED_STREAM;
+ mpctx->initialized_flags|=INITIALIZED_STREAM;
#ifdef CONFIG_GUI
if ( use_gui ) guiGetEvent( guiSetStream,(char *)mpctx->stream );
#endif
if(mpctx->file_format == DEMUXER_TYPE_PLAYLIST) {
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, "\nThis looks like a playlist, but "
+ "playlist support will not be used automatically.\n"
+ "MPlayer's playlist code is unsafe and should only be used with "
+ "trusted sources.\nPlayback will probably fail.\n\n");
+#if 0
play_tree_t* entry;
// Handle playlist
current_module="handle_playlist";
mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",
- filename_recode(filename));
- entry = parse_playtree(mpctx->stream,0);
- mpctx->eof=playtree_add_playlist(entry);
+ filename_recode(mpctx->filename));
+ entry = parse_playtree(mpctx->stream, mpctx->mconfig, 0);
+ mpctx->eof=playtree_add_playlist(mpctx, entry);
goto goto_next_file;
+#endif
}
mpctx->stream->start_pos+=seek_to_byte;
@@ -3120,15 +3553,15 @@ if(stream_dump_type==5){
FILE *f;
current_module="dumpstream";
if(mpctx->stream->type==STREAMTYPE_STREAM && mpctx->stream->fd<0){
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_DumpstreamFdUnavailable);
- exit_player(EXIT_ERROR);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Cannot dump this stream - no file descriptor available.\n");
+ exit_player(mpctx, EXIT_ERROR);
}
stream_reset(mpctx->stream);
stream_seek(mpctx->stream,mpctx->stream->start_pos);
f=fopen(stream_dump_name,"wb");
if(!f){
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CantOpenDumpfile);
- exit_player(EXIT_ERROR);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Cannot open dump file.\n");
+ exit_player(mpctx, EXIT_ERROR);
}
if (dvd_chapter > 1) {
int chapter = dvd_chapter - 1;
@@ -3138,8 +3571,8 @@ if(stream_dump_type==5){
len=stream_read(mpctx->stream,buf,4096);
if(len>0) {
if(fwrite(buf,len,1,f) != 1) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile,stream_dump_name);
- exit_player(EXIT_ERROR);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"%s: Error writing file.\n",stream_dump_name);
+ exit_player(mpctx, EXIT_ERROR);
}
}
if(dvd_last_chapter > 0) {
@@ -3150,19 +3583,19 @@ if(stream_dump_type==5){
}
}
if(fclose(f)) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile,stream_dump_name);
- exit_player(EXIT_ERROR);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"%s: Error writing file.\n",stream_dump_name);
+ exit_player(mpctx, EXIT_ERROR);
}
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CoreDumped);
- exit_player_with_rc(EXIT_EOF, 0);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Core dumped ;)\n");
+ exit_player_with_rc(mpctx, EXIT_EOF, 0);
}
#ifdef CONFIG_DVDREAD
if(mpctx->stream->type==STREAMTYPE_DVD){
current_module="dvd lang->id";
- if(audio_id==-1) audio_id=dvd_aid_from_lang(mpctx->stream,audio_lang);
- if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=-1;
- if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(mpctx->stream,dvdsub_lang);
+ if(opts->audio_id==-1) opts->audio_id=dvd_aid_from_lang(mpctx->stream,audio_lang);
+ if(dvdsub_lang && opts->sub_id==-2) opts->sub_id=-1;
+ if(dvdsub_lang && opts->sub_id==-1) opts->sub_id=dvd_sid_from_lang(mpctx->stream,dvdsub_lang);
// setup global sub numbering
mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub.
mpctx->global_sub_size += dvd_number_of_subs(mpctx->stream);
@@ -3173,9 +3606,9 @@ if(mpctx->stream->type==STREAMTYPE_DVD){
#ifdef CONFIG_DVDNAV
if(mpctx->stream->type==STREAMTYPE_DVDNAV){
current_module="dvdnav lang->id";
- if(audio_id==-1) audio_id=mp_dvdnav_aid_from_lang(mpctx->stream,audio_lang);
- if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=-1;
- if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=mp_dvdnav_sid_from_lang(mpctx->stream,dvdsub_lang);
+ if(opts->audio_id==-1) opts->audio_id=mp_dvdnav_aid_from_lang(mpctx->stream,audio_lang);
+ if(dvdsub_lang && opts->sub_id==-2) opts->sub_id=-1;
+ if(dvdsub_lang && opts->sub_id==-1) opts->sub_id=mp_dvdnav_sid_from_lang(mpctx->stream,dvdsub_lang);
// setup global sub numbering
mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub.
mpctx->global_sub_size += mp_dvdnav_number_of_subs(mpctx->stream);
@@ -3190,13 +3623,13 @@ if(stream_cache_size>0){
if(!stream_enable_cache(mpctx->stream,stream_cache_size*1024,
stream_cache_size*1024*(stream_cache_min_percent / 100.0),
stream_cache_size*1024*(stream_cache_seek_min_percent / 100.0)))
- if((mpctx->eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY))) goto goto_next_file;
+ if((mpctx->stop_play = libmpdemux_was_interrupted(mpctx, PT_NEXT_ENTRY))) goto goto_next_file;
}
//============ Open DEMUXERS --- DETECT file type =======================
current_module="demux_open";
-mpctx->demuxer=demux_open(mpctx->stream,mpctx->file_format,audio_id,video_id,dvdsub_id,filename);
+mpctx->demuxer=demux_open(opts, mpctx->stream,mpctx->file_format,opts->audio_id,opts->video_id,opts->sub_id,mpctx->filename);
// HACK to get MOV Reference Files working
@@ -3217,18 +3650,18 @@ if (mpctx->demuxer && mpctx->demuxer->type==DEMUXER_TYPE_PLAYLIST)
if ((strlen(bname)>10) && !strncmp(bname,"qt",2) && !strncmp(bname+3,"gateQT",6))
continue;
- if (!strncmp(bname,mp_basename(filename),strlen(bname))) // ignoring self-reference
+ if (!strncmp(bname,mp_basename(mpctx->filename),strlen(bname))) // ignoring self-reference
continue;
entry = play_tree_new();
- if (filename && !strcmp(mp_basename(playlist_entry),playlist_entry)) // add reference path of current file
+ if (mpctx->filename && !strcmp(mp_basename(playlist_entry),playlist_entry)) // add reference path of current file
{
- temp=malloc((strlen(filename)-strlen(mp_basename(filename))+strlen(playlist_entry)+1));
+ temp=malloc((strlen(mpctx->filename)-strlen(mp_basename(mpctx->filename))+strlen(playlist_entry)+1));
if (temp)
{
- strncpy(temp, filename, strlen(filename)-strlen(mp_basename(filename)));
- temp[strlen(filename)-strlen(mp_basename(filename))]='\0';
+ strncpy(temp, mpctx->filename, strlen(mpctx->filename)-strlen(mp_basename(mpctx->filename)));
+ temp[strlen(mpctx->filename)-strlen(mp_basename(mpctx->filename))]='\0';
strcat(temp, playlist_entry);
play_tree_add_file(entry,temp);
mp_msg(MSGT_CPLAYER,MSGL_V,"Resolving reference to %s.\n",temp);
@@ -3250,20 +3683,31 @@ if (mpctx->demuxer && mpctx->demuxer->type==DEMUXER_TYPE_PLAYLIST)
{
entry = play_tree_new();
play_tree_set_child(entry,list);
- mpctx->eof=playtree_add_playlist(entry);
+ mpctx->stop_play = playtree_add_playlist(mpctx, entry);
goto goto_next_file;
}
}
if(!mpctx->demuxer)
goto goto_next_file;
+
+ if (mpctx->demuxer->matroska_data.ordered_chapters)
+ build_ordered_chapter_timeline(mpctx);
+
+ if (!mpctx->sources) {
+ mpctx->sources = talloc_ptrtype(NULL, mpctx->sources);
+ *mpctx->sources = (struct content_source){.stream = mpctx->stream,
+ .demuxer = mpctx->demuxer};
+ mpctx->num_sources = 1;
+ }
+
if(dvd_chapter>1) {
- float pts;
- if (demuxer_seek_chapter(mpctx->demuxer, dvd_chapter-1, 1, &pts, NULL, NULL) >= 0 && pts > -1.0)
+ double pts;
+ if (seek_chapter(mpctx, dvd_chapter-1, &pts, NULL) >= 0 && pts > -1.0)
seek(mpctx, pts, SEEK_ABSOLUTE);
}
-initialized_flags|=INITIALIZED_DEMUXER;
+mpctx->initialized_flags|=INITIALIZED_DEMUXER;
if (mpctx->stream->type != STREAMTYPE_DVD && mpctx->stream->type != STREAMTYPE_DVDNAV) {
int i;
@@ -3272,23 +3716,26 @@ if (mpctx->stream->type != STREAMTYPE_DVD && mpctx->stream->type != STREAMTYPE_D
mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub.
for (i = 0; i < MAX_S_STREAMS; i++)
if (mpctx->demuxer->s_streams[i])
- maxid = FFMAX(maxid, ((sh_sub_t *)mpctx->demuxer->s_streams[i])->sid);
+ maxid = FFMAX(maxid, mpctx->demuxer->s_streams[i]->sid);
mpctx->global_sub_size += maxid + 1;
}
-// Make dvdsub_id always selectable if set.
-if (mpctx->global_sub_size <= mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id)
- mpctx->global_sub_size = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id + 1;
+// Make opts->sub_id always selectable if set.
+if (mpctx->global_sub_size <= mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id)
+ mpctx->global_sub_size = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id + 1;
#ifdef CONFIG_ASS
if (ass_enabled && ass_library) {
- for (i = 0; i < mpctx->demuxer->num_attachments; ++i) {
- demux_attachment_t* att = mpctx->demuxer->attachments + i;
- if (extract_embedded_fonts &&
- att->name && att->type && att->data && att->data_size &&
- (strcmp(att->type, "application/x-truetype-font") == 0 ||
- strcmp(att->type, "application/x-font") == 0))
- ass_add_font(ass_library, att->name, att->data, att->data_size);
- }
+ for (int j = 0; j < mpctx->num_sources; j++) {
+ struct demuxer *d = mpctx->sources[j].demuxer;
+ for (int i = 0; i < d->num_attachments; i++) {
+ struct demux_attachment *att = d->attachments + i;
+ if (extract_embedded_fonts
+ && att->name && att->type && att->data && att->data_size
+ && (strcmp(att->type, "application/x-truetype-font") == 0
+ || strcmp(att->type, "application/x-font") == 0))
+ ass_add_font(ass_library, att->name, att->data, att->data_size);
+ }
+ }
}
#endif
@@ -3301,7 +3748,7 @@ mpctx->d_video=mpctx->demuxer->video;
mpctx->d_sub=mpctx->demuxer->sub;
// select audio stream
-select_audio(mpctx->demuxer, audio_id, audio_lang);
+select_audio(mpctx->demuxer, opts->audio_id, audio_lang);
// DUMP STREAMS:
if((stream_dump_type)&&(stream_dump_type<4)){
@@ -3315,8 +3762,8 @@ if((stream_dump_type)&&(stream_dump_type<4)){
case 3: ds=mpctx->d_sub;break;
}
if(!ds){
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_DumpSelectedStreamMissing);
- exit_player(EXIT_ERROR);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"dump: FATAL: Selected stream missing!\n");
+ exit_player(mpctx, EXIT_ERROR);
}
// disable other streams:
if(mpctx->d_audio && mpctx->d_audio!=ds) {ds_free_packs(mpctx->d_audio); mpctx->d_audio->id=-2; }
@@ -3325,8 +3772,8 @@ if((stream_dump_type)&&(stream_dump_type<4)){
// let's dump it!
f=fopen(stream_dump_name,"wb");
if(!f){
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CantOpenDumpfile);
- exit_player(EXIT_ERROR);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Cannot open dump file.\n");
+ exit_player(mpctx, EXIT_ERROR);
}
while(!ds->eof){
unsigned char* start;
@@ -3341,8 +3788,8 @@ if((stream_dump_type)&&(stream_dump_type<4)){
}
}
fclose(f);
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CoreDumped);
- exit_player_with_rc(EXIT_EOF, 0);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Core dumped ;)\n");
+ exit_player_with_rc(mpctx, EXIT_EOF, 0);
}
mpctx->sh_audio=mpctx->d_audio->sh;
@@ -3352,10 +3799,10 @@ if(mpctx->sh_video){
current_module="video_read_properties";
if(!video_read_properties(mpctx->sh_video)) {
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotReadVideoProperties);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Video: Cannot read properties.\n");
mpctx->sh_video=mpctx->d_video->sh=NULL;
} else {
- mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_FilefmtFourccSizeFpsFtime,
+ mp_tmsg(MSGT_CPLAYER,MSGL_V,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.3f ftime:=%6.4f\n",
mpctx->demuxer->file_format,mpctx->sh_video->format, mpctx->sh_video->disp_w,mpctx->sh_video->disp_h,
mpctx->sh_video->fps,mpctx->sh_video->frametime
);
@@ -3368,7 +3815,7 @@ if(mpctx->sh_video){
vo_fps = mpctx->sh_video->fps;
if(!mpctx->sh_video->fps && !force_fps){
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_FPSnotspecified);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"FPS not specified in the header or invalid, use the -fps option.\n");
mpctx->sh_video=mpctx->d_video->sh=NULL;
}
}
@@ -3376,7 +3823,7 @@ if(mpctx->sh_video){
}
if(!mpctx->sh_video && !mpctx->sh_audio){
- mp_msg(MSGT_CPLAYER,MSGL_FATAL, MSGTR_NoStreamFound);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL, "No stream found.\n");
#ifdef CONFIG_DVBIN
if(mpctx->stream->type == STREAMTYPE_DVB)
{
@@ -3387,11 +3834,13 @@ if(!mpctx->sh_video && !mpctx->sh_audio){
else
dir = DVB_CHANNEL_LOWER;
- if(dvb_step_channel(mpctx->stream, dir))
- mpctx->eof = mpctx->dvbin_reopen = 1;
+ if(dvb_step_channel(mpctx->stream, dir)) {
+ mpctx->stop_play = PT_NEXT_ENTRY;
+ mpctx->dvbin_reopen = 1;
+ }
}
#endif
- goto goto_next_file; // exit_player(MSGTR_Exit_error);
+ goto goto_next_file; // exit_player(_("Fatal error"));
}
/* display clip info */
@@ -3400,7 +3849,7 @@ demux_info_print(mpctx->demuxer);
//================== Read SUBTITLES (DVD & TEXT) ==========================
if(vo_spudec==NULL && mpctx->sh_video &&
(mpctx->stream->type==STREAMTYPE_DVD || mpctx->stream->type == STREAMTYPE_DVDNAV)){
- init_vo_spudec();
+ init_vo_spudec(mpctx);
}
if(mpctx->sh_video) {
@@ -3410,15 +3859,15 @@ if(mpctx->sh_video) {
current_module="read_subtitles_file";
if(sub_name){
for (i = 0; sub_name[i] != NULL; ++i)
- add_subtitles (sub_name[i], mpctx->sh_video->fps, 0);
+ add_subtitles(mpctx, sub_name[i], mpctx->sh_video->fps, 0);
}
if(sub_auto) { // auto load sub file ...
char *psub = get_path( "sub/" );
- char **tmp = sub_filenames((psub ? psub : ""), filename);
+ char **tmp = sub_filenames((psub ? psub : ""), mpctx->filename);
int i = 0;
free(psub); // release the buffer created by get_path() above
while (tmp[i]) {
- add_subtitles (tmp[i], mpctx->sh_video->fps, 1);
+ add_subtitles(mpctx, tmp[i], mpctx->sh_video->fps, 1);
free(tmp[i++]);
}
free(tmp);
@@ -3437,20 +3886,20 @@ if (mpctx->global_sub_size) {
if (vobsub_index_id >= 0) {
// if user asks for a vobsub id, use that first.
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_VOBSUB] + vobsub_index_id;
- } else if (dvdsub_id >= 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
+ } else if (opts->sub_id >= 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
// if user asks for a dvd sub id, use that next.
- mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id;
+ mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id;
} else if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] >= 0) {
// if there are text subs to use, use those. (autosubs come last here)
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_SUBS];
- } else if (dvdsub_id < 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
+ } else if (opts->sub_id < 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
// finally select subs by language and container hints
- if (dvdsub_id < 0 && dvdsub_lang)
- dvdsub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang);
- if (dvdsub_id < 0)
- dvdsub_id = demuxer_default_sub_track(mpctx->demuxer);
- if (dvdsub_id >= 0)
- mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id;
+ if (opts->sub_id < 0 && dvdsub_lang)
+ opts->sub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang);
+ if (opts->sub_id < 0)
+ opts->sub_id = demuxer_default_sub_track(mpctx->demuxer);
+ if (opts->sub_id >= 0)
+ mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id;
}
// rather than duplicate code, use the SUB_SELECT handler to init the right one.
mpctx->global_sub_pos--;
@@ -3467,7 +3916,7 @@ if (mpctx->global_sub_size) {
}
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_FILENAME=%s\n",
- filename_recode(filename));
+ filename_recode(mpctx->filename));
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_DEMUXER=%s\n", mpctx->demuxer->desc->name);
if (mpctx->sh_video) {
/* Assume FOURCC if all bytes >= 0x20 (' ') */
@@ -3502,14 +3951,14 @@ if (mpctx->global_sub_size) {
if(!mpctx->sh_video) goto main; // audio-only
-if(!reinit_video_chain()) {
+if(!reinit_video_chain(mpctx)) {
if(!mpctx->sh_video){
if(!mpctx->sh_audio) goto goto_next_file;
- goto main; // exit_player(MSGTR_Exit_error);
+ goto main; // exit_player(_("Fatal error"));
}
}
- if(vo_flags & 0x08 && vo_spudec)
+ if(mpctx->sh_video->output_flags & 0x08 && vo_spudec)
spudec_set_hw_spu(vo_spudec,mpctx->video_out);
#ifdef CONFIG_FREETYPE
@@ -3533,7 +3982,6 @@ if(verbose) term_osd = 0;
{
//int frame_corr_num=0; //
//float v_frame=0; // Video
-float time_frame=0; // Timer
//float num_frames=0; // number of frames played
int frame_time_remaining=0; // flag
@@ -3543,12 +3991,12 @@ mpctx->num_buffered_frames=0;
// Make sure old OSD does not stay around,
// e.g. with -fixed-vo and same-resolution files
clear_osd_msgs();
-update_osd_msg();
+update_osd_msg(mpctx);
//================ SETUP AUDIO ==========================
if(mpctx->sh_audio){
- reinit_audio_chain();
+ reinit_audio_chain(mpctx);
if (mpctx->sh_audio && mpctx->sh_audio->codec)
mp_msg(MSGT_IDENTIFY,MSGL_INFO, "ID_AUDIO_CODEC=%s\n", mpctx->sh_audio->codec->name);
}
@@ -3569,18 +4017,18 @@ if(mpctx->sh_audio){
}
if(!mpctx->sh_audio){
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Audio: no sound\n");
mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks.\n",mpctx->d_audio->packs);
ds_free_packs(mpctx->d_audio); // free buffered chunks
//mpctx->d_audio->id=-2; // do not read audio chunks
- //uninit_player(INITIALIZED_AO); // close device
+ //uninit_player(mpctx, INITIALIZED_AO); // close device
}
if(!mpctx->sh_video){
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Video_NoVideo);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Video: no video\n");
mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused video chunks.\n",mpctx->d_video->packs);
ds_free_packs(mpctx->d_video);
mpctx->d_video->id=-2;
- //if(!fixed_vo) uninit_player(INITIALIZED_VO);
+ //if(!fixed_vo) uninit_player(mpctx, INITIALIZED_VO);
}
if (!mpctx->sh_video && !mpctx->sh_audio)
@@ -3590,7 +4038,7 @@ if (!mpctx->sh_video && !mpctx->sh_audio)
if(force_fps && mpctx->sh_video){
vo_fps = mpctx->sh_video->fps=force_fps;
mpctx->sh_video->frametime=1.0f/mpctx->sh_video->fps;
- mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_FPSforced,mpctx->sh_video->fps,mpctx->sh_video->frametime);
+ mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"FPS forced to be %5.3f (ftime: %5.3f).\n",mpctx->sh_video->fps,mpctx->sh_video->frametime);
}
#ifdef CONFIG_GUI
@@ -3603,17 +4051,17 @@ if ( use_gui ) {
}
#endif
-mp_input_set_section(NULL);
+ mp_input_set_section(mpctx->input, NULL);
//TODO: add desired (stream-based) sections here
-if (mpctx->stream->type==STREAMTYPE_TV) mp_input_set_section("tv");
-if (mpctx->stream->type==STREAMTYPE_DVDNAV) mp_input_set_section("dvdnav");
+ if (mpctx->stream->type==STREAMTYPE_TV) mp_input_set_section(mpctx->input, "tv");
+ if (mpctx->stream->type==STREAMTYPE_DVDNAV) mp_input_set_section(mpctx->input, "dvdnav");
//==================== START PLAYING =======================
-if(mpctx->loop_times>1) mpctx->loop_times--; else
-if(mpctx->loop_times==1) mpctx->loop_times = -1;
+if(opts->loop_times>1) opts->loop_times--; else
+if(opts->loop_times==1) opts->loop_times = -1;
-mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_StartPlaying);
+mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Starting playback...\n");
total_time_usage_start=GetTimer();
audio_time_usage=0; video_time_usage=0; vout_time_usage=0;
@@ -3621,7 +4069,7 @@ total_frame_cnt=0; drop_frame_cnt=0; // fix for multifile fps benchmark
play_n_frames=play_n_frames_mf;
if(play_n_frames==0){
- mpctx->eof=PT_NEXT_ENTRY; goto goto_next_file;
+ mpctx->stop_play=PT_NEXT_ENTRY; goto goto_next_file;
}
if (seek_to_sec) {
@@ -3630,7 +4078,7 @@ if (seek_to_sec) {
}
if (end_at.type == END_AT_SIZE) {
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_MPEndposNoSizeBased);
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Option -endpos in MPlayer does not yet support size units.\n");
end_at.type = END_AT_NONE;
}
@@ -3642,11 +4090,21 @@ if (mpctx->stream->type == STREAMTYPE_DVDNAV) {
}
#endif
-while(!mpctx->eof){
+ get_relative_time(mpctx); // reset current delta
+ mpctx->time_frame = 0;
+ mpctx->drop_message_shown = 0;
+ mpctx->update_video_immediately = true;
+ mpctx->total_avsync_change = 0;
+ // Make sure VO knows current pause state
+ if (mpctx->sh_video)
+ vo_control(mpctx->video_out, mpctx->paused ? VOCTRL_PAUSE : VOCTRL_RESUME,
+ NULL);
+
+while(!mpctx->stop_play){
float aq_sleep_time=0;
if(dvd_last_chapter>0) {
- int cur_chapter = demuxer_get_current_chapter(mpctx->demuxer);
+ int cur_chapter = get_current_chapter(mpctx);
if(cur_chapter!=-1 && cur_chapter+1>dvd_last_chapter)
goto goto_next_file;
}
@@ -3654,16 +4112,16 @@ if(dvd_last_chapter>0) {
if(!mpctx->sh_audio && mpctx->d_audio->sh) {
mpctx->sh_audio = mpctx->d_audio->sh;
mpctx->sh_audio->ds = mpctx->d_audio;
- reinit_audio_chain();
+ reinit_audio_chain(mpctx);
}
/*========================== PLAY AUDIO ============================*/
-if (mpctx->sh_audio)
- if (!fill_audio_out_buffers())
+if (mpctx->sh_audio && !mpctx->paused)
+ if (!fill_audio_out_buffers(mpctx))
// at eof, all audio at least written to ao
if (!mpctx->sh_video)
- mpctx->eof = PT_NEXT_ENTRY;
+ mpctx->stop_play = AT_END_OF_FILE;
if(!mpctx->sh_video) {
@@ -3671,15 +4129,14 @@ if(!mpctx->sh_video) {
double a_pos=0;
// sh_audio can be NULL due to video stream switching
// TODO: handle this better
- if((!quiet || end_at.type == END_AT_TIME) && mpctx->sh_audio)
- a_pos = playing_audio_pts(mpctx->sh_audio, mpctx->d_audio, mpctx->audio_out);
+ if (mpctx->sh_audio)
+ a_pos = playing_audio_pts(mpctx);
- if(!quiet)
- print_status(a_pos, 0, 0);
+ print_status(mpctx, a_pos, false);
if(end_at.type == END_AT_TIME && end_at.pos < a_pos)
- mpctx->eof = PT_NEXT_ENTRY;
- update_osd_msg();
+ mpctx->stop_play = PT_NEXT_ENTRY;
+ update_osd_msg(mpctx);
} else {
@@ -3689,18 +4146,40 @@ if(!mpctx->sh_video) {
vo_fps=mpctx->sh_video->fps;
if (!mpctx->num_buffered_frames) {
- double frame_time = update_video(&blit_frame);
+ double frame_time = update_video(mpctx, &blit_frame);
mp_dbg(MSGT_AVSYNC,MSGL_DBG2,"*** ftime=%5.3f ***\n",frame_time);
if (mpctx->sh_video->vf_initialized < 0) {
- mp_msg(MSGT_CPLAYER,MSGL_FATAL, MSGTR_NotInitializeVOPorVO);
- mpctx->eof = 1; goto goto_next_file;
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL, "\nFATAL: Could not initialize video filters (-vf) or video output (-vo).\n");
+ mpctx->stop_play = PT_NEXT_ENTRY;
+ goto goto_next_file;
+ }
+ if (blit_frame) {
+ struct vf_instance *vf = mpctx->sh_video->vfilter;
+ vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
+ vf->control(vf, VFCTRL_DRAW_OSD, mpctx->osd);
+ vo_osd_changed(0);
}
if (frame_time < 0)
- mpctx->eof = 1;
+ mpctx->stop_play = AT_END_OF_FILE;
else {
// might return with !eof && !blit_frame if !correct_pts
mpctx->num_buffered_frames += blit_frame;
- time_frame += frame_time / playback_speed; // for nosound
+ if (mpctx->update_video_immediately) {
+ // Show this frame immediately, rest normally
+ mpctx->update_video_immediately = false;
+ } else {
+ mpctx->time_frame += frame_time / opts->playback_speed;
+ adjust_sync(mpctx, frame_time);
+ }
+ }
+ }
+ if (mpctx->timeline) {
+ struct timeline_part *next = mpctx->timeline + mpctx->timeline_part + 1;
+ if (mpctx->sh_video->pts >= next->start
+ || mpctx->stop_play == AT_END_OF_FILE
+ && mpctx->timeline_part + 1 < mpctx->num_timeline_parts) {
+ seek(mpctx, next->start, SEEK_ABSOLUTE);
+ continue;
}
}
@@ -3714,12 +4193,12 @@ if(!mpctx->sh_video) {
#endif
current_module="vo_check_events";
- if (vo_config_count) mpctx->video_out->check_events();
+ vo_check_events(mpctx->video_out);
#ifdef CONFIG_X11
if (stop_xscreensaver) {
current_module = "stop_xscreensaver";
- xscreensaver_heartbeat();
+ xscreensaver_heartbeat(mpctx->x11_state);
}
#endif
if (heartbeat_cmd) {
@@ -3731,7 +4210,7 @@ if(!mpctx->sh_video) {
}
}
- frame_time_remaining = sleep_until_update(&time_frame, &aq_sleep_time);
+ frame_time_remaining = sleep_until_update(mpctx, &mpctx->time_frame, &aq_sleep_time);
//====================== FLIP PAGE (VIDEO BLT): =========================
@@ -3739,14 +4218,15 @@ if(!mpctx->sh_video) {
if (!frame_time_remaining && blit_frame) {
unsigned int t2=GetTimer();
- if(vo_config_count) mpctx->video_out->flip_page();
+ vo_flip_page(mpctx->video_out);
mpctx->num_buffered_frames--;
- vout_time_usage += (GetTimer() - t2) * 0.000001;
+ mpctx->last_vo_flip_duration = (GetTimer() - t2) * 0.000001;
+ vout_time_usage += mpctx->last_vo_flip_duration;
+ print_status(mpctx, MP_NOPTS_VALUE, true);
}
-//====================== A-V TIMESTAMP CORRECTION: =========================
-
- adjust_sync_and_print_status(frame_time_remaining, time_frame);
+ else
+ print_status(mpctx, MP_NOPTS_VALUE, false);
//============================ Auto QUALITY ============================
@@ -3768,16 +4248,24 @@ if(auto_quality>0){
set_video_quality(mpctx->sh_video,output_quality);
}
- if (play_n_frames >= 0 && !frame_time_remaining && blit_frame) {
- --play_n_frames;
- if (play_n_frames <= 0) mpctx->eof = PT_NEXT_ENTRY;
+ if (!frame_time_remaining && blit_frame) {
+ if (play_n_frames >= 0) {
+ --play_n_frames;
+ if (play_n_frames <= 0)
+ mpctx->stop_play = PT_NEXT_ENTRY;
+ }
+ if (mpctx->step_frames > 0) {
+ mpctx->step_frames--;
+ if (mpctx->step_frames == 0)
+ pause_player(mpctx);
+ }
}
// FIXME: add size based support for -endpos
if (end_at.type == END_AT_TIME &&
!frame_time_remaining && end_at.pos <= mpctx->sh_video->pts)
- mpctx->eof = PT_NEXT_ENTRY;
+ mpctx->stop_play = PT_NEXT_ENTRY;
} // end if(mpctx->sh_video)
@@ -3798,64 +4286,62 @@ if(auto_quality>0){
}
#endif
-//============================ Handle PAUSE ===============================
-
- current_module="pause";
-
- if (mpctx->osd_function == OSD_PAUSE) {
- mpctx->was_paused = 1;
- pause_loop();
- }
-
-// handle -sstep
-if(step_sec>0) {
- mpctx->osd_function=OSD_FFW;
- rel_seek_secs+=step_sec;
-}
-
- edl_update(mpctx);
-
//================= Keyboard events, SEEKing ====================
current_module="key_events";
{
+ while (1) {
mp_cmd_t* cmd;
- int brk_cmd = 0;
- while( !brk_cmd && (cmd = mp_input_get_cmd(0,0,0)) != NULL) {
- brk_cmd = run_command(mpctx, cmd);
+ while ((cmd = mp_input_get_cmd(mpctx->input, 0,0,0)) != NULL) {
+ run_command(mpctx, cmd);
mp_cmd_free(cmd);
- if (brk_cmd == 2)
- goto goto_enable_cache;
+ if (mpctx->stop_play)
+ break;
}
+ if (!mpctx->paused || mpctx->stop_play || mpctx->rel_seek_secs
+ || mpctx->abs_seek_pos)
+ break;
+ if (mpctx->sh_video) {
+ update_osd_msg(mpctx);
+ int hack = vo_osd_changed(0);
+ vo_osd_changed(hack);
+ if (hack)
+ if (redraw_osd(mpctx->sh_video, mpctx->osd) < 0) {
+ add_step_frame(mpctx);
+ break;
+ }
+ else
+ vo_osd_changed(0);
+ }
+ pause_loop(mpctx);
+ }
+}
+
+// handle -sstep
+if (step_sec > 0 && !mpctx->paused) {
+ mpctx->osd_function=OSD_FFW;
+ mpctx->rel_seek_secs+=step_sec;
}
- mpctx->was_paused = 0;
+
+ edl_update(mpctx);
/* Looping. */
- if(mpctx->eof==1 && mpctx->loop_times>=0) {
- mp_msg(MSGT_CPLAYER,MSGL_V,"loop_times = %d, eof = %d\n", mpctx->loop_times,mpctx->eof);
+ if(mpctx->stop_play==AT_END_OF_FILE && opts->loop_times>=0) {
+ mp_msg(MSGT_CPLAYER,MSGL_V,"loop_times = %d\n", opts->loop_times);
- if(mpctx->loop_times>1) mpctx->loop_times--; else
- if(mpctx->loop_times==1) mpctx->loop_times=-1;
+ if(opts->loop_times>1) opts->loop_times--; else
+ if(opts->loop_times==1) opts->loop_times=-1;
play_n_frames=play_n_frames_mf;
- mpctx->eof=0;
- abs_seek_pos=SEEK_ABSOLUTE; rel_seek_secs=seek_to_sec;
- loop_seek = 1;
+ mpctx->stop_play=0;
+ mpctx->abs_seek_pos=SEEK_ABSOLUTE; mpctx->rel_seek_secs=seek_to_sec;
}
-if(rel_seek_secs || abs_seek_pos){
- if (seek(mpctx, rel_seek_secs, abs_seek_pos) >= 0) {
- // Set OSD:
- if(!loop_seek){
- if( !edl_decision )
- set_osd_bar(0,"Position",0,100,demuxer_get_percent_pos(mpctx->demuxer));
- }
- }
+if(mpctx->rel_seek_secs || mpctx->abs_seek_pos){
+ seek(mpctx, mpctx->rel_seek_secs, mpctx->abs_seek_pos);
- rel_seek_secs=0;
- abs_seek_pos=0;
- loop_seek=0;
- edl_decision = 0;
+ mpctx->rel_seek_secs=0;
+ mpctx->abs_seek_pos=0;
}
#ifdef CONFIG_GUI
@@ -3868,7 +4354,7 @@ if(rel_seek_secs || abs_seek_pos){
guiIntfStruct.Position=demuxer_get_percent_pos(mpctx->demuxer);
}
if ( mpctx->sh_video ) guiIntfStruct.TimeSec=mpctx->sh_video->pts;
- else if ( mpctx->sh_audio ) guiIntfStruct.TimeSec=playing_audio_pts(mpctx->sh_audio, mpctx->d_audio, mpctx->audio_out);
+ else if ( mpctx->sh_audio ) guiIntfStruct.TimeSec=playing_audio_pts(mpctx);
guiIntfStruct.LengthInSec=demuxer_get_time_length(mpctx->demuxer);
guiGetEvent( guiReDraw,NULL );
guiGetEvent( guiSetVolume,NULL );
@@ -3885,15 +4371,15 @@ if(rel_seek_secs || abs_seek_pos){
}
#endif /* CONFIG_GUI */
-} // while(!mpctx->eof)
+} // while(!mpctx->stop_play)
-mp_msg(MSGT_GLOBAL,MSGL_V,"EOF code: %d \n",mpctx->eof);
+mp_msg(MSGT_GLOBAL,MSGL_V,"EOF code: %d \n",mpctx->stop_play);
#ifdef CONFIG_DVBIN
if(mpctx->dvbin_reopen)
{
- mpctx->eof = 0;
- uninit_player(INITIALIZED_ALL-(INITIALIZED_GUI|INITIALIZED_STREAM|INITIALIZED_INPUT|INITIALIZED_GETCH2|(fixed_vo?INITIALIZED_VO:0)));
+ mpctx->stop_play = 0;
+ uninit_player(mpctx, INITIALIZED_ALL-(INITIALIZED_GUI|INITIALIZED_STREAM|INITIALIZED_GETCH2|(opts->fixed_vo?INITIALIZED_VO:0)));
cache_uninit(mpctx->stream);
mpctx->dvbin_reopen = 0;
goto goto_enable_cache;
@@ -3931,7 +4417,7 @@ if(benchmark){
}
// time to uninit all, except global stuff:
-uninit_player(INITIALIZED_ALL-(INITIALIZED_GUI+INITIALIZED_INPUT+(fixed_vo?INITIALIZED_VO:0)));
+uninit_player(mpctx, INITIALIZED_ALL-(INITIALIZED_GUI+(opts->fixed_vo?INITIALIZED_VO:0)));
if(mpctx->set_of_sub_size > 0) {
current_module="sub_free";
@@ -3952,38 +4438,36 @@ if(ass_library)
ass_clear_fonts(ass_library);
#endif
-if(mpctx->eof == PT_NEXT_ENTRY || mpctx->eof == PT_PREV_ENTRY) {
- mpctx->eof = mpctx->eof == PT_NEXT_ENTRY ? 1 : -1;
- if(play_tree_iter_step(mpctx->playtree_iter,mpctx->play_tree_step,0) == PLAY_TREE_ITER_ENTRY) {
- mpctx->eof = 1;
- } else {
+ if (!mpctx->stop_play) // In case some goto jumped here...
+ mpctx->stop_play = PT_NEXT_ENTRY;
+
+int playtree_direction = 1;
+
+if(mpctx->stop_play == PT_NEXT_ENTRY || mpctx->stop_play == PT_PREV_ENTRY) {
+ if(play_tree_iter_step(mpctx->playtree_iter,mpctx->play_tree_step,0) != PLAY_TREE_ITER_ENTRY) {
play_tree_iter_free(mpctx->playtree_iter);
mpctx->playtree_iter = NULL;
}
mpctx->play_tree_step = 1;
-} else if(mpctx->eof == PT_UP_NEXT || mpctx->eof == PT_UP_PREV) {
- mpctx->eof = mpctx->eof == PT_UP_NEXT ? 1 : -1;
+} else if(mpctx->stop_play == PT_UP_NEXT || mpctx->stop_play == PT_UP_PREV) {
+ int direction = mpctx->stop_play == PT_UP_NEXT ? 1 : -1;
if(mpctx->playtree_iter) {
- if(play_tree_iter_up_step(mpctx->playtree_iter,mpctx->eof,0) == PLAY_TREE_ITER_ENTRY) {
- mpctx->eof = 1;
- } else {
+ if(play_tree_iter_up_step(mpctx->playtree_iter,direction,0) != PLAY_TREE_ITER_ENTRY) {
play_tree_iter_free(mpctx->playtree_iter);
mpctx->playtree_iter = NULL;
}
}
-} else if (mpctx->eof == PT_STOP) {
+} else if (mpctx->stop_play == PT_STOP) {
play_tree_iter_free(mpctx->playtree_iter);
mpctx->playtree_iter = NULL;
} else { // NEXT PREV SRC
- mpctx->eof = mpctx->eof == PT_PREV_SRC ? -1 : 1;
+ playtree_direction = mpctx->stop_play == PT_PREV_SRC ? -1 : 1;
}
-if(mpctx->eof == 0) mpctx->eof = 1;
-
while(mpctx->playtree_iter != NULL) {
- filename = play_tree_iter_get_file(mpctx->playtree_iter,mpctx->eof);
- if(filename == NULL) {
- if(play_tree_iter_step(mpctx->playtree_iter,mpctx->eof,0) != PLAY_TREE_ITER_ENTRY) {
+ mpctx->filename = play_tree_iter_get_file(mpctx->playtree_iter, playtree_direction);
+ if(mpctx->filename == NULL) {
+ if(play_tree_iter_step(mpctx->playtree_iter, playtree_direction, 0) != PLAY_TREE_ITER_ENTRY) {
play_tree_iter_free(mpctx->playtree_iter);
mpctx->playtree_iter = NULL;
};
@@ -4001,13 +4485,13 @@ if(use_gui && !mpctx->playtree_iter) {
#endif
if(use_gui || mpctx->playtree_iter != NULL || player_idle_mode){
- if(!mpctx->playtree_iter) filename = NULL;
- mpctx->eof = 0;
+ if(!mpctx->playtree_iter) mpctx->filename = NULL;
+ mpctx->stop_play = 0;
goto play_next_file;
}
-exit_player_with_rc(EXIT_EOF, 0);
+exit_player_with_rc(mpctx, EXIT_EOF, 0);
return 1;
}
diff --git a/mplayer.h b/mplayer.h
index bae7f3ea16..5ca10cec6b 100644
--- a/mplayer.h
+++ b/mplayer.h
@@ -2,6 +2,8 @@
#ifndef MPLAYER_MPLAYER_H
#define MPLAYER_MPLAYER_H
+#include "mp_msg.h"
+
extern char* current_module;
extern char * dvd_device;
@@ -15,13 +17,11 @@ extern char * video_driver;
extern char * audio_driver;
extern float audio_delay;
-extern int osd_level;
extern unsigned int osd_visible;
extern char * font_name;
extern char * sub_font_name;
extern float font_factor;
-extern float movie_aspect;
extern double force_fps;
//extern char **sub_name;
@@ -29,25 +29,24 @@ extern float sub_delay;
extern float sub_fps;
extern int sub_auto;
-extern char * filename;
-
extern int stream_cache_size;
extern int autosync;
-// libmpcodecs:
-extern int fullscreen;
-extern int flip;
-
extern int frame_dropping;
extern int auto_quality;
-extern int audio_id;
-extern int video_id;
-extern int dvdsub_id;
extern int vobsub_id;
-void exit_player(const char* how);
-void update_set_of_subtitles(void);
+static inline void exit_player_bad(const char *how)
+{
+ if (how)
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "Deprecated exit call: %s", how);
+ exit(1);
+}
+
+struct MPContext;
+
+void update_set_of_subtitles(struct MPContext *mpctx);
#endif /* MPLAYER_MPLAYER_H */
diff --git a/options.h b/options.h
new file mode 100644
index 0000000000..08a150bbdd
--- /dev/null
+++ b/options.h
@@ -0,0 +1,81 @@
+#ifndef MPLAYER_OPTIONS_H
+#define MPLAYER_OPTIONS_H
+
+typedef struct MPOpts {
+ char **video_driver_list;
+ char **audio_driver_list;
+ int fixed_vo;
+ int vo_ontop;
+ int screen_size_x;
+ int screen_size_y;
+ int vo_screenwidth;
+ int vo_screenheight;
+ int force_window_position;
+ float force_monitor_aspect;
+ float monitor_pixel_aspect;
+ int vidmode;
+ int fullscreen;
+ int vo_dbpp;
+ float vo_panscanrange;
+
+ // ranges -100 - 100, 1000 if the vo default should be used
+ int vo_gamma_gamma;
+ int vo_gamma_brightness;
+ int vo_gamma_contrast;
+ int vo_gamma_saturation;
+ int vo_gamma_hue;
+
+ int osd_level;
+ int osd_duration;
+ int loop_times;
+ int ordered_chapters;
+ int correct_pts;
+ int user_correct_pts;
+ int key_fifo_size;
+ int doubleclick_time;
+ int audio_id;
+ int video_id;
+ int sub_id;
+ float playback_speed;
+ struct m_obj_settings *vf_settings;
+ int softzoom;
+ float movie_aspect;
+ float screen_size_xy;
+ int flip;
+ int vd_use_slices;
+ struct lavc_param {
+ int workaround_bugs;
+ int error_resilience;
+ int error_concealment;
+ int gray;
+ int vstats;
+ int idct_algo;
+ int debug;
+ int vismv;
+ int skip_top;
+ int skip_bottom;
+ int fast;
+ char *lowres_str;
+ char *skip_loop_filter_str;
+ char *skip_idct_str;
+ char *skip_frame_str;
+ int threads;
+ int bitexact;
+ char *avopt;
+ } lavc_param;
+ struct input_conf {
+ char *config_file;
+ unsigned int ar_delay;
+ unsigned int ar_rate;
+ char *js_dev;
+ char *ar_dev;
+ char *in_file;
+ int use_joystick;
+ int use_lirc;
+ int use_lircc;
+ int use_ar; // apple remote
+ int default_bindings;
+ } input;
+} MPOpts;
+
+#endif
diff --git a/osdep/findfiles.c b/osdep/findfiles.c
new file mode 100644
index 0000000000..879f6d5c98
--- /dev/null
+++ b/osdep/findfiles.c
@@ -0,0 +1,97 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <dirent.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "talloc.h"
+
+#if defined(__MINGW32__) || defined(__CYGWIN__)
+static const char dir_separators[] = "/\\:";
+#else
+static const char dir_separators[] = "/";
+#endif
+
+char **find_files(const char *original_file, const char *suffix,
+ int *num_results_ptr)
+{
+ void *tmpmem = talloc_new(NULL);
+ char *fname = talloc_strdup(tmpmem, original_file);
+ char *basename = NULL;
+ char *next = fname;
+ while (1) {
+ next = strpbrk(next, dir_separators);
+ if (!next)
+ break;
+ basename = next++;
+ }
+ char *directory;
+ if (basename) {
+ directory = fname;
+ *basename++ = 0;
+ } else {
+ directory = ".";
+ basename = fname;
+ }
+
+
+ char **results = talloc_size(NULL, 0);
+ DIR *dp = opendir(directory);
+ struct dirent *ep;
+ char ***names_by_matchlen = talloc_array(tmpmem, char **,
+ strlen(basename) + 1);
+ memset(names_by_matchlen, 0, talloc_get_size(names_by_matchlen));
+ int num_results = 0;
+ while ((ep = readdir(dp))) {
+ int suffix_offset = strlen(ep->d_name) - strlen(suffix);
+ // name must end with suffix
+ if (suffix_offset < 0 || strcmp(ep->d_name + suffix_offset, suffix))
+ continue;
+ // don't list the original name
+ if (!strcmp(ep->d_name, basename))
+ continue;
+
+ char *name = talloc_asprintf(results, "%s/%s", directory, ep->d_name);
+ char *s1 = ep->d_name;
+ char *s2 = basename;
+ int matchlen = 0;
+ while (*s1 && *s1++ == *s2++)
+ matchlen++;
+ int oldcount = talloc_get_size(names_by_matchlen[matchlen]) /
+ sizeof(char **);
+ names_by_matchlen[matchlen] = talloc_realloc(names_by_matchlen,
+ names_by_matchlen[matchlen],
+ char *, oldcount + 1);
+ names_by_matchlen[matchlen][oldcount] = name;
+ num_results++;
+ }
+ closedir(dp);
+ results = talloc_realloc(NULL, results, char *, num_results);
+ char **resptr = results;
+ for (int i = strlen(basename); i >= 0; i--) {
+ char **p = names_by_matchlen[i];
+ for (int j = 0; j < talloc_get_size(p) / sizeof(char *); j++)
+ *resptr++ = p[j];
+ }
+ assert(resptr == results + num_results);
+ talloc_free(tmpmem);
+ *num_results_ptr = num_results;
+ return results;
+}
diff --git a/osdep/findfiles.h b/osdep/findfiles.h
new file mode 100644
index 0000000000..97443e7319
--- /dev/null
+++ b/osdep/findfiles.h
@@ -0,0 +1,2 @@
+char **find_files(const char *original_file, const char *suffix,
+ int *num_results_ptr);
diff --git a/osdep/getch2-os2.c b/osdep/getch2-os2.c
index 272d2d45e9..27ebfaa354 100644
--- a/osdep/getch2-os2.c
+++ b/osdep/getch2-os2.c
@@ -32,6 +32,7 @@
#include "keycodes.h"
#include "input/input.h"
#include "mp_fifo.h"
+#include "getch2.h"
#if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV)
#include <locale.h>
@@ -164,13 +165,13 @@ static int getch2_internal( void )
return -1;
}
-void getch2( void )
+void getch2(struct mp_fifo *fifo)
{
int key;
key = getch2_internal();
if( key != -1 )
- mplayer_put_key( key );
+ mplayer_put_key(fifo, key);
}
void getch2_enable( void )
@@ -197,4 +198,3 @@ char *get_term_charset( void )
return charset;
}
#endif
-
diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c
index 3c428834ff..9dae9cd91d 100644
--- a/osdep/getch2-win.c
+++ b/osdep/getch2-win.c
@@ -30,6 +30,8 @@
#include "keycodes.h"
#include "input/input.h"
#include "mp_fifo.h"
+#include "getch2.h"
+
// HACK, stdin is used as something else below
#undef stdin
@@ -139,11 +141,11 @@ static int getch2_internal(void)
return -1;
}
-void getch2(void)
+void getch2(struct mp_fifo *fifo)
{
int r = getch2_internal();
if (r >= 0)
- mplayer_put_key(r);
+ mplayer_put_key(fifo, r);
}
void getch2_enable(void)
diff --git a/osdep/getch2.c b/osdep/getch2.c
index 4a591da2db..4aa09323eb 100644
--- a/osdep/getch2.c
+++ b/osdep/getch2.c
@@ -58,6 +58,7 @@
#include "mp_fifo.h"
#include "keycodes.h"
+#include "getch2.h"
#ifdef HAVE_TERMIOS
static struct termios tio_orig;
@@ -116,7 +117,7 @@ int load_termcap(char *termtype){
screen_height=tgetnum("li");
if(screen_width<1 || screen_width>255) screen_width=80;
if(screen_height<1 || screen_height>255) screen_height=24;
- erase_to_end_of_line= tgetstr("cd",&term_p);
+ erase_to_end_of_line= tgetstr("ce",&term_p);
termcap_add("kP",KEY_PGUP);
termcap_add("kN",KEY_PGDWN);
@@ -155,7 +156,7 @@ void get_screen_size(void){
#endif
}
-void getch2(void)
+void getch2(struct mp_fifo *fifo)
{
int retval = read(0, &getch2_buf[getch2_len], BUF_LEN-getch2_len);
if (retval < 1)
@@ -264,7 +265,7 @@ void getch2(void)
getch2_len -= len;
for (i = 0; i < getch2_len; i++)
getch2_buf[i] = getch2_buf[len+i];
- mplayer_put_key(code);
+ mplayer_put_key(fifo, code);
}
}
@@ -303,4 +304,3 @@ char* get_term_charset(void)
return charset;
}
#endif
-
diff --git a/osdep/getch2.h b/osdep/getch2.h
index f6f416b2a7..1156aedf7a 100644
--- a/osdep/getch2.h
+++ b/osdep/getch2.h
@@ -42,7 +42,8 @@ void getch2_enable(void);
void getch2_disable(void);
/* Read a character or a special key code (see keycodes.h) */
-void getch2(void);
+struct mp_fifo;
+void getch2(struct mp_fifo *fifo);
/* slave cmd function for Windows and OS/2 */
int mp_input_slave_cmd_func(int fd,char* dest,int size);
diff --git a/osdep/mmap_anon.c b/osdep/mmap_anon.c
index 727761cb6c..d5b3a3dd2f 100644
--- a/osdep/mmap_anon.c
+++ b/osdep/mmap_anon.c
@@ -27,6 +27,8 @@
#include <fcntl.h>
#include <sys/mman.h>
+#include "mmap_anon.h"
+
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
diff --git a/osdep/mplayer.rc b/osdep/mplayer.rc
index 0df832f830..7432b45231 100644
--- a/osdep/mplayer.rc
+++ b/osdep/mplayer.rc
@@ -51,4 +51,3 @@ FILETYPE VFT_APP
}
IDI_ICON1 ICON DISCARDABLE "etc/mplayer.ico"
-
diff --git a/osdep/priority.c b/osdep/priority.c
index 7a75153fa0..7a21868ddf 100644
--- a/osdep/priority.c
+++ b/osdep/priority.c
@@ -73,7 +73,7 @@ void set_priority(void)
if (strcasecmp(priority_presets_defs[i].name, proc_priority) == 0)
break;
}
- mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_SettingProcessPriority,
+ mp_tmsg(MSGT_CPLAYER, MSGL_STATUS, "Setting process priority: %s\n",
priority_presets_defs[i].name);
#ifdef __OS2__
@@ -86,4 +86,3 @@ void set_priority(void)
#endif
}
}
-
diff --git a/osdep/priority.h b/osdep/priority.h
index cb4bc56c3f..1a74f95665 100644
--- a/osdep/priority.h
+++ b/osdep/priority.h
@@ -28,4 +28,3 @@ extern char *proc_priority;
void set_priority(void);
#endif /* MPLAYER_PRIORITY_H */
-
diff --git a/osdep/shmem.c b/osdep/shmem.c
index 9788d02bc5..f1cec1be37 100644
--- a/osdep/shmem.c
+++ b/osdep/shmem.c
@@ -50,6 +50,8 @@
#include <sys/shm.h>
#endif
+#include "shmem.h"
+
#if defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
#define MAP_ANON MAP_ANONYMOUS
#endif
diff --git a/osdep/timer-darwin.c b/osdep/timer-darwin.c
index c292852c27..e0b4622c00 100644
--- a/osdep/timer-darwin.c
+++ b/osdep/timer-darwin.c
@@ -27,10 +27,9 @@
#include "timer.h"
/* global variables */
-static double relative_time;
static double timebase_ratio;
-const char *timer_name = "Darwin accurate";
+const char timer_name[] = "Darwin accurate";
@@ -63,19 +62,6 @@ unsigned int GetTimerMS(void)
return (unsigned int)(uint64_t)(mach_absolute_time() * timebase_ratio * 1e3);
}
-/* time spent between now and last call in seconds */
-float GetRelativeTime(void)
-{
- double last_time = relative_time;
-
- if (!relative_time)
- InitTimer();
-
- relative_time = mach_absolute_time() * timebase_ratio;
-
- return (float)(relative_time-last_time);
-}
-
/* initialize timer, must be called at least once at start */
void InitTimer(void)
{
@@ -84,8 +70,6 @@ void InitTimer(void)
mach_timebase_info(&timebase);
timebase_ratio = (double)timebase.numer / (double)timebase.denom
* (double)1e-9;
-
- relative_time = (double)(mach_absolute_time() * timebase_ratio);
}
#if 0
diff --git a/osdep/timer-linux.c b/osdep/timer-linux.c
index 8c1af557a0..073ca84182 100644
--- a/osdep/timer-linux.c
+++ b/osdep/timer-linux.c
@@ -27,8 +27,9 @@
#include <time.h>
#include <sys/time.h>
#include "config.h"
+#include "timer.h"
-const char *timer_name =
+const char timer_name[] =
#ifdef HAVE_NANOSLEEP
"nanosleep()";
#else
@@ -50,52 +51,20 @@ int usec_sleep(int usec_delay)
// Returns current time in microseconds
unsigned int GetTimer(void)
{
- struct timeval tv;
- //float s;
- gettimeofday(&tv,NULL);
- //s = tv.tv_usec; s *= 0.000001; s += tv.tv_sec;
- return tv.tv_sec * 1000000 + tv.tv_usec;
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ return tv.tv_sec * 1000000 + tv.tv_usec;
}
// Returns current time in milliseconds
unsigned int GetTimerMS(void)
{
- struct timeval tv;
- //float s;
- gettimeofday(&tv,NULL);
- //s = tv.tv_usec; s *= 0.000001; s += tv.tv_sec;
- return tv.tv_sec * 1000 + tv.tv_usec / 1000;
-}
-
-static unsigned int RelativeTime = 0;
-
-// Returns time spent between now and last call in seconds
-float GetRelativeTime(void)
-{
- unsigned int t,r;
- t = GetTimer();
- //t *= 16; printf("time = %ud\n", t);
- r = t - RelativeTime;
- RelativeTime = t;
- return (float) r * 0.000001F;
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
// Initialize timer, must be called at least once at start
void InitTimer(void)
{
- GetRelativeTime();
}
-
-
-#if 0
-#include <stdio.h>
-int main(void)
-{
- float t = 0;
- InitTimer();
- while (1) {
- t += GetRelativeTime();
- printf("time = %10.6f\r", t);
- fflush(stdout); }
-}
-#endif
diff --git a/osdep/timer-win2.c b/osdep/timer-win2.c
index 100a3b6868..ac8eaa1bd6 100644
--- a/osdep/timer-win2.c
+++ b/osdep/timer-win2.c
@@ -22,7 +22,7 @@
#include <mmsystem.h>
#include "timer.h"
-const char *timer_name = "Windows native";
+const char timer_name[] = "Windows native";
// Returns current time in microseconds
unsigned int GetTimer(void)
@@ -45,18 +45,6 @@ int usec_sleep(int usec_delay){
return 0;
}
-static DWORD RelativeTime = 0;
-
-float GetRelativeTime(void)
-{
- DWORD t, r;
- t = GetTimer();
- r = t - RelativeTime;
- RelativeTime = t;
- return (float) r *0.000001F;
-}
-
void InitTimer(void)
{
- GetRelativeTime();
}
diff --git a/osdep/timer.h b/osdep/timer.h
index 2e4f2fc8fe..c3925041ca 100644
--- a/osdep/timer.h
+++ b/osdep/timer.h
@@ -19,19 +19,12 @@
#ifndef MPLAYER_TIMER_H
#define MPLAYER_TIMER_H
-extern const char *timer_name;
+extern const char timer_name[];
void InitTimer(void);
unsigned int GetTimer(void);
unsigned int GetTimerMS(void);
-//int uGetTimer(void);
-float GetRelativeTime(void);
int usec_sleep(int usec_delay);
-/* timer's callback handling */
-typedef void timer_callback( void );
-unsigned set_timer_callback(unsigned ms,timer_callback func);
-void restore_timer(void);
-
#endif /* MPLAYER_TIMER_H */
diff --git a/parser-mecmd.c b/parser-mecmd.c
index 172ead5937..0576860365 100644
--- a/parser-mecmd.c
+++ b/parser-mecmd.c
@@ -78,7 +78,7 @@ m_config_parse_me_command_line(m_config_t *config, int argc, char **argv)
no_more_opts = 1;
if (i+1 >= argc)
{
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NoFileGivenOnCommandLine);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "'--' indicates no more options, but no filename was given on the command line.\n");
goto err_out;
}
continue;
@@ -93,7 +93,7 @@ m_config_parse_me_command_line(m_config_t *config, int argc, char **argv)
mp_opt = m_config_get_option(config,opt);
if(!mp_opt) {
tmp = M_OPT_UNKNOWN;
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NotAnMEncoderOption, opt);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "-%s is not an MEncoder option\n", opt);
goto err_out;
}
if(!entry || (mp_opt->flags & M_OPT_GLOBAL)){
@@ -105,7 +105,7 @@ m_config_parse_me_command_line(m_config_t *config, int argc, char **argv)
else
if(tmp < 0){
// mp_msg(MSGT_CFGPARSER, MSGL_ERR, "m_config_set_option() failed (%d)\n",tmp);
- mp_msg(MSGT_CFGPARSER, MSGL_FATAL, MSGTR_ErrorParsingOptionOnCommandLine, opt);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_FATAL, "Error parsing option on the command line: -%s\n", opt);
goto err_out;
}
} else {
@@ -142,7 +142,7 @@ m_config_parse_me_command_line(m_config_t *config, int argc, char **argv)
exit(0);
if(nf == 0) {
m_entry_list_free(lst);
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NoFileGiven);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "No file given\n");
return NULL;
}
return lst;
diff --git a/parser-mpcmd.c b/parser-mpcmd.c
index ed1dbf29ce..892fcfbf40 100644
--- a/parser-mpcmd.c
+++ b/parser-mpcmd.c
@@ -33,7 +33,9 @@ static int mode = 0;
// #define UNSET_GLOBAL (mode = GLOBAL)
-static int is_entry_option(char *opt, char *param, play_tree_t** ret) {
+static int is_entry_option(struct m_config *mconfig, char *opt, char *param,
+ play_tree_t** ret)
+{
play_tree_t* entry = NULL;
*ret = NULL;
@@ -42,7 +44,7 @@ static int is_entry_option(char *opt, char *param, play_tree_t** ret) {
if(!param)
return M_OPT_MISSING_PARAM;
- entry = parse_playlist_file(param);
+ entry = parse_playlist_file(mconfig, param);
if(!entry)
return -1;
else {
@@ -105,7 +107,7 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
no_more_opts = 1;
if (i+1 >= argc)
{
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NoFileGivenOnCommandLine);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "'--' indicates no more options, but no filename was given on the command line.\n");
goto err_out;
}
continue;
@@ -152,7 +154,7 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
char* end = NULL;
l = (i+1<argc) ? strtol(argv[i+1],&end,0) : 0;
if(!end || *end != '\0') {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_TheLoopOptionMustBeAnInteger, argv[i+1]);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "The loop option must be an integer: %s\n", argv[i+1]);
tmp = ERR_OUT_OF_RANGE;
} else {
play_tree_t* pt = last_entry ? last_entry : last_parent;
@@ -174,7 +176,7 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
const m_option_t* mp_opt = NULL;
play_tree_t* entry = NULL;
- tmp = is_entry_option(opt,(i+1<argc) ? argv[i + 1] : NULL,&entry);
+ tmp = is_entry_option(config, opt,(i+1<argc) ? argv[i + 1] : NULL,&entry);
if(tmp > 0) { // It's an entry
if(entry) {
add_entry(&last_parent,&last_entry,entry);
@@ -198,7 +200,7 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
}
} else {
tmp = M_OPT_UNKNOWN;
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_UnknownOptionOnCommandLine, opt);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Unknown option on the command line: -%s\n", opt);
}
}
}
@@ -208,7 +210,7 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
tmp = M_OPT_EXIT - tmp;
} else
if (tmp < 0) {
- mp_msg(MSGT_CFGPARSER, MSGL_FATAL, MSGTR_ErrorParsingOptionOnCommandLine, opt);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_FATAL, "Error parsing option on the command line: -%s\n", opt);
goto err_out;
}
i += tmp;
@@ -243,7 +245,7 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
last_entry = entry;
}
} else {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_InvalidPlayEntry, argv[i]);
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Invalid play entry %s\n", argv[i]);
}
} else { // dvd:// or dvd://x entry
diff --git a/playtree.c b/playtree.c
index 06d4c49759..5c629eadaa 100644
--- a/playtree.c
+++ b/playtree.c
@@ -408,7 +408,7 @@ play_tree_set_params_from(play_tree_t* dest,play_tree_t* src) {
}
// all children if deep < 0
-void
+static void
play_tree_set_flag(play_tree_t* pt, int flags , int deep) {
play_tree_t* i;
@@ -421,7 +421,7 @@ play_tree_set_flag(play_tree_t* pt, int flags , int deep) {
}
}
-void
+static void
play_tree_unset_flag(play_tree_t* pt, int flags , int deep) {
play_tree_t* i;
diff --git a/playtree.h b/playtree.h
index 9b5b82e2ba..f1935f2c40 100644
--- a/playtree.h
+++ b/playtree.h
@@ -4,7 +4,7 @@
/// \file
/// \ingroup Playtree
-struct stream_st;
+struct stream;
struct m_config;
/// \defgroup PlaytreeIterReturn Playtree iterator return code
@@ -227,8 +227,9 @@ play_tree_iter_get_file(play_tree_iter_t* iter, int d);
/// Create a playtree from a playlist file.
/** \ingroup PlaytreeParser
*/
+struct m_config;
play_tree_t*
-parse_playtree(struct stream_st *stream, int forced);
+parse_playtree(struct stream *stream, struct m_config *mconfig, int forced);
/// Clean a tree by destroying all empty elements.
play_tree_t*
@@ -238,7 +239,7 @@ play_tree_cleanup(play_tree_t* pt);
/** \ingroup PlaytreeParser
*/
play_tree_t*
-parse_playlist_file(char* file);
+parse_playlist_file(struct m_config *mconfig, char* file);
/// \defgroup PtAPI Playtree highlevel API
/// \ingroup Playtree
diff --git a/playtreeparser.c b/playtreeparser.c
index 4ce9bd84cb..8be4e2e350 100644
--- a/playtreeparser.c
+++ b/playtreeparser.c
@@ -20,9 +20,9 @@
#include "libmpdemux/demuxer.h"
#include "mp_msg.h"
-
+struct m_config;
extern play_tree_t*
-asx_parser_build_tree(char* buffer, int ref);
+asx_parser_build_tree(struct m_config *mconfig, char* buffer, int ref);
#define BUF_STEP 1024
@@ -199,7 +199,7 @@ parse_asx(play_tree_parser_t* p) {
/* NOTHING */;
mp_msg(MSGT_PLAYTREE,MSGL_DBG3,"Parsing asx file: [%s]\n",p->buffer);
- return asx_parser_build_tree(p->buffer,p->deep);
+ return asx_parser_build_tree(p->mconfig, p->buffer,p->deep);
}
static char*
@@ -579,7 +579,7 @@ parse_smil(play_tree_parser_t* p) {
}
static play_tree_t*
-embedded_playlist_parse(char *line) {
+embedded_playlist_parse(struct m_config *mconfig, char *line) {
int f=DEMUXER_TYPE_PLAYLIST;
stream_t* stream;
play_tree_parser_t* ptp;
@@ -595,7 +595,7 @@ embedded_playlist_parse(char *line) {
//add new playtree
mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding playlist %s to element entryref\n",line);
- ptp = play_tree_parser_new(stream,1);
+ ptp = play_tree_parser_new(stream, mconfig, 1);
entry = play_tree_parser_get_play_tree(ptp, 1);
play_tree_parser_free(ptp);
free_stream(stream);
@@ -630,7 +630,7 @@ parse_textplain(play_tree_parser_t* p) {
( ((tolower(c[1]) == 's') && (tolower(c[2])== 'm') && (tolower(c[3]) == 'i')) ||
((tolower(c[1]) == 'r') && (tolower(c[2])== 'a') && (tolower(c[3]) == 'm')) )
&& (!c[4] || c[4] == '?' || c[4] == '&')) ){
- entry=embedded_playlist_parse(line);
+ entry=embedded_playlist_parse(p->mconfig, line);
embedded = 1;
break;
}
@@ -656,7 +656,7 @@ parse_textplain(play_tree_parser_t* p) {
}
play_tree_t*
-parse_playtree(stream_t *stream, int forced) {
+parse_playtree(stream_t *stream, struct m_config *mconfig, int forced) {
play_tree_parser_t* p;
play_tree_t* ret;
@@ -664,7 +664,7 @@ parse_playtree(stream_t *stream, int forced) {
assert(stream != NULL);
#endif
- p = play_tree_parser_new(stream,0);
+ p = play_tree_parser_new(stream, mconfig, 0);
if(!p)
return NULL;
@@ -731,7 +731,7 @@ void play_tree_add_bpf(play_tree_t* pt, char* filename)
}
play_tree_t*
-parse_playlist_file(char* file) {
+parse_playlist_file(struct m_config *mconfig, char* file) {
stream_t *stream;
play_tree_t* ret;
int f=DEMUXER_TYPE_PLAYLIST;
@@ -745,7 +745,7 @@ parse_playlist_file(char* file) {
mp_msg(MSGT_PLAYTREE,MSGL_V,"Parsing playlist file %s...\n",file);
- ret = parse_playtree(stream,1);
+ ret = parse_playtree(stream, mconfig, 1);
free_stream(stream);
play_tree_add_bpf(ret, file);
@@ -756,13 +756,14 @@ parse_playlist_file(char* file) {
play_tree_parser_t*
-play_tree_parser_new(stream_t* stream,int deep) {
+play_tree_parser_new(stream_t* stream, struct m_config *mconfig, int deep) {
play_tree_parser_t* p;
p = calloc(1,sizeof(play_tree_parser_t));
if(!p)
return NULL;
p->stream = stream;
+ p->mconfig = mconfig;
p->deep = deep;
p->keep = 1;
diff --git a/playtreeparser.h b/playtreeparser.h
index f0e11a6970..437d09ad0c 100644
--- a/playtreeparser.h
+++ b/playtreeparser.h
@@ -12,10 +12,11 @@
/// \file
-struct stream_st;
+struct stream;
typedef struct play_tree_parser {
- struct stream_st* stream;
+ struct stream* stream;
+ struct m_config *mconfig;
char *buffer,*iter,*line;
int buffer_size , buffer_end;
int deep,keep;
@@ -28,7 +29,7 @@ typedef struct play_tree_parser {
* \return The new parser.
*/
play_tree_parser_t*
-play_tree_parser_new(struct stream_st* stream,int deep);
+play_tree_parser_new(struct stream* stream, struct m_config *mconfig, int deep);
/// Destroy a parser.
void
diff --git a/spudec.c b/spudec.c
index 3824f12462..6e5c85c146 100644
--- a/spudec.c
+++ b/spudec.c
@@ -88,7 +88,7 @@ typedef struct {
unsigned char *scaled_aimage;
int auto_palette; /* 1 if we lack a palette and must use an heuristic. */
int font_start_level; /* Darkest value used for the computed font */
- const vo_functions_t *hw_spu;
+ struct vo *hw_spu;
int spu_changed;
unsigned int forced_subs_only; /* flag: 0=display all subtitle, !0 display only forced subtitles */
unsigned int is_forced_sub; /* true if current subtitle is a forced subtitle */
@@ -492,7 +492,7 @@ static void spudec_decode(spudec_handle_t *this, int pts100)
packet.data = this->packet;
packet.size = this->packet_size;
packet.timestamp = pts100;
- this->hw_spu->draw_frame((uint8_t**)&pkg);
+ vo_draw_frame(this->hw_spu, (uint8_t**)&pkg);
}
}
@@ -744,8 +744,9 @@ static void scale_image(int x, int y, scale_pixel* table_x, scale_pixel* table_y
}
}
-void sws_spu_image(unsigned char *d1, unsigned char *d2, int dw, int dh, int ds,
- unsigned char *s1, unsigned char *s2, int sw, int sh, int ss)
+static void sws_spu_image(unsigned char *d1, unsigned char *d2, int dw, int dh,
+ int ds, unsigned char *s1, unsigned char *s2, int sw,
+ int sh, int ss)
{
struct SwsContext *ctx;
static SwsFilter filter;
@@ -770,7 +771,7 @@ void sws_spu_image(unsigned char *d1, unsigned char *d2, int dw, int dh, int ds,
sws_freeContext(ctx);
}
-void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))
+void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx)
{
spudec_handle_t *spu = (spudec_handle_t *)me;
scale_pixel *table_x;
@@ -787,7 +788,7 @@ void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*dra
|| (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) {
if (spu->image)
{
- draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height,
+ draw_alpha(ctx, spu->start_col, spu->start_row, spu->width, spu->height,
spu->image, spu->aimage, spu->stride);
spu->spu_changed = 0;
}
@@ -1088,7 +1089,7 @@ nothing_to_do:
spu->scaled_start_row = dys*sub_pos/100 - spu->scaled_height;
break;
}
- draw_alpha(spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height,
+ draw_alpha(ctx, spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height,
spu->scaled_image, spu->scaled_aimage, spu->scaled_stride);
spu->spu_changed = 0;
}
@@ -1107,7 +1108,7 @@ void spudec_update_palette(void * this, unsigned int *palette)
if (spu && palette) {
memcpy(spu->global_palette, palette, sizeof(spu->global_palette));
if(spu->hw_spu)
- spu->hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette);
+ vo_control(spu->hw_spu, VOCTRL_SET_SPU_PALETTE, spu->global_palette);
}
}
@@ -1211,11 +1212,11 @@ void spudec_free(void *this)
}
}
-void spudec_set_hw_spu(void *this, const vo_functions_t *hw_spu)
+void spudec_set_hw_spu(void *this, struct vo *hw_spu)
{
spudec_handle_t *spu = (spudec_handle_t*)this;
if (!spu)
return;
spu->hw_spu = hw_spu;
- hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette);
+ vo_control(hw_spu, VOCTRL_SET_SPU_PALETTE, spu->global_palette);
}
diff --git a/spudec.h b/spudec.h
index d4c794973b..c4efad02f6 100644
--- a/spudec.h
+++ b/spudec.h
@@ -6,7 +6,7 @@
void spudec_heartbeat(void *this, unsigned int pts100);
void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pts100);
void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
-void spudec_draw_scaled(void *this, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
+void spudec_draw_scaled(void *this, unsigned int dxs, unsigned int dys, void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx);
void spudec_update_palette(void *this, unsigned int *palette);
void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len);
void *spudec_new(unsigned int *palette);
@@ -14,7 +14,7 @@ void spudec_free(void *this);
void spudec_reset(void *this); // called after seek
int spudec_visible(void *this); // check if spu is visible
void spudec_set_font_factor(void * this, double factor); // sets the equivalent to ffactor
-void spudec_set_hw_spu(void *this, const vo_functions_t *hw_spu);
+void spudec_set_hw_spu(void *this, struct vo *hw_spu);
int spudec_changed(void *this);
void spudec_calc_bbox(void *me, unsigned int dxs, unsigned int dys, unsigned int* bbox);
void spudec_set_forced_subs_only(void * const this, const unsigned int flag);
diff --git a/stream/ai_alsa.c b/stream/ai_alsa.c
index 4371dd23ba..e913dde099 100644
--- a/stream/ai_alsa.c
+++ b/stream/ai_alsa.c
@@ -23,24 +23,24 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_hw_params_any(ai->alsa.handle, params);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_PcmBrokenConfig);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Broken configuration for this PCM: no configurations available.\n");
return -1;
}
err = snd_pcm_hw_params_set_access(ai->alsa.handle, params,
SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableAccessType);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Access type not available.\n");
return -1;
}
err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableSampleFmt);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Sample format not available.\n");
return -1;
}
err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
if (err < 0) {
ai->channels = snd_pcm_hw_params_get_channels(params);
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableChanCount,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Channel count not available - reverting to default: %d\n",
ai->channels);
} else {
ai->channels = ai->req_channels;
@@ -61,14 +61,14 @@ int ai_alsa_setup(audio_in_t *ai)
assert(ai->alsa.period_time >= 0);
err = snd_pcm_hw_params(ai->alsa.handle, params);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_CannotInstallHWParams);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to install hardware paramameters: %s");
snd_pcm_hw_params_dump(params, ai->alsa.log);
return -1;
}
ai->alsa.chunk_size = snd_pcm_hw_params_get_period_size(params, 0);
buffer_size = snd_pcm_hw_params_get_buffer_size(params);
if (ai->alsa.chunk_size == buffer_size) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_PeriodEqualsBufferSize, ai->alsa.chunk_size, (long)buffer_size);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size);
return -1;
}
snd_pcm_sw_params_current(ai->alsa.handle, swparams);
@@ -84,7 +84,7 @@ int ai_alsa_setup(audio_in_t *ai)
assert(err >= 0);
if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_CannotInstallSWParams);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to install software parameters:\n");
snd_pcm_sw_params_dump(swparams, ai->alsa.log);
return -1;
}
@@ -108,7 +108,7 @@ int ai_alsa_init(audio_in_t *ai)
err = snd_pcm_open(&ai->alsa.handle, ai->alsa.device, SND_PCM_STREAM_CAPTURE, 0);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_ErrorOpeningAudio, snd_strerror(err));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Error opening audio: %s\n", snd_strerror(err));
return -1;
}
@@ -142,7 +142,7 @@ int ai_alsa_xrun(audio_in_t *ai)
snd_pcm_status_alloca(&status);
if ((res = snd_pcm_status(ai->alsa.handle, status))<0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaStatusError, snd_strerror(res));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA status error: %s", snd_strerror(res));
return -1;
}
if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
@@ -150,18 +150,18 @@ int ai_alsa_xrun(audio_in_t *ai)
gettimeofday(&now, 0);
snd_pcm_status_get_trigger_tstamp(status, &tstamp);
timersub(&now, &tstamp, &diff);
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaXRUN,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA xrun!!! (at least %.3f ms long)\n",
diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
if (mp_msg_test(MSGT_TV, MSGL_V)) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaStatus);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA Status:\n");
snd_pcm_status_dump(status, ai->alsa.log);
}
if ((res = snd_pcm_prepare(ai->alsa.handle))<0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaXRUNPrepareError, snd_strerror(res));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA xrun: prepare error: %s", snd_strerror(res));
return -1;
}
return 0; /* ok, data should be accepted again */
}
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaReadWriteError);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA read/write error");
return -1;
}
diff --git a/stream/ai_alsa1x.c b/stream/ai_alsa1x.c
index 23e0b5d9ef..fa307a1cd8 100644
--- a/stream/ai_alsa1x.c
+++ b/stream/ai_alsa1x.c
@@ -24,27 +24,27 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_hw_params_any(ai->alsa.handle, params);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_PcmBrokenConfig);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Broken configuration for this PCM: no configurations available.\n");
return -1;
}
err = snd_pcm_hw_params_set_access(ai->alsa.handle, params,
SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableAccessType);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Access type not available.\n");
return -1;
}
err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableSampleFmt);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Sample format not available.\n");
return -1;
}
err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
if (err < 0) {
snd_pcm_hw_params_get_channels(params, &ai->channels);
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableChanCount,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Channel count not available - reverting to default: %d\n",
ai->channels);
} else {
ai->channels = ai->req_channels;
@@ -54,7 +54,7 @@ int ai_alsa_setup(audio_in_t *ai)
rate = ai->req_samplerate;
err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, &rate, &dir);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA1X_CannotSetSamplerate);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Cannot set samplerate.\n");
}
ai->samplerate = rate;
@@ -63,7 +63,7 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
&ai->alsa.buffer_time, &dir);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA1X_CannotSetBufferTime);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Cannot set buffer time.\n");
}
dir = 0;
@@ -71,12 +71,12 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
&ai->alsa.period_time, &dir);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA1X_CannotSetPeriodTime);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Cannot set period time.\n");
}
err = snd_pcm_hw_params(ai->alsa.handle, params);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_CannotInstallHWParams, snd_strerror(err));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to install hardware paramameters: %s", snd_strerror(err));
snd_pcm_hw_params_dump(params, ai->alsa.log);
return -1;
}
@@ -86,7 +86,7 @@ int ai_alsa_setup(audio_in_t *ai)
snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
ai->alsa.chunk_size = period_size;
if (period_size == buffer_size) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_PeriodEqualsBufferSize, ai->alsa.chunk_size, (long)buffer_size);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size);
return -1;
}
@@ -98,7 +98,7 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_sw_params_set_stop_threshold(ai->alsa.handle, swparams, buffer_size);
if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_CannotInstallSWParams);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to install software parameters:\n");
snd_pcm_sw_params_dump(swparams, ai->alsa.log);
return -1;
}
@@ -122,7 +122,7 @@ int ai_alsa_init(audio_in_t *ai)
err = snd_pcm_open(&ai->alsa.handle, ai->alsa.device, SND_PCM_STREAM_CAPTURE, 0);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_ErrorOpeningAudio, snd_strerror(err));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Error opening audio: %s\n", snd_strerror(err));
return -1;
}
@@ -156,7 +156,7 @@ int ai_alsa_xrun(audio_in_t *ai)
snd_pcm_status_alloca(&status);
if ((res = snd_pcm_status(ai->alsa.handle, status))<0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaStatusError, snd_strerror(res));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA status error: %s", snd_strerror(res));
return -1;
}
if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
@@ -164,18 +164,18 @@ int ai_alsa_xrun(audio_in_t *ai)
gettimeofday(&now, 0);
snd_pcm_status_get_trigger_tstamp(status, &tstamp);
timersub(&now, &tstamp, &diff);
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaXRUN,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA xrun!!! (at least %.3f ms long)\n",
diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
if (mp_msg_test(MSGT_TV, MSGL_V)) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaStatus);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA Status:\n");
snd_pcm_status_dump(status, ai->alsa.log);
}
if ((res = snd_pcm_prepare(ai->alsa.handle))<0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaXRUNPrepareError, snd_strerror(res));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA xrun: prepare error: %s", snd_strerror(res));
return -1;
}
return 0; /* ok, data should be accepted again */
}
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaReadWriteError);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA read/write error");
return -1;
}
diff --git a/stream/ai_oss.c b/stream/ai_oss.c
index d2d2f20163..d39454e855 100644
--- a/stream/ai_oss.c
+++ b/stream/ai_oss.c
@@ -41,7 +41,7 @@ int ai_oss_set_channels(audio_in_t *ai)
mp_msg(MSGT_TV, MSGL_V, "ioctl dsp channels: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_CHANNELS, &ioctl_param));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_Unable2SetChanCount,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set channel count: %d\n",
ai->req_channels);
return -1;
}
@@ -54,7 +54,7 @@ int ai_oss_set_channels(audio_in_t *ai)
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_STEREO, &ioctl_param),
ioctl_param);
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_Unable2SetStereo,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set stereo: %d\n",
ai->req_channels == 2);
return -1;
}
@@ -71,7 +71,7 @@ int ai_oss_init(audio_in_t *ai)
ai->oss.audio_fd = open(ai->oss.device, O_RDONLY);
if (ai->oss.audio_fd < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_Unable2Open,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to open '%s': %s\n",
ai->oss.device, strerror(errno));
return -1;
}
@@ -82,13 +82,13 @@ int ai_oss_init(audio_in_t *ai)
mp_msg(MSGT_TV, MSGL_V, "Supported formats: %x\n", ioctl_param);
if (!(ioctl_param & AFMT_S16_LE))
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_UnsupportedFmt);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "unsupported format\n");
ioctl_param = AFMT_S16_LE;
mp_msg(MSGT_TV, MSGL_V, "ioctl dsp setfmt: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETFMT, &ioctl_param));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_Unable2SetAudioFmt);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set audio format.");
return -1;
}
@@ -98,7 +98,7 @@ int ai_oss_init(audio_in_t *ai)
mp_msg(MSGT_TV, MSGL_V, "ioctl dsp speed: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &ioctl_param));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_Unable2SetSamplerate,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set samplerate: %d\n",
ai->req_samplerate);
return -1;
}
@@ -111,7 +111,7 @@ int ai_oss_init(audio_in_t *ai)
mp_msg(MSGT_TV, MSGL_V, "ioctl dsp trigger: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETTRIGGER, &ioctl_param));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_Unable2SetTrigger,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set trigger: %d\n",
PCM_ENABLE_INPUT);
}
@@ -119,17 +119,17 @@ int ai_oss_init(audio_in_t *ai)
mp_msg(MSGT_TV, MSGL_V, "ioctl dsp getblocksize: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETBLKSIZE, &ai->blocksize));
if (err < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_Unable2GetBlockSize);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to get block size!\n");
}
mp_msg(MSGT_TV, MSGL_V, "blocksize: %d\n", ai->blocksize);
// correct the blocksize to a reasonable value
if (ai->blocksize <= 0) {
ai->blocksize = 4096*ai->channels*2;
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_AudioBlockSizeZero, ai->blocksize);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Audio block size is zero, setting to %d!\n", ai->blocksize);
} else if (ai->blocksize < 4096*ai->channels*2) {
ai->blocksize *= 4096*ai->channels*2/ai->blocksize;
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIOSS_AudioBlockSize2Low, ai->blocksize);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Audio block size too low, setting to %d!\n", ai->blocksize);
}
ai->samplesize = 16;
diff --git a/stream/asf_mmst_streaming.c b/stream/asf_mmst_streaming.c
index 6d764617a4..a32938a871 100644
--- a/stream/asf_mmst_streaming.c
+++ b/stream/asf_mmst_streaming.c
@@ -35,7 +35,7 @@
#include <inttypes.h>
#include "config.h"
-
+#include "options.h"
#include "mp_msg.h"
#include "help_mp.h"
@@ -134,7 +134,7 @@ static void send_command (int s, int command, uint32_t switches,
memset(&cmd.buf[48 + length], 0, 8 - (length & 7));
if (send (s, cmd.buf, len8*8+48, 0) != (len8*8+48)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_WriteError);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"write error\n");
}
}
@@ -182,7 +182,7 @@ static void get_answer (int s)
len = recv (s, data, BUF_SIZE, 0) ;
if (!len) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_EOFAlert);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"\nAlert! EOF\n");
return;
}
@@ -229,7 +229,7 @@ static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl)
while (1) {
if (!get_data (s, pre_header, 8)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_PreHeaderReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"pre-header read failed\n");
return 0;
}
if (pre_header[4] == 0x02) {
@@ -241,12 +241,12 @@ static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl)
// mp_msg(MSGT_NETWORK,MSGL_INFO,"asf header packet detected, len=%d\n", packet_len);
if (packet_len < 0 || packet_len > HDR_BUF_SIZE - header_len) {
- mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MPDEMUX_MMST_InvalidHeaderSize);
+ mp_tmsg(MSGT_NETWORK, MSGL_FATAL, "Invalid header size, giving up.\n");
return 0;
}
if (!get_data (s, &header[header_len], packet_len)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_HeaderDataReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Header data read failed.\n");
return 0;
}
@@ -272,7 +272,7 @@ static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl)
char data[BUF_SIZE];
if (!get_data (s, (char*)&packet_len, 4)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_packet_lenReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"packet_len read failed.\n");
return 0;
}
@@ -281,13 +281,13 @@ static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl)
// mp_msg(MSGT_NETWORK,MSGL_INFO,"command packet detected, len=%d\n", packet_len);
if (packet_len < 0 || packet_len > BUF_SIZE) {
- mp_msg(MSGT_NETWORK, MSGL_FATAL,
- MSGTR_MPDEMUX_MMST_InvalidRTSPPacketSize);
+ mp_tmsg(MSGT_NETWORK, MSGL_FATAL,
+ "Invalid RTSP packet size, giving up.\n");
return 0;
}
if (!get_data (s, data, packet_len)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_CmdDataReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Command data read failed.\n");
return 0;
}
@@ -340,14 +340,14 @@ static int interp_header (uint8_t *header, int header_len)
i += 8;
if ( (guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22630ULL) ) {
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_MMST_HeaderObject);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"header object\n");
} else if ((guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22636ULL)) {
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_MMST_DataObject);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"data object\n");
} else if ((guid_1 == 0x6553200cc000e48eULL) && (guid_2 == 0x11cfa9478cabdca1ULL)) {
packet_length = get_32(header, i+92-24);
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_MMST_FileObjectPacketLen,
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"file object, packet length = %d (%d)\n",
packet_length, get_32(header, i+96-24));
@@ -355,13 +355,13 @@ static int interp_header (uint8_t *header, int header_len)
int stream_id = header[i+48] | header[i+49] << 8;
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_MMST_StreamObjectStreamID, stream_id);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"stream object, stream ID: %d\n", stream_id);
if (num_stream_ids < MAX_STREAMS) {
stream_ids[num_stream_ids] = stream_id;
num_stream_ids++;
} else {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_2ManyStreamID);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Too many IDs, stream skipped.");
}
} else {
@@ -377,7 +377,7 @@ static int interp_header (uint8_t *header, int header_len)
}
printf("\n");
#else
- mp_msg(MSGT_NETWORK,MSGL_WARN,MSGTR_MPDEMUX_MMST_UnknownObject);
+ mp_tmsg(MSGT_NETWORK,MSGL_WARN,"unknown object\n");
#endif
}
@@ -397,7 +397,7 @@ static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl)
char data[BUF_SIZE];
if (!get_data (s, pre_header, 8)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_PreHeaderReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"pre-header read failed\n");
return 0;
}
@@ -414,12 +414,12 @@ static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl)
// mp_msg(MSGT_NETWORK,MSGL_INFO,"asf media packet detected, len=%d\n", packet_len);
if (packet_len < 0 || packet_len > BUF_SIZE) {
- mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MPDEMUX_MMST_InvalidRTSPPacketSize);
+ mp_tmsg(MSGT_NETWORK, MSGL_FATAL, "Invalid RTSP packet size, giving up.\n");
return 0;
}
if (!get_data (s, data, packet_len)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_MediaDataReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Media data read failed.\n");
return 0;
}
@@ -431,26 +431,26 @@ static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl)
int command;
if (!get_data (s, (char*)&packet_len, 4)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_packet_lenReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"packet_len read failed.\n");
return 0;
}
packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4;
if (packet_len < 0 || packet_len > BUF_SIZE) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MPDEMUX_MMST_InvalidRTSPPacketSize);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Invalid RTSP packet size, giving up.\n");
return 0;
}
if (!get_data (s, data, packet_len)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_CmdDataReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Command data read failed.\n");
return 0;
}
if ( (pre_header[7] != 0xb0) || (pre_header[6] != 0x0b)
|| (pre_header[5] != 0xfa) || (pre_header[4] != 0xce) ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_MissingSignature);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"missing signature\n");
return -1;
}
@@ -461,7 +461,7 @@ static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl)
if (command == 0x1b)
send_command (s, 0x1b, 0, 0, 0, data);
else if (command == 0x1e) {
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_MMST_PatentedTechnologyJoke);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Everything done. Thank you for downloading a media file containing proprietary and patented technology.\n");
return 0;
}
else if (command == 0x21 ) {
@@ -470,7 +470,7 @@ static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl)
return 0;
}
else if (command != 0x05) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_UnknownCmd,command);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"unknown command %02x\n",command);
return -1;
}
}
@@ -491,7 +491,7 @@ static int asf_mmst_streaming_read( int fd, char *buffer, int size, streaming_ct
// buffer is empty - fill it!
int ret = get_media_packet( fd, packet_length1, stream_ctrl);
if( ret<0 ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_MMST_GetMediaPacketErr,strerror(errno));
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"get_media_packet error : %s\n",strerror(errno));
return -1;
} else if (ret==0) //EOF?
return ret;
@@ -544,7 +544,7 @@ int asf_mmst_streaming_start(stream_t *stream)
*/
unescpath=malloc(strlen(path)+1);
if (!unescpath) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
return -1;
}
url_unescape_string(unescpath,path);
@@ -559,7 +559,7 @@ int asf_mmst_streaming_start(stream_t *stream)
free(path);
return s;
}
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_MMST_Connected);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Connected\n");
seq_num=0;
@@ -639,6 +639,7 @@ int asf_mmst_streaming_start(stream_t *stream)
memset (data, 0, 40);
+ int audio_id = stream->opts->audio_id;
if (audio_id > 0) {
data[2] = 0xFF;
data[3] = 0xFF;
diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c
index 517bb49f52..7dfd2831b8 100644
--- a/stream/asf_streaming.c
+++ b/stream/asf_streaming.c
@@ -8,6 +8,7 @@
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "options.h"
#if HAVE_WINSOCK2_H
#include <winsock2.h>
@@ -37,7 +38,7 @@ static int asf_read_wrapper(int fd, void *buffer, int len, streaming_ctrl_t *str
while (len > 0) {
int got = nop_streaming_read(fd, buf, len, stream_ctrl);
if (got <= 0) {
- mp_msg(MSGT_NETWORK, MSGL_ERR, MSGTR_MPDEMUX_ASF_ErrReadingNetworkStream);
+ mp_tmsg(MSGT_NETWORK, MSGL_ERR, "Error while reading network stream.\n");
return got;
}
buf += got;
@@ -108,11 +109,11 @@ printf("0x%02X\n", stream_chunck->type );
if( drop_packet!=NULL ) *drop_packet = 0;
if( stream_chunck->size<8 ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_StreamChunkSize2Small, stream_chunck->size);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Ahhhh, stream_chunck size is too small: %d\n", stream_chunck->size);
return -1;
}
if( stream_chunck->size!=stream_chunck->size_confirm ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_SizeConfirmMismatch, stream_chunck->size, stream_chunck->size_confirm);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"size_confirm mismatch!: %d %d\n", stream_chunck->size, stream_chunck->size_confirm);
return -1;
}
/*
@@ -145,9 +146,6 @@ printf("0x%02X\n", stream_chunck->type );
return stream_chunck->size+4;
}
-extern int audio_id;
-extern int video_id;
-
static void close_s(stream_t *stream) {
closesocket(stream->fd);
stream->fd=-1;
@@ -187,13 +185,13 @@ static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl)
// Endian handling of the stream chunk
le2me_ASF_stream_chunck_t(&chunk);
size = asf_streaming( &chunk, &r) - sizeof(ASF_stream_chunck_t);
- if(r) mp_msg(MSGT_NETWORK,MSGL_WARN,MSGTR_MPDEMUX_ASF_WarnDropHeader);
+ if(r) mp_tmsg(MSGT_NETWORK,MSGL_WARN,"Warning: drop header ????\n");
if(size < 0){
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_ErrorParsingChunkHeader);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Error while parsing chunk header\n");
return -1;
}
if (chunk.type != ASF_STREAMING_HEADER) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_NoHeaderAtFirstChunk);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Didn't get a header as first chunk !!!!\n");
return -1;
}
@@ -201,7 +199,7 @@ static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl)
if (size > SIZE_MAX - buffer_size) return -1;
buffer = malloc(size+buffer_size);
if(buffer == NULL) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MPDEMUX_ASF_BufferMallocFailed,size+buffer_size);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Error: Can't allocate %d bytes buffer.\n",size+buffer_size);
return -1;
}
if( chunk_buffer!=NULL ) {
@@ -218,7 +216,7 @@ static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl)
if( chunk_size2read==0 ) {
ASF_header_t *asfh = (ASF_header_t *)buffer;
if(size < (int)sizeof(ASF_header_t)) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_ErrChunk2Small);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Error: Chunk is too small.\n");
return -1;
} else mp_msg(MSGT_NETWORK,MSGL_DBG2,"Got chunk\n");
chunk_size2read = AV_RL64(&asfh->objh.size);
@@ -359,34 +357,34 @@ static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl)
free(a_rates);
if (a_idx < 0 && v_idx < 0) {
- mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MPDEMUX_ASF_Bandwidth2SmallCannotPlay);
+ mp_tmsg(MSGT_NETWORK, MSGL_FATAL, "Bandwidth too small, file cannot be played!\n");
return -1;
}
- if (audio_id > 0)
+ if (*streaming_ctrl->audio_id_ptr > 0)
// a audio stream was forced
- asf_ctrl->audio_id = audio_id;
+ asf_ctrl->audio_id = *streaming_ctrl->audio_id_ptr;
else if (a_idx >= 0)
asf_ctrl->audio_id = asf_ctrl->audio_streams[a_idx];
else if (asf_ctrl->n_audio) {
- mp_msg(MSGT_NETWORK, MSGL_WARN, MSGTR_MPDEMUX_ASF_Bandwidth2SmallDeselectedAudio);
- audio_id = -2;
+ mp_tmsg(MSGT_NETWORK, MSGL_WARN, "Bandwidth too small, deselected audio stream.\n");
+ *streaming_ctrl->audio_id_ptr = -2;
}
- if (video_id > 0)
+ if (*streaming_ctrl->video_id_ptr > 0)
// a video stream was forced
- asf_ctrl->video_id = video_id;
+ asf_ctrl->video_id = *streaming_ctrl->video_id_ptr;
else if (v_idx >= 0)
asf_ctrl->video_id = asf_ctrl->video_streams[v_idx];
else if (asf_ctrl->n_video) {
- mp_msg(MSGT_NETWORK, MSGL_WARN, MSGTR_MPDEMUX_ASF_Bandwidth2SmallDeselectedVideo);
- video_id = -2;
+ mp_tmsg(MSGT_NETWORK, MSGL_WARN, "Bandwidth too small, deselected video stream.\n");
+ *streaming_ctrl->video_id_ptr = -2;
}
return 1;
len_err_out:
- mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MPDEMUX_ASF_InvalidLenInHeader);
+ mp_tmsg(MSGT_NETWORK, MSGL_FATAL, "Invalid length in ASF header!\n");
if (buffer) free(buffer);
if (v_rates) free(v_rates);
if (a_rates) free(a_rates);
@@ -408,14 +406,14 @@ static int asf_http_streaming_read( int fd, char *buffer, int size, streaming_ct
le2me_ASF_stream_chunck_t(&chunk);
chunk_size = asf_streaming( &chunk, &drop_chunk );
if(chunk_size < 0) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_ErrorParsingChunkHeader);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Error while parsing chunk header\n");
return -1;
}
chunk_size -= sizeof(ASF_stream_chunck_t);
if(chunk.type != ASF_STREAMING_HEADER && (!drop_chunk)) {
if (asf_http_ctrl->packet_size < chunk_size) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_ErrChunkBiggerThanPacket);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Error: chunk_size > packet_size\n");
return -1;
}
waiting = asf_http_ctrl->packet_size;
@@ -507,7 +505,7 @@ static int asf_http_streaming_type(char *content_type, char *features, HTTP_head
(!strcasecmp(content_type, "video/x-ms-afs")) ||
(!strcasecmp(content_type, "video/x-ms-wmv")) ||
(!strcasecmp(content_type, "video/x-ms-wma")) ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_ASFRedirector);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"=====> ASF Redirector\n");
return ASF_Redirector_e;
} else if( !strcasecmp(content_type, "text/plain") ) {
mp_msg(MSGT_NETWORK,MSGL_V,"=====> ASF Plain text\n");
@@ -549,7 +547,7 @@ static HTTP_header_t *asf_http_request(streaming_ctrl_t *streaming_ctrl) {
if( !strcasecmp( url->protocol, "http_proxy" ) ) {
server_url = url_new( (url->file)+1 );
if( server_url==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_InvalidProxyURL);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"invalid proxy URL\n");
http_free( http_hdr );
return NULL;
}
@@ -610,7 +608,7 @@ static HTTP_header_t *asf_http_request(streaming_ctrl_t *streaming_ctrl) {
// First request goes here.
break;
default:
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_UnknownASFStreamType);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"unknown ASF stream type\n");
}
http_set_field( http_hdr, "Connection: Close" );
@@ -624,7 +622,7 @@ static int asf_http_parse_response(asf_http_streaming_ctrl_t *asf_http_ctrl, HTT
char features[64] = "\0";
size_t len;
if( http_response_parse(http_hdr)<0 ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_Failed2ParseHTTPResponse);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Failed to parse HTTP response.\n");
return -1;
}
switch( http_hdr->status_code ) {
@@ -633,7 +631,7 @@ static int asf_http_parse_response(asf_http_streaming_ctrl_t *asf_http_ctrl, HTT
case 401: // Authentication required
return ASF_Authenticate_e;
default:
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_ServerReturn, http_hdr->status_code, http_hdr->reason_phrase);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Server returned %d:%s\n", http_hdr->status_code, http_hdr->reason_phrase);
return -1;
}
@@ -657,7 +655,7 @@ static int asf_http_parse_response(asf_http_streaming_ctrl_t *asf_http_ctrl, HTT
len = (unsigned int)(end-pragma);
}
if(len > sizeof(features) - 1) {
- mp_msg(MSGT_NETWORK,MSGL_WARN,MSGTR_MPDEMUX_ASF_ASFHTTPParseWarnCuttedPragma,pragma,len,sizeof(features) - 1);
+ mp_tmsg(MSGT_NETWORK,MSGL_WARN,"ASF HTTP PARSE WARNING : Pragma %s cut from %d bytes to %d\n",pragma,len,sizeof(features) - 1);
len = sizeof(features) - 1;
}
strncpy( features, pragma, len );
@@ -688,7 +686,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) {
asf_http_ctrl = malloc(sizeof(asf_http_streaming_ctrl_t));
if( asf_http_ctrl==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
return -1;
}
asf_http_ctrl->streaming_type = ASF_Unknown_e;
@@ -714,7 +712,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) {
for(i=0; i < (int)http_hdr->buffer_size ; ) {
int r = send( fd, http_hdr->buffer+i, http_hdr->buffer_size-i, 0 );
if(r <0) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_SocketWriteError,strerror(errno));
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"socket write error: %s\n",strerror(errno));
goto err_out;
}
i += r;
@@ -736,7 +734,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) {
}
ret = asf_http_parse_response(asf_http_ctrl, http_hdr);
if( ret<0 ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_HeaderParseFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Failed to parse header.\n");
goto err_out;
}
switch( asf_http_ctrl->streaming_type ) {
@@ -754,7 +752,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) {
ret = asf_streaming_parse_header(fd,stream->streaming_ctrl);
if(ret < 0) goto err_out;
if(asf_http_ctrl->n_audio == 0 && asf_http_ctrl->n_video == 0) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_NoStreamFound);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"No stream found.\n");
goto err_out;
}
asf_http_ctrl->request++;
@@ -780,7 +778,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) {
break;
case ASF_Unknown_e:
default:
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_UnknownASFStreamingType);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"unknown ASF streaming type\n");
goto err_out;
}
// Check if we got a redirect.
@@ -816,12 +814,14 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
if( stream->streaming_ctrl==NULL ) {
return STREAM_ERROR;
}
+ stream->streaming_ctrl->audio_id_ptr = &stream->opts->audio_id;
+ stream->streaming_ctrl->video_id_ptr = &stream->opts->video_id;
stream->streaming_ctrl->bandwidth = network_bandwidth;
url = url_new(stream->url);
stream->streaming_ctrl->url = check4proxies(url);
url_free(url);
- mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_MPDEMUX_ASF_InfoStreamASFURL, stream->url);
+ mp_tmsg(MSGT_OPEN, MSGL_INFO, "STREAM_ASF, URL: %s\n", stream->url);
if((!strncmp(stream->url, "http", 4)) && (*file_format!=DEMUXER_TYPE_ASF && *file_format!=DEMUXER_TYPE_UNKNOWN)) {
streaming_ctrl_free(stream->streaming_ctrl);
stream->streaming_ctrl = NULL;
@@ -829,7 +829,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
}
if(asf_streaming_start(stream, file_format) < 0) {
- mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_ASF_StreamingFailed);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed, exiting.\n");
streaming_ctrl_free(stream->streaming_ctrl);
stream->streaming_ctrl = NULL;
return STREAM_UNSUPPORTED;
@@ -852,4 +852,3 @@ const stream_info_t stream_info_asf = {
NULL,
0 // Urls are an option string
};
-
diff --git a/stream/audio_in.c b/stream/audio_in.c
index 93513e9604..99b5ccf7fb 100644
--- a/stream/audio_in.c
+++ b/stream/audio_in.c
@@ -185,16 +185,16 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size);
if (ret != ai->alsa.chunk_size) {
if (ret < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_ErrReadingAudio, snd_strerror(ret));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "\nError reading audio: %s\n", snd_strerror(ret));
if (ret == -EPIPE) {
if (ai_alsa_xrun(ai) == 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_XRUNSomeFramesMayBeLeftOut);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Recovered from cross-run, some frames may be left out!\n");
} else {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_ErrFatalCannotRecover);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Fatal error, cannot recover!\n");
}
}
} else {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_NotEnoughSamples);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "\nNot enough audio samples!\n");
}
return -1;
}
@@ -205,9 +205,9 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
ret = read(ai->oss.audio_fd, buffer, ai->blocksize);
if (ret != ai->blocksize) {
if (ret < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_ErrReadingAudio, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "\nError reading audio: %s\n", strerror(errno));
} else {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_NotEnoughSamples);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "\nNot enough audio samples!\n");
}
return -1;
}
diff --git a/stream/cache2.c b/stream/cache2.c
index acdb111f0b..aeefa73b05 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -39,9 +39,6 @@ static void *ThreadProc(void *s);
#include "cache2.h"
extern int use_gui;
-int stream_fill_buffer(stream_t *s);
-int stream_seek_long(stream_t *s,off_t pos);
-
typedef struct {
// constats:
unsigned char *buffer; // base pointer of the alllocated buffer memory
@@ -74,13 +71,13 @@ static int min_fill=0;
int cache_fill_status=0;
-void cache_stats(cache_vars_t* s){
+static void cache_stats(cache_vars_t* s){
int newb=s->max_filepos-s->read_filepos; // new bytes in the buffer
mp_msg(MSGT_CACHE,MSGL_INFO,"0x%06X [0x%06X] 0x%06X ",(int)s->min_filepos,(int)s->read_filepos,(int)s->max_filepos);
mp_msg(MSGT_CACHE,MSGL_INFO,"%3d %% (%3d%%)\n",100*newb/s->buffer_size,100*min_fill/s->buffer_size);
}
-int cache_read(cache_vars_t* s,unsigned char* buf,int size){
+static int cache_read(cache_vars_t* s,unsigned char* buf,int size){
int total=0;
while(size>0){
int pos,newb,len;
@@ -126,7 +123,7 @@ int cache_read(cache_vars_t* s,unsigned char* buf,int size){
return total;
}
-int cache_fill(cache_vars_t* s){
+static int cache_fill(cache_vars_t* s){
int back,back2,newb,space,len,pos;
off_t read=s->read_filepos;
@@ -246,7 +243,7 @@ static int cache_execute_control(cache_vars_t *s) {
return res;
}
-cache_vars_t* cache_init(int size,int sector){
+static cache_vars_t* cache_init(int size,int sector){
int num;
#if !defined(__MINGW32__) && !defined(PTHREAD_CACHE) && !defined(__OS2__)
cache_vars_t* s=shmem_alloc(sizeof(cache_vars_t));
@@ -356,7 +353,7 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){
mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %"PRId64" [%"PRId64"] %"PRId64" pre:%d eof:%d \n",
(int64_t)s->min_filepos,(int64_t)s->read_filepos,(int64_t)s->max_filepos,min,s->eof);
while(s->read_filepos<s->min_filepos || s->max_filepos-s->read_filepos<min){
- mp_msg(MSGT_CACHE,MSGL_STATUS,MSGTR_CacheFill,
+ mp_tmsg(MSGT_CACHE,MSGL_STATUS,"\rCache fill: %5.2f%% (%"PRId64" bytes) ",
100.0*(float)(s->max_filepos-s->read_filepos)/(float)(s->buffer_size),
(int64_t)s->max_filepos-s->read_filepos
);
diff --git a/stream/cdinfo.c b/stream/cdinfo.c
index 6e4544d366..4da80c71a1 100644
--- a/stream/cdinfo.c
+++ b/stream/cdinfo.c
@@ -25,7 +25,7 @@ cd_info_new(void) {
cd_info = malloc(sizeof(cd_info_t));
if( cd_info==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n");
return NULL;
}
@@ -59,14 +59,14 @@ cd_info_add_track(cd_info_t *cd_info, char *track_name, unsigned int track_nb, u
cd_track = malloc(sizeof(cd_track_t));
if( cd_track==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n");
return NULL;
}
memset(cd_track, 0, sizeof(cd_track_t));
cd_track->name = malloc(strlen(track_name)+1);
if( cd_track->name==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n");
free(cd_track);
return NULL;
}
diff --git a/stream/network.c b/stream/network.c
index 801bebaf24..15a0a9ba84 100644
--- a/stream/network.c
+++ b/stream/network.c
@@ -98,7 +98,7 @@ streaming_ctrl_new(void) {
streaming_ctrl_t *streaming_ctrl;
streaming_ctrl = malloc(sizeof(streaming_ctrl_t));
if( streaming_ctrl==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
return NULL;
}
memset( streaming_ctrl, 0, sizeof(streaming_ctrl_t) );
@@ -135,15 +135,15 @@ check4proxies( URL_t *url ) {
URL_t *proxy_url = url_new( proxy );
if( proxy_url==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_WARN,
- MSGTR_MPDEMUX_NW_InvalidProxySettingTryingWithout);
+ mp_tmsg(MSGT_NETWORK,MSGL_WARN,
+ "Invalid proxy setting... Trying without proxy.\n");
return url_out;
}
#ifdef HAVE_AF_INET6
if (network_ipv4_only_proxy && (gethostbyname(url->hostname)==NULL)) {
- mp_msg(MSGT_NETWORK,MSGL_WARN,
- MSGTR_MPDEMUX_NW_CantResolvTryingWithoutProxy);
+ mp_tmsg(MSGT_NETWORK,MSGL_WARN,
+ "Could not resolve remote hostname for AF_INET. Trying without proxy.\n");
url_free(proxy_url);
return url_out;
}
@@ -153,7 +153,7 @@ check4proxies( URL_t *url ) {
len = strlen( proxy_url->hostname ) + strlen( url->url ) + 20; // 20 = http_proxy:// + port
new_url = malloc( len+1 );
if( new_url==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
url_free(proxy_url);
return url_out;
}
@@ -238,7 +238,7 @@ http_send_request( URL_t *url, off_t pos ) {
ret = send( fd, http_hdr->buffer, http_hdr->buffer_size, 0 );
if( ret!=(int)http_hdr->buffer_size ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ErrSendingHTTPRequest);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Error while sending HTTP request: Didn't send all the request.\n");
goto err_out;
}
@@ -267,12 +267,12 @@ http_read_response( int fd ) {
do {
i = recv( fd, response, BUFFER_SIZE, 0 );
if( i<0 ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ReadFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Read failed.\n");
http_free( http_hdr );
return NULL;
}
if( i==0 ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_Read0CouldBeEOF);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"http_read_response read 0 (i.e. EOF).\n");
http_free( http_hdr );
return NULL;
}
@@ -286,8 +286,14 @@ int
http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry) {
char *aut;
+#define MPDEMUX_NW_AuthFailed _(\
+"Authentication failed. Please use the -user and -passwd options to provide your\n"\
+"username/password for a list of URLs, or form an URL like:\n"\
+"http://username:password@hostname/file\n")
+
+
if( *auth_retry==1 ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_AuthFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,MPDEMUX_NW_AuthFailed);
return -1;
}
if( *auth_retry>0 ) {
@@ -306,28 +312,28 @@ http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry) {
char *aut_space;
aut_space = strstr(aut, "realm=");
if( aut_space!=NULL ) aut_space += 6;
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_NW_AuthRequiredFor, aut_space);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Authentication required for %s\n", aut_space);
} else {
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_NW_AuthRequired);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Authentication required.\n");
}
if( network_username ) {
url->username = strdup(network_username);
if( url->username==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
return -1;
}
} else {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_AuthFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,MPDEMUX_NW_AuthFailed);
return -1;
}
if( network_password ) {
url->password = strdup(network_password);
if( url->password==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
return -1;
}
} else {
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_NW_NoPasswdProvidedTryingBlank);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"No password provided, trying blank password.\n");
}
(*auth_retry)++;
return 0;
@@ -360,7 +366,7 @@ http_seek( stream_t *stream, off_t pos ) {
}
break;
default:
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ErrServerReturned, http_hdr->status_code, http_hdr->reason_phrase );
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Server returns %d: %s\n", http_hdr->status_code, http_hdr->reason_phrase );
close( fd );
fd = -1;
}
@@ -382,7 +388,7 @@ streaming_bufferize( streaming_ctrl_t *streaming_ctrl, char *buffer, int size) {
//printf("streaming_bufferize\n");
streaming_ctrl->buffer = malloc(size);
if( streaming_ctrl->buffer==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
return -1;
}
memcpy( streaming_ctrl->buffer, buffer, size );
@@ -442,7 +448,7 @@ void fixup_network_stream_cache(stream_t *stream) {
stream_cache_size = (stream->streaming_ctrl->prebuffer_size/1024)*5;
if( stream_cache_size<64 ) stream_cache_size = 64; // 16KBytes min buffer
}
- mp_msg(MSGT_NETWORK,MSGL_INFO,MSGTR_MPDEMUX_NW_CacheSizeSetTo, stream_cache_size);
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %d KBytes\n", stream_cache_size);
}
}
diff --git a/stream/network.h b/stream/network.h
index bc4ec598ef..c00bffd5e5 100644
--- a/stream/network.h
+++ b/stream/network.h
@@ -53,6 +53,9 @@ typedef struct streaming_control {
int (*streaming_read)( int fd, char *buffer, int buffer_size, struct streaming_control *stream_ctrl );
int (*streaming_seek)( int fd, off_t pos, struct streaming_control *stream_ctrl );
void *data;
+ // hacks for asf
+ int *audio_id_ptr;
+ int *video_id_ptr;
} streaming_ctrl_t;
//int streaming_start( stream_t *stream, int *demuxer_type, URL_t *url );
diff --git a/stream/open.c b/stream/open.c
index 5ef0a9e3ff..6a16275fd3 100644
--- a/stream/open.c
+++ b/stream/open.c
@@ -30,7 +30,8 @@ int dvd_title=0;
// Open a new stream (stdin/file/vcd/url)
-stream_t* open_stream(char* filename,char** options, int* file_format){
+stream_t* open_stream(char* filename, struct MPOpts *options, int* file_format)
+{
// Check if playlist or unknown
if (*file_format != DEMUXER_TYPE_PLAYLIST){
*file_format=DEMUXER_TYPE_UNKNOWN;
@@ -45,4 +46,3 @@ if(!filename) {
return open_stream_full(filename,STREAM_READ,options,file_format);
}
-
diff --git a/stream/realrtsp/asmrp.c b/stream/realrtsp/asmrp.c
index d4f7ce8267..aafe76719c 100644
--- a/stream/realrtsp/asmrp.c
+++ b/stream/realrtsp/asmrp.c
@@ -687,4 +687,3 @@ int asmrp_match (const char *rules, int bandwidth, int *matches) {
return num_matches;
}
-
diff --git a/stream/realrtsp/sdpplin.c b/stream/realrtsp/sdpplin.c
index c4104fb00c..5d68d4f397 100644
--- a/stream/realrtsp/sdpplin.c
+++ b/stream/realrtsp/sdpplin.c
@@ -393,4 +393,3 @@ void sdpplin_free(sdpplin_t *description) {
free(description);
}
-
diff --git a/stream/stream.c b/stream/stream.c
index c145d1389e..8b8a84760a 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -32,7 +32,9 @@
//#include "vcd_read_bincue.h"
-static int (*stream_check_interrupt_cb)(int time) = NULL;
+struct input_ctx;
+static int (*stream_check_interrupt_cb)(struct input_ctx *ctx, int time);
+static struct input_ctx *stream_check_interrupt_ctx;
extern const stream_info_t stream_info_vcd;
extern const stream_info_t stream_info_cdda;
@@ -119,9 +121,11 @@ static const stream_info_t* const auto_open_streams[] = {
NULL
};
-stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode,
- char** options, int* file_format, int* ret,
- char** redirected_url) {
+static stream_t *open_stream_plugin(const stream_info_t *sinfo, char *filename,
+ int mode, struct MPOpts *options,
+ int *file_format, int *ret,
+ char **redirected_url)
+{
void* arg = NULL;
stream_t* s;
m_struct_t* desc = (m_struct_t*)sinfo->opts;
@@ -138,18 +142,9 @@ stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode,
return NULL;
}
}
- if(options) {
- int i;
- for(i = 0 ; options[i] != NULL ; i += 2) {
- mp_msg(MSGT_OPEN,MSGL_DBG2, "Set stream arg %s=%s\n",
- options[i],options[i+1]);
- if(!m_struct_set(desc,arg,options[i],options[i+1]))
- mp_msg(MSGT_OPEN,MSGL_WARN, "Failed to set stream option %s=%s\n",
- options[i],options[i+1]);
- }
- }
}
s = new_stream(-2,-2);
+ s->opts = options;
s->url=strdup(filename);
s->flags |= mode;
*ret = sinfo->open(s,mode,arg,file_format);
@@ -186,7 +181,9 @@ stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode,
}
-stream_t* open_stream_full(char* filename,int mode, char** options, int* file_format) {
+stream_t *open_stream_full(char *filename,int mode, struct MPOpts *options,
+ int* file_format)
+{
int i,j,l,r;
const stream_info_t* sinfo;
stream_t* s;
@@ -216,7 +213,7 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo
return s;
}
else if(r != STREAM_UNSUPPORTED) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_FailedToOpen,filename);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR, "Failed to open %s.\n",filename);
return NULL;
}
break;
@@ -228,7 +225,8 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo
return NULL;
}
-stream_t* open_output_stream(char* filename,char** options) {
+stream_t *open_output_stream(char *filename, struct MPOpts *options)
+{
int file_format; //unused
if(!filename) {
mp_msg(MSGT_OPEN,MSGL_ERR,"open_output_stream(), NULL filename, report this bug\n");
@@ -460,11 +458,14 @@ stream_t* new_ds_stream(demux_stream_t *ds) {
return s;
}
-void stream_set_interrupt_callback(int (*cb)(int)) {
+void stream_set_interrupt_callback(int (*cb)(struct input_ctx *, int),
+ struct input_ctx *ctx)
+{
stream_check_interrupt_cb = cb;
+ stream_check_interrupt_ctx = ctx;
}
int stream_check_interrupt(int time) {
if(!stream_check_interrupt_cb) return 0;
- return stream_check_interrupt_cb(time);
+ return stream_check_interrupt_cb(stream_check_interrupt_ctx, time);
}
diff --git a/stream/stream.h b/stream/stream.h
index 2bbe443757..51dbbc925c 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -70,7 +70,7 @@
#include "network.h"
#endif
-struct stream_st;
+struct stream;
typedef struct stream_info_st {
const char *info;
const char *name;
@@ -79,7 +79,7 @@ typedef struct stream_info_st {
/// mode isn't used atm (ie always READ) but it shouldn't be ignored
/// opts is at least in it's defaults settings and may have been
/// altered by url parsing if enabled and the options string parsing.
- int (*open)(struct stream_st* st, int mode, void* opts, int* file_format);
+ int (*open)(struct stream* st, int mode, void* opts, int* file_format);
const char* protocols[MAX_STREAM_PROTOCOLS];
const void* opts;
int opts_url; /* If this is 1 we will parse the url as an option string
@@ -87,19 +87,19 @@ typedef struct stream_info_st {
* options string given to open_stream_plugin */
} stream_info_t;
-typedef struct stream_st {
+typedef struct stream {
// Read
- int (*fill_buffer)(struct stream_st *s, char* buffer, int max_len);
+ int (*fill_buffer)(struct stream *s, char* buffer, int max_len);
// Write
- int (*write_buffer)(struct stream_st *s, char* buffer, int len);
+ int (*write_buffer)(struct stream *s, char* buffer, int len);
// Seek
- int (*seek)(struct stream_st *s,off_t pos);
+ int (*seek)(struct stream *s,off_t pos);
// Control
// Will be later used to let streams like dvd and cdda report
// their structure (ie tracks, chapters, etc)
- int (*control)(struct stream_st *s,int cmd,void* arg);
+ int (*control)(struct stream *s,int cmd,void* arg);
// Close
- void (*close)(struct stream_st *s);
+ void (*close)(struct stream *s);
int fd; // file descriptor, see man open(2)
int type; // see STREAMTYPE_*
@@ -113,20 +113,21 @@ typedef struct stream_st {
void* cache_data;
void* priv; // used for DVD, TV, RTSP etc
char* url; // strdup() of filename/url
+ struct MPOpts *opts;
#ifdef CONFIG_NETWORK
streaming_ctrl_t *streaming_ctrl;
#endif
unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE];
} stream_t;
+int stream_fill_buffer(stream_t *s);
+int stream_seek_long(stream_t *s,off_t pos);
#ifdef CONFIG_STREAM_CACHE
int stream_enable_cache(stream_t *stream,int size,int min,int prefill);
int cache_stream_fill_buffer(stream_t *s);
int cache_stream_seek_long(stream_t *s,off_t pos);
#else
// no cache, define wrappers:
-int stream_fill_buffer(stream_t *s);
-int stream_seek_long(stream_t *s,off_t pos);
#define cache_stream_fill_buffer(x) stream_fill_buffer(x)
#define cache_stream_seek_long(x,y) stream_seek_long(x,y)
#define stream_enable_cache(x,y,z,w) 1
@@ -289,17 +290,20 @@ inline static int stream_skip(stream_t *s,off_t len){
return 1;
}
+struct MPOpts;
void stream_reset(stream_t *s);
int stream_control(stream_t *s, int cmd, void *arg);
stream_t* new_stream(int fd,int type);
void free_stream(stream_t *s);
stream_t* new_memory_stream(unsigned char* data,int len);
-stream_t* open_stream(char* filename,char** options,int* file_format);
-stream_t* open_stream_full(char* filename,int mode, char** options, int* file_format);
-stream_t* open_output_stream(char* filename,char** options);
+stream_t* open_stream(char* filename, struct MPOpts *options,int* file_format);
+stream_t* open_stream_full(char* filename,int mode, struct MPOpts *options, int* file_format);
+stream_t* open_output_stream(char* filename,struct MPOpts *options);
/// Set the callback to be used by libstream to check for user
/// interruption during long blocking operations (cache filling, etc).
-void stream_set_interrupt_callback(int (*cb)(int));
+struct input_ctx;
+void stream_set_interrupt_callback(int (*cb)(struct input_ctx*, int),
+ struct input_ctx *ctx);
/// Call the interrupt checking callback if there is one.
int stream_check_interrupt(int time);
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 2403e85cd4..90172c46c7 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -195,7 +195,7 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
#endif
if(!cdd) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_MPDEMUX_CDDA_CantOpenCDDADevice);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Can't open CDDA device.\n");
m_struct_free(&stream_opts,opts);
free(cddb_info);
return STREAM_ERROR;
@@ -211,7 +211,7 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
}
if(cdda_open(cdd) != 0) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_MPDEMUX_CDDA_CantOpenDisc);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Can't open disc.\n");
cdda_close(cdd);
m_struct_free(&stream_opts,opts);
free(cddb_info);
@@ -219,7 +219,7 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
}
cd_info = cd_info_new();
- mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_MPDEMUX_CDDA_AudioCDFoundWithNTracks,cdda_tracks(cdd));
+ mp_tmsg(MSGT_OPEN,MSGL_INFO,"Found audio CD with %ld tracks.\n",cdda_tracks(cdd));
for(i=0;i<cdd->tracks;i++) {
char track_name[80];
long sec=cdda_track_firstsector(cdd,i+1);
diff --git a/stream/stream_cddb.c b/stream/stream_cddb.c
index 3a51cbc2ec..22e9eb9ad3 100644
--- a/stream/stream_cddb.c
+++ b/stream/stream_cddb.c
@@ -82,7 +82,7 @@ read_toc(const char *dev) {
drive = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if(!DeviceIoControl(drive, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(CDROM_TOC), &r, 0)) {
- mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadTOC);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to read TOC.\n");
return 0;
}
@@ -219,7 +219,7 @@ int cdd_identify(const char *dev)
int i, min, sec, frame;
cdtoc_last_track = read_toc(dev);
if (cdtoc_last_track < 0) {
- mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToOpenDevice, dev);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to open %s device.\n", dev);
return -1;
}
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CDDA_TRACKS=%d\n", cdtoc_last_track);
@@ -278,19 +278,19 @@ cddb_http_request(char *command, int (*reply_parser)(HTTP_header_t*,cddb_data_t*
url = url_new(request);
if( url==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_NotAValidURL);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "not a valid URL\n");
return -1;
}
fd = http_send_request(url,0);
if( fd<0 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToSendHTTPRequest);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Failed to send the HTTP request.\n");
return -1;
}
http_hdr = http_read_response( fd );
if( http_hdr==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadHTTPResponse);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Failed to read the HTTP response.\n");
return -1;
}
@@ -302,10 +302,10 @@ cddb_http_request(char *command, int (*reply_parser)(HTTP_header_t*,cddb_data_t*
ret = reply_parser(http_hdr, cddb_data);
break;
case 400:
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_HTTPErrorNOTFOUND);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Not Found.\n");
break;
default:
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_HTTPErrorUnknown);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "unknown error code\n");
}
http_free( http_hdr );
@@ -331,7 +331,7 @@ cddb_read_cache(cddb_data_t *cddb_data) {
#endif
);
if( file_fd<0 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_NoCacheFound);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "No cache found.\n");
return -1;
}
@@ -345,13 +345,13 @@ cddb_read_cache(cddb_data_t *cddb_data) {
cddb_data->xmcd_file = malloc(file_size+1);
if( cddb_data->xmcd_file==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n");
close(file_fd);
return -1;
}
cddb_data->xmcd_file_size = read(file_fd, cddb_data->xmcd_file, file_size);
if( cddb_data->xmcd_file_size!=file_size ) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, MSGTR_MPDEMUX_CDDB_NotAllXMCDFileHasBeenRead);
+ mp_tmsg(MSGT_DEMUX, MSGL_WARN, "Not all the xmcd file has been read.\n");
close(file_fd);
return -1;
}
@@ -383,7 +383,7 @@ cddb_write_cache(cddb_data_t *cddb_data) {
if( ret<0 ) {
#endif
perror("mkdir");
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToCreateDirectory, cddb_data->cache_dir);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Failed to create directory %s.\n", cddb_data->cache_dir);
return -1;
}
}
@@ -403,7 +403,7 @@ cddb_write_cache(cddb_data_t *cddb_data) {
return -1;
}
if( (unsigned int)wrote!=cddb_data->xmcd_file_size ) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, MSGTR_MPDEMUX_CDDB_NotAllXMCDFileHasBeenWritten);
+ mp_tmsg(MSGT_DEMUX, MSGL_WARN, "Not all of the xmcd file has been written.\n");
close(file_fd);
return -1;
}
@@ -424,7 +424,7 @@ cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
ret = sscanf( http_hdr->body, "%d ", &status);
if( ret!=1 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
@@ -432,13 +432,13 @@ cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
case 210:
ret = sscanf( http_hdr->body, "%d %99s %08lx", &status, category, &disc_id);
if( ret!=3 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
// Check if it's a xmcd database file
ptr = strstr(http_hdr->body, "# xmcd");
if( ptr==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_InvalidXMCDDatabaseReturned);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Invalid xmcd database file returned.\n");
return -1;
}
ptr = strdup(ptr);
@@ -455,7 +455,7 @@ cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
// Ok found the end
// do a sanity check
if( http_hdr->body_size<(unsigned int)(ptr2-ptr) ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_UnexpectedFIXME);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "unexpected FIXME\n");
return -1;
}
cddb_data->xmcd_file = ptr;
@@ -463,7 +463,7 @@ cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
cddb_data->xmcd_file[cddb_data->xmcd_file_size] = '\0';
return cddb_write_cache(cddb_data);
default:
- mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_UnhandledCode);
+ mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "unhandled code\n");
}
return 0;
}
@@ -483,7 +483,7 @@ cddb_parse_matches_list(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
ptr = strstr(http_hdr->body, "\n");
if( ptr==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_UnableToFindEOL);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Unable to find end of line.\n");
return -1;
}
ptr++;
@@ -491,7 +491,7 @@ cddb_parse_matches_list(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
// So let's take the first one.
ret = sscanf(ptr, "%99s %08lx %99s", cddb_data->category, &(cddb_data->disc_id), album_title);
if( ret!=3 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
ptr = strstr(http_hdr->body, album_title);
@@ -508,7 +508,7 @@ cddb_parse_matches_list(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
strncpy(album_title, ptr, len);
album_title[len]='\0';
}
- mp_msg(MSGT_DEMUX, MSGL_STATUS, MSGTR_MPDEMUX_CDDB_ParseOKFoundAlbumTitle, album_title);
+ mp_tmsg(MSGT_DEMUX, MSGL_STATUS, "Parse OK, found: %s\n", album_title);
return 0;
}
@@ -520,7 +520,7 @@ cddb_query_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
ret = sscanf( http_hdr->body, "%d ", &status);
if( ret!=1 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
@@ -529,7 +529,7 @@ cddb_query_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
// Found exact match
ret = sscanf(http_hdr->body, "%d %99s %08lx %99s", &status, cddb_data->category, &(cddb_data->disc_id), album_title);
if( ret!=4 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
ptr = strstr(http_hdr->body, album_title);
@@ -546,11 +546,11 @@ cddb_query_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
strncpy(album_title, ptr, len);
album_title[len]='\0';
}
- mp_msg(MSGT_DEMUX, MSGL_STATUS, MSGTR_MPDEMUX_CDDB_ParseOKFoundAlbumTitle, album_title);
+ mp_tmsg(MSGT_DEMUX, MSGL_STATUS, "Parse OK, found: %s\n", album_title);
return cddb_request_titles(cddb_data);
case 202:
// No match found
- mp_msg(MSGT_DEMUX, MSGL_WARN, MSGTR_MPDEMUX_CDDB_AlbumNotFound);
+ mp_tmsg(MSGT_DEMUX, MSGL_WARN, "Album not found.\n");
break;
case 210:
// Found exact matches, list follows
@@ -568,10 +568,10 @@ blues c711930d Santana / Supernatural
cddb_parse_matches_list(http_hdr, cddb_data);
return cddb_request_titles(cddb_data);
case 500:
- mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_ServerReturnsCommandSyntaxErr);
+ mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "Server returns: Command syntax error\n");
break;
default:
- mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_UnhandledCode);
+ mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "unhandled code\n");
}
return -1;
}
@@ -584,7 +584,7 @@ cddb_proto_level_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
ret = sscanf( http_hdr->body, "%d ", &status);
if( ret!=1 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
@@ -592,18 +592,18 @@ cddb_proto_level_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
case 210:
ptr = strstr(http_hdr->body, "max proto:");
if( ptr==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
ret = sscanf(ptr, "max proto: %d", &max);
if( ret!=1 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
cddb_data->freedb_proto_level = max;
return 0;
default:
- mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_UnhandledCode);
+ mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "unhandled code\n");
}
return -1;
}
@@ -619,7 +619,7 @@ cddb_freedb_sites_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
ret = sscanf( http_hdr->body, "%d ", &status);
if( ret!=1 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error");
return -1;
}
@@ -629,10 +629,10 @@ cddb_freedb_sites_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
ret = cddb_data->anonymous; // For gcc complaining about unused parameter.
return 0;
case 401:
- mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_NoSitesInfoAvailable);
+ mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "No sites information available.\n");
break;
default:
- mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_UnhandledCode);
+ mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "unhandled code\n");
}
return -1;
}
@@ -685,7 +685,7 @@ cddb_retrieve(cddb_data_t *cddb_data) {
cddb_create_hello(cddb_data);
if( cddb_get_proto_level(cddb_data)<0 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToGetProtocolLevel);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Failed to get the protocol level.\n");
return -1;
}
@@ -711,7 +711,7 @@ cddb_resolve(const char *dev, char **xmcd_file) {
{
cdtoc_last_track = read_toc(dev);
if (cdtoc_last_track < 0) {
- mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToOpenDevice, dev);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to open %s device.\n", dev);
return -1;
}
}
@@ -724,7 +724,7 @@ cddb_resolve(const char *dev, char **xmcd_file) {
// Check if there is a CD in the drive
// FIXME: That's not really a good way to check
if( cddb_data.disc_id==0 ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_NoCDInDrive);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "No CD in the drive.\n");
return -1;
}
@@ -740,7 +740,7 @@ cddb_resolve(const char *dev, char **xmcd_file) {
} else {
cddb_data.cache_dir = malloc(strlen(home_dir)+strlen(cddb_cache_dir)+1);
if( cddb_data.cache_dir==NULL ) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n");
return -1;
}
sprintf(cddb_data.cache_dir, "%s%s", home_dir, cddb_cache_dir );
diff --git a/stream/stream_cue.c b/stream/stream_cue.c
index ea9337afb1..ac1bdfc4f4 100644
--- a/stream/stream_cue.c
+++ b/stream/stream_cue.c
@@ -147,8 +147,8 @@ static int cue_getTrackinfo(char *Line, tTrack *track)
}
else if (strncmp(&Line[4], "PREGAP ", 7)==0) { ; /* ignore */ }
else if (strncmp(&Line[4], "FLAGS ", 6)==0) { ; /* ignore */ }
- else mp_msg (MSGT_OPEN,MSGL_INFO,
- MSGTR_MPDEMUX_CUEREAD_UnexpectedCuefileLine, Line);
+ else mp_tmsg (MSGT_OPEN,MSGL_INFO,
+ "[bincue] Unexpected cuefile line: %s\n", Line);
}
return 0;
}
@@ -199,7 +199,7 @@ static int cue_find_bin (char *firstline) {
fd_bin = open (bin_filename, O_RDONLY);
if (fd_bin == -1)
{
- mp_msg(MSGT_OPEN,MSGL_STATUS, MSGTR_MPDEMUX_CUEREAD_BinFilenameTested,
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS, "[bincue] bin filename tested: %s\n",
bin_filename);
/* now try to find it with the path of the cue file */
@@ -207,8 +207,8 @@ static int cue_find_bin (char *firstline) {
fd_bin = open (s, O_RDONLY);
if (fd_bin == -1)
{
- mp_msg(MSGT_OPEN,MSGL_STATUS,
- MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,
+ "[bincue] bin filename tested: %s\n", s);
/* now I would say the whole filename is shit, build our own */
strncpy(s, cue_filename, strlen(cue_filename) - 3 );
s[strlen(cue_filename) - 3] = '\0';
@@ -216,16 +216,16 @@ static int cue_find_bin (char *firstline) {
fd_bin = open (s, O_RDONLY);
if (fd_bin == -1)
{
- mp_msg(MSGT_OPEN,MSGL_STATUS,
- MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,
+ "[bincue] bin filename tested: %s\n", s);
/* ok try it with path */
snprintf(t, sizeof( t ), "%s/%s", bincue_path, s);
fd_bin = open (t, O_RDONLY);
if (fd_bin == -1)
{
- mp_msg(MSGT_OPEN,MSGL_STATUS,
- MSGTR_MPDEMUX_CUEREAD_BinFilenameTested,t);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,
+ "[bincue] bin filename tested: %s\n",t);
/* now I would say the whole filename is shit, build our own */
strncpy(s, cue_filename, strlen(cue_filename) - 3 );
s[strlen(cue_filename) - 3] = '\0';
@@ -233,19 +233,19 @@ static int cue_find_bin (char *firstline) {
fd_bin = open (s, O_RDONLY);
if (fd_bin == -1)
{
- mp_msg(MSGT_OPEN,MSGL_STATUS,
- MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,
+ "[bincue] bin filename tested: %s\n", s);
/* ok try it with path */
snprintf(t, sizeof( t ), "%s/%s", bincue_path, s);
fd_bin = open (t, O_RDONLY);
if (fd_bin == -1)
{
- mp_msg(MSGT_OPEN,MSGL_STATUS,
- MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,
+ "[bincue] bin filename tested: %s\n", s);
/* I'll give up */
- mp_msg(MSGT_OPEN,MSGL_ERR,
- MSGTR_MPDEMUX_CUEREAD_CannotFindBinFile);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,
+ "[bincue] Couldn't find the bin file - giving up.\n");
return -1;
}
}
@@ -257,8 +257,8 @@ static int cue_find_bin (char *firstline) {
}
- mp_msg(MSGT_OPEN,MSGL_INFO,
- MSGTR_MPDEMUX_CUEREAD_UsingBinFile, bin_filename);
+ mp_tmsg(MSGT_OPEN,MSGL_INFO,
+ "[bincue] Using bin file %s.\n", bin_filename);
return 0;
}
@@ -291,8 +291,8 @@ static inline int cue_mode_2_sector_size(int mode)
case MODE2_2336: return SIZEISO_MODE2_FORM2;
default:
- mp_msg(MSGT_OPEN,MSGL_FATAL,
- MSGTR_MPDEMUX_CUEREAD_UnknownModeForBinfile);
+ mp_tmsg(MSGT_OPEN,MSGL_FATAL,
+ "[bincue] unknown mode for binfile. Should not happen. Aborting.\n");
abort();
}
@@ -342,8 +342,8 @@ static int cue_read_cue (char *in_cue_filename)
fd_cue = fopen (in_cue_filename, "r");
if (fd_cue == NULL)
{
- mp_msg(MSGT_OPEN,MSGL_ERR,
- MSGTR_MPDEMUX_CUEREAD_CannotOpenCueFile, in_cue_filename);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,
+ "[bincue] Cannot open %s.\n", in_cue_filename);
return -1;
}
@@ -352,8 +352,8 @@ static int cue_read_cue (char *in_cue_filename)
if(! fgets( sLine, 256, fd_cue ) )
{
- mp_msg(MSGT_OPEN,MSGL_ERR,
- MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,
+ "[bincue] Error reading from %s\n", in_cue_filename);
fclose (fd_cue);
return -1;
}
@@ -368,8 +368,8 @@ static int cue_read_cue (char *in_cue_filename)
/* red the next line and call our track finder */
if(! fgets( sLine, 256, fd_cue ) )
{
- mp_msg(MSGT_OPEN,MSGL_ERR,
- MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,
+ "[bincue] Error reading from %s\n", in_cue_filename);
fclose (fd_cue);
return -1;
}
@@ -378,8 +378,8 @@ static int cue_read_cue (char *in_cue_filename)
{
if (cue_getTrackinfo(sLine, &tracks[nTracks++]) != 0)
{
- mp_msg(MSGT_OPEN,MSGL_ERR,
- MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,
+ "[bincue] Error reading from %s\n", in_cue_filename);
fclose (fd_cue);
return -1;
}
@@ -387,8 +387,8 @@ static int cue_read_cue (char *in_cue_filename)
/* make a fake track with stands for the Lead out */
if (fstat (fd_bin, &filestat) == -1) {
- mp_msg(MSGT_OPEN,MSGL_ERR,
- MSGTR_MPDEMUX_CUEREAD_ErrGettingBinFileSize);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,
+ "[bincue] Error getting size of bin file.\n");
fclose (fd_cue);
return -1;
}
@@ -482,8 +482,8 @@ static void cue_vcd_read_toc(void){
int i;
for (i = 0; i < nTracks; ++i) {
- mp_msg(MSGT_OPEN,MSGL_INFO,
- MSGTR_MPDEMUX_CUEREAD_InfoTrackFormat,
+ mp_tmsg(MSGT_OPEN,MSGL_INFO,
+ "track %02d: format=%d %02d:%02d:%02d\n",
i+1,
tracks[i].mode,
tracks[i].minute,
@@ -509,12 +509,12 @@ static int cue_vcd_read(stream_t *stream, char *mem, int size) {
return 0;
if(lseek(fd_bin, position+VCD_SECTOR_OFFS, SEEK_SET) == -1) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_MPDEMUX_CUEREAD_UnexpectedBinFileEOF);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR, "[bincue] unexpected end of bin file\n");
return 0;
}
if(read(fd_bin, mem, VCD_SECTOR_DATA) != VCD_SECTOR_DATA) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_MPDEMUX_CUEREAD_CannotReadNBytesOfPayload, VCD_SECTOR_DATA);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR, "[bincue] Couldn't read %d bytes of payload.\n", VCD_SECTOR_DATA);
return 0;
}
@@ -570,10 +570,10 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
ret2=cue_vcd_get_track_end(track);
ret=cue_vcd_seek_to_track(track);
if(ret<0){
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Error selecting VCD track." " (seek)\n");
return STREAM_UNSUPPORTED;
}
- mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_MPDEMUX_CUEREAD_CueStreamInfo_FilenameTrackTracksavail, filename, track, ret, ret2);
+ mp_tmsg(MSGT_OPEN,MSGL_INFO,"CUE stream_open, filename=%s, track=%d, available tracks: %d -> %d\n", filename, track, ret, ret2);
stream->fd = f;
stream->type = STREAMTYPE_VCDBINCUE;
@@ -599,4 +599,3 @@ const stream_info_t stream_info_cue = {
&stream_opts,
1 // Urls are an option string
};
-
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index 4047e84080..09429cbf08 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -66,13 +66,13 @@ static void dvd_set_speed(char *device, unsigned speed)
return;
case -1: /* restore default value */
if (dvd_speed == 0) return; /* we haven't touched the speed setting */
- mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDrestoreSpeed);
+ mp_tmsg(MSGT_OPEN, MSGL_INFO, "Restoring DVD speed... ");
break;
default: /* limit to <speed> KB/s */
// speed < 100 is multiple of DVD single speed (1350KB/s)
if (speed < 100)
speed *= 1350;
- mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitSpeed, speed);
+ mp_tmsg(MSGT_OPEN, MSGL_INFO, "Limiting DVD speed to %dKB/s... ", speed);
break;
}
@@ -105,14 +105,14 @@ static void dvd_set_speed(char *device, unsigned speed)
fd = open(device, O_RDWR | O_NONBLOCK);
if (fd == -1) {
- mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDspeedCantOpen);
+ mp_tmsg(MSGT_OPEN, MSGL_INFO, "Couldn't open DVD device for writing, changing DVD speed needs write access.\n");
return;
}
if (ioctl(fd, SG_IO, &sghdr) < 0)
- mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitFail);
+ mp_tmsg(MSGT_OPEN, MSGL_INFO, "failed\n");
else
- mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitOk);
+ mp_tmsg(MSGT_OPEN, MSGL_INFO, "successful\n");
close(fd);
#endif
@@ -170,26 +170,26 @@ int dvd_parse_chapter_range(const m_option_t *conf, const char *range) {
if(*range && isdigit(*range)) {
dvd_chapter = strtol(range, &s, 10);
if(range == s) {
- mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
return M_OPT_INVALID;
}
}
if(*s == 0)
return 0;
else if(*s != '-') {
- mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
return M_OPT_INVALID;
}
++s;
if(*s == 0)
return 0;
if(! isdigit(*s)) {
- mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
return M_OPT_INVALID;
}
dvd_last_chapter = strtol(s, &t, 10);
if (s == t || *t) {
- mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range);
+ mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
return M_OPT_INVALID;
}
return 0;
@@ -245,7 +245,7 @@ int dvd_aid_from_lang(stream_t *stream, unsigned char* lang) {
code=lang[1]|(lang[0]<<8);
for(i=0;i<d->nr_of_channels;i++) {
if(d->audio_streams[i].language==code) {
- mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDaudioChannel,
+ mp_tmsg(MSGT_OPEN,MSGL_INFO,"Selected DVD audio channel: %d language: %c%c\n",
d->audio_streams[i].id, lang[0],lang[1]);
return d->audio_streams[i].id;
}
@@ -253,7 +253,7 @@ int dvd_aid_from_lang(stream_t *stream, unsigned char* lang) {
}
lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang;
}
- mp_msg(MSGT_OPEN,MSGL_WARN,MSGTR_DVDnoMatchingAudio);
+ mp_tmsg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n");
}
return -1;
}
@@ -288,14 +288,14 @@ int dvd_sid_from_lang(stream_t *stream, unsigned char* lang) {
code=lang[1]|(lang[0]<<8);
for(i=0;i<d->nr_of_subtitles;i++) {
if(d->subtitles[i].language==code) {
- mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDsubtitleChannel, i, lang[0],lang[1]);
+ mp_tmsg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n", i, lang[0],lang[1]);
return d->subtitles[i].id;
}
}
lang+=2;
while (lang[0]==',' || lang[0]==' ') ++lang;
}
- mp_msg(MSGT_OPEN,MSGL_WARN,MSGTR_DVDnoMatchingSubtitle);
+ mp_tmsg(MSGT_OPEN,MSGL_WARN,"No matching DVD subtitle language found!\n");
return -1;
}
@@ -324,7 +324,7 @@ static int dvd_next_cell(dvd_priv_t *d) {
return next_cell;
}
-int dvd_read_sector(dvd_priv_t *d,unsigned char* data) {
+static int dvd_read_sector(dvd_priv_t *d,unsigned char* data) {
int len;
if(d->packs_left==0) {
@@ -444,7 +444,7 @@ read_next:
return d->cur_pack-1;
}
-void dvd_seek(dvd_priv_t *d,int pos) {
+static void dvd_seek(dvd_priv_t *d,int pos) {
d->packs_left=-1;
d->cur_pack=pos;
@@ -482,7 +482,7 @@ void dvd_seek(dvd_priv_t *d,int pos) {
d->angle_seek=1;
}
-void dvd_close(dvd_priv_t *d) {
+static void dvd_close(dvd_priv_t *d) {
ifoClose(d->vts_file);
ifoClose(d->vmg_file);
DVDCloseFile(d->title);
@@ -813,12 +813,12 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
snprintf(temp_device, len, "/dev/rdisk%d", i);
dvd = DVDOpen(temp_device);
if(!dvd) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,temp_device, strerror(errno));
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno));
} else {
#if DVDREAD_VERSION <= LIBDVDREAD_VERSION(0,9,4)
dvd_file_t *dvdfile = DVDOpenFile(dvd,dvd_title,DVD_READ_INFO_FILE);
if(!dvdfile) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,temp_device, strerror(errno));
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno));
DVDClose(dvd);
continue;
}
@@ -838,7 +838,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
{
dvd = DVDOpen(dvd_device_current);
if(!dvd) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device_current, strerror(errno));
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Couldn't open DVD device: %s (%s)\n",dvd_device_current, strerror(errno));
m_struct_free(&stream_opts,opts);
return STREAM_UNSUPPORTED;
}
@@ -852,7 +852,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
*/
vmg_file = ifoOpen(dvd, 0);
if(!vmg_file) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVMG);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n");
DVDClose( dvd );
m_struct_free(&stream_opts,opts);
return STREAM_UNSUPPORTED;
@@ -889,9 +889,9 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
/**
* Make sure our title number is valid.
*/
- mp_msg(MSGT_OPEN,MSGL_STATUS, MSGTR_DVDnumTitles, tt_srpt->nr_of_srpts );
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS, "There are %d titles on this DVD.\n", tt_srpt->nr_of_srpts );
if(dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR, "Invalid DVD title number: %d\n", dvd_title);
ifoClose( vmg_file );
DVDClose( dvd );
m_struct_free(&stream_opts,opts);
@@ -902,9 +902,9 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
/**
* Make sure the angle number is valid for this title.
*/
- mp_msg(MSGT_OPEN,MSGL_STATUS, MSGTR_DVDnumAngles, tt_srpt->title[dvd_title].nr_of_angles);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS, "There are %d angles in this DVD title.\n", tt_srpt->title[dvd_title].nr_of_angles);
if(dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR, "Invalid DVD angle number: %d\n", dvd_angle);
goto fail;
}
--dvd_angle; // remap 1.. -> 0..
@@ -915,7 +915,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
*/
vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr );
if(!vts_file) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO, tt_srpt->title[dvd_title].title_set_nr );
+ mp_tmsg(MSGT_OPEN,MSGL_ERR, "Cannot open the IFO file for DVD title %d.\n", tt_srpt->title[dvd_title].title_set_nr );
goto fail;
}
/**
@@ -923,7 +923,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
*/
title = DVDOpenFile(dvd, tt_srpt->title[dvd_title].title_set_nr, DVD_READ_TITLE_VOBS);
if(!title) {
- mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs, tt_srpt->title[dvd_title].title_set_nr);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR, "Cannot open title VOBS (VTS_%02d_1.VOB).\n", tt_srpt->title[dvd_title].title_set_nr);
ifoClose( vts_file );
goto fail;
}
@@ -983,7 +983,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
// 1 - stereo
// 5 - 5.1
audio_stream->channels=audio->channels;
- mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDaudioStreamInfo,
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,"audio stream: %d format: %s (%s) language: %s aid: %d.\n",
d->nr_of_channels,
dvd_audio_stream_types[ audio->audio_format ],
dvd_audio_stream_channels[ audio->channels ],
@@ -997,7 +997,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
d->nr_of_channels++;
}
}
- mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDnumAudioChannels,d->nr_of_channels );
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,"number of audio channels on disk: %d.\n",d->nr_of_channels );
}
/**
@@ -1029,13 +1029,13 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
else if(video->display_aspect_ratio == 3) /* 16:9 */
sub_stream->id = pgc->subp_control[i] >> 8 & 31;
- mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDsubtitleLanguage, sub_stream->id, tmp);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,"subtitle ( sid ): %d language: %s\n", sub_stream->id, tmp);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sub_stream->id);
if(language && tmp[0])
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", sub_stream->id, tmp);
d->nr_of_subtitles++;
}
- mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDnumSubtitles,d->nr_of_subtitles);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,"number of subtitles on disk: %d\n",d->nr_of_subtitles);
}
/**
@@ -1087,7 +1087,7 @@ fail:
m_struct_free(&stream_opts, opts);
return STREAM_UNSUPPORTED;
}
- mp_msg(MSGT_DVD,MSGL_ERR,MSGTR_NoDVDSupport);
+ mp_tmsg(MSGT_DVD,MSGL_ERR,"MPlayer was compiled without DVD support, exiting.\n");
m_struct_free(&stream_opts,opts);
return STREAM_UNSUPPORTED;
}
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index ea8a28fe5f..1700463787 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -541,7 +541,7 @@ static void show_audio_subs_languages(dvdnav_t *nav)
format = 1; //unknown
id = i + base[format];
if (lang != 0xFFFF) {
- mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDaudioStreamInfo, i,
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,"audio stream: %d format: %s (%s) language: %s aid: %d.\n", i,
dvd_audio_stream_types[format], dvd_audio_stream_channels[channels], tmp, id);
if(lang && tmp[0])
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", id, tmp);
@@ -562,7 +562,7 @@ static void show_audio_subs_languages(dvdnav_t *nav)
}
tmp[2] = 0;
if (lang != 0xFFFF)
- mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDsubtitleLanguage, i+0x20, tmp);
+ mp_tmsg(MSGT_OPEN,MSGL_STATUS,"subtitle ( sid ): %d language: %s\n", i+0x20, tmp);
}
}
@@ -575,7 +575,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
else if(dvd_device) filename= dvd_device;
else filename = DEFAULT_DVD_DEVICE;
if(!(priv=new_dvdnav_stream(filename))) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename, strerror(errno));
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Couldn't open DVD device: %s (%s)\n",filename, strerror(errno));
return STREAM_UNSUPPORTED;
}
diff --git a/stream/stream_file.c b/stream/stream_file.c
index e113e6788e..9514204a3b 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -126,7 +126,7 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
if(!strcmp(filename,"-")){
if(mode == STREAM_READ) {
// read from stdin
- mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN);
+ mp_tmsg(MSGT_OPEN,MSGL_INFO,"Reading from stdin...\n");
f=0; // 0=stdin
#if defined(__MINGW32__) || defined(__OS2__)
setmode(fileno(stdin),O_BINARY);
@@ -145,7 +145,7 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
#endif
f=open(filename,m, openmode);
if(f<0) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"File not found: '%s'\n",filename);
m_struct_free(&stream_opts,opts);
return STREAM_ERROR;
}
diff --git a/stream/stream_live555.c b/stream/stream_live555.c
index 619a8d90af..8d92134f5e 100644
--- a/stream/stream_live555.c
+++ b/stream/stream_live555.c
@@ -67,7 +67,7 @@ static int open_live_sdp(stream_t *stream,int mode, void* opts, int* file_format
f = open(filename,O_RDONLY);
#endif
if(f < 0) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"File not found: '%s'\n",filename);
return STREAM_ERROR;
}
diff --git a/stream/stream_nemesi.c b/stream/stream_nemesi.c
index 8333ba75ba..7cc4ccafa5 100644
--- a/stream/stream_nemesi.c
+++ b/stream/stream_nemesi.c
@@ -77,4 +77,3 @@ const stream_info_t stream_info_rtsp = {
NULL,
0 /* Urls are an option string */
};
-
diff --git a/stream/stream_netstream.c b/stream/stream_netstream.c
index ea410c41e7..0d35462aaa 100644
--- a/stream/stream_netstream.c
+++ b/stream/stream_netstream.c
@@ -201,7 +201,7 @@ static int seek(stream_t *s,off_t newpos) {
return 1;
}
-static int net_stream_reset(struct stream_st *s) {
+static int net_stream_reset(struct stream *s) {
mp_net_stream_packet_t* pack;
pack = send_net_stream_cmd(s,NET_STREAM_RESET,NULL,0);
@@ -212,7 +212,7 @@ static int net_stream_reset(struct stream_st *s) {
return 1;
}
-static int control(struct stream_st *s,int cmd,void* arg) {
+static int control(struct stream *s,int cmd,void* arg) {
switch(cmd) {
case STREAM_CTRL_RESET:
return net_stream_reset(s);
@@ -220,7 +220,7 @@ static int control(struct stream_st *s,int cmd,void* arg) {
return STREAM_UNSUPPORTED;
}
-static void close_s(struct stream_st *s) {
+static void close_s(struct stream *s) {
mp_net_stream_packet_t* pack;
pack = send_net_stream_cmd(s,NET_STREAM_CLOSE,NULL,0);
diff --git a/stream/stream_radio.c b/stream/stream_radio.c
index 49d75090a9..d25187f17b 100644
--- a/stream/stream_radio.c
+++ b/stream/stream_radio.c
@@ -155,7 +155,7 @@ static const struct m_struct_st stream_opts = {
stream_opts_fields
};
-static void close_s(struct stream_st * stream);
+static void close_s(struct stream *stream);
#ifdef CONFIG_RADIO_CAPTURE
static int clear_buffer(radio_priv_t* priv);
#endif
@@ -183,7 +183,7 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
/*parsing channels string*/
channels=priv->radio_param->channels;
- mp_msg(MSGT_RADIO, MSGL_INFO, MSGTR_RADIO_ChannelNamesDetected);
+ mp_tmsg(MSGT_RADIO, MSGL_INFO, "[radio] Radio channel names detected.\n");
priv->radio_channel_list = malloc(sizeof(radio_channels_t));
priv->radio_channel_list->index=1;
priv->radio_channel_list->next=NULL;
@@ -201,7 +201,7 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
priv->radio_channel_current->freq=atof(tmp);
if ((priv->radio_channel_current->freq>priv->rangehigh)||(priv->radio_channel_current->freq<priv->rangelow))
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_WrongFreqForChannel,
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Wrong frequency for channel %s\n",
priv->radio_channel_current->name);
while ((sep=strchr(priv->radio_channel_current->name, '_'))) sep[0] = ' ';
@@ -227,17 +227,17 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
priv->radio_channel_current = priv->radio_channel_current->next;
if (priv->radio_channel_current->index!=channel){
if (((float)((int)freq_channel))!=freq_channel)
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_WrongChannelNumberFloat,freq_channel);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Wrong channel number: %.2f\n",freq_channel);
else
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_WrongChannelNumberInt,(int)freq_channel);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Wrong channel number: %d\n",(int)freq_channel);
return STREAM_ERROR;
}
- mp_msg(MSGT_RADIO, MSGL_INFO, MSGTR_RADIO_SelectedChannel, priv->radio_channel_current->index,
+ mp_tmsg(MSGT_RADIO, MSGL_INFO, "[radio] Selected channel: %d - %s (freq: %.2f)\n", priv->radio_channel_current->index,
priv->radio_channel_current->name, priv->radio_channel_current->freq);
*pfreq=priv->radio_channel_current->freq;
}else{
if (freq_channel){
- mp_msg(MSGT_RADIO, MSGL_INFO, MSGTR_RADIO_FreqParameterDetected);
+ mp_tmsg(MSGT_RADIO, MSGL_INFO, "[radio] Radio frequency parameter detected.\n");
priv->radio_channel_list=malloc(sizeof(radio_channels_t));
priv->radio_channel_list->next=NULL;
priv->radio_channel_list->prev=NULL;
@@ -248,7 +248,7 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
*pfreq=freq_channel;
}
}
- mp_msg(MSGT_RADIO, MSGL_DBG2, MSGTR_RADIO_DoneParsingChannels);
+ mp_tmsg(MSGT_RADIO, MSGL_DBG2, "[radio] Done parsing channels.\n");
return STREAM_OK;
}
@@ -271,25 +271,25 @@ static int init_frac_v4l2(radio_priv_t* priv){
memset(&tuner,0,sizeof(tuner));
tuner.index=0;
if (ioctl(priv->radio_fd, VIDIOC_G_TUNER, &tuner)<0){
- mp_msg(MSGT_RADIO,MSGL_WARN,MSGTR_RADIO_GetTunerFailed,strerror(errno),priv->frac);
+ mp_tmsg(MSGT_RADIO,MSGL_WARN,"[radio] Warning: ioctl get tuner failed: %s. Setting frac to %d.\n",strerror(errno),priv->frac);
return STREAM_ERROR;
}
if(tuner.type!=V4L2_TUNER_RADIO){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_NotRadioDevice,priv->radio_param->device);
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] %s is no radio device!\n",priv->radio_param->device);
return STREAM_ERROR;
}
if(tuner.capability & V4L2_TUNER_CAP_LOW){
priv->frac=16000;
- mp_msg(MSGT_RADIO,MSGL_DBG2,MSGTR_RADIO_TunerCapLowYes,priv->frac);
+ mp_tmsg(MSGT_RADIO,MSGL_DBG2,"[radio] tuner is low:yes frac=%d\n",priv->frac);
}
else{
priv->frac=16;
- mp_msg(MSGT_RADIO,MSGL_DBG2,MSGTR_RADIO_TunerCapLowNo,priv->frac);
+ mp_tmsg(MSGT_RADIO,MSGL_DBG2,"[radio] tuner is low:no frac=%d\n",priv->frac);
}
priv->rangelow=((float)tuner.rangelow)/priv->frac;
priv->rangehigh=((float)tuner.rangehigh)/priv->frac;
- mp_msg(MSGT_RADIO,MSGL_V,MSGTR_RADIO_FreqRange,priv->rangelow,priv->rangehigh);
+ mp_tmsg(MSGT_RADIO,MSGL_V,"[radio] Allowed frequency range is %.2f-%.2f MHz.\n",priv->rangelow,priv->rangehigh);
return STREAM_OK;
}
@@ -306,7 +306,7 @@ static int set_frequency_v4l2(radio_priv_t* priv,float frequency){
freq.type=V4L2_TUNER_RADIO;
freq.frequency=frequency*priv->frac;
if(ioctl(priv->radio_fd,VIDIOC_S_FREQUENCY,&freq)<0){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_SetFreqFailed,freq.frequency,
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl set frequency 0x%x (%.2f) failed: %s\n",freq.frequency,
frequency,strerror(errno));
return STREAM_ERROR;
}
@@ -322,7 +322,7 @@ static int get_frequency_v4l2(radio_priv_t* priv,float* frequency){
struct v4l2_frequency freq;
memset(&freq,0,sizeof(freq));
if (ioctl(priv->radio_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_GetFreqFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl get frequency failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
*frequency=((float)freq.frequency)/priv->frac;
@@ -346,13 +346,13 @@ static void set_volume_v4l2(radio_priv_t* priv,int volume){
control.id=V4L2_CID_AUDIO_MUTE;
control.value = (volume==0?1:0);
if (ioctl(priv->radio_fd, VIDIOC_S_CTRL, &control)<0){
- mp_msg(MSGT_RADIO,MSGL_WARN,MSGTR_RADIO_SetMuteFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_WARN,"[radio] ioctl set mute failed: %s\n",strerror(errno));
}
memset(&qctrl,0,sizeof(qctrl));
qctrl.id = V4L2_CID_AUDIO_VOLUME;
if (ioctl(priv->radio_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
- mp_msg(MSGT_RADIO, MSGL_WARN, MSGTR_RADIO_QueryControlFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO, MSGL_WARN, "[radio] ioctl query control failed: %s\n",strerror(errno));
return;
}
@@ -360,7 +360,7 @@ static void set_volume_v4l2(radio_priv_t* priv,int volume){
control.id=V4L2_CID_AUDIO_VOLUME;
control.value=qctrl.minimum+volume*(qctrl.maximum-qctrl.minimum)/100;
if (ioctl(priv->radio_fd, VIDIOC_S_CTRL, &control) < 0) {
- mp_msg(MSGT_RADIO, MSGL_WARN,MSGTR_RADIO_SetVolumeFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO, MSGL_WARN,"[radio] ioctl set volume failed: %s\n",strerror(errno));
}
}
@@ -376,14 +376,14 @@ static int get_volume_v4l2(radio_priv_t* priv,int* volume){
memset(&qctrl,0,sizeof(qctrl));
qctrl.id = V4L2_CID_AUDIO_VOLUME;
if (ioctl(priv->radio_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_QueryControlFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] ioctl query control failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
memset(&control,0,sizeof(control));
control.id=V4L2_CID_AUDIO_VOLUME;
if (ioctl(priv->radio_fd, VIDIOC_G_CTRL, &control) < 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR,MSGTR_RADIO_GetVolumeFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO, MSGL_ERR,"[radio] ioctl get volume failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
@@ -402,7 +402,7 @@ static int get_volume_v4l2(radio_priv_t* priv,int* volume){
/* v4l2 driver info structure */
static const radio_driver_t radio_driver_v4l2={
"v4l2",
- MSGTR_RADIO_DriverV4L2,
+ _("[radio] Using V4Lv1 radio interface.\n")2,
init_frac_v4l2,
set_volume_v4l2,
get_volume_v4l2,
@@ -428,20 +428,20 @@ static int init_frac_v4l(radio_priv_t* priv){
struct video_tuner tuner;
memset(&tuner,0,sizeof(tuner));
if (ioctl(priv->radio_fd, VIDIOCGTUNER, &tuner) <0){
- mp_msg(MSGT_RADIO,MSGL_WARN,MSGTR_RADIO_GetTunerFailed,strerror(errno),priv->frac);
+ mp_tmsg(MSGT_RADIO,MSGL_WARN,"[radio] Warning: ioctl get tuner failed: %s. Setting frac to %d.\n",strerror(errno),priv->frac);
return STREAM_ERROR;
}
if(tuner.flags & VIDEO_TUNER_LOW){
priv->frac=16000;
- mp_msg(MSGT_RADIO,MSGL_DBG2,MSGTR_RADIO_TunerCapLowYes,priv->frac);
+ mp_tmsg(MSGT_RADIO,MSGL_DBG2,"[radio] tuner is low:yes frac=%d\n",priv->frac);
}else{
priv->frac=16;
- mp_msg(MSGT_RADIO,MSGL_DBG2,MSGTR_RADIO_TunerCapLowNo,priv->frac);
+ mp_tmsg(MSGT_RADIO,MSGL_DBG2,"[radio] tuner is low:no frac=%d\n",priv->frac);
}
priv->rangelow=((float)tuner.rangelow)/priv->frac;
priv->rangehigh=((float)tuner.rangehigh)/priv->frac;
- mp_msg(MSGT_RADIO,MSGL_V,MSGTR_RADIO_FreqRange,priv->rangelow,priv->rangehigh);
+ mp_tmsg(MSGT_RADIO,MSGL_V,"[radio] Allowed frequency range is %.2f-%.2f MHz.\n",priv->rangelow,priv->rangehigh);
return STREAM_OK;
}
@@ -455,7 +455,7 @@ static int set_frequency_v4l(radio_priv_t* priv,float frequency){
__u32 freq;
freq=frequency*priv->frac;
if (ioctl(priv->radio_fd, VIDIOCSFREQ, &freq) < 0) {
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_SetFreqFailed,freq,frequency,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl set frequency 0x%x (%.2f) failed: %s\n",freq,frequency,strerror(errno));
return STREAM_ERROR;
}
return STREAM_OK;
@@ -468,7 +468,7 @@ static int set_frequency_v4l(radio_priv_t* priv,float frequency){
static int get_frequency_v4l(radio_priv_t* priv,float* frequency){
__u32 freq;
if (ioctl(priv->radio_fd, VIDIOCGFREQ, &freq) < 0) {
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_GetFreqFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl get frequency failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
*frequency=((float)freq)/priv->frac;
@@ -490,7 +490,7 @@ static void set_volume_v4l(radio_priv_t* priv,int volume){
memset(&audio,0,sizeof(audio));
audio.flags = (volume==0?VIDEO_AUDIO_MUTE:0);
if (ioctl(priv->radio_fd, VIDIOCSAUDIO, &audio)<0){
- mp_msg(MSGT_RADIO,MSGL_WARN,MSGTR_RADIO_SetMuteFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_WARN,"[radio] ioctl set mute failed: %s\n",strerror(errno));
}
memset(&audio,0,sizeof(audio));
@@ -500,7 +500,7 @@ static void set_volume_v4l(radio_priv_t* priv,int volume){
audio.volume = volume* (65535 / 100);
if (ioctl(priv->radio_fd, VIDIOCSAUDIO, &audio) < 0){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_SetVolumeFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl set volume failed: %s\n",strerror(errno));
}
}
@@ -515,7 +515,7 @@ static int get_volume_v4l(radio_priv_t* priv,int* volume){
memset(&audio,0,sizeof(audio));
audio.audio=0;
if (ioctl(priv->radio_fd, VIDIOCGAUDIO, &audio) < 0){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_GetVolumeFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl get volume failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
@@ -533,7 +533,7 @@ static int get_volume_v4l(radio_priv_t* priv,int* volume){
/* v4l driver info structure */
static const radio_driver_t radio_driver_v4l={
"v4l",
- MSGTR_RADIO_DriverV4L,
+ _("[radio] Using V4Lv1 radio interface.\n"),
init_frac_v4l,
set_volume_v4l,
get_volume_v4l,
@@ -576,7 +576,7 @@ static int set_frequency_bsdbt848(radio_priv_t* priv,float frequency){
unsigned int freq;
freq=frequency*priv->frac;
if(ioctl(priv->radio_fd,RADIO_SETFREQ,&freq)<0){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_SetFreqFailed,freq, frequency, strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl set frequency 0x%x (%.2f) failed: %s\n",freq, frequency, strerror(errno));
return STREAM_ERROR;
}
return STREAM_OK;
@@ -590,7 +590,7 @@ static int set_frequency_bsdbt848(radio_priv_t* priv,float frequency){
static int get_frequency_bsdbt848(radio_priv_t* priv,float* frequency){
unsigned int freq;
if (ioctl(priv->radio_fd, RADIO_GETFREQ, &freq) < 0) {
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_GetFreqFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl get frequency failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
*frequency=((float)freq)/priv->frac;
@@ -614,7 +614,7 @@ static void set_volume_bsdbt848(radio_priv_t* priv,int volume){
audio_flags = (volume==0?AUDIO_MUTE:AUDIO_UNMUTE);
if (ioctl(priv->radio_fd, BT848_SAUDIO, &audio_flags)<0){
- mp_msg(MSGT_RADIO,MSGL_WARN,MSGTR_RADIO_SetMuteFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_WARN,"[radio] ioctl set mute failed: %s\n",strerror(errno));
}
}
@@ -630,7 +630,7 @@ static int get_volume_bsdbt848(radio_priv_t* priv,int* volume){
int audio_flags;
if (ioctl(priv->radio_fd, BT848_GAUDIO, &audio_flags)<0){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_GetVolumeFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] ioctl get volume failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
@@ -645,7 +645,7 @@ static int get_volume_bsdbt848(radio_priv_t* priv,int* volume){
/* bsdbt848 driver info structure */
static const radio_driver_t radio_driver_bsdbt848={
"bsdbt848",
- MSGTR_RADIO_DriverBSDBT848,
+ _("[radio] Using *BSD BT848 radio interface.\n"),
init_frac_bsdbt848,
set_volume_bsdbt848,
get_volume_bsdbt848,
@@ -659,7 +659,7 @@ static inline int init_frac(radio_priv_t* priv){
}
static inline int set_frequency(radio_priv_t* priv,float frequency){
if ((frequency<priv->rangelow)||(frequency>priv->rangehigh)){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongFreq,frequency);
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] Wrong frequency: %.2f\n",frequency);
return STREAM_ERROR;
}
if(priv->driver->set_frequency(priv,frequency)!=STREAM_OK)
@@ -667,7 +667,7 @@ static inline int set_frequency(radio_priv_t* priv,float frequency){
#ifdef CONFIG_RADIO_CAPTURE
if(clear_buffer(priv)!=STREAM_OK){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_ClearBufferFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] Clearing buffer failed: %s\n",strerror(errno));
return STREAM_ERROR;
}
#endif
@@ -722,16 +722,16 @@ static int read_chunk(audio_in_t *ai, unsigned char *buffer)
if (ret != ai->alsa.chunk_size) {
if (ret < 0) {
if (ret==-EAGAIN) return -1;
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_ErrReadingAudio, snd_strerror(ret));
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "\nError reading audio: %s\n", snd_strerror(ret));
if (ret == -EPIPE) {
if (ai_alsa_xrun(ai) == 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_XRUNSomeFramesMayBeLeftOut);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "Recovered from cross-run, some frames may be left out!\n");
} else {
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_ErrFatalCannotRecover);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "Fatal error, cannot recover!\n");
}
}
} else {
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_NotEnoughSamples);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "\nNot enough audio samples!\n");
}
return -1;
}
@@ -753,7 +753,7 @@ static int read_chunk(audio_in_t *ai, unsigned char *buffer)
if (ret<0){
if (errno==EAGAIN && bt==0) return -1; //no data avail yet
if (errno==EAGAIN) { usleep(1000); continue;} //nilling buffer to blocksize size
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_MPDEMUX_AUDIOIN_ErrReadingAudio, strerror(errno));
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "\nError reading audio: %s\n", strerror(errno));
return -1;
}
bt+=ret;
@@ -785,7 +785,7 @@ static int read_chunk(audio_in_t *ai, unsigned char *buffer)
static int grab_audio_frame(radio_priv_t *priv, char *buffer, int len)
{
int i;
- mp_msg(MSGT_RADIO, MSGL_DBG3, MSGTR_RADIO_BufferString,"grab_audio_frame",priv->audio_cnt,priv->audio_drop);
+ mp_tmsg(MSGT_RADIO, MSGL_DBG3, "[radio] %s: in buffer=%d dropped=%d\n","grab_audio_frame",priv->audio_cnt,priv->audio_drop);
/* Cache buffer must be filled by some audio packets when playing starts.
Otherwise MPlayer will quit with EOF error.
Probably, there is need more carefull checking rather than simple 'for' loop
@@ -835,7 +835,7 @@ static int init_audio(radio_priv_t *priv)
}
priv->do_capture=1;
- mp_msg(MSGT_RADIO,MSGL_V,MSGTR_RADIO_CaptureStarting);
+ mp_tmsg(MSGT_RADIO,MSGL_V,"[radio] Starting capture stuff.\n");
#ifdef CONFIG_ALSA
while ((tmp = strrchr(priv->radio_param->adevice, '='))){
tmp[0] = ':';
@@ -847,7 +847,7 @@ static int init_audio(radio_priv_t *priv)
#endif
if(audio_in_init(&priv->audio_in, is_oss?AUDIO_IN_OSS:AUDIO_IN_ALSA)<0){
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_AudioInInitFailed);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] audio_in_init failed.\n");
}
audio_in_set_device(&priv->audio_in, priv->radio_param->adevice);
@@ -855,7 +855,7 @@ static int init_audio(radio_priv_t *priv)
audio_in_set_samplerate(&priv->audio_in, priv->radio_param->arate);
if (audio_in_setup(&priv->audio_in) < 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_AudioInSetupFailed, strerror(errno));
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] audio_in_setup call failed: %s\n", strerror(errno));
return STREAM_ERROR;
}
#ifdef CONFIG_OSS_AUDIO
@@ -871,12 +871,12 @@ static int init_audio(radio_priv_t *priv)
priv->audio_in.bytes_per_sample+priv->audio_in.blocksize;
if (priv->audio_buffer_size < 256*priv->audio_in.blocksize)
priv->audio_buffer_size = 256*priv->audio_in.blocksize;
- mp_msg(MSGT_RADIO, MSGL_V, MSGTR_RADIO_AudioBuffer,
+ mp_tmsg(MSGT_RADIO, MSGL_V, "[radio] Audio capture - buffer=%d bytes (block=%d bytes).\n",
priv->audio_buffer_size,priv->audio_in.blocksize);
/* start capture */
priv->audio_ringbuffer = calloc(1, priv->audio_buffer_size);
if (!priv->audio_ringbuffer) {
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_AllocateBufferFailed,priv->audio_in.blocksize, priv->audio_buffer_size, strerror(errno));
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] cannot allocate audio buffer (block=%d,buf=%d): %s\n",priv->audio_in.blocksize, priv->audio_buffer_size, strerror(errno));
return STREAM_ERROR;
}
priv->audio_head = 0;
@@ -900,7 +900,7 @@ static int init_audio(radio_priv_t *priv)
* \parameter frequency pointer to float, which will contain frequency in MHz
* \return 1 if success,0 - otherwise
*/
-int radio_get_freq(struct stream_st *stream, float* frequency){
+int radio_get_freq(struct stream *stream, float *frequency){
radio_priv_t* priv=(radio_priv_t*)stream->priv;
if (!frequency)
@@ -915,7 +915,7 @@ int radio_get_freq(struct stream_st *stream, float* frequency){
* \parameter frequency frequency in MHz
* \return 1 if success,0 - otherwise
*/
-int radio_set_freq(struct stream_st *stream, float frequency){
+int radio_set_freq(struct stream *stream, float frequency){
radio_priv_t* priv=(radio_priv_t*)stream->priv;
if (set_frequency(priv,frequency)!=STREAM_OK){
@@ -924,7 +924,7 @@ int radio_set_freq(struct stream_st *stream, float frequency){
if (get_frequency(priv,&frequency)!=STREAM_OK){
return 0;
}
- mp_msg(MSGT_RADIO, MSGL_INFO, MSGTR_RADIO_CurrentFreq,frequency);
+ mp_tmsg(MSGT_RADIO, MSGL_INFO, "[radio] Current frequency: %.2f\n",frequency);
return 1;
}
@@ -934,7 +934,7 @@ int radio_set_freq(struct stream_st *stream, float frequency){
* \return 1 if success,0 - otherwise
*
*/
-int radio_step_freq(struct stream_st *stream, float step_interval){
+int radio_step_freq(struct stream *stream, float step_interval){
float frequency;
radio_priv_t* priv=(radio_priv_t*)stream->priv;
@@ -957,7 +957,7 @@ int radio_step_freq(struct stream_st *stream, float step_interval){
* if channel parameter is NULL function prints error message and does nothing, otherwise
* changes channel to prev or next in list
*/
-int radio_step_channel(struct stream_st *stream, int direction) {
+int radio_step_channel(struct stream *stream, int direction) {
radio_priv_t* priv=(radio_priv_t*)stream->priv;
if (priv->radio_channel_list) {
@@ -969,7 +969,7 @@ int radio_step_channel(struct stream_st *stream, int direction) {
priv->radio_channel_current = priv->radio_channel_list;
if(!radio_set_freq(stream,priv->radio_channel_current->freq))
return 0;
- mp_msg(MSGT_RADIO, MSGL_V, MSGTR_RADIO_SelectedChannel,
+ mp_tmsg(MSGT_RADIO, MSGL_V, "[radio] Selected channel: %d - %s (freq: %.2f)\n",
priv->radio_channel_current->index, priv->radio_channel_current->name,
priv->radio_channel_current->freq);
break;
@@ -981,13 +981,13 @@ int radio_step_channel(struct stream_st *stream, int direction) {
priv->radio_channel_current = priv->radio_channel_current->next;
if(!radio_set_freq(stream,priv->radio_channel_current->freq))
return 0;
- mp_msg(MSGT_RADIO, MSGL_V, MSGTR_RADIO_SelectedChannel,
+ mp_tmsg(MSGT_RADIO, MSGL_V, "[radio] Selected channel: %d - %s (freq: %.2f)\n",
priv->radio_channel_current->index, priv->radio_channel_current->name,
priv->radio_channel_current->freq);
break;
}
}else
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_ChangeChannelNoChannelList);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Can not change channel: no channel list given.\n");
return 1;
}
@@ -999,14 +999,14 @@ int radio_step_channel(struct stream_st *stream, int direction) {
* if channel parameter is NULL function prints error message and does nothing, otherwise
* changes channel to given
*/
-int radio_set_channel(struct stream_st *stream, char *channel) {
+int radio_set_channel(struct stream *stream, char *channel) {
radio_priv_t* priv=(radio_priv_t*)stream->priv;
int i, channel_int;
radio_channels_t* tmp;
char* endptr;
if (*channel=='\0')
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongChannelName,channel);
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] Wrong channel name: %s\n",channel);
if (priv->radio_channel_list) {
channel_int = strtol(channel,&endptr,10);
@@ -1017,7 +1017,7 @@ int radio_set_channel(struct stream_st *stream, char *channel) {
if (!strncmp(channel,tmp->name,sizeof(tmp->name)-1))
break;
if (!tmp){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongChannelName,channel);
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] Wrong channel name: %s\n",channel);
return 0;
}
}else{
@@ -1027,17 +1027,17 @@ int radio_set_channel(struct stream_st *stream, char *channel) {
else
break;
if (tmp->index!=channel_int){
- mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongChannelNumberInt,channel_int);
+ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] Wrong channel number: %d\n",channel_int);
return 0;
}
}
priv->radio_channel_current=tmp;
- mp_msg(MSGT_RADIO, MSGL_V, MSGTR_RADIO_SelectedChannel, priv->radio_channel_current->index,
+ mp_tmsg(MSGT_RADIO, MSGL_V, "[radio] Selected channel: %d - %s (freq: %.2f)\n", priv->radio_channel_current->index,
priv->radio_channel_current->name, priv->radio_channel_current->freq);
if(!radio_set_freq(stream, priv->radio_channel_current->freq))
return 0;
} else
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_ChangeChannelNoChannelList);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Can not change channel: no channel list given.\n");
return 1;
}
@@ -1047,7 +1047,7 @@ int radio_set_channel(struct stream_st *stream, char *channel) {
*
* NOTE: return value may be NULL (e.g. when channel list not initialized)
*/
-char* radio_get_channel_name(struct stream_st *stream){
+char* radio_get_channel_name(struct stream *stream){
radio_priv_t* priv=(radio_priv_t*)stream->priv;
if (priv->radio_channel_current) {
return priv->radio_channel_current->name;
@@ -1059,7 +1059,7 @@ char* radio_get_channel_name(struct stream_st *stream){
* \brief fills given buffer with audio data
* \return number of bytes, written into buffer
*/
-static int fill_buffer_s(struct stream_st *s, char* buffer, int max_len){
+static int fill_buffer_s(struct stream *s, char *buffer, int max_len){
int len=max_len;
#ifdef CONFIG_RADIO_CAPTURE
@@ -1129,7 +1129,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
else
priv->driver=NULL;
- mp_msg(MSGT_RADIO,MSGL_V,MSGTR_RADIO_AvailableDrivers);
+ mp_tmsg(MSGT_RADIO,MSGL_V,"[radio] Available drivers: ");
for(i=0;radio_drivers[i];i++){
mp_msg(MSGT_RADIO,MSGL_V,"%s, ",radio_drivers[i]->name);
if(strcmp(priv->radio_param->driver,radio_drivers[i]->name)==0)
@@ -1140,7 +1140,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
if(priv->driver)
mp_msg(MSGT_RADIO, MSGL_INFO, priv->driver->info);
else{
- mp_msg(MSGT_RADIO, MSGL_INFO, MSGTR_RADIO_DriverUnknownStr,priv->radio_param->driver);
+ mp_tmsg(MSGT_RADIO, MSGL_INFO, "[radio] Unknown driver name: %s\n",priv->radio_param->driver);
close_s(stream);
return STREAM_ERROR;
}
@@ -1160,12 +1160,12 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
priv->radio_fd = open(priv->radio_param->device, O_RDONLY);
if (priv->radio_fd < 0) {
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_UnableOpenDevice,
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Unable to open '%s': %s\n",
priv->radio_param->device, strerror(errno));
close_s(stream);
return STREAM_ERROR;
}
- mp_msg(MSGT_RADIO, MSGL_V, MSGTR_RADIO_RadioDevice, priv->radio_fd,priv->radio_param->device);
+ mp_tmsg(MSGT_RADIO, MSGL_V, "[radio] Radio fd: %d, %s\n", priv->radio_fd,priv->radio_param->device);
fcntl(priv->radio_fd, F_SETFD, FD_CLOEXEC);
get_volume(priv, &priv->old_snd_volume);
@@ -1182,11 +1182,11 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
}
if ((frequency<priv->rangelow)||(frequency>priv->rangehigh)){
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_WrongFreq,frequency);
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Wrong frequency: %.2f\n",frequency);
close_s(stream);
return STREAM_ERROR;
}else
- mp_msg(MSGT_RADIO, MSGL_INFO, MSGTR_RADIO_UsingFreq,frequency);
+ mp_tmsg(MSGT_RADIO, MSGL_INFO, "[radio] Using frequency: %.2f.\n",frequency);
if(set_frequency(priv,frequency)!=STREAM_OK){
close_s(stream);
@@ -1205,7 +1205,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
if(!stream_enable_cache(stream,5*priv->audio_in.samplerate*priv->audio_in.channels*
priv->audio_in.bytes_per_sample,2*priv->audio_in.samplerate*priv->audio_in.channels*
priv->audio_in.bytes_per_sample,priv->audio_in.blocksize)) {
- mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_StreamEnableCacheFailed,strerror(errno));
+ mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Call to stream_enable_cache failed: %s\n",strerror(errno));
close_s(stream);
return STREAM_ERROR;
}
@@ -1220,7 +1220,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
/*****************************************************************
* Close stream. Clear structures.
*/
-static void close_s(struct stream_st * stream){
+static void close_s(struct stream *stream){
radio_priv_t* priv=(radio_priv_t*)stream->priv;
radio_channels_t * tmp;
if (!priv) return;
@@ -1263,4 +1263,3 @@ const stream_info_t stream_info_radio = {
&stream_opts,
1 // Urls are an option string
};
-
diff --git a/stream/stream_radio.h b/stream/stream_radio.h
index e77f4aa05e..69066970e3 100644
--- a/stream/stream_radio.h
+++ b/stream/stream_radio.h
@@ -36,11 +36,11 @@ typedef struct radio_param_s{
extern radio_param_t stream_radio_defaults;
-int radio_set_freq(struct stream_st *stream, float freq);
-int radio_get_freq(struct stream_st *stream, float* freq);
-char* radio_get_channel_name(struct stream_st *stream);
-int radio_set_channel(struct stream_st *stream, char *channel);
-int radio_step_channel(struct stream_st *stream, int direction);
-int radio_step_freq(struct stream_st *stream, float step_interval);
+int radio_set_freq(struct stream *stream, float freq);
+int radio_get_freq(struct stream *stream, float* freq);
+char* radio_get_channel_name(struct stream *stream);
+int radio_set_channel(struct stream *stream, char *channel);
+int radio_step_channel(struct stream *stream, int direction);
+int radio_step_freq(struct stream *stream, float step_interval);
#endif /* MPLAYER_STREAM_RADIO_H */
diff --git a/stream/stream_rtsp.c b/stream/stream_rtsp.c
index 336db6144c..e02255e531 100644
--- a/stream/stream_rtsp.c
+++ b/stream/stream_rtsp.c
@@ -130,7 +130,7 @@ rtsp_streaming_start (stream_t *stream)
}
static void
-rtsp_streaming_close (struct stream_st *s)
+rtsp_streaming_close (struct stream *s)
{
rtsp_session_t *rtsp = NULL;
diff --git a/stream/stream_smb.c b/stream/stream_smb.c
index 17ba027687..f1b11f8d9b 100644
--- a/stream/stream_smb.c
+++ b/stream/stream_smb.c
@@ -119,14 +119,14 @@ static int open_f (stream_t *stream, int mode, void *opts, int* file_format) {
err = smbc_init(smb_auth_fn, 1);
if (err < 0) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBInitError,err);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Cannot init the libsmbclient library: %d\n",err);
m_struct_free(&stream_opts, opts);
return STREAM_ERROR;
}
fd = smbc_open(filename, m,0644);
if (fd < 0) {
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBFileNotFound, filename);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Could not open from LAN: '%s'\n", filename);
m_struct_free(&stream_opts, opts);
return STREAM_ERROR;
}
diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c
index 53e82f7da2..324075d16f 100644
--- a/stream/stream_vcd.c
+++ b/stream/stream_vcd.c
@@ -112,7 +112,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
f=open(p->device,O_RDONLY);
#endif
if(f<0){
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,p->device);
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"CD-ROM Device '%s' not found.\n",p->device);
m_struct_free(&stream_opts,opts);
return STREAM_ERROR;
}
@@ -126,7 +126,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
}
ret2=vcd_get_track_end(vcd,p->track);
if(ret2<0){
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Error selecting VCD track." " (get)\n");
close(f);
free(vcd);
m_struct_free(&stream_opts,opts);
@@ -134,7 +134,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
}
ret=vcd_seek_to_track(vcd,p->track);
if(ret<0){
- mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");
+ mp_tmsg(MSGT_OPEN,MSGL_ERR,"Error selecting VCD track." " (seek)\n");
close(f);
free(vcd);
m_struct_free(&stream_opts,opts);
diff --git a/stream/stream_vstream.c b/stream/stream_vstream.c
index ff173855f5..7575b76bb1 100644
--- a/stream/stream_vstream.c
+++ b/stream/stream_vstream.c
@@ -95,11 +95,11 @@ static int seek(stream_t *s,off_t newpos) {
return 1;
}
-static int control(struct stream_st *s,int cmd,void* arg) {
+static int control(struct stream *s,int cmd,void *arg) {
return STREAM_UNSUPPORTED;
}
-static void close_s(struct stream_st *s) {
+static void close_s(struct stream *s) {
}
static int open_s(stream_t *stream, int mode, void* opts, int* file_format) {
diff --git a/stream/tcp.c b/stream/tcp.c
index ff4db78847..0291fba544 100644
--- a/stream/tcp.c
+++ b/stream/tcp.c
@@ -109,7 +109,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
case AF_INET6: our_s_addr = (void *) &server_address.six.sin6_addr; break;
#endif
default:
- mp_msg(MSGT_NETWORK,MSGL_ERR, MSGTR_MPDEMUX_NW_UnknownAF, af);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR, "Unknown address family %d\n", af);
return TCP_ERROR_FATAL;
}
@@ -124,7 +124,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
if ( inet_addr(host)==INADDR_NONE )
#endif
{
- if(verb) mp_msg(MSGT_NETWORK,MSGL_STATUS,MSGTR_MPDEMUX_NW_ResolvingHostForAF, host, af2String(af));
+ if(verb) mp_tmsg(MSGT_NETWORK,MSGL_STATUS,"Resolving %s for %s...\n", host, af2String(af));
#ifdef HAVE_GETHOSTBYNAME2
hp=(struct hostent*)gethostbyname2( host, af );
@@ -132,7 +132,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
hp=(struct hostent*)gethostbyname( host );
#endif
if( hp==NULL ) {
- if(verb) mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_CantResolv, af2String(af), host);
+ if(verb) mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Couldn't resolve name for %s: %s\n", af2String(af), host);
return TCP_ERROR_FATAL;
}
@@ -159,7 +159,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
break;
#endif
default:
- mp_msg(MSGT_NETWORK,MSGL_ERR, MSGTR_MPDEMUX_NW_UnknownAF, af);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR, "Unknown address family %d\n", af);
return TCP_ERROR_FATAL;
}
@@ -168,7 +168,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
#else
inet_ntop(af, our_s_addr, buf, 255);
#endif
- if(verb) mp_msg(MSGT_NETWORK,MSGL_STATUS,MSGTR_MPDEMUX_NW_ConnectingToServer, host, buf , port );
+ if(verb) mp_tmsg(MSGT_NETWORK,MSGL_STATUS,"Connecting to server %s[%s]: %d...\n", host, buf , port );
// Turn the socket as non blocking so we can timeout on the connection
#if !HAVE_WINSOCK2_H
@@ -183,7 +183,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
#else
if( (WSAGetLastError() != WSAEINPROGRESS) && (WSAGetLastError() != WSAEWOULDBLOCK) ) {
#endif
- if(verb) mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_CantConnect2Server, af2String(af));
+ if(verb) mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Failed to connect to server with %s\n", af2String(af));
closesocket(socket_server_fd);
return TCP_ERROR_PORT;
}
@@ -196,7 +196,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
while((ret = select(socket_server_fd+1, NULL, &set, NULL, &tv)) == 0) {
if(count > 30 || stream_check_interrupt(500)) {
if(count > 30)
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ConnTimeout);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"connection timeout\n");
else
mp_msg(MSGT_NETWORK,MSGL_V,"Connection interrupted by user\n");
return TCP_ERROR_TIMEOUT;
@@ -207,7 +207,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
tv.tv_sec = 0;
tv.tv_usec = 500000;
}
- if (ret < 0) mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_SelectFailed);
+ if (ret < 0) mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Select failed.\n");
// Turn back the socket as blocking
#if !HAVE_WINSOCK2_H
@@ -220,11 +220,11 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
err_len = sizeof(int);
ret = getsockopt(socket_server_fd,SOL_SOCKET,SO_ERROR,&err,&err_len);
if(ret < 0) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_GetSockOptFailed,strerror(errno));
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"getsockopt failed: %s\n",strerror(errno));
return TCP_ERROR_FATAL;
}
if(err > 0) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ConnectError,strerror(err));
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"connect error: %s\n",strerror(err));
return TCP_ERROR_PORT;
}
diff --git a/stream/tv.c b/stream/tv.c
index 240596b32d..324e059c5d 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -83,7 +83,7 @@ static void tv_scan(tvi_handle_t *tvh)
//Channel scanner without tuner is useless and causes crash due to uninitialized chanlist_s
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
{
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_ScannerNotAvailableWithoutTuner);
+ mp_tmsg(MSGT_TV, MSGL_WARN, "Channel scanner is not available without tuner\n");
tvh->tv_param->scan=0;
return;
}
@@ -220,7 +220,7 @@ static int norm_from_string(tvi_handle_t *tvh, char* norm)
if(ret!=TVI_CONTROL_UNKNOWN)
{
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_BogusNormParameter, norm,"default");
+ mp_tmsg(MSGT_TV, MSGL_WARN, "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n", norm,"default");
return 0;
}
@@ -239,7 +239,7 @@ static int norm_from_string(tvi_handle_t *tvh, char* norm)
else if (!strcasecmp(norm, "ntscjp"))
return TV_NORM_NTSCJP;
else {
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_BogusNormParameter, norm, "PAL");
+ mp_tmsg(MSGT_TV, MSGL_WARN, "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n", norm, "PAL");
return TV_NORM_PAL;
}
}
@@ -248,7 +248,7 @@ static void parse_channels(tvi_handle_t *tvh)
{
char** channels = tvh->tv_param->channels;
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_ChannelNamesDetected);
+ mp_tmsg(MSGT_TV, MSGL_INFO, "TV channel names detected.\n");
tv_channel_list = malloc(sizeof(tv_channels_t));
tv_channel_list->index=1;
tv_channel_list->next=NULL;
@@ -288,7 +288,7 @@ static void parse_channels(tvi_handle_t *tvh)
}
}
if (tv_channel_current->freq == 0)
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoFreqForChannel,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Couldn't find frequency for channel %s (%s)\n",
tv_channel_current->number, tv_channel_current->name);
else {
sep = strchr(tv_channel_current->name, '-');
@@ -328,22 +328,22 @@ int tv_set_norm(tvi_handle_t *tvh, char* norm)
{
tvh->norm = norm_from_string(tvh, norm);
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedNorm, norm);
+ mp_tmsg(MSGT_TV, MSGL_V, "Selected norm : %s\n", norm);
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
return 0;
}
tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);
return 1;
}
-int tv_set_norm_i(tvi_handle_t *tvh, int norm)
+static int tv_set_norm_i(tvi_handle_t *tvh, int norm)
{
tvh->norm = norm;
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedNormId, norm);
+ mp_tmsg(MSGT_TV, MSGL_V, "Selected norm id: %d\n", norm);
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
return 0;
}
@@ -368,7 +368,7 @@ static int open_tv(tvi_handle_t *tvh)
if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoVideoInputPresent);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Error: No video input present!\n");
return 0;
}
@@ -396,7 +396,14 @@ static int open_tv(tvi_handle_t *tvh)
case IMGFMT_BGR15:
break;
default:
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnknownImageFormat,tvh->tv_param->outfmt);
+ mp_tmsg(MSGT_TV, MSGL_ERR,
+ "==================================================================\n"\
+ " WARNING: UNTESTED OR UNKNOWN OUTPUT IMAGE FORMAT REQUESTED (0x%x)\n"\
+ " This may cause buggy playback or program crash! Bug reports will\n"\
+ " be ignored! You should try again with YV12 (which is the default\n"\
+ " colorspace) and read the documentation!\n"\
+ "==================================================================\n"
+ ,tvh->tv_param->outfmt);
}
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &tvh->tv_param->outfmt);
}
@@ -433,8 +440,8 @@ static int open_tv(tvi_handle_t *tvh)
else
tvh->tv_param->height = 480/tvh->tv_param->decimation;
}
- mp_msg(MSGT_TV, MSGL_INFO,
- MSGTR_TV_MJP_WidthHeight, tvh->tv_param->width, tvh->tv_param->height);
+ mp_tmsg(MSGT_TV, MSGL_INFO,
+ " MJP: width %d height %d\n", tvh->tv_param->width, tvh->tv_param->height);
}
#endif
@@ -452,7 +459,7 @@ static int open_tv(tvi_handle_t *tvh)
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tvh->tv_param->width);
else
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnableToSetWidth, tvh->tv_param->width);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set requested width: %d\n", tvh->tv_param->width);
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tvh->tv_param->width);
}
}
@@ -464,14 +471,14 @@ static int open_tv(tvi_handle_t *tvh)
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tvh->tv_param->height);
else
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnableToSetHeight, tvh->tv_param->height);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to set requested height: %d\n", tvh->tv_param->height);
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tvh->tv_param->height);
}
}
if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
{
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_NoTuner);
+ mp_tmsg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n");
goto done;
}
@@ -487,15 +494,15 @@ static int open_tv(tvi_handle_t *tvh)
}
if (tvh->chanlist == -1)
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_UnableFindChanlist,
+ mp_tmsg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n",
tvh->tv_param->chanlist);
else
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedChanlist,
+ mp_tmsg(MSGT_TV, MSGL_V, "Selected channel list: %s (including %d channels)\n",
chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
if (tvh->tv_param->freq && tvh->tv_param->channel)
{
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_ChannelFreqParamConflict);
+ mp_tmsg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultaneously!\n");
goto done;
}
@@ -537,7 +544,7 @@ static int open_tv(tvi_handle_t *tvh)
tv_channel_current = tv_channel_current->next;
}
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
tv_channel_current->name, (float)tv_channel_current->freq/1000);
tv_set_norm_i(tvh, tv_channel_current->norm);
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
@@ -552,14 +559,14 @@ static int open_tv(tvi_handle_t *tvh)
funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedFrequency,
+ mp_tmsg(MSGT_TV, MSGL_V, "Selected frequency: %lu (%.3f)\n",
freq, (float)freq/16);
}
if (tvh->tv_param->channel) {
struct CHANLIST cl;
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_RequestedChannel, tvh->tv_param->channel);
+ mp_tmsg(MSGT_TV, MSGL_V, "Requested channel: %s\n", tvh->tv_param->channel);
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
{
cl = tvh->chanlist_s[i];
@@ -569,7 +576,7 @@ static int open_tv(tvi_handle_t *tvh)
{
strcpy(tv_channel_last_real, cl.name);
tvh->channel = i;
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
cl.name, (float)cl.freq/1000);
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
break;
@@ -607,7 +614,7 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param)
int i;
tvi_handle_t* h;
if(tv_param->driver && !strcmp(tv_param->driver,"help")){
- mp_msg(MSGT_TV,MSGL_INFO,MSGTR_TV_AvailableDrivers);
+ mp_tmsg(MSGT_TV,MSGL_INFO,"Available drivers:\n");
for(i=0;tvi_driver_list[i];i++){
mp_msg(MSGT_TV,MSGL_INFO," %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name);
if(tvi_driver_list[i]->comment)
@@ -628,7 +635,7 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param)
continue;
h->tv_param=tv_param;
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_DriverInfo, tvi_driver_list[i]->short_name,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n name: %s\n author: %s\n comment: %s\n", tvi_driver_list[i]->short_name,
tvi_driver_list[i]->name,
tvi_driver_list[i]->author,
tvi_driver_list[i]->comment?tvi_driver_list[i]->comment:"");
@@ -638,9 +645,9 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param)
}
if(tv_param->driver)
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoSuchDriver, tv_param->driver);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "No such driver: %s\n", tv_param->driver);
else
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_DriverAutoDetectionFailed);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "TV driver autodetection failed.\n");
return NULL;
}
@@ -755,7 +762,7 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
case AF_FORMAT_MPEG2:
case AF_FORMAT_AC3:
default:
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnsupportedAudioType,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Audio type '%s (%x)' unsupported!\n",
af_fmt2str(audio_format, buf, 128), audio_format);
goto no_audio;
}
@@ -785,7 +792,7 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
sh_audio->wf->nBlockAlign = sh_audio->samplesize * sh_audio->channels;
sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;
- mp_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_TV_AudioFormat,
+ mp_tmsg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,
sh_audio->wf->nSamplesPerSec);
@@ -841,7 +848,7 @@ int tv_set_color_options(tvi_handle_t *tvh, int opt, int value)
case TV_COLOR_CONTRAST:
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
default:
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_UnknownColorOption, opt);
+ mp_tmsg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
}
return TVI_CONTROL_UNKNOWN;
@@ -862,7 +869,7 @@ int tv_get_color_options(tvi_handle_t *tvh, int opt, int* value)
case TV_COLOR_CONTRAST:
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_CONTRAST, value);
default:
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_UnknownColorOption, opt);
+ mp_tmsg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
}
return TVI_CONTROL_UNKNOWN;
@@ -873,7 +880,7 @@ int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq)
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
{
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_CurrentFrequency,
+ mp_tmsg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
*freq, (float)*freq/16);
}
return 1;
@@ -889,7 +896,7 @@ int tv_set_freq(tvi_handle_t *tvh, unsigned long freq)
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_CurrentFrequency,
+ mp_tmsg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
freq, (float)freq/16);
}
tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);
@@ -933,7 +940,7 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction)
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
cl = tvh->chanlist_s[--tvh->channel];
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
cl.name, (float)cl.freq/1000);
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
}
@@ -945,7 +952,7 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction)
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
cl = tvh->chanlist_s[++tvh->channel];
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
cl.name, (float)cl.freq/1000);
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
}
@@ -965,7 +972,7 @@ int tv_step_channel(tvi_handle_t *tvh, int direction) {
tv_set_norm_i(tvh, tv_channel_current->norm);
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
}
if (direction == TV_CHANNEL_LOWER) {
@@ -977,7 +984,7 @@ int tv_step_channel(tvi_handle_t *tvh, int direction) {
tv_channel_current = tv_channel_current->next;
tv_set_norm_i(tvh, tv_channel_current->norm);
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
}
} else tv_step_channel_real(tvh, direction);
@@ -998,7 +1005,7 @@ int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
if (!strcasecmp(cl.name, channel))
{
tvh->channel = i;
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
cl.name, (float)cl.freq/1000);
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
break;
@@ -1018,7 +1025,7 @@ int tv_set_channel(tvi_handle_t *tvh, char *channel) {
for (i = 1; i < channel_int; i++)
if (tv_channel_current->next)
tv_channel_current = tv_channel_current->next;
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
tv_channel_current->name, (float)tv_channel_current->freq/1000);
tv_set_norm_i(tvh, tv_channel_current->norm);
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
@@ -1036,7 +1043,7 @@ int tv_last_channel(tvi_handle_t *tvh) {
tv_channel_last = tv_channel_current;
tv_channel_current = tmp;
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
tv_channel_current->name, (float)tv_channel_current->freq/1000);
tv_set_norm_i(tvh, tv_channel_current->norm);
tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
@@ -1051,7 +1058,7 @@ int tv_last_channel(tvi_handle_t *tvh) {
{
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
tvh->channel = i;
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
+ mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
cl.name, (float)cl.freq/1000);
tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
break;
@@ -1069,7 +1076,7 @@ int tv_step_norm(tvi_handle_t *tvh)
tvh->norm = 0;
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,
&tvh->norm) != TVI_CONTROL_TRUE) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
return 0;
}
}
diff --git a/stream/tvi_bsdbt848.c b/stream/tvi_bsdbt848.c
index 431e8f9100..f21f9d4eee 100644
--- a/stream/tvi_bsdbt848.c
+++ b/stream/tvi_bsdbt848.c
@@ -233,7 +233,7 @@ static int control(priv_t *priv, int cmd, void *arg)
{
if(ioctl(priv->tunerfd, TVTUNER_GETFREQ, &priv->tunerfreq) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "TVTUNER_GETFREQ", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "TVTUNER_GETFREQ", strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -247,7 +247,7 @@ static int control(priv_t *priv, int cmd, void *arg)
if(ioctl(priv->tunerfd, TVTUNER_SETFREQ, &priv->tunerfreq) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "TVTUNER_SETFREQ", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "TVTUNER_SETFREQ", strerror(errno));
return 0;
}
@@ -258,7 +258,7 @@ static int control(priv_t *priv, int cmd, void *arg)
int status;
if(ioctl(priv->tunerfd, TVTUNER_GETSTATUS, &status) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "GETSTATUS", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "GETSTATUS", strerror(errno));
return 0;
}
*(int*)arg=(status & 0x02)? 100 : 0;
@@ -274,7 +274,7 @@ static int control(priv_t *priv, int cmd, void *arg)
{
if(ioctl(priv->btfd, METEORGINPUT, &priv->input) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORGINPUT", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORGINPUT", strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -288,7 +288,7 @@ static int control(priv_t *priv, int cmd, void *arg)
if(ioctl(priv->btfd, METEORSINPUT, &priv->input) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSINPUT", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSINPUT", strerror(errno));
return 0;
}
@@ -317,7 +317,7 @@ static int control(priv_t *priv, int cmd, void *arg)
if(ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &dspspeed) == -1)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848InvalidAudioRate, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Invalid audio rate. Error: %s\n", strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -405,20 +405,20 @@ static int control(priv_t *priv, int cmd, void *arg)
if(ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFMT", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSFMT", strerror(errno));
return TVI_CONTROL_FALSE;
}
if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSETGEO", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSETGEO", strerror(errno));
return 0;
}
tmp_fps = priv->fps;
if(ioctl(priv->btfd, METEORSFPS, &tmp_fps) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSFPS", strerror(errno));
return 0;
}
@@ -426,7 +426,7 @@ static int control(priv_t *priv, int cmd, void *arg)
if(priv->tunerready == TRUE &&
ioctl(priv->tunerfd, BT848_SAUDIO, &priv->tv_param->audio_id) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "BT848_SAUDIO", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "BT848_SAUDIO", strerror(errno));
}
#endif
@@ -455,7 +455,7 @@ static int control(priv_t *priv, int cmd, void *arg)
if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorSettingWidth, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Error setting picture width. Error: %s\n", strerror(errno));
return 0;
}
@@ -480,7 +480,7 @@ static int control(priv_t *priv, int cmd, void *arg)
if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorSettingWidth, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Error setting picture width. Error: %s\n", strerror(errno));
return 0;
}
@@ -502,7 +502,7 @@ static int control(priv_t *priv, int cmd, void *arg)
if(ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSFPS", strerror(errno));
return 0;
}
@@ -553,33 +553,33 @@ priv->btfd = open(priv->btdev, O_RDONLY);
if(priv->btfd < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningBktrDev, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Unable to open bktr device. Error: %s\n", strerror(errno));
priv->videoready = FALSE;
}
if(priv->videoready == TRUE &&
ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "SETEORSFMT", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "SETEORSFMT", strerror(errno));
}
if(priv->videoready == TRUE &&
ioctl(priv->btfd, METEORSINPUT, &priv->source) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSINPUT", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSINPUT", strerror(errno));
}
tmp_fps = priv->fps;
if(priv->videoready == TRUE &&
ioctl(priv->btfd, METEORSFPS, &tmp_fps) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSFPS", strerror(errno));
}
if(priv->videoready == TRUE &&
ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSGEQ", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSGEQ", strerror(errno));
}
if(priv->videoready == TRUE)
@@ -591,7 +591,7 @@ if(priv->videoready == TRUE)
if(priv->livebuf == (u_char *) MAP_FAILED)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848MmapFailed, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: mmap failed. Error: %s\n", strerror(errno));
priv->videoready = FALSE;
}
@@ -601,7 +601,7 @@ if(priv->videoready == TRUE)
if(priv->framebuf[count].buf == NULL)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848FrameBufAllocFailed, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Frame buffer allocation failed. Error: %s\n", strerror(errno));
priv->videoready = FALSE;
break;
}
@@ -619,7 +619,7 @@ priv->tunerfd = open(priv->tunerdev, O_RDONLY);
if(priv->tunerfd < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningTunerDev, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Unable to open tuner device. Error: %s\n", strerror(errno));
priv->tunerready = FALSE;
}
@@ -637,7 +637,7 @@ priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/priv->fps *
if((priv->dspfd = open (priv->dspdev, O_RDONLY, 0)) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningDspDev, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Unable to open dsp device. Error: %s\n", strerror(errno));
priv->dspready = FALSE;
}
@@ -645,7 +645,7 @@ marg = (256 << 16) | 12;
if (ioctl(priv->dspfd, SNDCTL_DSP_SETFRAGMENT, &marg ) < 0 )
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "SNDCTL_DSP_SETFRAGMENT", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "SNDCTL_DSP_SETFRAGMENT", strerror(errno));
priv->dspready = FALSE;
}
@@ -655,7 +655,7 @@ if((priv->dspready == TRUE) &&
(ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &priv->dspspeed) == -1) ||
(ioctl(priv->dspfd, SNDCTL_DSP_SETFMT, &priv->dspfmt) == -1)))
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorConfiguringDsp, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Configuration of dsp failed. Error: %s\n", strerror(errno));
close(priv->dspfd);
priv->dspready = FALSE;
}
@@ -680,7 +680,7 @@ marg = SIGUSR1;
if(ioctl(priv->btfd, METEORSSIGNAL, &marg) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSSIGNAL", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSSIGNAL", strerror(errno));
return 0;
}
@@ -694,7 +694,7 @@ marg = METEOR_CAP_CONTINOUS;
if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORCAPTUR", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORCAPTUR", strerror(errno));
return 0;
}
@@ -711,7 +711,7 @@ marg = METEOR_SIG_MODE_MASK;
if(ioctl( priv->btfd, METEORSSIGNAL, &marg) < 0 )
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSSIGNAL", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "METEORSSIGNAL", strerror(errno));
return 0;
}
@@ -719,7 +719,7 @@ marg = METEOR_CAP_STOP_CONT;
if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0 )
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848UnableToStopCapture, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Unable to stop capture. Error: %s\n", strerror(errno));
return 0;
}
@@ -814,7 +814,7 @@ while(bytesread < len)
if(ret == -1)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorReadingAudio, strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Error reading audio data. Error: %s\n", strerror(errno));
return 0;
}
@@ -854,7 +854,7 @@ if(priv->dspready == FALSE) return 0;
#ifdef CONFIG_SUN_AUDIO
if(ioctl(priv->dspfd, AUDIO_GETINFO, &auinf) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "AUDIO_GETINFO", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "AUDIO_GETINFO", strerror(errno));
return TVI_CONTROL_FALSE;
}
else
@@ -862,7 +862,7 @@ else
#else
if(ioctl(priv->dspfd, FIONREAD, &bytesavail) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "FIONREAD", strerror(errno));
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n", "FIONREAD", strerror(errno));
return TVI_CONTROL_FALSE;
}
#endif
diff --git a/stream/tvi_dshow.c b/stream/tvi_dshow.c
index 37816f82cb..b77f9cb20a 100644
--- a/stream/tvi_dshow.c
+++ b/stream/tvi_dshow.c
@@ -1042,10 +1042,10 @@ static HRESULT set_nearest_freq(priv_t * priv, long lFreq)
if (load_freq_table(chanlist2country(priv->tv_param->chanlist), tunerInput, &(priv->freq_table), &(priv->freq_table_len), &(priv->first_channel)) != S_OK) {//FIXME
priv->freq_table_len=0;
priv->freq_table=NULL;
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableExtractFreqTable);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unable to load frequency table from kstvtune.ax\n");
return E_FAIL;
};
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TVI_DS_FreqTableLoaded, tunerInput == TunerInputAntenna ? "broadcast" : "cable",
+ mp_tmsg(MSGT_TV, MSGL_V, "tvi_dshow: loaded system (%s) frequency table for country id=%d (channels:%d).\n", tunerInput == TunerInputAntenna ? "broadcast" : "cable",
chanlist2country(priv->tv_param->chanlist), priv->freq_table_len);
}
@@ -1062,14 +1062,14 @@ static HRESULT set_nearest_freq(priv_t * priv, long lFreq)
mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: set_nearest_freq #%d (%ld) => %d (%ld)\n",i+priv->first_channel,priv->freq_table[i], nChannel,lFreqDiff);
}
if (nChannel == -1) {
- mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_UnableFindNearestChannel);
+ mp_tmsg(MSGT_TV,MSGL_ERR, "tvi_dshow: Unable to find nearest channel in system frequency table\n");
return E_FAIL;
}
mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: set_nearest_freq #%d (%ld)\n",nChannel,priv->freq_table[nChannel - priv->first_channel]);
hr = OLE_CALL_ARGS(priv->pTVTuner, put_Channel, nChannel,
AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT);
if (FAILED(hr)) {
- mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableToSetChannel, (unsigned int)hr);
+ mp_tmsg(MSGT_TV,MSGL_ERR,"tvi_dshow: Unable to switch to nearest channel from system frequency table. Error:0x%x\n", (unsigned int)hr);
return E_FAIL;
}
return S_OK;
@@ -1096,7 +1096,7 @@ static int set_frequency(priv_t * priv, long lFreq)
if (priv->direct_setfreq_call) { //using direct call to set frequency
hr = set_frequency_direct(priv->pTVTuner, lFreq);
if (FAILED(hr)) {
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TVI_DS_DirectSetFreqFailed);
+ mp_tmsg(MSGT_TV, MSGL_V, "tvi_dshow: Unable to set frequency directly. OS built-in channels table will be used.\n");
priv->direct_setfreq_call = 0;
}
}
@@ -1171,7 +1171,7 @@ static int get_frequency(priv_t * priv, long *plFreq)
if (priv->direct_getfreq_call) { //using direct call to get frequency
hr = get_frequency_direct(priv->pTVTuner, plFreq);
if (FAILED(hr)) {
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_DirectGetFreqFailed);
+ mp_tmsg(MSGT_TV, MSGL_INFO, "tvi_dshow: Unable to get frequency directly. OS built-in channels table will be used.\n");
priv->direct_getfreq_call = 0;
}
}
@@ -1205,7 +1205,7 @@ static void get_capabilities(priv_t * priv)
mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: get_capabilities called\n");
if (priv->pTVTuner) {
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TVI_DS_SupportedNorms);
+ mp_tmsg(MSGT_TV, MSGL_V, "tvi_dshow: supported norms:");
hr = OLE_CALL_ARGS(priv->pTVTuner, get_AvailableTVFormats,
&lAvailableFormats);
if (FAILED(hr))
@@ -1229,7 +1229,7 @@ static void get_capabilities(priv_t * priv)
tv_available_inputs = (long *) malloc(sizeof(long) * lInputPins);
tv_available_inputs_count = 0;
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TVI_DS_AvailableVideoInputs);
+ mp_tmsg(MSGT_TV, MSGL_V, "tvi_dshow: available video inputs:");
for (i = 0; i < lInputPins; i++) {
OLE_CALL_ARGS(priv->pCrossbar, get_CrossbarPinInfo, 1, i,
&lRelated, &lPhysicalType);
@@ -1250,7 +1250,7 @@ static void get_capabilities(priv_t * priv)
hr = OLE_CALL_ARGS(priv->chains[1]->pCaptureFilter, EnumPins, &pEnum);
if (FAILED(hr))
return;
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TVI_DS_AvailableAudioInputs);
+ mp_tmsg(MSGT_TV, MSGL_V, "tvi_dshow: available audio inputs:");
i = 0;
while (OLE_CALL_ARGS(pEnum, Next, 1, &pPin, NULL) == S_OK) {
memset(&pi, 0, sizeof(pi));
@@ -1272,7 +1272,7 @@ static void get_capabilities(priv_t * priv)
else
OLE_CALL_ARGS(pIAMixer, put_MixLevel, 1.0);
#endif
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TVI_DS_InputSelected);
+ mp_tmsg(MSGT_TV, MSGL_V, "(selected)");
} else {
OLE_CALL_ARGS(pIAMixer, put_Enable, FALSE);
#if 0
@@ -1417,7 +1417,7 @@ static HRESULT build_sub_graph(priv_t * priv, chain_t * chain, const GUID* ppin_
hr = OLE_CALL_ARGS(chain->pCapturePin, ConnectionMediaType, chain->pmt);
if(FAILED(hr))
{
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TVI_DS_GetActualMediatypeFailed, (unsigned int)hr);
+ mp_tmsg(MSGT_TV, MSGL_WARN, "tvi_dshow: Unable to get actual mediatype (Error:0x%x). Assuming equal to requested.\n", (unsigned int)hr);
}
if(priv->tv_param->hidden_video_renderer){
@@ -1531,7 +1531,7 @@ static int set_crossbar_input(priv_t * priv, int input)
//connecting given input with video decoder
hr = OLE_CALL_ARGS(priv->pCrossbar, Route, nVideoDecoder, lInput);
if (hr != S_OK) {
- mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableConnectInputVideoDecoder, (unsigned int)hr);
+ mp_tmsg(MSGT_TV,MSGL_ERR,"Unable to connect given input to video decoder. Error:0x%x\n", (unsigned int)hr);
return TVI_CONTROL_FALSE;
}
}
@@ -1539,7 +1539,7 @@ static int set_crossbar_input(priv_t * priv, int input)
hr = OLE_CALL_ARGS(priv->pCrossbar, Route, nAudioDecoder,
lInputRelated);
if (hr != S_OK) {
- mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableConnectInputAudioDecoder, (unsigned int)hr);
+ mp_tmsg(MSGT_TV,MSGL_ERR,"Unable to connect given input to audio decoder. Error:0x%x\n", (unsigned int)hr);
return TVI_CONTROL_FALSE;
}
}
@@ -1943,11 +1943,11 @@ static IBaseFilter *find_capture_device(int index, REFCLSID category)
OLE_CALL(pClassEnum,Reset);
for (i = 0; OLE_CALL_ARGS(pClassEnum, Next, 1, &pM, &cFetched) == S_OK; i++) {
if(get_device_name(pM, tmp, DEVICE_NAME_MAX_LEN)!=TVI_CONTROL_TRUE)
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableGetDeviceName, i);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unable to get name for device #%d\n", i);
else
- mp_msg(MSGT_TV, MSGL_V, MSGTR_TVI_DS_DeviceName, i, tmp);
+ mp_tmsg(MSGT_TV, MSGL_V, "tvi_dshow: Device #%d: %s\n", i, tmp);
if (index != -1 && i == index) {
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_UsingDevice, index, tmp);
+ mp_tmsg(MSGT_TV, MSGL_INFO, "tvi_dshow: Using device #%d: %s\n", index, tmp);
hr = OLE_CALL_ARGS(pM, BindToObject, 0, 0, &IID_IBaseFilter,(void *) &pFilter);
if (FAILED(hr))
pFilter = NULL;
@@ -1955,7 +1955,7 @@ static IBaseFilter *find_capture_device(int index, REFCLSID category)
OLE_RELEASE_SAFE(pM);
}
if (index != -1 && !pFilter) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_DeviceNotFound,
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Device #%d not found\n",
index);
}
OLE_RELEASE_SAFE(pClassEnum);
@@ -2011,7 +2011,7 @@ static HRESULT get_available_formats_stream(chain_t *chain)
return E_FAIL;
}
} else {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnsupportedMediaType,"get_available_formats_stream");
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unsupported media type passed to %s\n","get_available_formats_stream");
return E_FAIL;
}
done = 0;
@@ -2106,7 +2106,7 @@ static HRESULT get_available_formats_pin(ICaptureGraphBuilder2 * pBuilder,
} else if (chain->type == audio) {
size = sizeof(AUDIO_STREAM_CONFIG_CAPS);
} else {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnsupportedMediaType,"get_available_formats_pin");
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unsupported media type passed to %s\n","get_available_formats_pin");
return E_FAIL;
}
@@ -2470,7 +2470,7 @@ static HRESULT build_video_chain(priv_t *priv)
if (priv->chains[0]->pStreamConfig) {
hr = OLE_CALL_ARGS(priv->chains[0]->pStreamConfig, SetFormat, priv->chains[0]->pmt);
if (FAILED(hr)) {
- mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectVideoFormat, (unsigned int)hr);
+ mp_tmsg(MSGT_TV,MSGL_ERR,"tvi_dshow: Unable to select video format. Error:0x%x\n", (unsigned int)hr);
}
}
@@ -2487,7 +2487,7 @@ static HRESULT build_video_chain(priv_t *priv)
priv->chains[0]->rbuf->buffersize *= 1024 * 1024;
hr=build_sub_graph(priv, priv->chains[0], &PIN_CATEGORY_CAPTURE);
if(FAILED(hr)){
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVideoSubGraph,(unsigned int)hr);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unable to build video chain of capture graph. Error:0x%x\n",(unsigned int)hr);
return hr;
}
return S_OK;
@@ -2513,7 +2513,7 @@ static HRESULT build_audio_chain(priv_t *priv)
hr = OLE_CALL_ARGS(priv->chains[1]->pStreamConfig, SetFormat,
priv->chains[1]->pmt);
if (FAILED(hr)) {
- mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectAudioFormat, (unsigned int)hr);
+ mp_tmsg(MSGT_TV,MSGL_ERR,"tvi_dshow: Unable to select audio format. Error:0x%x\n", (unsigned int)hr);
}
}
@@ -2530,7 +2530,7 @@ static HRESULT build_audio_chain(priv_t *priv)
hr=build_sub_graph(priv, priv->chains[1],&PIN_CATEGORY_CAPTURE);
if(FAILED(hr)){
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildAudioSubGraph,(unsigned int)hr);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unable to build audio chain of capture graph. Error:0x%x\n",(unsigned int)hr);
return 0;
}
}
@@ -2561,7 +2561,7 @@ static HRESULT build_vbi_chain(priv_t *priv)
hr=build_sub_graph(priv, priv->chains[2],&PIN_CATEGORY_VBI);
if(FAILED(hr)){
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVBISubGraph,(unsigned int)hr);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unable to build VBI chain of capture graph. Error:0x%x\n",(unsigned int)hr);
return 0;
}
}
@@ -2603,12 +2603,12 @@ static int start(priv_t * priv)
mp_msg(MSGT_TV, MSGL_DBG2, "Debug pause end\n");
}
if (!priv->pMediaControl) {
- mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableGetMediaControlInterface,(unsigned int)E_POINTER);
+ mp_tmsg(MSGT_TV,MSGL_ERR,"tvi_dshow: Unable to get IMediaControl interface. Error:0x%x\n",(unsigned int)E_POINTER);
return 0;
}
hr = OLE_CALL(priv->pMediaControl, Run);
if (FAILED(hr)) {
- mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableStartGraph, (unsigned int)hr);
+ mp_tmsg(MSGT_TV,MSGL_ERR,"tvi_dshow: Unable to start graph! Error:0x%x\n", (unsigned int)hr);
return 0;
}
mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Graph is started.\n");
@@ -2681,7 +2681,7 @@ static int init(priv_t * priv)
mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Searching for available video capture devices\n");
priv->chains[0]->pCaptureFilter = find_capture_device(priv->dev_index, &CLSID_VideoInputDeviceCategory);
if(!priv->chains[0]->pCaptureFilter){
- mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_NoVideoCaptureDevice);
+ mp_tmsg(MSGT_TV,MSGL_ERR, "tvi_dshow: Unable to find video capture device\n");
break;
}
hr = OLE_CALL_ARGS(priv->pGraph, AddFilter, priv->chains[0]->pCaptureFilter, NULL);
@@ -2693,7 +2693,7 @@ static int init(priv_t * priv)
if (priv->adev_index != -1) {
priv->chains[1]->pCaptureFilter = find_capture_device(priv->adev_index, &CLSID_AudioInputDeviceCategory); //output available audio edevices
if(!priv->chains[1]->pCaptureFilter){
- mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_NoAudioCaptureDevice);
+ mp_tmsg(MSGT_TV,MSGL_ERR, "tvi_dshow: Unable to find audio capture device\n");
break;
}
@@ -2713,7 +2713,7 @@ static int init(priv_t * priv)
mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Get IID_IAMVideoProcAmp failed (0x%x).\n", (unsigned int)hr);
if (hr != S_OK) {
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_VideoAdjustigNotSupported);
+ mp_tmsg(MSGT_TV, MSGL_INFO, "tvi_dshow: Adjusting of brightness/hue/saturation/contrast is not supported by device\n");
priv->pVideoProcAmp = NULL;
}
@@ -2723,7 +2723,7 @@ static int init(priv_t * priv)
priv->chains[0]->pCaptureFilter,
&IID_IAMCrossbar, (void **) &(priv->pCrossbar));
if (FAILED(hr)) {
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_SelectingInputNotSupported);
+ mp_tmsg(MSGT_TV, MSGL_INFO, "tvi_dshow: Selection of capture source is not supported by device\n");
priv->pCrossbar = NULL;
}
@@ -2749,7 +2749,7 @@ static int init(priv_t * priv)
}
OLE_RELEASE_SAFE(pTVAudio);
if (FAILED(hr))
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TVI_DS_UnableSetAudioMode, priv->tv_param->amode,(unsigned int)hr);
+ mp_tmsg(MSGT_TV, MSGL_WARN, "tvi_dshow: Unable to set audio mode %d. Error:0x%x\n", priv->tv_param->amode,(unsigned int)hr);
}
}
@@ -2787,19 +2787,19 @@ static int init(priv_t * priv)
}
if (!priv->chains[0]->pStreamConfig)
- mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_ChangingWidthHeightNotSupported);
+ mp_tmsg(MSGT_TV, MSGL_INFO, "tvi_dshow: Changing video width/height is not supported by device.\n");
if (!priv->chains[0]->arpmt[priv->chains[0]->nFormatUsed]
|| !extract_video_format(priv->chains[0]->arpmt[priv->chains[0]->nFormatUsed],
&(priv->fcc), &(priv->width),
&(priv->height))) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_ErrorParsingVideoFormatStruct);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unable to parse video format structure.\n");
break;
}
if (priv->chains[1]->arpmt[priv->chains[1]->nFormatUsed]) {
if (!extract_audio_format(priv->chains[1]->pmt, &(priv->samplerate), NULL, NULL)) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_ErrorParsingAudioFormatStruct);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Unable to parse audio format structure.\n");
DisplayMediaType("audio format failed",priv->chains[1]->arpmt[priv->chains[1]->nFormatUsed]);
break;
}
@@ -2807,7 +2807,7 @@ static int init(priv_t * priv)
hr = OLE_QUERYINTERFACE(priv->pGraph, IID_IMediaControl,priv->pMediaControl);
if(FAILED(hr)){
- mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_UnableGetMediaControlInterface,(unsigned int)hr);
+ mp_tmsg(MSGT_TV,MSGL_ERR, "tvi_dshow: Unable to get IMediaControl interface. Error:0x%x\n",(unsigned int)hr);
break;
}
hr = OLE_CALL_ARGS(priv->pBuilder, FindInterface,
@@ -2867,7 +2867,7 @@ static int init(priv_t * priv)
OLE_RELEASE_SAFE(pVPOutPin);
if (FAILED(hr)) {
- mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_UnableTerminateVPPin, (unsigned int)hr);
+ mp_tmsg(MSGT_TV,MSGL_ERR, "tvi_dshow: Unable to terminate VideoPort pin with any filter in graph. Error:0x%x\n", (unsigned int)hr);
break;
}
}
@@ -2909,7 +2909,7 @@ static int init(priv_t * priv)
} while(0);
if (!result){
- mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_GraphInitFailure);
+ mp_tmsg(MSGT_TV,MSGL_ERR, "tvi_dshow: Directshow graph initialization failure.\n");
uninit(priv);
}
return result;
@@ -3041,12 +3041,12 @@ static tvi_handle_t *tvi_init_dshow(tv_param_t* tv_param)
if (sscanf(tv_param->device, "%d", &a) == 1) {
priv->dev_index = a;
} else {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_WrongDeviceParam, tv_param->device);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Wrong device parameter: %s\n", tv_param->device);
free_handle(h);
return NULL;
}
if (priv->dev_index < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_WrongDeviceIndex, a);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Wrong device index: %d\n", a);
free_handle(h);
return NULL;
}
@@ -3055,12 +3055,12 @@ static tvi_handle_t *tvi_init_dshow(tv_param_t* tv_param)
if (sscanf(tv_param->adevice, "%d", &a) == 1) {
priv->adev_index = a;
} else {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_WrongADeviceParam, tv_param->adevice);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Wrong adevice parameter: %s\n", tv_param->adevice);
free_handle(h);
return NULL;
}
if (priv->dev_index < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_WrongADeviceIndex, a);
+ mp_tmsg(MSGT_TV, MSGL_ERR, "tvi_dshow: Wrong adevice index: %d\n", a);
free_handle(h);
return NULL;
}
@@ -3320,7 +3320,7 @@ static int control(priv_t * priv, int cmd, void *arg)
break;
if (!priv->chains[1]->arpmt[i]) {
//request not found. failing back to first available
- mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TVI_DS_SamplerateNotsupported, samplerate);
+ mp_tmsg(MSGT_TV, MSGL_WARN, "tvi_dshow: Samplerate %d is not supported by device. Failing back to first available.\n", samplerate);
i = 0;
}
if (priv->chains[1]->pmt)
diff --git a/stream/tvi_vbi.c b/stream/tvi_vbi.c
index 58d830e1d2..15524d8ccd 100644
--- a/stream/tvi_vbi.c
+++ b/stream/tvi_vbi.c
@@ -810,7 +810,7 @@ static void prepare_visible_page(priv_vbi_t* priv){
curr_pg=get_from_cache(priv,priv->curr_pagenum,
get_subpagenum_from_cache(priv,priv->curr_pagenum));
if (!pg && !curr_pg){
- p=MSGTR_TV_NoTeletext;
+ p=_("No teletext");
for(i=0;i<VBI_COLUMNS && *p;i++){
GET_UTF8(priv->display_page[i].unicode,*p++,break;);
}
@@ -1664,7 +1664,7 @@ int teletext_control(void* p, int cmd, void *arg)
priv->subpagenum=0x3f7f;
pll_reset(priv,fine_tune);
if(tv_param->tlang==-1){
- mp_msg(MSGT_TV,MSGL_INFO,MSGTR_TV_TTSupportedLanguages);
+ mp_tmsg(MSGT_TV,MSGL_INFO,"Supported Teletext languages:\n");
for(i=0; tt_languages[i].lang_code; i++){
mp_msg(MSGT_TV,MSGL_INFO," %3d %s\n",
tt_languages[i].lang_code, tt_languages[i].lang_name);
@@ -1677,7 +1677,7 @@ int teletext_control(void* p, int cmd, void *arg)
break;
}
if (priv->primary_language!=tt_languages[i].lang_code){
- mp_msg(MSGT_TV,MSGL_INFO,MSGTR_TV_TTSelectedLanguage,
+ mp_tmsg(MSGT_TV,MSGL_INFO,"Selected default teletext language: %s\n",
tt_languages[i].lang_name);
priv->primary_language=tt_languages[i].lang_code;
}
diff --git a/stream/url.c b/stream/url.c
index 92e872e599..ff61edbc70 100644
--- a/stream/url.c
+++ b/stream/url.c
@@ -54,19 +54,19 @@ url_new(const char* url) {
if( url==NULL ) return NULL;
if (strlen(url) > (SIZE_MAX / 3 - 1)) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
escfilename=malloc(strlen(url)*3+1);
if (!escfilename ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
// Create the URL container
Curl = malloc(sizeof(URL_t));
if( Curl==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
@@ -78,7 +78,7 @@ url_new(const char* url) {
// Copy the url in the URL container
Curl->url = strdup(escfilename);
if( Curl->url==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
mp_msg(MSGT_OPEN,MSGL_V,"Filename for url is now %s\n",escfilename);
@@ -98,7 +98,7 @@ url_new(const char* url) {
pos1 = ptr1-escfilename;
Curl->protocol = malloc(pos1+1);
if( Curl->protocol==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
strncpy(Curl->protocol, escfilename, pos1);
@@ -120,7 +120,7 @@ url_new(const char* url) {
int len = ptr2-ptr1;
Curl->username = malloc(len+1);
if( Curl->username==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
strncpy(Curl->username, ptr1, len);
@@ -133,7 +133,7 @@ url_new(const char* url) {
Curl->username[ptr3-ptr1]='\0';
Curl->password = malloc(len2+1);
if( Curl->password==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
strncpy( Curl->password, ptr3+1, len2);
@@ -185,7 +185,7 @@ url_new(const char* url) {
// copy the hostname in the URL container
Curl->hostname = malloc(pos2-pos1+1);
if( Curl->hostname==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
strncpy(Curl->hostname, ptr1, pos2-pos1);
@@ -200,7 +200,7 @@ url_new(const char* url) {
// copy the path/filename in the URL container
Curl->file = strdup(ptr2);
if( Curl->file==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
}
@@ -209,7 +209,7 @@ url_new(const char* url) {
if( Curl->file==NULL ) {
Curl->file = malloc(2);
if( Curl->file==NULL ) {
- mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
+ mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
goto err_out;
}
strcpy(Curl->file, "/");
@@ -287,7 +287,7 @@ url_escape_string_part(char *outbuf, const char *inbuf) {
*outbuf++=c; // already
// dont escape again
- mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_URL_StringAlreadyEscaped,c,c1,c2);
+ mp_tmsg(MSGT_NETWORK,MSGL_ERR,"String appears to be already escaped in url_escape %c%c1%c2\n",c,c1,c2);
// error as this should not happen against RFC 2396
// to escape a string twice
} else {
diff --git a/sub_cc.c b/sub_cc.c
index 7c3c688d9d..5131f83d69 100644
--- a/sub_cc.c
+++ b/sub_cc.c
@@ -330,4 +330,3 @@ void subcc_process_data(unsigned char *inputdata,unsigned int len)
subcc_decode(inputdata, len);
}
-
diff --git a/sub_cc.h b/sub_cc.h
index 344fbbab77..cf5d1fbcc5 100644
--- a/sub_cc.h
+++ b/sub_cc.h
@@ -7,4 +7,3 @@ void subcc_init(void);
void subcc_process_data(unsigned char *inputdata,unsigned int len);
#endif /* MPLAYER_SUB_CC_H */
-
diff --git a/subdir.mak b/subdir.mak
index 7148ce6fcd..9c02815fe0 100644
--- a/subdir.mak
+++ b/subdir.mak
@@ -32,9 +32,7 @@ $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
$(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
-
-$(SUBDIR)x86/%.d: $(SUBDIR)x86/%.asm
- $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@
+ $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:%.o=%.d)
clean::
rm -f $(EXAMPLES) $(addprefix $(SUBDIR),*-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
diff --git a/subopt-helper.c b/subopt-helper.c
index 50283cfbf3..ad133772af 100644
--- a/subopt-helper.c
+++ b/subopt-helper.c
@@ -331,4 +331,3 @@ int strargcasecmp(strarg_t *arg, char *str) {
res = arg->len - strlen(str);
return res;
}
-
diff --git a/subreader.c b/subreader.c
index d4b1db7cef..ef39b810a2 100644
--- a/subreader.c
+++ b/subreader.c
@@ -1150,7 +1150,7 @@ subtitle* subcp_recode (subtitle *sub)
#ifndef max
#define max(a,b) (((a)>(b))?(a):(b))
#endif
-subtitle* sub_fribidi (subtitle *sub, int sub_utf8)
+static subtitle* sub_fribidi (subtitle *sub, int sub_utf8)
{
FriBidiChar logical[LINE_LEN+1], visual[LINE_LEN+1]; // Hopefully these two won't smash the stack
char *ip = NULL, *op = NULL;
diff --git a/subreader.h b/subreader.h
index ef94d275c5..28246ec483 100644
--- a/subreader.h
+++ b/subreader.h
@@ -68,12 +68,12 @@ sub_data* sub_read_file (char *filename, float pts);
subtitle* subcp_recode (subtitle *sub);
// enca_fd is the file enca uses to determine the codepage.
// setting to NULL disables enca.
-struct stream_st;
-void subcp_open (struct stream_st *st); /* for demux_ogg.c */
+struct stream;
+void subcp_open (struct stream *st); /* for demux_ogg.c */
void subcp_close (void); /* for demux_ogg.c */
#ifdef CONFIG_ENCA
const char* guess_buffer_cp(unsigned char* buffer, int buflen, const char *preferred_language, const char *fallback);
-const char* guess_cp(struct stream_st *st, const char *preferred_language, const char *fallback);
+const char* guess_cp(struct stream *st, const char *preferred_language, const char *fallback);
#endif
char ** sub_filenames(const char *path, char *fname);
void list_sub_file(sub_data* subd);
diff --git a/talloc.c b/talloc.c
new file mode 100644
index 0000000000..63550cf4d4
--- /dev/null
+++ b/talloc.c
@@ -0,0 +1,1758 @@
+/*
+ Samba Unix SMB/CIFS implementation.
+
+ Samba trivial allocation library - new interface
+
+ NOTE: Please read talloc_guide.txt for full documentation
+
+ Copyright (C) Andrew Tridgell 2004
+ Copyright (C) Stefan Metzmacher 2006
+
+ ** NOTE! The following LGPL license applies to the talloc
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ inspired by http://swapped.cc/halloc/
+*/
+
+// Hardcode these for MPlayer assuming a working system.
+// Original used autoconf detection with workarounds for broken systems.
+#define HAVE_VA_COPY
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#define strnlen rep_strnlen
+static size_t rep_strnlen(const char *s, size_t max)
+{
+ size_t len;
+
+ for (len = 0; len < max; len++) {
+ if (s[len] == '\0') {
+ break;
+ }
+ }
+ return len;
+}
+
+
+
+#ifdef _SAMBA_BUILD_
+#include "version.h"
+#if (SAMBA_VERSION_MAJOR<4)
+#include "includes.h"
+/* This is to circumvent SAMBA3's paranoid malloc checker. Here in this file
+ * we trust ourselves... */
+#ifdef malloc
+#undef malloc
+#endif
+#ifdef realloc
+#undef realloc
+#endif
+#define _TALLOC_SAMBA3
+#endif /* (SAMBA_VERSION_MAJOR<4) */
+#endif /* _SAMBA_BUILD_ */
+
+#ifndef _TALLOC_SAMBA3
+// Workarounds for missing standard features, not used in MPlayer
+// #include "replace.h"
+#include "talloc.h"
+#endif /* not _TALLOC_SAMBA3 */
+
+/* use this to force every realloc to change the pointer, to stress test
+ code that might not cope */
+#define ALWAYS_REALLOC 0
+
+
+#define MAX_TALLOC_SIZE 0x10000000
+#define TALLOC_MAGIC 0xe814ec70
+#define TALLOC_FLAG_FREE 0x01
+#define TALLOC_FLAG_LOOP 0x02
+#define TALLOC_FLAG_POOL 0x04 /* This is a talloc pool */
+#define TALLOC_FLAG_POOLMEM 0x08 /* This is allocated in a pool */
+#define TALLOC_MAGIC_REFERENCE ((const char *)1)
+
+/* by default we abort when given a bad pointer (such as when talloc_free() is called
+ on a pointer that came from malloc() */
+#ifndef TALLOC_ABORT
+#define TALLOC_ABORT(reason) abort()
+#endif
+
+#ifndef discard_const_p
+#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
+# define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr)))
+#else
+# define discard_const_p(type, ptr) ((type *)(ptr))
+#endif
+#endif
+
+/* these macros gain us a few percent of speed on gcc */
+#if (__GNUC__ >= 3)
+/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1
+ as its first argument */
+#ifndef likely
+#define likely(x) __builtin_expect(!!(x), 1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+#else
+#ifndef likely
+#define likely(x) (x)
+#endif
+#ifndef unlikely
+#define unlikely(x) (x)
+#endif
+#endif
+
+/* this null_context is only used if talloc_enable_leak_report() or
+ talloc_enable_leak_report_full() is called, otherwise it remains
+ NULL
+*/
+static void *null_context;
+static void *autofree_context;
+
+struct talloc_reference_handle {
+ struct talloc_reference_handle *next, *prev;
+ void *ptr;
+};
+
+typedef int (*talloc_destructor_t)(void *);
+
+struct talloc_chunk {
+ struct talloc_chunk *next, *prev;
+ struct talloc_chunk *parent, *child;
+ struct talloc_reference_handle *refs;
+ talloc_destructor_t destructor;
+ const char *name;
+ size_t size;
+ unsigned flags;
+
+ /*
+ * "pool" has dual use:
+ *
+ * For the talloc pool itself (i.e. TALLOC_FLAG_POOL is set), "pool"
+ * marks the end of the currently allocated area.
+ *
+ * For members of the pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool"
+ * is a pointer to the struct talloc_chunk of the pool that it was
+ * allocated from. This way children can quickly find the pool to chew
+ * from.
+ */
+ void *pool;
+};
+
+/* 16 byte alignment seems to keep everyone happy */
+#define TC_HDR_SIZE ((sizeof(struct talloc_chunk)+15)&~15)
+#define TC_PTR_FROM_CHUNK(tc) ((void *)(TC_HDR_SIZE + (char*)tc))
+
+static void talloc_abort_double_free(void)
+{
+ TALLOC_ABORT("Bad talloc magic value - double free");
+}
+
+static void talloc_abort_unknown_value(void)
+{
+ TALLOC_ABORT("Bad talloc magic value - unknown value");
+}
+
+/* panic if we get a bad magic value */
+static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr)
+{
+ const char *pp = (const char *)ptr;
+ struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE);
+ if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) {
+ if (tc->flags & TALLOC_FLAG_FREE) {
+ talloc_abort_double_free();
+ } else {
+ talloc_abort_unknown_value();
+ }
+ }
+ return tc;
+}
+
+/* hook into the front of the list */
+#define _TLIST_ADD(list, p) \
+do { \
+ if (!(list)) { \
+ (list) = (p); \
+ (p)->next = (p)->prev = NULL; \
+ } else { \
+ (list)->prev = (p); \
+ (p)->next = (list); \
+ (p)->prev = NULL; \
+ (list) = (p); \
+ }\
+} while (0)
+
+/* remove an element from a list - element doesn't have to be in list. */
+#define _TLIST_REMOVE(list, p) \
+do { \
+ if ((p) == (list)) { \
+ (list) = (p)->next; \
+ if (list) (list)->prev = NULL; \
+ } else { \
+ if ((p)->prev) (p)->prev->next = (p)->next; \
+ if ((p)->next) (p)->next->prev = (p)->prev; \
+ } \
+ if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \
+} while (0)
+
+
+/*
+ return the parent chunk of a pointer
+*/
+static inline struct talloc_chunk *talloc_parent_chunk(const void *ptr)
+{
+ struct talloc_chunk *tc;
+
+ if (unlikely(ptr == NULL)) {
+ return NULL;
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
+ while (tc->prev) tc=tc->prev;
+
+ return tc->parent;
+}
+
+void *talloc_parent(const void *ptr)
+{
+ struct talloc_chunk *tc = talloc_parent_chunk(ptr);
+ return tc? TC_PTR_FROM_CHUNK(tc) : NULL;
+}
+
+/*
+ find parents name
+*/
+const char *talloc_parent_name(const void *ptr)
+{
+ struct talloc_chunk *tc = talloc_parent_chunk(ptr);
+ return tc? tc->name : NULL;
+}
+
+/*
+ A pool carries an in-pool object count count in the first 16 bytes.
+ bytes. This is done to support talloc_steal() to a parent outside of the
+ pool. The count includes the pool itself, so a talloc_free() on a pool will
+ only destroy the pool if the count has dropped to zero. A talloc_free() of a
+ pool member will reduce the count, and eventually also call free(3) on the
+ pool memory.
+
+ The object count is not put into "struct talloc_chunk" because it is only
+ relevant for talloc pools and the alignment to 16 bytes would increase the
+ memory footprint of each talloc chunk by those 16 bytes.
+*/
+
+#define TALLOC_POOL_HDR_SIZE 16
+
+static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc)
+{
+ return (unsigned int *)((char *)tc + sizeof(struct talloc_chunk));
+}
+
+/*
+ Allocate from a pool
+*/
+
+static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
+ size_t size)
+{
+ struct talloc_chunk *pool_ctx = NULL;
+ size_t space_left;
+ struct talloc_chunk *result;
+ size_t chunk_size;
+
+ if (parent == NULL) {
+ return NULL;
+ }
+
+ if (parent->flags & TALLOC_FLAG_POOL) {
+ pool_ctx = parent;
+ }
+ else if (parent->flags & TALLOC_FLAG_POOLMEM) {
+ pool_ctx = (struct talloc_chunk *)parent->pool;
+ }
+
+ if (pool_ctx == NULL) {
+ return NULL;
+ }
+
+ space_left = ((char *)pool_ctx + TC_HDR_SIZE + pool_ctx->size)
+ - ((char *)pool_ctx->pool);
+
+ /*
+ * Align size to 16 bytes
+ */
+ chunk_size = ((size + 15) & ~15);
+
+ if (space_left < chunk_size) {
+ return NULL;
+ }
+
+ result = (struct talloc_chunk *)pool_ctx->pool;
+
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
+ VALGRIND_MAKE_MEM_UNDEFINED(result, size);
+#endif
+
+ pool_ctx->pool = (void *)((char *)result + chunk_size);
+
+ result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM;
+ result->pool = pool_ctx;
+
+ *talloc_pool_objectcount(pool_ctx) += 1;
+
+ return result;
+}
+
+/*
+ Allocate a bit of memory as a child of an existing pointer
+*/
+static inline void *__talloc(const void *context, size_t size)
+{
+ struct talloc_chunk *tc = NULL;
+
+ if (unlikely(context == NULL)) {
+ context = null_context;
+ }
+
+ if (unlikely(size >= MAX_TALLOC_SIZE)) {
+ abort(); // return NULL;
+ }
+
+ if (context != NULL) {
+ tc = talloc_alloc_pool(talloc_chunk_from_ptr(context),
+ TC_HDR_SIZE+size);
+ }
+
+ if (tc == NULL) {
+ tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size);
+ if (unlikely(tc == NULL)) abort(); // return NULL;
+ tc->flags = TALLOC_MAGIC;
+ tc->pool = NULL;
+ }
+
+ tc->size = size;
+ tc->destructor = NULL;
+ tc->child = NULL;
+ tc->name = NULL;
+ tc->refs = NULL;
+
+ if (likely(context)) {
+ struct talloc_chunk *parent = talloc_chunk_from_ptr(context);
+
+ if (parent->child) {
+ parent->child->parent = NULL;
+ tc->next = parent->child;
+ tc->next->prev = tc;
+ } else {
+ tc->next = NULL;
+ }
+ tc->parent = parent;
+ tc->prev = NULL;
+ parent->child = tc;
+ } else {
+ tc->next = tc->prev = tc->parent = NULL;
+ }
+
+ return TC_PTR_FROM_CHUNK(tc);
+}
+
+/*
+ * Create a talloc pool
+ */
+
+void *talloc_pool(const void *context, size_t size)
+{
+ void *result = __talloc(context, size + TALLOC_POOL_HDR_SIZE);
+ struct talloc_chunk *tc;
+
+ if (unlikely(result == NULL)) {
+ return NULL;
+ }
+
+ tc = talloc_chunk_from_ptr(result);
+
+ tc->flags |= TALLOC_FLAG_POOL;
+ tc->pool = (char *)result + TALLOC_POOL_HDR_SIZE;
+
+ *talloc_pool_objectcount(tc) = 1;
+
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
+ VALGRIND_MAKE_MEM_NOACCESS(tc->pool, size);
+#endif
+
+ return result;
+}
+
+/*
+ setup a destructor to be called on free of a pointer
+ the destructor should return 0 on success, or -1 on failure.
+ if the destructor fails then the free is failed, and the memory can
+ be continued to be used
+*/
+void _talloc_set_destructor(const void *ptr, int (*destructor)(void *))
+{
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
+ tc->destructor = destructor;
+}
+
+/*
+ increase the reference count on a piece of memory.
+*/
+int talloc_increase_ref_count(const void *ptr)
+{
+ if (unlikely(!talloc_reference(null_context, ptr))) {
+ return -1;
+ }
+ return 0;
+}
+
+/*
+ helper for talloc_reference()
+
+ this is referenced by a function pointer and should not be inline
+*/
+static int talloc_reference_destructor(struct talloc_reference_handle *handle)
+{
+ struct talloc_chunk *ptr_tc = talloc_chunk_from_ptr(handle->ptr);
+ _TLIST_REMOVE(ptr_tc->refs, handle);
+ return 0;
+}
+
+/*
+ more efficient way to add a name to a pointer - the name must point to a
+ true string constant
+*/
+static inline void _talloc_set_name_const(const void *ptr, const char *name)
+{
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
+ tc->name = name;
+}
+
+/*
+ internal talloc_named_const()
+*/
+static inline void *_talloc_named_const(const void *context, size_t size, const char *name)
+{
+ void *ptr;
+
+ ptr = __talloc(context, size);
+ if (unlikely(ptr == NULL)) {
+ return NULL;
+ }
+
+ _talloc_set_name_const(ptr, name);
+
+ return ptr;
+}
+
+/*
+ make a secondary reference to a pointer, hanging off the given context.
+ the pointer remains valid until both the original caller and this given
+ context are freed.
+
+ the major use for this is when two different structures need to reference the
+ same underlying data, and you want to be able to free the two instances separately,
+ and in either order
+*/
+void *_talloc_reference(const void *context, const void *ptr)
+{
+ struct talloc_chunk *tc;
+ struct talloc_reference_handle *handle;
+ if (unlikely(ptr == NULL)) return NULL;
+
+ tc = talloc_chunk_from_ptr(ptr);
+ handle = (struct talloc_reference_handle *)_talloc_named_const(context,
+ sizeof(struct talloc_reference_handle),
+ TALLOC_MAGIC_REFERENCE);
+ if (unlikely(handle == NULL)) return NULL;
+
+ /* note that we hang the destructor off the handle, not the
+ main context as that allows the caller to still setup their
+ own destructor on the context if they want to */
+ talloc_set_destructor(handle, talloc_reference_destructor);
+ handle->ptr = discard_const_p(void, ptr);
+ _TLIST_ADD(tc->refs, handle);
+ return handle->ptr;
+}
+
+
+/*
+ internal talloc_free call
+*/
+static inline int _talloc_free(void *ptr)
+{
+ struct talloc_chunk *tc;
+
+ if (unlikely(ptr == NULL)) {
+ return -1;
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
+
+ if (unlikely(tc->refs)) {
+ int is_child;
+ /* check this is a reference from a child or grantchild
+ * back to it's parent or grantparent
+ *
+ * in that case we need to remove the reference and
+ * call another instance of talloc_free() on the current
+ * pointer.
+ */
+ is_child = talloc_is_parent(tc->refs, ptr);
+ _talloc_free(tc->refs);
+ if (is_child) {
+ return _talloc_free(ptr);
+ }
+ return -1;
+ }
+
+ if (unlikely(tc->flags & TALLOC_FLAG_LOOP)) {
+ /* we have a free loop - stop looping */
+ return 0;
+ }
+
+ if (unlikely(tc->destructor)) {
+ talloc_destructor_t d = tc->destructor;
+ if (d == (talloc_destructor_t)-1) {
+ return -1;
+ }
+ tc->destructor = (talloc_destructor_t)-1;
+ if (d(ptr) == -1) {
+ tc->destructor = d;
+ return -1;
+ }
+ tc->destructor = NULL;
+ }
+
+ if (tc->parent) {
+ _TLIST_REMOVE(tc->parent->child, tc);
+ if (tc->parent->child) {
+ tc->parent->child->parent = tc->parent;
+ }
+ } else {
+ if (tc->prev) tc->prev->next = tc->next;
+ if (tc->next) tc->next->prev = tc->prev;
+ }
+
+ tc->flags |= TALLOC_FLAG_LOOP;
+
+ while (tc->child) {
+ /* we need to work out who will own an abandoned child
+ if it cannot be freed. In priority order, the first
+ choice is owner of any remaining reference to this
+ pointer, the second choice is our parent, and the
+ final choice is the null context. */
+ void *child = TC_PTR_FROM_CHUNK(tc->child);
+ const void *new_parent = null_context;
+ if (unlikely(tc->child->refs)) {
+ struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs);
+ if (p) new_parent = TC_PTR_FROM_CHUNK(p);
+ }
+ if (unlikely(_talloc_free(child) == -1)) {
+ if (new_parent == null_context) {
+ struct talloc_chunk *p = talloc_parent_chunk(ptr);
+ if (p) new_parent = TC_PTR_FROM_CHUNK(p);
+ }
+ talloc_steal(new_parent, child);
+ }
+ }
+
+ tc->flags |= TALLOC_FLAG_FREE;
+
+ if (tc->flags & (TALLOC_FLAG_POOL|TALLOC_FLAG_POOLMEM)) {
+ struct talloc_chunk *pool;
+ unsigned int *pool_object_count;
+
+ pool = (tc->flags & TALLOC_FLAG_POOL)
+ ? tc : (struct talloc_chunk *)tc->pool;
+
+ pool_object_count = talloc_pool_objectcount(pool);
+
+ if (*pool_object_count == 0) {
+ TALLOC_ABORT("Pool object count zero!");
+ }
+
+ *pool_object_count -= 1;
+
+ if (*pool_object_count == 0) {
+ free(pool);
+ }
+ }
+ else {
+ free(tc);
+ }
+ return 0;
+}
+
+/*
+ move a lump of memory from one talloc context to another return the
+ ptr on success, or NULL if it could not be transferred.
+ passing NULL as ptr will always return NULL with no side effects.
+*/
+void *_talloc_steal(const void *new_ctx, const void *ptr)
+{
+ struct talloc_chunk *tc, *new_tc;
+
+ if (unlikely(!ptr)) {
+ return NULL;
+ }
+
+ if (unlikely(new_ctx == NULL)) {
+ new_ctx = null_context;
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
+
+ if (unlikely(new_ctx == NULL)) {
+ if (tc->parent) {
+ _TLIST_REMOVE(tc->parent->child, tc);
+ if (tc->parent->child) {
+ tc->parent->child->parent = tc->parent;
+ }
+ } else {
+ if (tc->prev) tc->prev->next = tc->next;
+ if (tc->next) tc->next->prev = tc->prev;
+ }
+
+ tc->parent = tc->next = tc->prev = NULL;
+ return discard_const_p(void, ptr);
+ }
+
+ new_tc = talloc_chunk_from_ptr(new_ctx);
+
+ if (unlikely(tc == new_tc || tc->parent == new_tc)) {
+ return discard_const_p(void, ptr);
+ }
+
+ if (tc->parent) {
+ _TLIST_REMOVE(tc->parent->child, tc);
+ if (tc->parent->child) {
+ tc->parent->child->parent = tc->parent;
+ }
+ } else {
+ if (tc->prev) tc->prev->next = tc->next;
+ if (tc->next) tc->next->prev = tc->prev;
+ }
+
+ tc->parent = new_tc;
+ if (new_tc->child) new_tc->child->parent = NULL;
+ _TLIST_ADD(new_tc->child, tc);
+
+ return discard_const_p(void, ptr);
+}
+
+
+
+/*
+ remove a secondary reference to a pointer. This undo's what
+ talloc_reference() has done. The context and pointer arguments
+ must match those given to a talloc_reference()
+*/
+static inline int talloc_unreference(const void *context, const void *ptr)
+{
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
+ struct talloc_reference_handle *h;
+
+ if (unlikely(context == NULL)) {
+ context = null_context;
+ }
+
+ for (h=tc->refs;h;h=h->next) {
+ struct talloc_chunk *p = talloc_parent_chunk(h);
+ if (p == NULL) {
+ if (context == NULL) break;
+ } else if (TC_PTR_FROM_CHUNK(p) == context) {
+ break;
+ }
+ }
+ if (h == NULL) {
+ return -1;
+ }
+
+ return _talloc_free(h);
+}
+
+/*
+ remove a specific parent context from a pointer. This is a more
+ controlled varient of talloc_free()
+*/
+int talloc_unlink(const void *context, void *ptr)
+{
+ struct talloc_chunk *tc_p, *new_p;
+ void *new_parent;
+
+ if (ptr == NULL) {
+ return -1;
+ }
+
+ if (context == NULL) {
+ context = null_context;
+ }
+
+ if (talloc_unreference(context, ptr) == 0) {
+ return 0;
+ }
+
+ if (context == NULL) {
+ if (talloc_parent_chunk(ptr) != NULL) {
+ return -1;
+ }
+ } else {
+ if (talloc_chunk_from_ptr(context) != talloc_parent_chunk(ptr)) {
+ return -1;
+ }
+ }
+
+ tc_p = talloc_chunk_from_ptr(ptr);
+
+ if (tc_p->refs == NULL) {
+ return _talloc_free(ptr);
+ }
+
+ new_p = talloc_parent_chunk(tc_p->refs);
+ if (new_p) {
+ new_parent = TC_PTR_FROM_CHUNK(new_p);
+ } else {
+ new_parent = NULL;
+ }
+
+ if (talloc_unreference(new_parent, ptr) != 0) {
+ return -1;
+ }
+
+ talloc_steal(new_parent, ptr);
+
+ return 0;
+}
+
+/*
+ add a name to an existing pointer - va_list version
+*/
+static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+
+static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap)
+{
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
+ tc->name = talloc_vasprintf(ptr, fmt, ap);
+ if (likely(tc->name)) {
+ _talloc_set_name_const(tc->name, ".name");
+ }
+ return tc->name;
+}
+
+/*
+ add a name to an existing pointer
+*/
+const char *talloc_set_name(const void *ptr, const char *fmt, ...)
+{
+ const char *name;
+ va_list ap;
+ va_start(ap, fmt);
+ name = talloc_set_name_v(ptr, fmt, ap);
+ va_end(ap);
+ return name;
+}
+
+
+/*
+ create a named talloc pointer. Any talloc pointer can be named, and
+ talloc_named() operates just like talloc() except that it allows you
+ to name the pointer.
+*/
+void *talloc_named(const void *context, size_t size, const char *fmt, ...)
+{
+ va_list ap;
+ void *ptr;
+ const char *name;
+
+ ptr = __talloc(context, size);
+ if (unlikely(ptr == NULL)) return NULL;
+
+ va_start(ap, fmt);
+ name = talloc_set_name_v(ptr, fmt, ap);
+ va_end(ap);
+
+ if (unlikely(name == NULL)) {
+ _talloc_free(ptr);
+ return NULL;
+ }
+
+ return ptr;
+}
+
+/*
+ return the name of a talloc ptr, or "UNNAMED"
+*/
+const char *talloc_get_name(const void *ptr)
+{
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
+ if (unlikely(tc->name == TALLOC_MAGIC_REFERENCE)) {
+ return ".reference";
+ }
+ if (likely(tc->name)) {
+ return tc->name;
+ }
+ return "UNNAMED";
+}
+
+
+/*
+ check if a pointer has the given name. If it does, return the pointer,
+ otherwise return NULL
+*/
+void *talloc_check_name(const void *ptr, const char *name)
+{
+ const char *pname;
+ if (unlikely(ptr == NULL)) return NULL;
+ pname = talloc_get_name(ptr);
+ if (likely(pname == name || strcmp(pname, name) == 0)) {
+ return discard_const_p(void, ptr);
+ }
+ return NULL;
+}
+
+
+/*
+ this is for compatibility with older versions of talloc
+*/
+void *talloc_init(const char *fmt, ...)
+{
+ va_list ap;
+ void *ptr;
+ const char *name;
+
+ /*
+ * samba3 expects talloc_report_depth_cb(NULL, ...)
+ * reports all talloc'ed memory, so we need to enable
+ * null_tracking
+ */
+ talloc_enable_null_tracking();
+
+ ptr = __talloc(NULL, 0);
+ if (unlikely(ptr == NULL)) return NULL;
+
+ va_start(ap, fmt);
+ name = talloc_set_name_v(ptr, fmt, ap);
+ va_end(ap);
+
+ if (unlikely(name == NULL)) {
+ _talloc_free(ptr);
+ return NULL;
+ }
+
+ return ptr;
+}
+
+/*
+ this is a replacement for the Samba3 talloc_destroy_pool functionality. It
+ should probably not be used in new code. It's in here to keep the talloc
+ code consistent across Samba 3 and 4.
+*/
+void talloc_free_children(void *ptr)
+{
+ struct talloc_chunk *tc;
+
+ if (unlikely(ptr == NULL)) {
+ return;
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
+
+ while (tc->child) {
+ /* we need to work out who will own an abandoned child
+ if it cannot be freed. In priority order, the first
+ choice is owner of any remaining reference to this
+ pointer, the second choice is our parent, and the
+ final choice is the null context. */
+ void *child = TC_PTR_FROM_CHUNK(tc->child);
+ const void *new_parent = null_context;
+ if (unlikely(tc->child->refs)) {
+ struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs);
+ if (p) new_parent = TC_PTR_FROM_CHUNK(p);
+ }
+ if (unlikely(_talloc_free(child) == -1)) {
+ if (new_parent == null_context) {
+ struct talloc_chunk *p = talloc_parent_chunk(ptr);
+ if (p) new_parent = TC_PTR_FROM_CHUNK(p);
+ }
+ talloc_steal(new_parent, child);
+ }
+ }
+
+ if ((tc->flags & TALLOC_FLAG_POOL)
+ && (*talloc_pool_objectcount(tc) == 1)) {
+ tc->pool = ((char *)tc + TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE);
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
+ VALGRIND_MAKE_MEM_NOACCESS(
+ tc->pool, tc->size - TALLOC_POOL_HDR_SIZE);
+#endif
+ }
+}
+
+/*
+ Allocate a bit of memory as a child of an existing pointer
+*/
+void *_talloc(const void *context, size_t size)
+{
+ return __talloc(context, size);
+}
+
+/*
+ externally callable talloc_set_name_const()
+*/
+void talloc_set_name_const(const void *ptr, const char *name)
+{
+ _talloc_set_name_const(ptr, name);
+}
+
+/*
+ create a named talloc pointer. Any talloc pointer can be named, and
+ talloc_named() operates just like talloc() except that it allows you
+ to name the pointer.
+*/
+void *talloc_named_const(const void *context, size_t size, const char *name)
+{
+ return _talloc_named_const(context, size, name);
+}
+
+/*
+ free a talloc pointer. This also frees all child pointers of this
+ pointer recursively
+
+ return 0 if the memory is actually freed, otherwise -1. The memory
+ will not be freed if the ref_count is > 1 or the destructor (if
+ any) returns non-zero
+*/
+int talloc_free(void *ptr)
+{
+ return _talloc_free(ptr);
+}
+
+
+
+/*
+ A talloc version of realloc. The context argument is only used if
+ ptr is NULL
+*/
+void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name)
+{
+ struct talloc_chunk *tc;
+ void *new_ptr;
+ bool malloced = false;
+
+ /* size zero is equivalent to free() */
+ if (unlikely(size == 0)) {
+ _talloc_free(ptr);
+ return NULL;
+ }
+
+ if (unlikely(size >= MAX_TALLOC_SIZE)) {
+ abort(); // return NULL;
+ }
+
+ /* realloc(NULL) is equivalent to malloc() */
+ if (ptr == NULL) {
+ return _talloc_named_const(context, size, name);
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
+
+ /* don't allow realloc on referenced pointers */
+ if (unlikely(tc->refs)) {
+ abort(); // return NULL;
+ }
+
+ /* don't shrink if we have less than 1k to gain */
+ if ((size < tc->size) && ((tc->size - size) < 1024)) {
+ tc->size = size;
+ return ptr;
+ }
+
+ /* by resetting magic we catch users of the old memory */
+ tc->flags |= TALLOC_FLAG_FREE;
+
+#if ALWAYS_REALLOC
+ new_ptr = malloc(size + TC_HDR_SIZE);
+ if (new_ptr) {
+ memcpy(new_ptr, tc, tc->size + TC_HDR_SIZE);
+ free(tc);
+ }
+#else
+ if (tc->flags & TALLOC_FLAG_POOLMEM) {
+
+ new_ptr = talloc_alloc_pool(tc, size + TC_HDR_SIZE);
+ *talloc_pool_objectcount((struct talloc_chunk *)
+ (tc->pool)) -= 1;
+
+ if (new_ptr == NULL) {
+ new_ptr = malloc(TC_HDR_SIZE+size);
+ malloced = true;
+ }
+
+ if (new_ptr) {
+ memcpy(new_ptr, tc, MIN(tc->size,size) + TC_HDR_SIZE);
+ }
+ }
+ else {
+ new_ptr = realloc(tc, size + TC_HDR_SIZE);
+ }
+#endif
+ if (unlikely(!new_ptr)) {
+ tc->flags &= ~TALLOC_FLAG_FREE;
+ abort(); // return NULL;
+ }
+
+ tc = (struct talloc_chunk *)new_ptr;
+ tc->flags &= ~TALLOC_FLAG_FREE;
+ if (malloced) {
+ tc->flags &= ~TALLOC_FLAG_POOLMEM;
+ }
+ if (tc->parent) {
+ tc->parent->child = tc;
+ }
+ if (tc->child) {
+ tc->child->parent = tc;
+ }
+
+ if (tc->prev) {
+ tc->prev->next = tc;
+ }
+ if (tc->next) {
+ tc->next->prev = tc;
+ }
+
+ tc->size = size;
+ _talloc_set_name_const(TC_PTR_FROM_CHUNK(tc), name);
+
+ return TC_PTR_FROM_CHUNK(tc);
+}
+
+/*
+ a wrapper around talloc_steal() for situations where you are moving a pointer
+ between two structures, and want the old pointer to be set to NULL
+*/
+void *_talloc_move(const void *new_ctx, const void *_pptr)
+{
+ const void **pptr = discard_const_p(const void *,_pptr);
+ void *ret = _talloc_steal(new_ctx, *pptr);
+ (*pptr) = NULL;
+ return ret;
+}
+
+/*
+ return the total size of a talloc pool (subtree)
+*/
+size_t talloc_total_size(const void *ptr)
+{
+ size_t total = 0;
+ struct talloc_chunk *c, *tc;
+
+ if (ptr == NULL) {
+ ptr = null_context;
+ }
+ if (ptr == NULL) {
+ return 0;
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
+
+ if (tc->flags & TALLOC_FLAG_LOOP) {
+ return 0;
+ }
+
+ tc->flags |= TALLOC_FLAG_LOOP;
+
+ total = tc->size;
+ for (c=tc->child;c;c=c->next) {
+ total += talloc_total_size(TC_PTR_FROM_CHUNK(c));
+ }
+
+ tc->flags &= ~TALLOC_FLAG_LOOP;
+
+ return total;
+}
+
+/*
+ return the total number of blocks in a talloc pool (subtree)
+*/
+size_t talloc_total_blocks(const void *ptr)
+{
+ size_t total = 0;
+ struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr);
+
+ if (tc->flags & TALLOC_FLAG_LOOP) {
+ return 0;
+ }
+
+ tc->flags |= TALLOC_FLAG_LOOP;
+
+ total++;
+ for (c=tc->child;c;c=c->next) {
+ total += talloc_total_blocks(TC_PTR_FROM_CHUNK(c));
+ }
+
+ tc->flags &= ~TALLOC_FLAG_LOOP;
+
+ return total;
+}
+
+/*
+ return the number of external references to a pointer
+*/
+size_t talloc_reference_count(const void *ptr)
+{
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
+ struct talloc_reference_handle *h;
+ size_t ret = 0;
+
+ for (h=tc->refs;h;h=h->next) {
+ ret++;
+ }
+ return ret;
+}
+
+/*
+ report on memory usage by all children of a pointer, giving a full tree view
+*/
+void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
+ void (*callback)(const void *ptr,
+ int depth, int max_depth,
+ int is_ref,
+ void *private_data),
+ void *private_data)
+{
+ struct talloc_chunk *c, *tc;
+
+ if (ptr == NULL) {
+ ptr = null_context;
+ }
+ if (ptr == NULL) return;
+
+ tc = talloc_chunk_from_ptr(ptr);
+
+ if (tc->flags & TALLOC_FLAG_LOOP) {
+ return;
+ }
+
+ callback(ptr, depth, max_depth, 0, private_data);
+
+ if (max_depth >= 0 && depth >= max_depth) {
+ return;
+ }
+
+ tc->flags |= TALLOC_FLAG_LOOP;
+ for (c=tc->child;c;c=c->next) {
+ if (c->name == TALLOC_MAGIC_REFERENCE) {
+ struct talloc_reference_handle *h = (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c);
+ callback(h->ptr, depth + 1, max_depth, 1, private_data);
+ } else {
+ talloc_report_depth_cb(TC_PTR_FROM_CHUNK(c), depth + 1, max_depth, callback, private_data);
+ }
+ }
+ tc->flags &= ~TALLOC_FLAG_LOOP;
+}
+
+static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_depth, int is_ref, void *_f)
+{
+ const char *name = talloc_get_name(ptr);
+ FILE *f = (FILE *)_f;
+
+ if (is_ref) {
+ fprintf(f, "%*sreference to: %s\n", depth*4, "", name);
+ return;
+ }
+
+ if (depth == 0) {
+ fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n",
+ (max_depth < 0 ? "full " :""), name,
+ (unsigned long)talloc_total_size(ptr),
+ (unsigned long)talloc_total_blocks(ptr));
+ return;
+ }
+
+ fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d) %p\n",
+ depth*4, "",
+ name,
+ (unsigned long)talloc_total_size(ptr),
+ (unsigned long)talloc_total_blocks(ptr),
+ (int)talloc_reference_count(ptr), ptr);
+
+#if 0
+ fprintf(f, "content: ");
+ if (talloc_total_size(ptr)) {
+ int tot = talloc_total_size(ptr);
+ int i;
+
+ for (i = 0; i < tot; i++) {
+ if ((((char *)ptr)[i] > 31) && (((char *)ptr)[i] < 126)) {
+ fprintf(f, "%c", ((char *)ptr)[i]);
+ } else {
+ fprintf(f, "~%02x", ((char *)ptr)[i]);
+ }
+ }
+ }
+ fprintf(f, "\n");
+#endif
+}
+
+/*
+ report on memory usage by all children of a pointer, giving a full tree view
+*/
+void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f)
+{
+ talloc_report_depth_cb(ptr, depth, max_depth, talloc_report_depth_FILE_helper, f);
+ fflush(f);
+}
+
+/*
+ report on memory usage by all children of a pointer, giving a full tree view
+*/
+void talloc_report_full(const void *ptr, FILE *f)
+{
+ talloc_report_depth_file(ptr, 0, -1, f);
+}
+
+/*
+ report on memory usage by all children of a pointer
+*/
+void talloc_report(const void *ptr, FILE *f)
+{
+ talloc_report_depth_file(ptr, 0, 1, f);
+}
+
+/*
+ report on any memory hanging off the null context
+*/
+static void talloc_report_null(void)
+{
+ if (talloc_total_size(null_context) != 0) {
+ talloc_report(null_context, stderr);
+ }
+}
+
+/*
+ report on any memory hanging off the null context
+*/
+static void talloc_report_null_full(void)
+{
+ if (talloc_total_size(null_context) != 0) {
+ talloc_report_full(null_context, stderr);
+ }
+}
+
+/*
+ enable tracking of the NULL context
+*/
+void talloc_enable_null_tracking(void)
+{
+ if (null_context == NULL) {
+ null_context = _talloc_named_const(NULL, 0, "null_context");
+ }
+}
+
+/*
+ disable tracking of the NULL context
+*/
+void talloc_disable_null_tracking(void)
+{
+ _talloc_free(null_context);
+ null_context = NULL;
+}
+
+/*
+ enable leak reporting on exit
+*/
+void talloc_enable_leak_report(void)
+{
+ talloc_enable_null_tracking();
+ atexit(talloc_report_null);
+}
+
+/*
+ enable full leak reporting on exit
+*/
+void talloc_enable_leak_report_full(void)
+{
+ talloc_enable_null_tracking();
+ atexit(talloc_report_null_full);
+}
+
+/*
+ talloc and zero memory.
+*/
+void *_talloc_zero(const void *ctx, size_t size, const char *name)
+{
+ void *p = _talloc_named_const(ctx, size, name);
+
+ if (p) {
+ memset(p, '\0', size);
+ }
+
+ return p;
+}
+
+/*
+ memdup with a talloc.
+*/
+void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name)
+{
+ void *newp = _talloc_named_const(t, size, name);
+
+ if (likely(newp)) {
+ memcpy(newp, p, size);
+ }
+
+ return newp;
+}
+
+static inline char *__talloc_strlendup(const void *t, const char *p, size_t len)
+{
+ char *ret;
+
+ ret = (char *)__talloc(t, len + 1);
+ if (unlikely(!ret)) return NULL;
+
+ memcpy(ret, p, len);
+ ret[len] = 0;
+
+ _talloc_set_name_const(ret, ret);
+ return ret;
+}
+
+/*
+ strdup with a talloc
+*/
+char *talloc_strdup(const void *t, const char *p)
+{
+ if (unlikely(!p)) return NULL;
+ return __talloc_strlendup(t, p, strlen(p));
+}
+
+/*
+ strndup with a talloc
+*/
+char *talloc_strndup(const void *t, const char *p, size_t n)
+{
+ if (unlikely(!p)) return NULL;
+ return __talloc_strlendup(t, p, strnlen(p, n));
+}
+
+static inline char *__talloc_strlendup_append(char *s, size_t slen,
+ const char *a, size_t alen)
+{
+ char *ret;
+
+ ret = talloc_realloc(NULL, s, char, slen + alen + 1);
+ if (unlikely(!ret)) return NULL;
+
+ /* append the string and the trailing \0 */
+ memcpy(&ret[slen], a, alen);
+ ret[slen+alen] = 0;
+
+ _talloc_set_name_const(ret, ret);
+ return ret;
+}
+
+/*
+ * Appends at the end of the string.
+ */
+char *talloc_strdup_append(char *s, const char *a)
+{
+ if (unlikely(!s)) {
+ return talloc_strdup(NULL, a);
+ }
+
+ if (unlikely(!a)) {
+ return s;
+ }
+
+ return __talloc_strlendup_append(s, strlen(s), a, strlen(a));
+}
+
+/*
+ * Appends at the end of the talloc'ed buffer,
+ * not the end of the string.
+ */
+char *talloc_strdup_append_buffer(char *s, const char *a)
+{
+ size_t slen;
+
+ if (unlikely(!s)) {
+ return talloc_strdup(NULL, a);
+ }
+
+ if (unlikely(!a)) {
+ return s;
+ }
+
+ slen = talloc_get_size(s);
+ if (likely(slen > 0)) {
+ slen--;
+ }
+
+ return __talloc_strlendup_append(s, slen, a, strlen(a));
+}
+
+/*
+ * Appends at the end of the string.
+ */
+char *talloc_strndup_append(char *s, const char *a, size_t n)
+{
+ if (unlikely(!s)) {
+ return talloc_strdup(NULL, a);
+ }
+
+ if (unlikely(!a)) {
+ return s;
+ }
+
+ return __talloc_strlendup_append(s, strlen(s), a, strnlen(a, n));
+}
+
+/*
+ * Appends at the end of the talloc'ed buffer,
+ * not the end of the string.
+ */
+char *talloc_strndup_append_buffer(char *s, const char *a, size_t n)
+{
+ size_t slen;
+
+ if (unlikely(!s)) {
+ return talloc_strdup(NULL, a);
+ }
+
+ if (unlikely(!a)) {
+ return s;
+ }
+
+ slen = talloc_get_size(s);
+ if (likely(slen > 0)) {
+ slen--;
+ }
+
+ return __talloc_strlendup_append(s, slen, a, strnlen(a, n));
+}
+
+#ifndef HAVE_VA_COPY
+#ifdef HAVE___VA_COPY
+#define va_copy(dest, src) __va_copy(dest, src)
+#else
+#define va_copy(dest, src) (dest) = (src)
+#endif
+#endif
+
+char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
+{
+ int len;
+ char *ret;
+ va_list ap2;
+ char c;
+
+ /* this call looks strange, but it makes it work on older solaris boxes */
+ va_copy(ap2, ap);
+ len = vsnprintf(&c, 1, fmt, ap2);
+ va_end(ap2);
+ if (unlikely(len < 0)) {
+ abort(); // return NULL;
+ }
+
+ ret = (char *)__talloc(t, len+1);
+ if (unlikely(!ret)) return NULL;
+
+ va_copy(ap2, ap);
+ vsnprintf(ret, len+1, fmt, ap2);
+ va_end(ap2);
+
+ _talloc_set_name_const(ret, ret);
+ return ret;
+}
+
+
+/*
+ Perform string formatting, and return a pointer to newly allocated
+ memory holding the result, inside a memory pool.
+ */
+char *talloc_asprintf(const void *t, const char *fmt, ...)
+{
+ va_list ap;
+ char *ret;
+
+ va_start(ap, fmt);
+ ret = talloc_vasprintf(t, fmt, ap);
+ va_end(ap);
+ return ret;
+}
+
+static inline char *__talloc_vaslenprintf_append(char *s, size_t slen,
+ const char *fmt, va_list ap)
+ PRINTF_ATTRIBUTE(3,0);
+
+static inline char *__talloc_vaslenprintf_append(char *s, size_t slen,
+ const char *fmt, va_list ap)
+{
+ ssize_t alen;
+ va_list ap2;
+ char c;
+
+ va_copy(ap2, ap);
+ alen = vsnprintf(&c, 1, fmt, ap2);
+ va_end(ap2);
+
+ if (alen <= 0) {
+ /* Either the vsnprintf failed or the format resulted in
+ * no characters being formatted. In the former case, we
+ * ought to return NULL, in the latter we ought to return
+ * the original string. Most current callers of this
+ * function expect it to never return NULL.
+ */
+ return s;
+ }
+
+ s = talloc_realloc(NULL, s, char, slen + alen + 1);
+ if (!s) return NULL;
+
+ va_copy(ap2, ap);
+ vsnprintf(s + slen, alen + 1, fmt, ap2);
+ va_end(ap2);
+
+ _talloc_set_name_const(s, s);
+ return s;
+}
+
+/**
+ * Realloc @p s to append the formatted result of @p fmt and @p ap,
+ * and return @p s, which may have moved. Good for gradually
+ * accumulating output into a string buffer. Appends at the end
+ * of the string.
+ **/
+char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
+{
+ if (unlikely(!s)) {
+ return talloc_vasprintf(NULL, fmt, ap);
+ }
+
+ return __talloc_vaslenprintf_append(s, strlen(s), fmt, ap);
+}
+
+/**
+ * Realloc @p s to append the formatted result of @p fmt and @p ap,
+ * and return @p s, which may have moved. Always appends at the
+ * end of the talloc'ed buffer, not the end of the string.
+ **/
+char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap)
+{
+ size_t slen;
+
+ if (unlikely(!s)) {
+ return talloc_vasprintf(NULL, fmt, ap);
+ }
+
+ slen = talloc_get_size(s);
+ if (likely(slen > 0)) {
+ slen--;
+ }
+
+ return __talloc_vaslenprintf_append(s, slen, fmt, ap);
+}
+
+/*
+ Realloc @p s to append the formatted result of @p fmt and return @p
+ s, which may have moved. Good for gradually accumulating output
+ into a string buffer.
+ */
+char *talloc_asprintf_append(char *s, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ s = talloc_vasprintf_append(s, fmt, ap);
+ va_end(ap);
+ return s;
+}
+
+/*
+ Realloc @p s to append the formatted result of @p fmt and return @p
+ s, which may have moved. Good for gradually accumulating output
+ into a buffer.
+ */
+char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ s = talloc_vasprintf_append_buffer(s, fmt, ap);
+ va_end(ap);
+ return s;
+}
+
+/*
+ alloc an array, checking for integer overflow in the array size
+*/
+void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)
+{
+ if (count >= MAX_TALLOC_SIZE/el_size) {
+ abort(); // return NULL;
+ }
+ return _talloc_named_const(ctx, el_size * count, name);
+}
+
+/*
+ alloc an zero array, checking for integer overflow in the array size
+*/
+void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name)
+{
+ if (count >= MAX_TALLOC_SIZE/el_size) {
+ abort(); // return NULL;
+ }
+ return _talloc_zero(ctx, el_size * count, name);
+}
+
+/*
+ realloc an array, checking for integer overflow in the array size
+*/
+void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name)
+{
+ if (count >= MAX_TALLOC_SIZE/el_size) {
+ abort(); // return NULL;
+ }
+ return _talloc_realloc(ctx, ptr, el_size * count, name);
+}
+
+/*
+ a function version of talloc_realloc(), so it can be passed as a function pointer
+ to libraries that want a realloc function (a realloc function encapsulates
+ all the basic capabilities of an allocation library, which is why this is useful)
+*/
+void *talloc_realloc_fn(const void *context, void *ptr, size_t size)
+{
+ return _talloc_realloc(context, ptr, size, NULL);
+}
+
+
+static int talloc_autofree_destructor(void *ptr)
+{
+ autofree_context = NULL;
+ return 0;
+}
+
+static void talloc_autofree(void)
+{
+ _talloc_free(autofree_context);
+}
+
+/*
+ return a context which will be auto-freed on exit
+ this is useful for reducing the noise in leak reports
+*/
+void *talloc_autofree_context(void)
+{
+ if (autofree_context == NULL) {
+ autofree_context = _talloc_named_const(NULL, 0, "autofree_context");
+ talloc_set_destructor(autofree_context, talloc_autofree_destructor);
+ atexit(talloc_autofree);
+ }
+ return autofree_context;
+}
+
+size_t talloc_get_size(const void *context)
+{
+ struct talloc_chunk *tc;
+
+ if (context == NULL)
+ return 0;
+
+ tc = talloc_chunk_from_ptr(context);
+
+ return tc->size;
+}
+
+/*
+ find a parent of this context that has the given name, if any
+*/
+void *talloc_find_parent_byname(const void *context, const char *name)
+{
+ struct talloc_chunk *tc;
+
+ if (context == NULL) {
+ return NULL;
+ }
+
+ tc = talloc_chunk_from_ptr(context);
+ while (tc) {
+ if (tc->name && strcmp(tc->name, name) == 0) {
+ return TC_PTR_FROM_CHUNK(tc);
+ }
+ while (tc && tc->prev) tc = tc->prev;
+ if (tc) {
+ tc = tc->parent;
+ }
+ }
+ return NULL;
+}
+
+/*
+ show the parentage of a context
+*/
+void talloc_show_parents(const void *context, FILE *file)
+{
+ struct talloc_chunk *tc;
+
+ if (context == NULL) {
+ fprintf(file, "talloc no parents for NULL\n");
+ return;
+ }
+
+ tc = talloc_chunk_from_ptr(context);
+ fprintf(file, "talloc parents of '%s'\n", talloc_get_name(context));
+ while (tc) {
+ fprintf(file, "\t'%s'\n", talloc_get_name(TC_PTR_FROM_CHUNK(tc)));
+ while (tc && tc->prev) tc = tc->prev;
+ if (tc) {
+ tc = tc->parent;
+ }
+ }
+ fflush(file);
+}
+
+/*
+ return 1 if ptr is a parent of context
+*/
+int talloc_is_parent(const void *context, const void *ptr)
+{
+ struct talloc_chunk *tc;
+
+ if (context == NULL) {
+ return 0;
+ }
+
+ tc = talloc_chunk_from_ptr(context);
+ while (tc) {
+ if (TC_PTR_FROM_CHUNK(tc) == ptr) return 1;
+ while (tc && tc->prev) tc = tc->prev;
+ if (tc) {
+ tc = tc->parent;
+ }
+ }
+ return 0;
+}
diff --git a/talloc.h b/talloc.h
new file mode 100644
index 0000000000..5431971655
--- /dev/null
+++ b/talloc.h
@@ -0,0 +1,183 @@
+#ifndef _TALLOC_H_
+#define _TALLOC_H_
+/*
+ Unix SMB/CIFS implementation.
+ Samba temporary memory allocation functions
+
+ Copyright (C) Andrew Tridgell 2004-2005
+ Copyright (C) Stefan Metzmacher 2006
+
+ ** NOTE! The following LGPL license applies to the talloc
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+/* this is only needed for compatibility with the old talloc */
+typedef void TALLOC_CTX;
+
+/*
+ this uses a little trick to allow __LINE__ to be stringified
+*/
+#ifndef __location__
+#define __TALLOC_STRING_LINE1__(s) #s
+#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s)
+#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__)
+#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__
+#endif
+
+#ifndef TALLOC_DEPRECATED
+#define TALLOC_DEPRECATED 0
+#endif
+
+#ifndef PRINTF_ATTRIBUTE
+#if (__GNUC__ >= 3)
+/** Use gcc attribute to check printf fns. a1 is the 1-based index of
+ * the parameter containing the format, and a2 the index of the first
+ * argument. Note that some gcc 2.x versions don't handle this
+ * properly **/
+#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
+#else
+#define PRINTF_ATTRIBUTE(a1, a2)
+#endif
+#endif
+
+/* try to make talloc_set_destructor() and talloc_steal() type safe,
+ if we have a recent gcc */
+#if (__GNUC__ >= 3)
+#define _TALLOC_TYPEOF(ptr) __typeof__(ptr)
+#define talloc_set_destructor(ptr, function) \
+ do { \
+ int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \
+ _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \
+ } while(0)
+/* this extremely strange macro is to avoid some braindamaged warning
+ stupidity in gcc 4.1.x */
+#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; })
+#else
+#define talloc_set_destructor(ptr, function) \
+ _talloc_set_destructor((ptr), (int (*)(void *))(function))
+#define _TALLOC_TYPEOF(ptr) void *
+#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr))
+#endif
+
+#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr))
+#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr))
+
+/* useful macros for creating type checked pointers */
+#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
+#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
+#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr)))
+
+#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__)
+
+#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
+#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
+
+#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
+#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
+#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
+#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count)
+
+#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type)
+#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
+
+#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
+
+#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type)
+#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type)
+
+#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type)
+
+#if TALLOC_DEPRECATED
+#define talloc_zero_p(ctx, type) talloc_zero(ctx, type)
+#define talloc_p(ctx, type) talloc(ctx, type)
+#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count)
+#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count)
+#define talloc_destroy(ctx) talloc_free(ctx)
+#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a))
+#endif
+
+/* The following definitions come from talloc.c */
+void *_talloc(const void *context, size_t size);
+void *talloc_pool(const void *context, size_t size);
+void _talloc_set_destructor(const void *ptr, int (*destructor)(void *));
+int talloc_increase_ref_count(const void *ptr);
+size_t talloc_reference_count(const void *ptr);
+void *_talloc_reference(const void *context, const void *ptr);
+int talloc_unlink(const void *context, void *ptr);
+const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+void talloc_set_name_const(const void *ptr, const char *name);
+void *talloc_named(const void *context, size_t size,
+ const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
+void *talloc_named_const(const void *context, size_t size, const char *name);
+const char *talloc_get_name(const void *ptr);
+void *talloc_check_name(const void *ptr, const char *name);
+void *talloc_parent(const void *ptr);
+const char *talloc_parent_name(const void *ptr);
+void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
+int talloc_free(void *ptr);
+void talloc_free_children(void *ptr);
+void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name);
+void *_talloc_steal(const void *new_ctx, const void *ptr);
+void *_talloc_move(const void *new_ctx, const void *pptr);
+size_t talloc_total_size(const void *ptr);
+size_t talloc_total_blocks(const void *ptr);
+void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
+ void (*callback)(const void *ptr,
+ int depth, int max_depth,
+ int is_ref,
+ void *private_data),
+ void *private_data);
+void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f);
+void talloc_report_full(const void *ptr, FILE *f);
+void talloc_report(const void *ptr, FILE *f);
+void talloc_enable_null_tracking(void);
+void talloc_disable_null_tracking(void);
+void talloc_enable_leak_report(void);
+void talloc_enable_leak_report_full(void);
+void *_talloc_zero(const void *ctx, size_t size, const char *name);
+void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name);
+void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
+void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
+void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
+void *talloc_realloc_fn(const void *context, void *ptr, size_t size);
+void *talloc_autofree_context(void);
+size_t talloc_get_size(const void *ctx);
+void *talloc_find_parent_byname(const void *ctx, const char *name);
+void talloc_show_parents(const void *context, FILE *file);
+int talloc_is_parent(const void *context, const void *ptr);
+
+char *talloc_strdup(const void *t, const char *p);
+char *talloc_strdup_append(char *s, const char *a);
+char *talloc_strdup_append_buffer(char *s, const char *a);
+
+char *talloc_strndup(const void *t, const char *p, size_t n);
+char *talloc_strndup_append(char *s, const char *a, size_t n);
+char *talloc_strndup_append_buffer(char *s, const char *a, size_t n);
+
+char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+
+char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+
+#endif
diff --git a/unrar_exec.c b/unrar_exec.c
index db59d9adc7..6de8c59bef 100644
--- a/unrar_exec.c
+++ b/unrar_exec.c
@@ -233,4 +233,3 @@ void unrar_exec_freelist(ArchiveList_struct *list)
list = tmp;
}
}
-
diff --git a/vidix/.gitignore b/vidix/.gitignore
new file mode 100644
index 0000000000..96d02a288a
--- /dev/null
+++ b/vidix/.gitignore
@@ -0,0 +1,5 @@
+/pci_dev_ids.c
+/pci_ids.h
+/pci_names.c
+/pci_names.h
+/pci_vendors.h
diff --git a/vidix/drivers.c b/vidix/drivers.c
index 428b2d7ca4..559dee30e0 100644
--- a/vidix/drivers.c
+++ b/vidix/drivers.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <string.h>
+#include "drivers.h"
#include "config.h"
#include "vidix.h"
#include "libavutil/common.h"
diff --git a/vidix/nvidia_vid.c b/vidix/nvidia_vid.c
index 227fbcf6ef..79f3880ebd 100644
--- a/vidix/nvidia_vid.c
+++ b/vidix/nvidia_vid.c
@@ -441,12 +441,12 @@ struct rivatv_info {
};
typedef struct rivatv_info rivatv_info;
-uint8_t nvReadVGA (struct rivatv_chip *chip, int index) {
+static uint8_t nvReadVGA (struct rivatv_chip *chip, int index) {
VID_WR08 (chip->PCIO, 0x3D4, index);
return VID_RD08 (chip->PCIO, 0x3D5);
}
-void nvWriteVGA (struct rivatv_chip *chip, int index, int data) {
+static void nvWriteVGA (struct rivatv_chip *chip, int index, int data) {
VID_WR08 (chip->PCIO, 0x3D4, index);
VID_WR08 (chip->PCIO, 0x3D5, data);
}
@@ -1149,4 +1149,3 @@ int main(int argc,char* argv[]){
}
#endif
-
diff --git a/vidix/sysdep/pci_alpha.c b/vidix/sysdep/pci_alpha.c
index 997aaa70a1..74839e3625 100644
--- a/vidix/sysdep/pci_alpha.c
+++ b/vidix/sysdep/pci_alpha.c
@@ -26,4 +26,3 @@ static long pci_config_read_long(
pciconfig_read(bus, dev<<3, cmd, 4, &retval);
return retval;
}
-
diff --git a/vobsub.h b/vobsub.h
index c14ce9c711..72029a9a56 100644
--- a/vobsub.h
+++ b/vobsub.h
@@ -27,4 +27,3 @@ int vobsub_set_from_lang(void *vobhandle, unsigned char * lang);
void vobsub_seek(void * vobhandle, float pts);
#endif /* MPLAYER_VOBSUB_H */
-