1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-13 18:45:25 +00:00

options: move audio_output_channels, audio_output_format to struct

This commit is contained in:
Uoti Urpala 2010-10-31 07:26:40 +02:00
parent 45e1333581
commit 4de0369e8d
12 changed files with 30 additions and 20 deletions

View File

@ -37,7 +37,6 @@ extern char * codecs_file;
extern int field_dominance;
/* from dec_audio, currently used for ac3surround decoder only */
extern int audio_output_channels;
extern int fakemono;
/* defined in network.c */
@ -569,8 +568,8 @@ const m_option_t common_opts[] = {
// force video/audio rate:
{"fps", &force_fps, CONF_TYPE_DOUBLE, CONF_MIN, 0, 0, NULL},
{"srate", &force_srate, CONF_TYPE_INT, CONF_RANGE, 1000, 8*48000, NULL},
{"channels", &audio_output_channels, CONF_TYPE_INT, CONF_RANGE, 1, 8, NULL},
{"format", &audio_output_format, CONF_TYPE_AFMT, 0, 0, 0, NULL},
OPT_INTRANGE("channels", audio_output_channels, 0, 1, 8),
OPT_AUDIOFORMAT("format", audio_output_format, 0),
OPT_FLOATRANGE("speed", playback_speed, 0, 0.01, 100.0),
// set a-v distance

View File

@ -29,6 +29,8 @@ void set_default_mplayer_options(struct MPOpts *opts)
.audio_id = -1,
.video_id = -1,
.sub_id = -1,
.audio_output_channels = 2,
.audio_output_format = -1, // AF_FORMAT_UNKNOWN
.playback_speed = 1.,
.drc_level = 1.,
.movie_aspect = -1.,

View File

@ -21,6 +21,7 @@
#include <unistd.h>
#include "config.h"
#include "options.h"
#include "mp_msg.h"
#include "ad_internal.h"
@ -46,9 +47,10 @@ static int init(sh_audio_t *sh)
static int preinit(sh_audio_t *sh_audio)
{
struct MPOpts *opts = sh_audio->opts;
DMO_AudioDecoder* ds_adec;
int chans=(audio_output_channels==sh_audio->wf->nChannels) ?
audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1);
int chans=(opts->audio_output_channels==sh_audio->wf->nChannels) ?
opts->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_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll);

View File

