summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-10-31 00:04:18 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:16:55 +0200
commit389c32b5c72897a8b1b3c929c8f278e8980f2290 (patch)
tree47f7784ec12f9d53172f7ad326ed78f2f9889f74 /libmpcodecs
parent8939645dcf39c398e1b70b851b3410299ca619ce (diff)
downloadmpv-389c32b5c72897a8b1b3c929c8f278e8980f2290.tar.bz2
mpv-389c32b5c72897a8b1b3c929c8f278e8980f2290.tar.xz
Remove MEncoder
Disable MEncoder compilation and remove files used by MEncoder only. There's no attempt to remove all references to MEncoder from the build system, documentation etc at this point. Removed files: (muxers, audio/video encoders, misc) mencoder.c cfg-mencoder.h parser-mecmd.[ch] xvid_vbr.[ch] libmpdemux/muxer* libmpcodecs/ae* libmpcodecs/ve* libmpcodecs/native/rtjpegn.[ch] libmpcodecs/native/mmx.h // was used by rtjpegn only Rationale: MEncoder is still useful for some people, but there's not much potential for further development; in the long run almost all use cases can be handled better by solutions based on something else (for example using FFmpeg or encoding MPlayer output). FFmpeg is already getting video filtering support which should work for some common MEncoder uses. Keeping MEncoder working takes extra work that is away from player development. While that amount of work is not huge (mostly MEncoder can be just ignored), it's not completely insignificant either. MEncoder is still maintained to some degree in the svn tree, so if necessary it's possible to use it from there for now. This tree has never had major improvements for the MEncoder side, so using svn MEncoder instead should be no major loss.
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ae.c116
-rw-r--r--libmpcodecs/ae.h65
-rw-r--r--libmpcodecs/ae_faac.c215
-rw-r--r--libmpcodecs/ae_faac.h27
-rw-r--r--libmpcodecs/ae_lame.c493
-rw-r--r--libmpcodecs/ae_lame.h26
-rw-r--r--libmpcodecs/ae_lavc.c244
-rw-r--r--libmpcodecs/ae_lavc.h26
-rw-r--r--libmpcodecs/ae_pcm.c101
-rw-r--r--libmpcodecs/ae_pcm.h26
-rw-r--r--libmpcodecs/ae_toolame.c236
-rw-r--r--libmpcodecs/ae_toolame.h34
-rw-r--r--libmpcodecs/ae_twolame.c235
-rw-r--r--libmpcodecs/ae_twolame.h32
-rw-r--r--libmpcodecs/native/mmx.h98
-rw-r--r--libmpcodecs/native/rtjpegn.c1758
-rw-r--r--libmpcodecs/native/rtjpegn.h44
-rw-r--r--libmpcodecs/ve.c75
-rw-r--r--libmpcodecs/ve_lavc.c1050
-rw-r--r--libmpcodecs/ve_libdv.c135
-rw-r--r--libmpcodecs/ve_nuv.c255
-rw-r--r--libmpcodecs/ve_qtvideo.c359
-rw-r--r--libmpcodecs/ve_raw.c177
-rw-r--r--libmpcodecs/ve_vfw.c377
-rw-r--r--libmpcodecs/ve_x264.c308
-rw-r--r--libmpcodecs/ve_x264.h26
-rw-r--r--libmpcodecs/ve_xvid4.c1527
27 files changed, 0 insertions, 8065 deletions
diff --git a/libmpcodecs/ae.c b/libmpcodecs/ae.c
deleted file mode 100644
index 1669359981..0000000000
--- a/libmpcodecs/ae.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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 <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <math.h>
-#include "config.h"
-#include "libmpdemux/aviheader.h"
-#include "libmpdemux/ms_hdr.h"
-#include "stream/stream.h"
-#include "libmpdemux/muxer.h"
-#include "ae.h"
-
-#include "ae_pcm.h"
-
-#ifdef CONFIG_TOOLAME
-#include "ae_toolame.h"
-#endif
-
-#ifdef CONFIG_MP3LAME
-#include "ae_lame.h"
-#endif
-
-#ifdef CONFIG_LIBAVCODEC
-#include "ae_lavc.h"
-#endif
-
-#ifdef CONFIG_FAAC
-#include "ae_faac.h"
-#endif
-
-#ifdef CONFIG_TWOLAME
-#include "ae_twolame.h"
-#endif
-
-audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
-{
- int ris;
- audio_encoder_t *encoder;
- if(! params)
- return NULL;
-
- encoder = calloc(1, sizeof(audio_encoder_t));
- memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
- encoder->stream = stream;
-
- switch(stream->codec)
- {
- case ACODEC_PCM:
- ris = mpae_init_pcm(encoder);
- break;
-#ifdef CONFIG_TOOLAME
- case ACODEC_TOOLAME:
- ris = mpae_init_toolame(encoder);
- break;
-#endif
-#ifdef CONFIG_LIBAVCODEC
- case ACODEC_LAVC:
- ris = mpae_init_lavc(encoder);
- break;
-#endif
-#ifdef CONFIG_MP3LAME
- case ACODEC_VBRMP3:
- ris = mpae_init_lame(encoder);
- break;
-#endif
-#ifdef CONFIG_FAAC
- case ACODEC_FAAC:
- ris = mpae_init_faac(encoder);
- break;
-#endif
-#ifdef CONFIG_TWOLAME
- case ACODEC_TWOLAME:
- ris = mpae_init_twolame(encoder);
- break;
-#endif
- default:
- ris = 0;
- break;
- }
-
- if(! ris)
- {
- free(encoder);
- return NULL;
- }
- encoder->bind(encoder, stream);
- encoder->decode_buffer = malloc(encoder->decode_buffer_size);
- if(! encoder->decode_buffer)
- {
- free(encoder);
- return NULL;
- }
-
- encoder->codec = stream->codec;
- return encoder;
-}
diff --git a/libmpcodecs/ae.h b/libmpcodecs/ae.h
deleted file mode 100644
index 440e4ddf4f..0000000000
--- a/libmpcodecs/ae.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef MPLAYER_AE_H
-#define MPLAYER_AE_H
-
-#include "libmpdemux/muxer.h"
-
-#define ACODEC_COPY 0
-#define ACODEC_PCM 1
-#define ACODEC_VBRMP3 2
-#define ACODEC_NULL 3
-#define ACODEC_LAVC 4
-#define ACODEC_TOOLAME 5
-#define ACODEC_FAAC 6
-#define ACODEC_TWOLAME 7
-
-#define AE_NEEDS_COMPRESSED_INPUT 1
-
-typedef struct {
- int channels;
- int sample_rate;
- int bitrate;
- int samples_per_frame;
- int audio_preload;
-} audio_encoding_params_t;
-
-typedef struct audio_encoder_s {
- int codec;
- int flags;
- muxer_stream_t *stream;
- audio_encoding_params_t params;
- int audio_preload; //in ms
- int input_format;
- int min_buffer_size, max_buffer_size; //for init_audio_filters
- unsigned char *decode_buffer;
- int decode_buffer_size;
- int decode_buffer_len;
- void *priv;
- int (*bind)(struct audio_encoder_s*, muxer_stream_t*);
- int (*get_frame_size)(struct audio_encoder_s*);
- int (*set_decoded_len)(struct audio_encoder_s *encoder, int len);
- int (*encode)(struct audio_encoder_s *encoder, uint8_t *dest, void *src, int nsamples, int max_size);
- void (*fixup)(struct audio_encoder_s *encoder);
- int (*close)(struct audio_encoder_s *encoder);
-} audio_encoder_t;
-
-audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params);
-
-#endif /* MPLAYER_AE_H */
diff --git a/libmpcodecs/ae_faac.c b/libmpcodecs/ae_faac.c
deleted file mode 100644
index 63c716378d..0000000000
--- a/libmpcodecs/ae_faac.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include "m_option.h"
-#include "mp_msg.h"
-#include "libmpdemux/aviheader.h"
-#include "libaf/af_format.h"
-#include "libaf/reorder_ch.h"
-#include "libmpdemux/ms_hdr.h"
-#include "stream/stream.h"
-#include "libmpdemux/muxer.h"
-#include <faac.h>
-#include "ae.h"
-
-
-static faacEncHandle faac;
-static faacEncConfigurationPtr config = NULL;
-static int
- param_bitrate = 128,
- param_quality = 0,
- param_object_type = 1,
- param_mpeg = 2,
- param_tns = 0,
- param_raw = 0,
- param_cutoff = 0,
- param_format = 16,
- param_debug = 0;
-
-static int enc_frame_size = 0, divisor;
-static unsigned long samples_input, max_bytes_output;
-static unsigned char *decoder_specific_buffer = NULL;
-static unsigned long decoder_specific_len = 0;
-
-const m_option_t faacopts_conf[] = {
- {"br", &param_bitrate, CONF_TYPE_INT, 0, 0, 0, NULL},
- {"quality", &param_quality, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL},
- {"object", &param_object_type, CONF_TYPE_INT, CONF_RANGE, 1, 4, NULL},
- {"mpeg", &param_mpeg, CONF_TYPE_INT, CONF_RANGE, 2, 4, NULL},
- {"tns", &param_tns, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"cutoff", &param_cutoff, CONF_TYPE_INT, 0, 0, 0, NULL},
- {"format", &param_format, CONF_TYPE_INT, 0, 0, 0, NULL},
- {"raw", &param_raw, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"debug", &param_debug, CONF_TYPE_INT, CONF_RANGE, 0, 100000000, NULL},
- {NULL, NULL, 0, 0, 0, 0, NULL}
-};
-
-
-static int bind_faac(audio_encoder_t *encoder, muxer_stream_t *mux_a)
-{
- mux_a->wf = calloc(1, sizeof(WAVEFORMATEX) + decoder_specific_len + 256);
- mux_a->wf->wFormatTag = 0x706D;
- mux_a->wf->nChannels = encoder->params.channels;
- mux_a->h.dwSampleSize=0; // VBR
- mux_a->h.dwRate=encoder->params.sample_rate;
- mux_a->h.dwScale=encoder->params.samples_per_frame;
- mux_a->wf->nSamplesPerSec=mux_a->h.dwRate;
- mux_a->wf->nAvgBytesPerSec = encoder->params.bitrate / 8;
-
- mux_a->wf->nBlockAlign = mux_a->h.dwScale;
- mux_a->h.dwSuggestedBufferSize = (encoder->params.audio_preload*mux_a->wf->nAvgBytesPerSec)/1000;
- mux_a->h.dwSuggestedBufferSize -= mux_a->h.dwSuggestedBufferSize % mux_a->wf->nBlockAlign;
-
- mux_a->wf->cbSize = decoder_specific_len;
- mux_a->wf->wBitsPerSample = 0; /* does not apply */
- ((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->wID = 1;
- ((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->fdwFlags = 2;
- ((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->nBlockSize = mux_a->wf->nBlockAlign;
- ((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->nFramesPerBlock = 1;
- ((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->nCodecDelay = 0;
-
- // Fix allocation
- mux_a->wf = realloc(mux_a->wf, sizeof(WAVEFORMATEX)+mux_a->wf->cbSize);
-
- if(config->inputFormat == FAAC_INPUT_FLOAT)
- encoder->input_format = AF_FORMAT_FLOAT_NE;
- else if(config->inputFormat == FAAC_INPUT_32BIT)
- encoder->input_format = AF_FORMAT_S32_NE;
- else
- encoder->input_format = AF_FORMAT_S16_NE;
-
- encoder->min_buffer_size = mux_a->h.dwSuggestedBufferSize;
- encoder->max_buffer_size = mux_a->h.dwSuggestedBufferSize*2;
-
- if(decoder_specific_buffer && decoder_specific_len)
- memcpy(mux_a->wf + 1, decoder_specific_buffer, decoder_specific_len);
-
- return 1;
-}
-
-static int get_frame_size(audio_encoder_t *encoder)
-{
- int sz = enc_frame_size;
- enc_frame_size = 0;
- return sz;
-}
-
-static int encode_faac(audio_encoder_t *encoder, uint8_t *dest, void *src, int len, int max_size)
-{
- if (encoder->params.channels >= 5)
- reorder_channel_nch(src, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
- AF_CHANNEL_LAYOUT_AAC_DEFAULT,
- encoder->params.channels,
- len / divisor, divisor);
-
- // len is divided by the number of bytes per sample
- enc_frame_size = faacEncEncode(faac, (int32_t*) src, len / divisor, dest, max_size);
-
- return enc_frame_size;
-}
-
-int close_faac(audio_encoder_t *encoder)
-{
- return 1;
-}
-
-int mpae_init_faac(audio_encoder_t *encoder)
-{
- if(encoder->params.channels < 1 || encoder->params.channels > 6 || (param_mpeg != 2 && param_mpeg != 4))
- {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, "AE_FAAC, unsupported number of channels: %d, or mpeg version: %d, exit\n", encoder->params.channels, param_mpeg);
- return 0;
- }
-
- faac = faacEncOpen(encoder->params.sample_rate, encoder->params.channels, &samples_input, &max_bytes_output);
- if(!faac)
- {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, "AE_FAAC, couldn't init, exit\n");
- return 0;
- }
- mp_msg(MSGT_MENCODER, MSGL_V, "AE_FAAC, sample_input: %lu, max_bytes_output: %lu\n", samples_input, max_bytes_output);
- config = faacEncGetCurrentConfiguration(faac);
- if(!config)
- {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, "AE_FAAC, couldn't get init configuration, exit\n");
- return 0;
- }
-
- param_bitrate *= 1000;
- if(param_quality)
- config->quantqual = param_quality;
- else
- config->bitRate = param_bitrate / encoder->params.channels;
-
- if(param_format==33)
- {
- config->inputFormat = FAAC_INPUT_FLOAT;
- divisor = 4;
- }
- else if(param_format==32)
- {
- config->inputFormat = FAAC_INPUT_32BIT;
- divisor = 4;
- }
- else
- {
- config->inputFormat = FAAC_INPUT_16BIT;
- divisor = 2;
- }
- config->outputFormat = param_raw ? 0 : 1; // 1 is ADTS
- config->aacObjectType = param_object_type;
- if(MAIN==0) config->aacObjectType--;
- config->mpegVersion = (param_mpeg == 4 ? MPEG4 : MPEG2);
- config->useTns = param_tns;
- config->allowMidside = 1;
- config->shortctl = SHORTCTL_NORMAL;
- param_cutoff = param_cutoff ? param_cutoff : encoder->params.sample_rate / 2;
- if(param_cutoff > encoder->params.sample_rate / 2)
- param_cutoff = encoder->params.sample_rate / 2;
- config->bandWidth = param_cutoff;
- if(encoder->params.channels == 6)
- config->useLfe = 1;
-
- if(!faacEncSetConfiguration(faac, config))
- {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, "AE_FAAC, counldn't set specified parameters, exiting\n");
- return 0;
- }
-
- if(param_raw)
- faacEncGetDecoderSpecificInfo(faac, &decoder_specific_buffer, &decoder_specific_len);
- else
- decoder_specific_len = 0;
-
- encoder->params.bitrate = param_bitrate;
- encoder->params.samples_per_frame = 1024;
- encoder->decode_buffer_size = divisor * samples_input; //samples * 16 bits_per_sample
-
- encoder->bind = bind_faac;
- encoder->get_frame_size = get_frame_size;
- encoder->encode = encode_faac;
- encoder->close = close_faac;
-
- return 1;
-}
diff --git a/libmpcodecs/ae_faac.h b/libmpcodecs/ae_faac.h
deleted file mode 100644
index dddc0bf5ad..0000000000
--- a/libmpcodecs/ae_faac.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef MPLAYER_AE_FAAC_H
-#define MPLAYER_AE_FAAC_H
-
-#include "ae.h"
-#include "libmpdemux/muxer.h"
-
-int mpae_init_faac(audio_encoder_t *encoder);
-
-#endif /* MPLAYER_AE_FAAC_H */
diff --git a/libmpcodecs/ae_lame.c b/libmpcodecs/ae_lame.c
deleted file mode 100644
index 90ed31dfe7..0000000000
--- a/libmpcodecs/ae_lame.c
+++ /dev/null
@@ -1,493 +0,0 @@
-/*
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include "m_option.h"
-#include "mp_msg.h"
-#include "libmpdemux/aviheader.h"
-#include "libmpdemux/ms_hdr.h"
-#include "stream/stream.h"
-#include "libmpdemux/muxer.h"
-#include "ae_pcm.h"
-#include "libaf/af_format.h"
-#include "libmpdemux/mp3_hdr.h"
-
-#undef CDECL
-#include <lame/lame.h>
-
-lame_global_flags *lame;
-static int lame_param_quality=0; // best
-static int lame_param_algqual=5; // same as old default
-static int lame_param_vbr=vbr_default;
-static int lame_param_mode=-1; // unset
-static int lame_param_padding=-1; // unset
-static int lame_param_br=-1; // unset
-static int lame_param_ratio=-1; // unset
-static float lame_param_scale=-1; // unset
-static int lame_param_lowpassfreq = 0; //auto
-static int lame_param_highpassfreq = 0; //auto
-static int lame_param_free_format = 0; //disabled
-static int lame_param_br_min = 0; //not specified
-static int lame_param_br_max = 0; //not specified
-
-#ifdef CONFIG_MP3LAME_PRESET
-int lame_param_fast=0; // unset
-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")
-
-
-
-const m_option_t lameopts_conf[] = {
- {"q", &lame_param_quality, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
- {"aq", &lame_param_algqual, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
- {"vbr", &lame_param_vbr, CONF_TYPE_INT, CONF_RANGE, 0, vbr_max_indicator, NULL},
- {"cbr", &lame_param_vbr, CONF_TYPE_FLAG, 0, 0, 0, NULL},
- {"abr", &lame_param_vbr, CONF_TYPE_FLAG, 0, 0, vbr_abr, NULL},
- {"mode", &lame_param_mode, CONF_TYPE_INT, CONF_RANGE, 0, MAX_INDICATOR, NULL},
- {"padding", &lame_param_padding, CONF_TYPE_INT, CONF_RANGE, 0, PAD_MAX_INDICATOR, NULL},
- {"br", &lame_param_br, CONF_TYPE_INT, CONF_RANGE, 0, 1024, NULL},
- {"ratio", &lame_param_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
- {"vol", &lame_param_scale, CONF_TYPE_FLOAT, CONF_RANGE, 0, 10, NULL},
- {"lowpassfreq",&lame_param_lowpassfreq, CONF_TYPE_INT, CONF_RANGE, -1, 48000,0},
- {"highpassfreq",&lame_param_highpassfreq, CONF_TYPE_INT, CONF_RANGE, -1, 48000,0},
- {"nofree", &lame_param_free_format, CONF_TYPE_FLAG, 0, 0, 0, NULL},
- {"free", &lame_param_free_format, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"br_min", &lame_param_br_min, CONF_TYPE_INT, CONF_RANGE, 0, 1024, NULL},
- {"br_max", &lame_param_br_max, CONF_TYPE_INT, CONF_RANGE, 0, 1024, NULL},
-#ifdef CONFIG_MP3LAME_PRESET
- {"fast", &lame_param_fast, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"preset", &lame_param_preset, CONF_TYPE_STRING, 0, 0, 0, NULL},
-#else
- {"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", 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_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_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);
- mux_a->wf->nSamplesPerSec=mux_a->h.dwRate;
- if(! lame_param_vbr)
- mux_a->wf->nAvgBytesPerSec=lame_param_br * 125;
- else
- mux_a->wf->nAvgBytesPerSec=192000/8; // FIXME!
- mux_a->wf->nBlockAlign=encoder->params.samples_per_frame; // required for l3codeca.acm + WMP 6.4
- mux_a->wf->wBitsPerSample=0; //16;
- // from NaNdub: (requires for l3codeca.acm)
- mux_a->wf->cbSize=12;
- ((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->wID=1;
- ((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->fdwFlags=2;
- ((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nBlockSize=encoder->params.samples_per_frame; // ???
- ((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nFramesPerBlock=1;
- ((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nCodecDelay=0;
-
- encoder->input_format = AF_FORMAT_S16_NE;
- encoder->min_buffer_size = 4608;
- encoder->max_buffer_size = mux_a->h.dwRate * mux_a->wf->nChannels * 2;
-
- return 1;
-}
-
-#define min(a, b) ((a) <= (b) ? (a) : (b))
-
-static int get_frame_size(audio_encoder_t *encoder)
-{
- int sz;
- if(encoder->stream->buffer_len < 4)
- return 0;
- sz = mp_decode_mp3_header(encoder->stream->buffer);
- if(sz <= 0)
- return 0;
- return sz;
-}
-
-static int encode_lame(audio_encoder_t *encoder, uint8_t *dest, void *src, int len, int max_size)
-{
- int n = 0;
- if(encoder->params.channels == 1)
- n = lame_encode_buffer(lame, (short *)src, (short *)src, len/2, dest, max_size);
- else
- n = lame_encode_buffer_interleaved(lame,(short *)src, len/4, dest, max_size);
-
- return n < 0 ? 0 : n;
-}
-
-
-static int close_lame(audio_encoder_t *encoder)
-{
- return 1;
-}
-
-static void fixup(audio_encoder_t *encoder)
-{
- // fixup CBR mp3 audio header:
- if(!lame_param_vbr) {
- encoder->stream->h.dwSampleSize=1;
- if (encoder->stream->h.dwLength)
- ((MPEGLAYER3WAVEFORMAT*)(encoder->stream->wf))->nBlockSize=
- (encoder->stream->size+(encoder->stream->h.dwLength>>1))/encoder->stream->h.dwLength;
- encoder->stream->h.dwLength=encoder->stream->size;
- encoder->stream->h.dwRate=encoder->stream->wf->nAvgBytesPerSec;
- encoder->stream->h.dwScale=1;
- encoder->stream->wf->nBlockAlign=1;
- 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);
- }
-}
-
-int mpae_init_lame(audio_encoder_t *encoder)
-{
- encoder->params.bitrate = lame_param_br * 125;
- encoder->params.samples_per_frame = encoder->params.sample_rate < 32000 ? 576 : 1152;
- encoder->decode_buffer_size = 2304;
-
- lame=lame_init();
- lame_set_bWriteVbrTag(lame,0);
- lame_set_in_samplerate(lame,encoder->params.sample_rate);
- //lame_set_in_samplerate(lame,sh_audio->samplerate); // if resampling done by lame
- lame_set_num_channels(lame,encoder->params.channels);
- lame_set_out_samplerate(lame,encoder->params.sample_rate);
- lame_set_quality(lame,lame_param_algqual); // 0 = best q
- if(lame_param_free_format) lame_set_free_format(lame,1);
- if(lame_param_vbr){ // VBR:
- lame_set_VBR(lame,lame_param_vbr); // vbr mode
- lame_set_VBR_q(lame,lame_param_quality); // 0 = best vbr q 5=~128k
- if(lame_param_br>0) lame_set_VBR_mean_bitrate_kbps(lame,lame_param_br);
- if(lame_param_br_min>0) lame_set_VBR_min_bitrate_kbps(lame,lame_param_br_min);
- if(lame_param_br_max>0) lame_set_VBR_max_bitrate_kbps(lame,lame_param_br_max);
- } else { // CBR:
- if(lame_param_br>0) lame_set_brate(lame,lame_param_br);
- }
- 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_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_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_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) ) {
- lame_print_config(lame);
- lame_print_internals(lame);
- }
-
- encoder->bind = bind_lame;
- encoder->get_frame_size = get_frame_size;
- encoder->encode = encode_lame;
- encoder->fixup = fixup;
- encoder->close = close_lame;
- return 1;
-}
-
-#ifdef CONFIG_MP3LAME_PRESET
-/* lame_presets_set
- taken out of presets_set in lame-3.93.1/frontend/parse.c and modified */
-static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_name )
-{
- int mono = 0;
-
- if (strcmp(preset_name, "help") == 0) {
- 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"\
-"