diff options
Diffstat (limited to 'libmpcodecs')
65 files changed, 901 insertions, 883 deletions
diff --git a/libmpcodecs/ad_acm.c b/libmpcodecs/ad_acm.c index b179515754..46af4fae7d 100644 --- a/libmpcodecs/ad_acm.c +++ b/libmpcodecs/ad_acm.c @@ -22,7 +22,6 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "libmpdemux/aviprint.h" #include "loader/wineacm.h" @@ -75,7 +74,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; } @@ -106,7 +105,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_dmo.c b/libmpcodecs/ad_dmo.c index d89e9d646c..1501c21078 100644 --- a/libmpcodecs/ad_dmo.c +++ b/libmpcodecs/ad_dmo.c @@ -22,7 +22,6 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "ad_internal.h" #include "libaf/reorder_ch.h" @@ -52,7 +51,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 e88ed0c2fa..8fb94660a4 100644 --- a/libmpcodecs/ad_dshow.c +++ b/libmpcodecs/ad_dshow.c @@ -22,7 +22,6 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "ad_internal.h" @@ -49,7 +48,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 b0bb169d95..41f6a1426d 100644 --- a/libmpcodecs/ad_dvdpcm.c +++ b/libmpcodecs/ad_dvdpcm.c @@ -22,7 +22,6 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "ad_internal.h" static const ad_info_t info = @@ -56,7 +55,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 4f62765257..14fe9a6280 100644 --- a/libmpcodecs/ad_faad.c +++ b/libmpcodecs/ad_faad.c @@ -172,7 +172,7 @@ static int init(sh_audio_t *sh) sh->samplesize=2; //sh->o_bps = sh->samplesize*faac_channels*faac_samplerate; if(!sh->i_bps) { - mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: compressed input bitrate missing, assuming 128kbit/s!\n"); + mp_msg(MSGT_DECAUDIO, MSGL_V, "FAAD: compressed input bitrate missing, assuming 128kbit/s!\n"); sh->i_bps = 128*1000/8; // XXX: HACK!!! ::atmos } else mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: got %dkbit/s bitrate from MP4 header!\n",sh->i_bps*8/1000); diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 9d1b8356ad..c954fb2311 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -22,7 +22,6 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "ad_internal.h" #include "libaf/reorder_ch.h" @@ -68,7 +67,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; } @@ -108,7 +107,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 \"%s\" init OK!\n", lavc_codec->name); @@ -143,19 +142,18 @@ static int init(sh_audio_t *sh_audio) mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Unsupported sample format\n"); return 0; } - if(sh_audio->wf){ + /* If the audio is AAC the container level data may be unreliable + * because of SBR handling problems (possibly half real sample rate at + * container level). Default AAC decoding with ad_faad has used codec-level + * values for a long time without generating complaints so it should be OK. + */ + if (sh_audio->wf && lavc_context->codec_id != CODEC_ID_AAC) { // If the decoder uses the wrong number of channels all is lost anyway. // sh_audio->channels=sh_audio->wf->nChannels; - - if (lavc_context->codec_id == CODEC_ID_AAC && - sh_audio->samplerate == 2*sh_audio->wf->nSamplesPerSec) { - mp_msg(MSGT_DECAUDIO, MSGL_WARN, - "Ignoring broken container sample rate for ACC with SBR\n"); - } else if (sh_audio->wf->nSamplesPerSec) - sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; - + if (sh_audio->wf->nSamplesPerSec) + sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; if (sh_audio->wf->nAvgBytesPerSec) - sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; + sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; } sh_audio->samplesize=af_fmt2bits(sh_audio->sample_format)/ 8; return 1; @@ -166,7 +164,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 119839b9bc..f45fd00a17 100644 --- a/libmpcodecs/ad_hwac3.c +++ b/libmpcodecs/ad_hwac3.c @@ -28,10 +28,9 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "mpbswap.h" #include "libavutil/common.h" -#include "libavutil/intreadwrite.h" +#include "ffmpeg_files/intreadwrite.h" #include "ad_internal.h" diff --git a/libmpcodecs/ad_hwmpa.c b/libmpcodecs/ad_hwmpa.c index 30caa9b0f9..87c00b6f42 100644 --- a/libmpcodecs/ad_hwmpa.c +++ b/libmpcodecs/ad_hwmpa.c @@ -24,7 +24,6 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "libaf/af_format.h" #include "ad_internal.h" diff --git a/libmpcodecs/ad_liba52.c b/libmpcodecs/ad_liba52.c index 2e2006abc1..29e546a602 100644 --- a/libmpcodecs/ad_liba52.c +++ b/libmpcodecs/ad_liba52.c @@ -26,7 +26,6 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "mpbswap.h" #include "ad_internal.h" diff --git a/libmpcodecs/ad_libdv.c b/libmpcodecs/ad_libdv.c index 8485a8883f..cbcb46efea 100644 --- a/libmpcodecs/ad_libdv.c +++ b/libmpcodecs/ad_libdv.c @@ -25,7 +25,6 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" #include "img_format.h" @@ -102,7 +101,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_msadpcm.c b/libmpcodecs/ad_msadpcm.c index 64dc39c485..162c7c04d3 100644 --- a/libmpcodecs/ad_msadpcm.c +++ b/libmpcodecs/ad_msadpcm.c @@ -30,7 +30,7 @@ #include "config.h" #include "libavutil/common.h" -#include "libavutil/intreadwrite.h" +#include "ffmpeg_files/intreadwrite.h" #include "mpbswap.h" #include "ad_internal.h" diff --git a/libmpcodecs/ad_pcm.c b/libmpcodecs/ad_pcm.c index 0dd50e0c65..29e78d69af 100644 --- a/libmpcodecs/ad_pcm.c +++ b/libmpcodecs/ad_pcm.c @@ -19,7 +19,9 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <stdbool.h> +#include "talloc.h" #include "config.h" #include "ad_internal.h" #include "libaf/af_format.h" @@ -33,6 +35,13 @@ static const ad_info_t info = { "" }; +struct ad_pcm_context { + unsigned char *buffer; + int buffer_pos; + int buffer_len; + int buffer_size; +}; + LIBAD_EXTERN(pcm) static int init(sh_audio_t * sh_audio) @@ -114,6 +123,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; } @@ -125,12 +135,17 @@ 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, ...) { + struct ad_pcm_context *ctx = sh->context; int skip; switch (cmd) { + case ADCTRL_RESYNC_STREAM: + ctx->buffer_len = 0; + return true; case ADCTRL_SKIP_FRAME: skip = sh->i_bps / 16; skip = skip & (~3); @@ -143,13 +158,45 @@ 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) + int len = sh_audio->channels * sh_audio->samplesize; + 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->buffer_len - ctx->buffer_pos <= 0) { + double pts; + unsigned char *ptr; + int plen = ds_get_packet_pts(sh_audio->ds, &ptr, &pts); + if (plen < 0) + break; + if (ctx->buffer_size < plen) { + talloc_free(ctx->buffer); + ctx->buffer = talloc_size(ctx, plen); + ctx->buffer_size = plen; + } + memcpy(ctx->buffer, ptr, plen); + ctx->buffer_len = plen; + ctx->buffer_pos = 0; + if (pts != MP_NOPTS_VALUE) { + sh_audio->pts = pts; + sh_audio->pts_bytes = 0; + } + } + int from_stored = ctx->buffer_len - ctx->buffer_pos; + if (from_stored > minlen - len) + from_stored = minlen - len; + memcpy(buf + len, ctx->buffer + ctx->buffer_pos, from_stored); + ctx->buffer_pos += 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_realaud.c b/libmpcodecs/ad_realaud.c index 1d475f8dda..0b7fb219f7 100644 --- a/libmpcodecs/ad_realaud.c +++ b/libmpcodecs/ad_realaud.c @@ -26,7 +26,6 @@ #ifdef HAVE_LIBDL #include <dlfcn.h> #endif -#include "help_mp.h" #include "path.h" #include "ad_internal.h" @@ -42,46 +41,16 @@ static const ad_info_t info = { LIBAD_EXTERN(realaud) -/* These functions are required for loading Real binary libs. - * Add forward declarations to avoid warnings with -Wmissing-prototypes. */ -void *__builtin_new(unsigned long size); -void __builtin_delete(void *ize); -void *__builtin_vec_new(unsigned long size); -void __builtin_vec_delete(void *mem); -void __pure_virtual(void); - -void *__builtin_new(unsigned long size) -{ +void *__builtin_new(unsigned long size) { return malloc(size); } -void __builtin_delete(void* ize) -{ +// required for cook's uninit: +void __builtin_delete(void* ize) { free(ize); } -void *__builtin_vec_new(unsigned long size) -{ - return malloc(size); -} - -void __builtin_vec_delete(void *mem) -{ - free(mem); -} - -void __pure_virtual(void) -{ - printf("FATAL: __pure_virtual() called!\n"); -// exit(1); -} - #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) -void ___brk_addr(void); -void ___brk_addr(void) {exit(0);} -char **__environ={NULL}; -#undef stderr -FILE *stderr=NULL; void *__ctype_b=NULL; #endif @@ -266,7 +235,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_twin.c b/libmpcodecs/ad_twin.c index 823ace89dd..954ca17809 100644 --- a/libmpcodecs/ad_twin.c +++ b/libmpcodecs/ad_twin.c @@ -28,7 +28,6 @@ #include "loader/wine/windef.h" #include "libaf/af_format.h" -#include "help_mp.h" static const ad_info_t info = { diff --git a/libmpcodecs/ae_lame.c b/libmpcodecs/ae_lame.c index 14f81409e7..90ed31dfe7 100644 --- a/libmpcodecs/ae_lame.c +++ b/libmpcodecs/ae_lame.c @@ -28,8 +28,6 @@ #include "libmpdemux/ms_hdr.h" #include "stream/stream.h" #include "libmpdemux/muxer.h" -#include "help_mp.h" -#include "ae_lame.h" #include "ae_pcm.h" #include "libaf/af_format.h" #include "libmpdemux/mp3_hdr.h" @@ -58,6 +56,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"\ |