@ -25,6 +25,7 @@
#include <unistd.h>
#include "config.h"
#include "options.h"
#include "ad_internal.h"
#include "libaf/reorder_ch.h"
@ -83,6 +84,7 @@ static int aac_probe(unsigned char *buffer, int len)
static int init(sh_audio_t *sh)
{
struct MPOpts *opts = sh->opts;
unsigned long faac_samplerate;
unsigned char faac_channels;
int faac_init, pos = 0;
@ -105,7 +107,8 @@ static int init(sh_audio_t *sh)
/* XXX: FAAD support FLOAT output, how do we handle
* that (FAAD_FMT_FLOAT)? ::atmos
*/
if (audio_output_channels <= 2) faac_conf->downMatrix = 1;
if (opts->audio_output_channels <= 2)
faac_conf->downMatrix = 1;
switch(sh->samplesize){
case 1: // 8Bit
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: 8Bit samplesize not supported by FAAD, assuming 16Bit!\n");
@ -177,7 +180,7 @@ static int init(sh_audio_t *sh)
} else { // We have ES DS in codecdata
faacDecConfigurationPtr faac_conf = faacDecGetCurrentConfiguration(faac_hdec);
if (audio_output_channels <= 2) {
if (opts->audio_output_channels <= 2) {
faac_conf->downMatrix = 1;
faacDecSetConfiguration(faac_hdec, faac_conf);
}
@ -199,7 +202,8 @@ static int init(sh_audio_t *sh)
mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Negotiated samplerate: %ldHz channels: %d\n", faac_samplerate, faac_channels);
// 8 channels is aac channel order #7.
sh->channels = faac_channels == 7 ? 8 : faac_channels;
if (audio_output_channels <= 2) sh->channels = faac_channels > 1 ? 2 : 1;
if (opts->audio_output_channels <= 2)
sh->channels = faac_channels > 1 ? 2 : 1;
sh->samplerate = faac_samplerate;
sh->samplesize=2;
//sh->o_bps = sh->samplesize*faac_channels*faac_samplerate;

View File

@ -120,7 +120,7 @@ static int init(sh_audio_t *sh_audio)
lavc_context->block_align = sh_audio->wf->nBlockAlign;
lavc_context->bits_per_coded_sample = sh_audio->wf->wBitsPerSample;
}
lavc_context->request_channels = audio_output_channels;
lavc_context->request_channels = opts->audio_output_channels;
lavc_context->codec_tag = sh_audio->format; //FOURCC
lavc_context->codec_type = CODEC_TYPE_AUDIO;
lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi

View File

@ -28,7 +28,6 @@
#include "ad.h"
extern int audio_output_channels;
static int init(sh_audio_t *sh);
static int preinit(sh_audio_t *sh);
static void uninit(sh_audio_t *sh);

View File

@ -141,10 +141,11 @@ static sample_t dynrng_call (sample_t c, void *data)
static int preinit(sh_audio_t *sh)
{
struct MPOpts *opts = sh->opts;
/* Dolby AC3 audio: */
/* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */
if (sh->samplesize < 4) sh->samplesize = 4;
sh->audio_out_minsize=audio_output_channels*sh->samplesize*256*6;
sh->audio_out_minsize=opts->audio_output_channels*sh->samplesize*256*6;
sh->audio_in_minsize=3840;
a52_level = 1.0;
return 1;
@ -219,7 +220,7 @@ static int init(sh_audio_t *sh_audio)
/* 'a52 cannot upmix' hotfix:*/
a52_printinfo(sh_audio);
sh_audio->channels=audio_output_channels;
sh_audio->channels=opts->audio_output_channels;
while(sh_audio->channels>0){
switch(sh_audio->channels){
case 1: a52_flags=A52_MONO; break;

View File

@ -25,8 +25,9 @@
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include "config.h"
#include "config.h"
#include "options.h"
#include "mp_msg.h"
#include "ad_internal.h"
@ -280,8 +281,10 @@ end:
static int preinit(sh_audio_t *sh)
{
struct MPOpts *opts = sh->opts;
/* 256 = samples per block, 16 = max number of blocks */
sh->audio_out_minsize = audio_output_channels * sizeof(int16_t) * 256 * 16;
sh->audio_out_minsize = opts->audio_output_channels * sizeof(int16_t) * 256 * 16;
sh->audio_in_minsize = DTSBUFFER_SIZE;
sh->samplesize=2;
@ -308,8 +311,8 @@ static int init(sh_audio_t *sh)
}
channels_info(flags);
assert(audio_output_channels >= 1 && audio_output_channels <= 6);
sh->channels = audio_output_channels;
assert(opts->audio_output_channels >= 1 && opts->audio_output_channels <= 6);
sh->channels = opts->audio_output_channels;
decoded_bytes = decode_audio(sh, sh->a_buffer, 1, sh->a_buffer_size);
if(decoded_bytes > 0)

View File

@ -44,8 +44,6 @@
int fakemono = 0;
#endif
/* used for ac3surround decoder - set using -channels option */
int audio_output_channels = 2;
af_cfg_t af_cfg = { 1, NULL }; // Configuration for audio filters
void afm_help(void)

View File

@ -530,5 +530,6 @@ m_option_free(const m_option_t* opt,void* dst) {
#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)}
#define OPT_AUDIOFORMAT(optname, varname, flags) {optname, NULL, &m_option_type_afmt, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
#endif /* MPLAYER_M_OPTION_H */

View File

@ -337,7 +337,6 @@ static int softsleep=0;
double force_fps=0;
static int force_srate=0;
static int audio_output_format=-1; // AF_FORMAT_UNKNOWN
int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode
static int play_n_frames=-1;
static int play_n_frames_mf=-1;
@ -1774,7 +1773,7 @@ void reinit_audio_chain(struct MPContext *mpctx)
current_module="af_preinit";
ao_data.samplerate=force_srate;
ao_data.channels=0;
ao_data.format=audio_output_format;
ao_data.format = opts->audio_output_format;
// first init to detect best values
if(!init_audio_filters(mpctx->sh_audio, // preliminary init
// input:

View File

@ -41,6 +41,8 @@ typedef struct MPOpts {
int sub_id;
char *audio_lang;
char *sub_lang;
int audio_output_channels;
int audio_output_format;
float playback_speed;
float drc_level;
struct m_obj_settings *vf_settings;