diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-11-03 02:01:37 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-11-03 02:16:26 +0100 |
commit | 988f585fcb1cfb40fe4b706c32b31594b536bba0 (patch) | |
tree | 659b8d9f4daf4ce497b42c83f7adb45725fa4f65 /libavformat/flvenc.c | |
parent | 0b3e9d5dc61bb705d93db1e87d78d8d5131905c6 (diff) | |
parent | 594b54b51e9f3af8aac18184d634b85a836b42b6 (diff) | |
download | ffmpeg-988f585fcb1cfb40fe4b706c32b31594b536bba0.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (44 commits)
replacement Indeo 3 decoder
gsm demuxer: do not allocate packet twice.
flvenc: use first packet delay as global delay.
ac3enc: doxygen update.
imc: return error codes instead of 0 for error conditions.
imc: return meaningful error codes instead of -1
imc: do not set channel layout for stereo
imc: validate channel count
imc: check for ff_fft_init() failure
imc: check output buffer size before decoding
imc: use DSPContext.bswap16_buf() to byte-swap packet data
rtsp: add allowed_media_types option
libgsm: add flush function to reset the decoder state when seeking
libgsm: simplify decoding by using a loop
gsm: log error message when packet is too small
libgsmdec: do not needlessly set *data_size to 0
gsmdec: do not needlessly set *data_size to 0
gsmdec: add flush function to reset the decoder state when seeking
libgsmdec: check output buffer size before decoding
gsmdec: log error message when output buffer is too small.
...
Conflicts:
Changelog
ffplay.c
libavcodec/indeo3.c
libavcodec/mjpeg_parser.c
libavcodec/vp3.c
libavformat/cutils.c
libavformat/id3v2.c
libavutil/parseutils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/flvenc.c')
-rw-r--r-- | libavformat/flvenc.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 627bb6d3ab..5e86640c3e 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -60,10 +60,10 @@ typedef struct FLVContext { int64_t duration_offset; int64_t filesize_offset; int64_t duration; + int64_t delay; ///< first dts delay (needed for AVC & Speex) } FLVContext; typedef struct FLVStreamContext { - int delay; ///< first dts delay for each stream (needed for AVC & Speex) int64_t last_ts; ///< last timestamp for each stream } FLVStreamContext; @@ -210,6 +210,8 @@ static int flv_write_header(AVFormatContext *s) s->streams[i]->priv_data = sc; sc->last_ts = -1; } + flv->delay = AV_NOPTS_VALUE; + avio_write(pb, "FLV", 3); avio_w8(pb,1); avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc @@ -444,10 +446,15 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n"); return -1; } - if (!sc->delay && pkt->dts < 0) - sc->delay = -pkt->dts; + if (flv->delay == AV_NOPTS_VALUE) + flv->delay = -pkt->dts; + if (pkt->dts < -flv->delay) { + av_log(s, AV_LOG_WARNING, "Packets are not in the proper order with " + "respect to DTS\n"); + return AVERROR(EINVAL); + } - ts = pkt->dts + sc->delay; // add delay to force positive dts + ts = pkt->dts + flv->delay; // add delay to force positive dts /* check Speex packet duration */ if (enc->codec_id == CODEC_ID_SPEEX && ts - sc->last_ts > 160) { @@ -481,7 +488,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) avio_write(pb, data ? data : pkt->data, size); avio_wb32(pb,size+flags_size+11); // previous tag size - flv->duration = FFMAX(flv->duration, pkt->pts + sc->delay + pkt->duration); + flv->duration = FFMAX(flv->duration, pkt->pts + flv->delay + pkt->duration); avio_flush(pb); |