X-Git-Url: https://git.piment-noir.org/?p=deb_ffmpeg.git;a=blobdiff_plain;f=ffmpeg%2Flibavformat%2Foggenc.c;h=f3413c54c9c4300a2d3bfc5167b6d50293c735b8;hp=4a54126f8fdc39bfa3ae72bb700e30a137feb862;hb=f6fa7814ccfe3e76514b36cf04f5cd3cb657c8cf;hpb=2ba45a602cbfa7b771effba9b11bb4245c21bc00 diff --git a/ffmpeg/libavformat/oggenc.c b/ffmpeg/libavformat/oggenc.c index 4a54126..f3413c5 100644 --- a/ffmpeg/libavformat/oggenc.c +++ b/ffmpeg/libavformat/oggenc.c @@ -307,12 +307,10 @@ static int ogg_build_flac_headers(AVCodecContext *avctx, OGGStreamContext *oggstream, int bitexact, AVDictionary **m) { - enum FLACExtradataFormat format; - uint8_t *streaminfo; uint8_t *p; - if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo)) - return -1; + if (avctx->extradata_size < FLAC_STREAMINFO_SIZE) + return AVERROR(EINVAL); // first packet: STREAMINFO oggstream->header_len[0] = 51; @@ -328,7 +326,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx, bytestream_put_buffer(&p, "fLaC", 4); bytestream_put_byte(&p, 0x00); // streaminfo bytestream_put_be24(&p, 34); - bytestream_put_buffer(&p, streaminfo, FLAC_STREAMINFO_SIZE); + bytestream_put_buffer(&p, avctx->extradata, FLAC_STREAMINFO_SIZE); // second packet: VorbisComment p = ogg_write_vorbiscomment(4, bitexact, &oggstream->header_len[1], m, 0); @@ -350,7 +348,7 @@ static int ogg_build_speex_headers(AVCodecContext *avctx, uint8_t *p; if (avctx->extradata_size < SPEEX_HEADER_SIZE) - return -1; + return AVERROR_INVALIDDATA; // first packet: Speex header p = av_mallocz(SPEEX_HEADER_SIZE); @@ -379,7 +377,7 @@ static int ogg_build_opus_headers(AVCodecContext *avctx, uint8_t *p; if (avctx->extradata_size < OPUS_HEADER_SIZE) - return -1; + return AVERROR_INVALIDDATA; /* first packet: Opus header */ p = av_mallocz(avctx->extradata_size); @@ -448,12 +446,12 @@ static int ogg_write_header(AVFormatContext *s) st->codec->codec_id != AV_CODEC_ID_FLAC && st->codec->codec_id != AV_CODEC_ID_OPUS) { av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i); - return -1; + return AVERROR(EINVAL); } if (!st->codec->extradata || !st->codec->extradata_size) { av_log(s, AV_LOG_ERROR, "No extradata present\n"); - return -1; + return AVERROR_INVALIDDATA; } oggstream = av_mallocz(sizeof(*oggstream)); if (!oggstream) @@ -513,7 +511,7 @@ static int ogg_write_header(AVFormatContext *s) oggstream->header, oggstream->header_len) < 0) { av_log(s, AV_LOG_ERROR, "Extradata corrupted\n"); av_freep(&st->priv_data); - return -1; + return AVERROR_INVALIDDATA; } p = ogg_write_vorbiscomment(7, s->flags & AVFMT_FLAG_BITEXACT, @@ -582,7 +580,10 @@ static int ogg_write_packet_internal(AVFormatContext *s, AVPacket *pkt) } granule = (oggstream->last_kf_pts<kfgshift) | pframe_count; } else if (st->codec->codec_id == AV_CODEC_ID_OPUS) - granule = pkt->pts + pkt->duration + av_rescale_q(st->codec->delay, (AVRational){ 1, st->codec->sample_rate }, st->time_base); + granule = pkt->pts + pkt->duration + + av_rescale_q(st->codec->initial_padding, + (AVRational){ 1, st->codec->sample_rate }, + st->time_base); else granule = pkt->pts + pkt->duration;