[FFmpeg-devel] [PATCH] ffmpeg: merge extradata checks in write_frame
Clément Bœsch
u at pkh.me
Thu Sep 1 18:14:45 EEST 2016
From: Clément Bœsch <clement at stupeflix.com>
---
ffmpeg.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/ffmpeg.c b/ffmpeg.c
index 3229823..493b605 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -638,11 +638,11 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
AVCodecContext *avctx = ost->encoding_needed ? ost->enc_ctx : ost->st->codec;
int ret;
- if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) {
- ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
- if (ost->st->codec->extradata) {
- memcpy(ost->st->codec->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size);
- ost->st->codec->extradata_size = ost->enc_ctx->extradata_size;
+ if (!ost->st->codecpar->extradata_size && ost->enc_ctx->extradata_size) {
+ ost->st->codecpar->extradata = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (ost->st->codecpar->extradata) {
+ memcpy(ost->st->codecpar->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size);
+ ost->st->codecpar->extradata_size = ost->enc_ctx->extradata_size;
}
}
@@ -696,15 +696,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
}
if (pkt->size == 0 && pkt->side_data_elems == 0)
return;
- if (!ost->st->codecpar->extradata && avctx->extradata) {
- ost->st->codecpar->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!ost->st->codecpar->extradata) {
- av_log(NULL, AV_LOG_ERROR, "Could not allocate extradata buffer to copy parser data.\n");
- exit_program(1);
- }
- ost->st->codecpar->extradata_size = avctx->extradata_size;
- memcpy(ost->st->codecpar->extradata, avctx->extradata, avctx->extradata_size);
- }
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
if (pkt->dts != AV_NOPTS_VALUE &&
--
2.9.3
More information about the ffmpeg-devel
mailing list