Skip to content
Snippets Groups Projects
Commit ed39cda0 authored by Anton Khirnov's avatar Anton Khirnov
Browse files

flacenc: send final extradata in packet side data

parent 0957b274
No related branches found
No related tags found
No related merge requests found
...@@ -114,6 +114,9 @@ typedef struct FlacEncodeContext { ...@@ -114,6 +114,9 @@ typedef struct FlacEncodeContext {
unsigned int md5_buffer_size; unsigned int md5_buffer_size;
DSPContext dsp; DSPContext dsp;
FLACDSPContext flac_dsp; FLACDSPContext flac_dsp;
int flushed;
int64_t next_pts;
} FlacEncodeContext; } FlacEncodeContext;
...@@ -1212,6 +1215,20 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -1212,6 +1215,20 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
s->max_framesize = s->max_encoded_framesize; s->max_framesize = s->max_encoded_framesize;
av_md5_final(s->md5ctx, s->md5sum); av_md5_final(s->md5ctx, s->md5sum);
write_streaminfo(s, avctx->extradata); 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; return 0;
} }
...@@ -1264,6 +1281,9 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -1264,6 +1281,9 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
avpkt->pts = frame->pts; avpkt->pts = frame->pts;
avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
avpkt->size = out_bytes; avpkt->size = out_bytes;
s->next_pts = avpkt->pts + avpkt->duration;
*got_packet_ptr = 1; *got_packet_ptr = 1;
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment