oggparsecelt: use ff_alloc_extradata()
Signed-off-by: James Almer <jamrial@gmail.com> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
aae8975ffb
commit
00408f95e7
@ -44,16 +44,10 @@ static int celt_header(AVFormatContext *s, int idx)
|
|||||||
|
|
||||||
uint32_t version, sample_rate, nb_channels, frame_size;
|
uint32_t version, sample_rate, nb_channels, frame_size;
|
||||||
uint32_t overlap, extra_headers;
|
uint32_t overlap, extra_headers;
|
||||||
uint8_t *extradata;
|
|
||||||
|
|
||||||
extradata = av_malloc(2 * sizeof(uint32_t) +
|
|
||||||
FF_INPUT_BUFFER_PADDING_SIZE);
|
|
||||||
priv = av_malloc(sizeof(struct oggcelt_private));
|
priv = av_malloc(sizeof(struct oggcelt_private));
|
||||||
if (!extradata || !priv) {
|
if (!priv || ff_alloc_extradata(st->codec, 2 * sizeof(uint32_t)))
|
||||||
av_free(extradata);
|
|
||||||
av_free(priv);
|
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
|
||||||
version = AV_RL32(p + 28);
|
version = AV_RL32(p + 28);
|
||||||
/* unused header size field skipped */
|
/* unused header size field skipped */
|
||||||
sample_rate = AV_RL32(p + 36);
|
sample_rate = AV_RL32(p + 36);
|
||||||
@ -67,16 +61,13 @@ static int celt_header(AVFormatContext *s, int idx)
|
|||||||
st->codec->sample_rate = sample_rate;
|
st->codec->sample_rate = sample_rate;
|
||||||
st->codec->channels = nb_channels;
|
st->codec->channels = nb_channels;
|
||||||
st->codec->frame_size = frame_size;
|
st->codec->frame_size = frame_size;
|
||||||
av_free(st->codec->extradata);
|
|
||||||
st->codec->extradata = extradata;
|
|
||||||
st->codec->extradata_size = 2 * sizeof(uint32_t);
|
|
||||||
if (sample_rate)
|
if (sample_rate)
|
||||||
avpriv_set_pts_info(st, 64, 1, sample_rate);
|
avpriv_set_pts_info(st, 64, 1, sample_rate);
|
||||||
priv->extra_headers_left = 1 + extra_headers;
|
priv->extra_headers_left = 1 + extra_headers;
|
||||||
av_free(os->private);
|
av_free(os->private);
|
||||||
os->private = priv;
|
os->private = priv;
|
||||||
AV_WL32(extradata + 0, overlap);
|
AV_WL32(st->codec->extradata + 0, overlap);
|
||||||
AV_WL32(extradata + 4, version);
|
AV_WL32(st->codec->extradata + 4, version);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (priv && priv->extra_headers_left) {
|
} else if (priv && priv->extra_headers_left) {
|
||||||
/* Extra headers (vorbiscomment) */
|
/* Extra headers (vorbiscomment) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user