1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/mlpdec: fix time_base for packet timestamps

This commit is contained in:
Paul B Mahol 2021-09-05 17:55:19 +02:00
parent 5d92b73c64
commit 7ebeef6aff

View File

@ -22,8 +22,12 @@
*/
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "rawdec.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/mlp.h"
#include "libavcodec/mlp_parse.h"
static int av_always_inline mlp_thd_probe(const AVProbeData *p, uint32_t sync)
{
@ -50,6 +54,40 @@ static int av_always_inline mlp_thd_probe(const AVProbeData *p, uint32_t sync)
return 0;
}
static int mlp_read_header(AVFormatContext *s)
{
int ret = ff_raw_audio_read_header(s);
if (ret < 0)
return ret;
ret = ffio_ensure_seekback(s->pb, 10);
if (ret == 0) {
uint8_t buffer[10];
int read, sample_rate = 0;
read = avio_read(s->pb, buffer, 10);
if (read == 10) {
switch (buffer[7]) {
case SYNC_TRUEHD:
sample_rate = mlp_samplerate(buffer[8] >> 4);
break;
case SYNC_MLP:
sample_rate = mlp_samplerate(buffer[9] >> 4);
break;
}
if (sample_rate)
avpriv_set_pts_info(s->streams[0], 64, 1, sample_rate);
}
if (read > 0)
avio_seek(s->pb, -read, SEEK_CUR);
}
return 0;
}
#if CONFIG_MLP_DEMUXER
static int mlp_probe(const AVProbeData *p)
{
@ -60,7 +98,7 @@ const AVInputFormat ff_mlp_demuxer = {
.name = "mlp",
.long_name = NULL_IF_CONFIG_SMALL("raw MLP"),
.read_probe = mlp_probe,
.read_header = ff_raw_audio_read_header,
.read_header = mlp_read_header,
.read_packet = ff_raw_read_partial_packet,
.flags = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
.extensions = "mlp",
@ -80,7 +118,7 @@ const AVInputFormat ff_truehd_demuxer = {
.name = "truehd",
.long_name = NULL_IF_CONFIG_SMALL("raw TrueHD"),
.read_probe = thd_probe,
.read_header = ff_raw_audio_read_header,
.read_header = mlp_read_header,
.read_packet = ff_raw_read_partial_packet,
.flags = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
.extensions = "thd",
@ -89,4 +127,3 @@ const AVInputFormat ff_truehd_demuxer = {
.priv_class = &ff_raw_demuxer_class,
};
#endif