mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 09:32:40 +00:00
22b3f522ca
Most libavcodec decoders output non-interleaved audio. Add direct support for this, and remove the hack that repacked non-interleaved audio back to packed audio. Remove the minlen argument from the decoder callback. Instead of forcing every decoder to have its own decode loop to fill the buffer until minlen is reached, leave this to the caller. So if a decoder doesn't return enough data, it's simply called again. (In future, I even want to change it so that decoders don't read packets directly, but instead the caller has to pass packets to the decoders. This fits well with this change, because now the decoder callback typically decodes at most one packet.) ad_mpg123.c receives some heavy refactoring. The main problem is that it wanted to handle format changes when there was no data in the decode output buffer yet. This sounds reasonable, but actually it would write data into a buffer prepared for old data, since the caller doesn't know about the format change yet. (I.e. the best place for a format change would be _after_ writing the last sample to the output buffer.) It's possible that this code was not perfectly sane before this commit, and perhaps lost one frame of data after a format change, but I didn't confirm this. Trying to fix this, I ended up rewriting the decoding and also the probing.
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
/*
|
|
* 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_AD_H
|
|
#define MPLAYER_AD_H
|
|
|
|
#include "mpvcore/codecs.h"
|
|
#include "demux/stheader.h"
|
|
#include "demux/demux.h"
|
|
|
|
#include "audio/format.h"
|
|
#include "audio/audio.h"
|
|
|
|
struct mp_decoder_list;
|
|
|
|
/* interface of video decoder drivers */
|
|
struct ad_functions {
|
|
const char *name;
|
|
void (*add_decoders)(struct mp_decoder_list *list);
|
|
int (*preinit)(sh_audio_t *sh);
|
|
int (*init)(sh_audio_t *sh, const char *decoder);
|
|
void (*uninit)(sh_audio_t *sh);
|
|
int (*control)(sh_audio_t *sh, int cmd, void *arg);
|
|
int (*decode_audio)(sh_audio_t *sh, struct mp_audio *buffer, int maxlen);
|
|
};
|
|
|
|
enum ad_ctrl {
|
|
ADCTRL_RESYNC_STREAM = 1, // resync, called after seeking
|
|
};
|
|
|
|
#endif /* MPLAYER_AD_H */
|