aboutsummaryrefslogtreecommitdiff
path: root/libavformat/mxfdec.c
diff options
context:
space:
mode:
authorMarton Balint2018-08-26 21:23:02 +0200
committerMarton Balint2018-09-05 22:41:09 +0200
commit6aaf1b504c6a0e0e5e2f4c97712b0f83a4115e10 (patch)
treee98b234c1ccf7e4b18d07aa212d6484fa99a6b08 /libavformat/mxfdec.c
parent776909e42e2a9cef37035f070464bbbfa3441c39 (diff)
avformat/mxfdec: do not use sound essence descriptor quantization bits for bits_per_coded_sample
It refers to the uncompressed quantization, therefore is not correct for AAC. Also change mxf_set_pts to work based on current edit unit if bits_per_coded_sample is not available. Fixes error messages in the sample of ticket #7366. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r--libavformat/mxfdec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 8e1089620f..134f27784b 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2390,7 +2390,6 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
if (st->codecpar->codec_id == AV_CODEC_ID_NONE || (st->codecpar->codec_id == AV_CODEC_ID_PCM_ALAW && (enum AVCodecID)container_ul->id != AV_CODEC_ID_NONE))
st->codecpar->codec_id = (enum AVCodecID)container_ul->id;
st->codecpar->channels = descriptor->channels;
- st->codecpar->bits_per_coded_sample = descriptor->bits_per_sample;
if (descriptor->sample_rate.den > 0) {
st->codecpar->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
@@ -2423,6 +2422,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
} else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
st->need_parsing = AVSTREAM_PARSE_FULL;
}
+ st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
enum AVMediaType type;
container_ul = mxf_get_codec_ul(mxf_data_essence_container_uls, essence_container_ul);
@@ -3269,7 +3269,8 @@ static int64_t mxf_set_current_edit_unit(MXFContext *mxf, AVStream *st, int64_t
static int mxf_set_audio_pts(MXFContext *mxf, AVCodecParameters *par,
AVPacket *pkt)
{
- MXFTrack *track = mxf->fc->streams[pkt->stream_index]->priv_data;
+ AVStream *st = mxf->fc->streams[pkt->stream_index];
+ MXFTrack *track = st->priv_data;
int64_t bits_per_sample = par->bits_per_coded_sample;
if (!bits_per_sample)
@@ -3280,8 +3281,10 @@ static int mxf_set_audio_pts(MXFContext *mxf, AVCodecParameters *par,
if ( par->channels <= 0
|| bits_per_sample <= 0
|| par->channels * (int64_t)bits_per_sample < 8)
- return AVERROR(EINVAL);
- track->sample_count += pkt->size / (par->channels * (int64_t)bits_per_sample / 8);
+ track->sample_count = mxf_compute_sample_count(mxf, st, av_rescale_q(track->sample_count, st->time_base, av_inv_q(track->edit_rate)) + 1);
+ else
+ track->sample_count += pkt->size / (par->channels * (int64_t)bits_per_sample / 8);
+
return 0;
}