mirror of
https://github.com/mpv-player/mpv
synced 2025-03-21 10:51:51 +00:00
demux: use no overlapping packets for lossless audio
Worthless optimization, but at least it justifies that the --audio-backward-overlap option has an "auto" choice. Tested with PCM and FLAC.
This commit is contained in:
parent
70d1e7e560
commit
1c088f570c
@ -558,7 +558,8 @@ Playback Control
|
|||||||
|
|
||||||
The solution is to feed a previous packet to the decoder each time, and then
|
The solution is to feed a previous packet to the decoder each time, and then
|
||||||
discard the output. This option controls how many packets to feed. The
|
discard the output. This option controls how many packets to feed. The
|
||||||
``auto`` choice is currently hardcoded to 1 for audio, and 0 for video.
|
``auto`` choice is currently hardcoded to 0 for video, and uses 1 for lossy
|
||||||
|
audio, 0 for lossless audio.
|
||||||
|
|
||||||
``--video-backward-overlap`` can potentially handle intra-refresh video,
|
``--video-backward-overlap`` can potentially handle intra-refresh video,
|
||||||
depending on the exact conditions. You may have to use the
|
depending on the exact conditions. You may have to use the
|
||||||
|
@ -292,6 +292,13 @@ const char *mp_codec_from_av_codec_id(int codec_id)
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mp_codec_is_lossless(const char *codec)
|
||||||
|
{
|
||||||
|
const AVCodecDescriptor *desc =
|
||||||
|
avcodec_descriptor_get(mp_codec_to_av_codec_id(codec));
|
||||||
|
return desc && (desc->props & AV_CODEC_PROP_LOSSLESS);
|
||||||
|
}
|
||||||
|
|
||||||
// kv is in the format as by OPT_KEYVALUELIST(): kv[0]=key0, kv[1]=val0, ...
|
// kv is in the format as by OPT_KEYVALUELIST(): kv[0]=key0, kv[1]=val0, ...
|
||||||
// Copy them to the dict.
|
// Copy them to the dict.
|
||||||
void mp_set_avdict(AVDictionary **dict, char **kv)
|
void mp_set_avdict(AVDictionary **dict, char **kv)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define MP_AVCOMMON_H
|
#define MP_AVCOMMON_H
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <libavutil/avutil.h>
|
#include <libavutil/avutil.h>
|
||||||
#include <libavutil/rational.h>
|
#include <libavutil/rational.h>
|
||||||
@ -44,6 +45,7 @@ void mp_add_lavc_encoders(struct mp_decoder_list *list);
|
|||||||
char **mp_get_lavf_demuxers(void);
|
char **mp_get_lavf_demuxers(void);
|
||||||
int mp_codec_to_av_codec_id(const char *codec);
|
int mp_codec_to_av_codec_id(const char *codec);
|
||||||
const char *mp_codec_from_av_codec_id(int codec_id);
|
const char *mp_codec_from_av_codec_id(int codec_id);
|
||||||
|
bool mp_codec_is_lossless(const char *codec);
|
||||||
void mp_set_avdict(struct AVDictionary **dict, char **kv);
|
void mp_set_avdict(struct AVDictionary **dict, char **kv);
|
||||||
void mp_avdict_print_unset(struct mp_log *log, int msgl, struct AVDictionary *d);
|
void mp_avdict_print_unset(struct mp_log *log, int msgl, struct AVDictionary *d);
|
||||||
int mp_set_avopts(struct mp_log *log, void *avobj, char **kv);
|
int mp_set_avopts(struct mp_log *log, void *avobj, char **kv);
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "options/m_config.h"
|
#include "options/m_config.h"
|
||||||
#include "options/m_option.h"
|
#include "options/m_option.h"
|
||||||
#include "mpv_talloc.h"
|
#include "mpv_talloc.h"
|
||||||
|
#include "common/av_common.h"
|
||||||
#include "common/msg.h"
|
#include "common/msg.h"
|
||||||
#include "common/global.h"
|
#include "common/global.h"
|
||||||
#include "common/recorder.h"
|
#include "common/recorder.h"
|
||||||
@ -951,8 +952,8 @@ static void demux_add_sh_stream_locked(struct demux_internal *in,
|
|||||||
switch (ds->type) {
|
switch (ds->type) {
|
||||||
case STREAM_AUDIO:
|
case STREAM_AUDIO:
|
||||||
ds->back_preroll = in->opts->audio_back_preroll;
|
ds->back_preroll = in->opts->audio_back_preroll;
|
||||||
if (ds->back_preroll < 0)
|
if (ds->back_preroll < 0) // auto
|
||||||
ds->back_preroll = 1; // auto
|
ds->back_preroll = mp_codec_is_lossless(sh->codec->codec) ? 0 : 1;
|
||||||
break;
|
break;
|
||||||
case STREAM_VIDEO:
|
case STREAM_VIDEO:
|
||||||
ds->back_preroll = in->opts->video_back_preroll;
|
ds->back_preroll = in->opts->video_back_preroll;
|
||||||
|
Loading…
Reference in New Issue
Block a user