Commit 8dbf98e6 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'ecab1c77'

* commit 'ecab1c77':
  oggdec: add support for Opus in Ogg demuxing

Conflicts:
	Changelog
	libavformat/oggparseopus.c
	libavformat/version.h

See: e62fd661Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 3ce0edde ecab1c77
...@@ -48,6 +48,7 @@ static int opus_header(AVFormatContext *avf, int idx) ...@@ -48,6 +48,7 @@ static int opus_header(AVFormatContext *avf, int idx)
if (!priv) if (!priv)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
if (os->flags & OGG_FLAG_BOS) { if (os->flags & OGG_FLAG_BOS) {
if (os->psize < OPUS_HEAD_SIZE || (AV_RL8(packet + 8) & 0xF0) != 0) if (os->psize < OPUS_HEAD_SIZE || (AV_RL8(packet + 8) & 0xF0) != 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -62,6 +63,7 @@ static int opus_header(AVFormatContext *avf, int idx) ...@@ -62,6 +63,7 @@ static int opus_header(AVFormatContext *avf, int idx)
extradata = av_malloc(os->psize + FF_INPUT_BUFFER_PADDING_SIZE); extradata = av_malloc(os->psize + FF_INPUT_BUFFER_PADDING_SIZE);
if (!extradata) if (!extradata)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
memcpy(extradata, packet, os->psize); memcpy(extradata, packet, os->psize);
st->codec->extradata = extradata; st->codec->extradata = extradata;
st->codec->extradata_size = os->psize; st->codec->extradata_size = os->psize;
...@@ -79,6 +81,7 @@ static int opus_header(AVFormatContext *avf, int idx) ...@@ -79,6 +81,7 @@ static int opus_header(AVFormatContext *avf, int idx)
priv->need_comments--; priv->need_comments--;
return 1; return 1;
} }
return 0; return 0;
} }
...@@ -93,6 +96,7 @@ static int opus_packet(AVFormatContext *avf, int idx) ...@@ -93,6 +96,7 @@ static int opus_packet(AVFormatContext *avf, int idx)
if (!os->psize) if (!os->psize)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
toc = *packet; toc = *packet;
toc_config = toc >> 3; toc_config = toc >> 3;
toc_count = toc & 3; toc_count = toc & 3;
...@@ -106,12 +110,14 @@ static int opus_packet(AVFormatContext *avf, int idx) ...@@ -106,12 +110,14 @@ static int opus_packet(AVFormatContext *avf, int idx)
} else if (toc_count) { } else if (toc_count) {
nb_frames = 2; nb_frames = 2;
} }
os->pduration = frame_size * nb_frames; os->pduration = frame_size * nb_frames;
if (os->lastpts != AV_NOPTS_VALUE) { if (os->lastpts != AV_NOPTS_VALUE) {
if (st->start_time == AV_NOPTS_VALUE) if (st->start_time == AV_NOPTS_VALUE)
st->start_time = os->lastpts; st->start_time = os->lastpts;
priv->cur_dts = os->lastdts = os->lastpts -= priv->pre_skip; priv->cur_dts = os->lastdts = os->lastpts -= priv->pre_skip;
} }
priv->cur_dts += os->pduration; priv->cur_dts += os->pduration;
if ((os->flags & OGG_FLAG_EOS)) { if ((os->flags & OGG_FLAG_EOS)) {
int64_t skip = priv->cur_dts - os->granule + priv->pre_skip; int64_t skip = priv->cur_dts - os->granule + priv->pre_skip;
...@@ -124,6 +130,7 @@ static int opus_packet(AVFormatContext *avf, int idx) ...@@ -124,6 +130,7 @@ static int opus_packet(AVFormatContext *avf, int idx)
os->pduration); os->pduration);
} }
} }
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment