diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-06-01 13:55:03 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-06-01 13:55:49 +0200 |
commit | 05c5dd403d6a6974eb0a0688fcd22fe0417c2d84 (patch) | |
tree | a828719793f5dc2ecf6d393122cb7a711deb796a /libavcodec/flacenc.c | |
parent | 03bb99ae1a99fa315621308b885a8fc70702c9bc (diff) | |
parent | ed39cda02923316b6710c1bcc34d3445370be5b4 (diff) | |
download | ffmpeg-05c5dd403d6a6974eb0a0688fcd22fe0417c2d84.tar.gz |
Merge commit 'ed39cda02923316b6710c1bcc34d3445370be5b4'
* commit 'ed39cda02923316b6710c1bcc34d3445370be5b4':
flacenc: send final extradata in packet side data
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/flacenc.c')
-rw-r--r-- | libavcodec/flacenc.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index b6ae4af9a7..1c448f5ff8 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -115,6 +115,9 @@ typedef struct FlacEncodeContext { unsigned int md5_buffer_size; DSPContext dsp; FLACDSPContext flac_dsp; + + int flushed; + int64_t next_pts; } FlacEncodeContext; @@ -1239,6 +1242,20 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, s->max_framesize = s->max_encoded_framesize; av_md5_final(s->md5ctx, s->md5sum); write_streaminfo(s, avctx->extradata); + + if (avctx->side_data_only_packets && !s->flushed) { + uint8_t *side_data = av_packet_new_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, + avctx->extradata_size); + if (!side_data) + return AVERROR(ENOMEM); + memcpy(side_data, avctx->extradata, avctx->extradata_size); + + avpkt->pts = s->next_pts; + + *got_packet_ptr = 1; + s->flushed = 1; + } + return 0; } @@ -1289,6 +1306,9 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, avpkt->pts = frame->pts; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); avpkt->size = out_bytes; + + s->next_pts = avpkt->pts + avpkt->duration; + *got_packet_ptr = 1; return 0; } |