Signed-off-by: Vittorio Giovara <[email protected]>
---
libavcodec/a64multienc.c | 6 ++++--
libavcodec/aliaspixenc.c | 7 ++++---
libavcodec/asvenc.c | 7 ++++---
libavcodec/bmpenc.c | 6 ++++--
libavcodec/cljrenc.c | 7 ++++---
libavcodec/dnxhdenc.c | 12 ++++++++----
libavcodec/dpxenc.c | 7 ++++---
libavcodec/dvenc.c | 11 ++++++-----
libavcodec/ffv1enc.c | 9 +++++----
libavcodec/flashsvenc.c | 16 ++++++++++------
libavcodec/gif.c | 7 ++++---
libavcodec/huffyuvenc.c | 7 ++++---
libavcodec/jpeglsenc.c | 7 ++++---
libavcodec/lclenc.c | 7 ++++---
libavcodec/libschroedingerenc.c | 16 ++++++++++++++--
libavcodec/libtheoraenc.c | 16 ++++++++++++++--
libavcodec/libvpxenc.c | 14 ++++++++++----
libavcodec/libx264.c | 17 ++++++++++++-----
libavcodec/libx265.c | 13 ++++++++++---
libavcodec/libxavs.c | 16 +++++++++++-----
libavcodec/libxvid.c | 25 +++++++++++++++----------
libavcodec/ljpegenc.c | 8 +++++---
libavcodec/mpegvideo_enc.c | 14 ++++++++++++--
libavcodec/pamenc.c | 13 ++++---------
libavcodec/pcxenc.c | 13 ++++---------
libavcodec/pngenc.c | 8 +++++---
libavcodec/pnmenc.c | 17 +++++------------
libavcodec/proresenc.c | 7 ++++---
libavcodec/qsvenc.c | 14 +++++++++++---
libavcodec/qtrleenc.c | 13 ++++++++++---
libavcodec/rawenc.c | 7 +++++--
libavcodec/sgienc.c | 7 ++++---
libavcodec/sunrastenc.c | 6 ++++--
libavcodec/svq1enc.c | 13 ++++++++++---
libavcodec/targaenc.c | 13 ++++---------
libavcodec/tiffenc.c | 14 +++++---------
libavcodec/utvideoenc.c | 5 +++--
libavcodec/v210enc.c | 6 ++++--
libavcodec/v410enc.c | 7 ++++---
libavcodec/xbmenc.c | 12 ++++--------
libavcodec/xwdenc.c | 7 ++++---
libavcodec/zmbvenc.c | 11 +++++++++--
42 files changed, 275 insertions(+), 173 deletions(-)
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index f065ebb..13da2cc 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -217,8 +217,6 @@ static av_cold int a64multi_encode_init(AVCodecContext
*avctx)
AV_WB32(avctx->extradata, c->mc_lifetime);
AV_WB32(avctx->extradata + 16, INTERLACED);
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
if (!avctx->codec_tag)
avctx->codec_tag = AV_RL32("a64m");
@@ -366,6 +364,10 @@ static int a64multi_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
pkt->pts = pkt->dts = c->next_pts;
c->next_pts = AV_NOPTS_VALUE;
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = req_size;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = !!req_size;
diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c
index 5e3bcb4..873fae1 100644
--- a/libavcodec/aliaspixenc.c
+++ b/libavcodec/aliaspixenc.c
@@ -33,9 +33,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int width, height, bits_pixel, i, j, length, ret;
uint8_t *in_buf, *buf;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
width = avctx->width;
height = avctx->height;
@@ -98,6 +95,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
/* Total length */
av_shrink_packet(pkt, buf - pkt->data);
pkt->flags |= AV_PKT_FLAG_KEY;
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index c10d9fe..f006626 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -269,6 +269,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
pkt->data[i] = ff_reverse[pkt->data[i]];
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = size * 4;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -282,9 +286,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
int i;
const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
ff_asv_common_init(avctx);
ff_fdctdsp_init(&a->fdsp, avctx);
ff_pixblockdsp_init(&a->pdsp, avctx);
diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
index 7260baa..fb6dbf2 100644
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -69,8 +69,6 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
int bit_count = avctx->bits_per_coded_sample;
uint8_t *ptr, *buf;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB444:
compression = BMP_BITFIELDS;
@@ -148,6 +146,10 @@ static int bmp_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
ptr -= p->linesize[0]; // ... and go back
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/cljrenc.c b/libavcodec/cljrenc.c
index e2db7a6..a39af6a 100644
--- a/libavcodec/cljrenc.c
+++ b/libavcodec/cljrenc.c
@@ -41,9 +41,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return ret;
}
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
init_put_bits(&pb, pkt->data, pkt->size);
for (y = 0; y < avctx->height; y++) {
@@ -63,6 +60,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
flush_put_bits(&pb);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = put_bits_count(&pb) / 8;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 0c98c56..de1e887 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -364,9 +364,6 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale,
ctx->m.mb_num * sizeof(uint8_t), fail);
- avctx->coded_frame->key_frame = 1;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
-
if (avctx->thread_count > MAX_THREADS) {
av_log(avctx, AV_LOG_ERROR, "too many threads\n");
return AVERROR(EINVAL);
@@ -1028,6 +1025,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx,
AVPacket *pkt,
int first_field = 1;
int offset, i, ret;
uint8_t *buf;
+ AVPacketCodingParams *params;
if ((ret = ff_alloc_packet(pkt, ctx->cid_table->frame_size)) < 0) {
av_log(avctx, AV_LOG_ERROR,
@@ -1081,7 +1079,13 @@ encode_coding_unit:
goto encode_coding_unit;
}
- avctx->coded_frame->quality = ctx->qscale * FF_QP2LAMBDA;
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+ params->quality = ctx->qscale * FF_QP2LAMBDA;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c
index aaa5d93..988ea8e 100644
--- a/libavcodec/dpxenc.c
+++ b/libavcodec/dpxenc.c
@@ -35,9 +35,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
{
DPXContext *s = avctx->priv_data;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
s->big_endian = 1;
s->bits_per_component = 8;
s->descriptor = 50; /* RGB */
@@ -167,6 +164,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
write32(buf + 16, size); /* file size */
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 3bbcaf0..6bad6ce 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -714,11 +714,8 @@ static int dvvideo_encode_frame(AVCodecContext *c,
AVPacket *pkt,
return ret;
}
- c->pix_fmt = s->sys->pix_fmt;
- s->frame = frame;
- c->coded_frame->key_frame = 1;
- c->coded_frame->pict_type = AV_PICTURE_TYPE_I;
-
+ c->pix_fmt = s->sys->pix_fmt;
+ s->frame = frame;
s->buf = pkt->data;
c->execute(c, dv_encode_video_segment, s->work_chunks, NULL,
dv_work_pool_size(s->sys), sizeof(DVwork_chunk));
@@ -727,6 +724,10 @@ static int dvvideo_encode_frame(AVCodecContext *c,
AVPacket *pkt,
dv_format_frame(s, pkt->data);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 33d1391..b9d8161 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -721,8 +721,6 @@ static av_cold int ffv1_encode_init(AVCodecContext *avctx)
if ((ret = ffv1_allocate_initial_states(s)) < 0)
return ret;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
-
if (!s->transparency)
s->plane_count = 2;
@@ -1045,9 +1043,12 @@ static int ffv1_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
} else if (avctx->flags & CODEC_FLAG_PASS1)
avctx->stats_out[0] = '\0';
- avctx->coded_frame->key_frame = f->key_frame;
-
f->picture_number++;
+
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = buf_p - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY * f->key_frame;
*got_packet = 1;
diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
index a2f89dc..192b42e 100644
--- a/libavcodec/flashsvenc.c
+++ b/libavcodec/flashsvenc.c
@@ -216,6 +216,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
int res;
int I_frame = 0;
int opt_w = 4, opt_h = 4;
+ AVPacketCodingParams *params;
/* First frame needs to be a keyframe */
if (avctx->frame_number == 0) {
@@ -256,19 +257,22 @@ static int flashsv_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
p->data[0] + p->linesize[0] * (s->image_height - 1),
s->image_height * FFABS(p->linesize[0]));
+ res = ff_packet_default_coding_params(pkt);
+ if (res < 0)
+ return res;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
//mark the frame type so the muxer can mux it correctly
if (I_frame) {
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
+ params->pict_type = AV_PICTURE_TYPE_I;
+ pkt->flags |= AV_PKT_FLAG_KEY;
s->last_key_frame = avctx->frame_number;
ff_dlog(avctx, "Inserting keyframe at frame %d\n",
avctx->frame_number);
} else {
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
- avctx->coded_frame->key_frame = 0;
+ params->pict_type = AV_PICTURE_TYPE_P;
}
- if (avctx->coded_frame->key_frame)
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index cb1c71b..09be908 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -130,9 +130,6 @@ static av_cold int gif_encode_init(AVCodecContext *avctx)
{
GIFContext *s = avctx->priv_data;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
s->lzw = av_mallocz(ff_lzw_encode_state_size);
if (!s->lzw)
return AVERROR(ENOMEM);
@@ -159,6 +156,10 @@ static int gif_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
gif_image_write_header(avctx, &outbuf_ptr, (uint32_t *)pict->data[1]);
gif_image_write_image(avctx, &outbuf_ptr, end, pict->data[0],
pict->linesize[0]);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = outbuf_ptr - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 3b40404..75eb1f4 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -154,9 +154,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0)
= 16132
s->version = 2;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
@@ -660,6 +657,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
s->picture_number++;
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = size * 4;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 3021394..7b2ee1d 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -400,6 +400,10 @@ static int encode_picture_ls(AVCodecContext *avctx,
AVPacket *pkt,
emms_c();
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = put_bits_count(&pb) >> 3;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -415,9 +419,6 @@ memfail:
static av_cold int encode_init_ls(AVCodecContext *ctx)
{
- ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- ctx->coded_frame->key_frame = 1;
-
if (ctx->pix_fmt != AV_PIX_FMT_GRAY8 &&
ctx->pix_fmt != AV_PIX_FMT_GRAY16 &&
ctx->pix_fmt != AV_PIX_FMT_RGB24 &&
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index 35543ac..4258a5f 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -113,6 +113,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
return -1;
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = c->zstream.total_out;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -136,9 +140,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
avctx->extradata= av_mallocz(8);
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
// Will be user settable someday
c->compression = 6;
c->flags = 0;
diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c
index 3e648d0..e51787d 100644
--- a/libavcodec/libschroedingerenc.c
+++ b/libavcodec/libschroedingerenc.c
@@ -269,6 +269,7 @@ static int libschroedinger_encode_frame(AVCodecContext
*avctx, AVPacket *pkt,
int parse_code;
int last_frame_in_sequence = 0;
int pkt_size, ret;
+ AVPacketCodingParams *params;
if (!frame) {
/* Push end of sequence if not already signalled. */
@@ -384,7 +385,6 @@ static int libschroedinger_encode_frame(AVCodecContext
*avctx, AVPacket *pkt,
}
memcpy(pkt->data, p_frame_output->p_encbuf, p_frame_output->size);
- avctx->coded_frame->key_frame = p_frame_output->key_frame;
/* Use the frame number of the encoded frame as the pts. It is OK to
* do so since Dirac is a constant frame rate codec. It expects input
* to be of constant frame rate. */
@@ -402,8 +402,20 @@ static int libschroedinger_encode_frame(AVCodecContext
*avctx, AVPacket *pkt,
p_schro_params->enc_buf_size = 0;
}
- if (p_frame_output->key_frame)
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ goto error;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+
+ if (p_frame_output->key_frame) {
+ params->pict_type = AV_PICTURE_TYPE_I;
pkt->flags |= AV_PKT_FLAG_KEY;
+ } else {
+ params->pict_type = AV_PICTURE_TYPE_P;
+ }
+
*got_packet = 1;
error:
diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index 7087322..03eed07 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -268,6 +268,7 @@ static int encode_frame(AVCodecContext* avc_context,
AVPacket *pkt,
TheoraContext *h = avc_context->priv_data;
ogg_packet o_packet;
int result, i, ret;
+ AVPacketCodingParams *params;
// EOS, finish and get 1st pass stats if applicable
if (!frame) {
@@ -334,12 +335,23 @@ static int encode_frame(AVCodecContext* avc_context,
AVPacket *pkt,
}
memcpy(pkt->data, o_packet.packet, o_packet.bytes);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+
// HACK: assumes no encoder delay, this is true until libtheora becomes
// multithreaded (which will be disabled unless explicitly requested)
pkt->pts = pkt->dts = frame->pts;
- avc_context->coded_frame->key_frame = !(o_packet.granulepos &
h->keyframe_mask);
- if (!(o_packet.granulepos & h->keyframe_mask))
+ if (!(o_packet.granulepos & h->keyframe_mask)) {
+ params->pict_type = AV_PICTURE_TYPE_I;
pkt->flags |= AV_PKT_FLAG_KEY;
+ } else {
+ params->pict_type = AV_PICTURE_TYPE_P;
+ }
+
*got_packet = 1;
return 0;
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 49d0511..e695535 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -388,15 +388,21 @@ static int storeframe(AVCodecContext *avctx, struct
FrameListData *cx_frame,
{
int ret = ff_alloc_packet(pkt, cx_frame->sz);
if (ret >= 0) {
+ AVPacketCodingParams *params;
memcpy(pkt->data, cx_frame->buf, pkt->size);
pkt->pts = pkt->dts = cx_frame->pts;
- avctx->coded_frame->key_frame = !!(cx_frame->flags & VPX_FRAME_IS_KEY);
+
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
if (!!(cx_frame->flags & VPX_FRAME_IS_KEY)) {
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- pkt->flags |= AV_PKT_FLAG_KEY;
+ params->pict_type = AV_PICTURE_TYPE_I;
+ pkt->flags |= AV_PKT_FLAG_KEY;
} else
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+ params->pict_type = AV_PICTURE_TYPE_P;
} else {
av_log(avctx, AV_LOG_ERROR,
"Error getting output packet of size %zu.\n", cx_frame->sz);
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 7fef7f2..9825c28 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -133,9 +133,10 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt,
const AVFrame *frame,
{
X264Context *x4 = ctx->priv_data;
x264_nal_t *nal;
- int nnal, i, ret;
+ int nnal, i, ret, rets;
x264_picture_t pic_out;
AVFrameSideData *side_data;
+ AVPacketCodingParams *params;
x264_picture_init( &x4->pic );
x4->pic.img.i_csp = x4->params.i_csp;
@@ -245,23 +246,29 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt,
const AVFrame *frame,
pkt->pts = pic_out.i_pts;
pkt->dts = pic_out.i_dts;
+ rets = ff_packet_default_coding_params(pkt);
+ if (rets < 0)
+ return rets;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
switch (pic_out.i_type) {
case X264_TYPE_IDR:
case X264_TYPE_I:
- ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ params->pict_type = AV_PICTURE_TYPE_I;
break;
case X264_TYPE_P:
- ctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+ params->pict_type = AV_PICTURE_TYPE_P;
break;
case X264_TYPE_B:
case X264_TYPE_BREF:
- ctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+ params->pict_type = AV_PICTURE_TYPE_B;
break;
}
pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
if (ret)
- ctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
+ params->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
*got_packet = ret;
return 0;
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 145480f..ae1b008 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -251,6 +251,7 @@ static int libx265_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
int nnal;
int ret;
int i;
+ AVPacketCodingParams *params;
ctx->api->picture_init(ctx->params, &x265pic);
@@ -298,16 +299,22 @@ static int libx265_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
pkt->pts = x265pic_out.pts;
pkt->dts = x265pic_out.dts;
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
switch (x265pic_out.sliceType) {
case X265_TYPE_IDR:
case X265_TYPE_I:
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ params->pict_type = AV_PICTURE_TYPE_I;
break;
case X265_TYPE_P:
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+ params->pict_type = AV_PICTURE_TYPE_P;
break;
case X265_TYPE_B:
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+ params->pict_type = AV_PICTURE_TYPE_B;
break;
}
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 4dd778e..9510a46 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -119,6 +119,7 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
xavs_nal_t *nal;
int nnal, i, ret;
xavs_picture_t pic_out;
+ AVPacketCodingParams *params;
x4->pic.img.i_csp = XAVS_CSP_I420;
x4->pic.img.i_plane = 3;
@@ -169,28 +170,33 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket
*pkt,
} else
pkt->dts = pkt->pts;
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
switch (pic_out.i_type) {
case XAVS_TYPE_IDR:
case XAVS_TYPE_I:
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ params->pict_type = AV_PICTURE_TYPE_I;
break;
case XAVS_TYPE_P:
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+ params->pict_type = AV_PICTURE_TYPE_P;
break;
case XAVS_TYPE_B:
case XAVS_TYPE_BREF:
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+ params->pict_type = AV_PICTURE_TYPE_B;
break;
}
/* There is no IDR frame in AVS JiZhun */
/* Sequence header is used as a flag */
if (pic_out.i_type == XAVS_TYPE_I) {
- avctx->coded_frame->key_frame = 1;
pkt->flags |= AV_PKT_FLAG_KEY;
}
- avctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
+ params->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
x4->out_frame_count++;
*got_packet = ret;
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index b4cf0e0..986c01e 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -654,7 +654,6 @@ static int xvid_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
{
int xerr, i, ret, user_packet = !!pkt->data;
struct xvid_context *x = avctx->priv_data;
- AVFrame *p = avctx->coded_frame;
int mb_width = (avctx->width + 15) / 16;
int mb_height = (avctx->height + 15) / 16;
char *tmp;
@@ -738,25 +737,31 @@ static int xvid_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
}
if (xerr > 0) {
- *got_packet = 1;
+ AVPacketCodingParams *params;
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
- p->quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
+ params->quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
if (xvid_enc_stats.type == XVID_TYPE_PVOP)
- p->pict_type = AV_PICTURE_TYPE_P;
+ params->pict_type = AV_PICTURE_TYPE_P;
else if (xvid_enc_stats.type == XVID_TYPE_BVOP)
- p->pict_type = AV_PICTURE_TYPE_B;
+ params->pict_type = AV_PICTURE_TYPE_B;
else if (xvid_enc_stats.type == XVID_TYPE_SVOP)
- p->pict_type = AV_PICTURE_TYPE_S;
+ params->pict_type = AV_PICTURE_TYPE_S;
else
- p->pict_type = AV_PICTURE_TYPE_I;
+ params->pict_type = AV_PICTURE_TYPE_I;
if (xvid_enc_frame.out_flags & XVID_KEYFRAME) {
- p->key_frame = 1;
pkt->flags |= AV_PKT_FLAG_KEY;
if (x->quicktime_format)
return xvid_strip_vol_header(avctx, pkt,
xvid_enc_stats.hlength, xerr);
- } else
- p->key_frame = 0;
+ }
+
+ *got_packet = 1;
pkt->size = xerr;
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index c652653..cc801cb 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -244,6 +244,11 @@ static int ljpeg_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
ff_mjpeg_encode_picture_trailer(&pb, header_bits);
flush_put_bits(&pb);
+
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = put_bits_ptr(&pb) - pb.buf;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -276,9 +281,6 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));
ff_idctdsp_init(&s->idsp, avctx);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 2e0dc72..dacfcad 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1459,8 +1459,6 @@ static void frame_end(MpegEncContext *s)
ff_mpeg_unref_picture(s, &s->picture[i]);
}
}
-
- av_frame_copy_props(s->avctx->coded_frame, s->current_picture.f);
}
static void update_noise_reduction(MpegEncContext *s)
@@ -1574,6 +1572,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket
*pkt,
/* output? */
if (s->new_picture.f->data[0]) {
+ AVPacketCodingParams *params;
if (!pkt->data &&
(ret = ff_alloc_packet(pkt,
s->mb_width*s->mb_height*MAX_MB_BYTES)) < 0)
return ret;
@@ -1615,6 +1614,17 @@ vbv_retry:
frame_end(s);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+ params->pict_type = s->current_picture.f->pict_type;
+ params->quality = s->current_picture.f->quality;
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
+ params->error[i] = s->current_picture.f->error[i];
+
if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits);
diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c
index 483089a..67e6e7f 100644
--- a/libavcodec/pamenc.c
+++ b/libavcodec/pamenc.c
@@ -101,26 +101,21 @@ static int pam_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
}
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = bytestream - bytestream_start;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
-static av_cold int pam_encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
- return 0;
-}
-
AVCodec ff_pam_encoder = {
.name = "pam",
.long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PAM,
- .init = pam_encode_init,
.encode2 = pam_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB32, AV_PIX_FMT_GRAY8,
AV_PIX_FMT_MONOWHITE,
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c
index 24bca97..0dd492f 100644
--- a/libavcodec/pcxenc.c
+++ b/libavcodec/pcxenc.c
@@ -32,14 +32,6 @@
static const uint32_t monoblack_pal[16] = { 0x000000, 0xFFFFFF };
-static av_cold int pcx_encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
- return 0;
-}
-
/**
* PCX run-length encoder
* @param dst output buffer
@@ -183,6 +175,10 @@ static int pcx_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
}
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = buf - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -195,7 +191,6 @@ AVCodec ff_pcx_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PCX,
- .init = pcx_encode_init,
.encode2 = pcx_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24,
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index bbeee01..2ecf36e 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "bytestream.h"
#include "huffyuvencdsp.h"
+#include "internal.h"
#include "png.h"
/* TODO:
@@ -434,6 +435,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
}
png_write_chunk(&s->bytestream, MKTAG('I', 'E', 'N', 'D'), NULL, 0);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ goto fail;
+
pkt->size = s->bytestream - s->bytestream_start;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -455,9 +460,6 @@ static av_cold int png_enc_init(AVCodecContext *avctx)
{
PNGEncContext *s = avctx->priv_data;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
ff_huffyuvencdsp_init(&s->hdsp);
s->filter_type = av_clip(avctx->prediction_method,
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index 58fd4fe..a22ddda 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -111,6 +111,11 @@ static int pnm_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
ptr2 += p->linesize[2];
}
}
+
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = bytestream - bytestream_start;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -118,21 +123,12 @@ static int pnm_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
return 0;
}
-static av_cold int pnm_encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
- return 0;
-}
-
#if CONFIG_PGM_ENCODER
AVCodec ff_pgm_encoder = {
.name = "pgm",
.long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PGM,
- .init = pnm_encode_init,
.encode2 = pnm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE
@@ -146,7 +142,6 @@ AVCodec ff_pgmyuv_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV)
image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PGMYUV,
- .init = pnm_encode_init,
.encode2 = pnm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_NONE
@@ -160,7 +155,6 @@ AVCodec ff_ppm_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PPM,
- .init = pnm_encode_init,
.encode2 = pnm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_NONE
@@ -174,7 +168,6 @@ AVCodec ff_pbm_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PBM,
- .init = pnm_encode_init,
.encode2 = pnm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_MONOWHITE,
AV_PIX_FMT_NONE },
diff --git a/libavcodec/proresenc.c b/libavcodec/proresenc.c
index 3e99d10..518c6d5 100644
--- a/libavcodec/proresenc.c
+++ b/libavcodec/proresenc.c
@@ -939,9 +939,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
uint8_t frame_flags;
ctx->pic = pic;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
pkt_size = ctx->frame_size_upper_bound;
if ((ret = ff_alloc_packet(pkt, pkt_size + FF_MIN_BUFFER_SIZE)) < 0) {
@@ -1085,6 +1082,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
frame_size = buf - orig_buf;
bytestream_put_be32(&orig_buf, frame_size);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = frame_size;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 8b0ecd1..216b627 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -393,14 +393,22 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
print_interlace_msg(avctx, q);
if (sync) {
+ AVPacketCodingParams *params;
MFXVideoCORE_SyncOperation(q->session, sync, 60000);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+
if (bs.FrameType & MFX_FRAMETYPE_I || bs.FrameType & MFX_FRAMETYPE_xI)
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ params->pict_type = AV_PICTURE_TYPE_I;
else if (bs.FrameType & MFX_FRAMETYPE_P || bs.FrameType &
MFX_FRAMETYPE_xP)
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+ params->pict_type = AV_PICTURE_TYPE_P;
else if (bs.FrameType & MFX_FRAMETYPE_B || bs.FrameType &
MFX_FRAMETYPE_xB)
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+ params->pict_type = AV_PICTURE_TYPE_B;
pkt->dts = av_rescale_q(bs.DecodeTimeStamp, (AVRational){1, 90000},
avctx->time_base);
pkt->pts = av_rescale_q(bs.TimeStamp, (AVRational){1, 90000},
avctx->time_base);
diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 8417864..96ba951 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -296,7 +296,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
QtrleEncContext * const s = avctx->priv_data;
- AVFrame * const p = avctx->coded_frame;
+ AVPacketCodingParams *params;
int ret;
if ((ret = ff_alloc_packet(pkt, s->max_buf_size)) < 0) {
@@ -305,13 +305,20 @@ static int qtrle_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
return ret;
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+
if (avctx->gop_size == 0 || (s->avctx->frame_number % avctx->gop_size) ==
0) {
/* I-Frame */
- p->pict_type = AV_PICTURE_TYPE_I;
+ params->pict_type = AV_PICTURE_TYPE_I;
s->key_frame = 1;
} else {
/* P-Frame */
- p->pict_type = AV_PICTURE_TYPE_P;
+ params->pict_type = AV_PICTURE_TYPE_P;
s->key_frame = 0;
}
diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index a360c34..bf44b1a 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -35,8 +35,6 @@ static av_cold int raw_encode_init(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc);
if(!avctx->codec_tag)
avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
@@ -63,6 +61,11 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
for(x = 1; x < avctx->height*avctx->width*2; x += 2)
pkt->data[x] ^= 0x80;
}
+
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c
index 73e1a67..18876ea 100644
--- a/libavcodec/sgienc.c
+++ b/libavcodec/sgienc.c
@@ -49,9 +49,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
unsigned int bytes_per_channel, pixmax, put_be;
unsigned char *end_buf;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
width = avctx->width;
height = avctx->height;
bytes_per_channel = 1;
@@ -193,6 +190,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
}
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
/* total length */
pkt->size = buf - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c
index 0627c47..a2bcdef 100644
--- a/libavcodec/sunrastenc.c
+++ b/libavcodec/sunrastenc.c
@@ -153,8 +153,6 @@ static av_cold int sunrast_encode_init(AVCodecContext
*avctx)
return AVERROR(EINVAL);
}
- avctx->coded_frame->key_frame = 1;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->maptype = RMT_NONE;
s->maplength = 0;
@@ -200,6 +198,10 @@ static int sunrast_encode_frame(AVCodecContext *avctx,
AVPacket *avpkt,
if (s->type == RT_BYTE_ENCODED)
AV_WB32(&avpkt->data[16], s->length);
+ ret = ff_packet_default_coding_params(avpkt);
+ if (ret < 0)
+ return ret;
+
*got_packet_ptr = 1;
avpkt->flags |= AV_PKT_FLAG_KEY;
avpkt->size = bytestream2_tell_p(&s->p);
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 2244eaf..0bd7b3d 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -561,6 +561,7 @@ static int svq1_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
SVQ1EncContext *const s = avctx->priv_data;
+ AVPacketCodingParams *params;
int i, ret;
if (!pkt->data &&
@@ -601,9 +602,6 @@ static int svq1_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
s->pict_type = AV_PICTURE_TYPE_I;
s->quality = pict->quality;
- avctx->coded_frame->pict_type = s->pict_type;
- avctx->coded_frame->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
-
svq1_write_header(s, s->pict_type);
for (i = 0; i < 3; i++)
if (svq1_encode_plane(s, i,
@@ -622,6 +620,15 @@ static int svq1_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
flush_put_bits(&s->pb);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+ params->pict_type = s->pict_type;
+ params->quality = s->quality;
+
pkt->size = put_bits_count(&s->pb) / 8;
if (s->pict_type == AV_PICTURE_TYPE_I)
pkt->flags |= AV_PKT_FLAG_KEY;
diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index 048183f..d19676b 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -141,6 +141,10 @@ static int targa_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
* aspect ratio and encoder ID fields available? */
memcpy(out, "\0\0\0\0\0\0\0\0TRUEVISION-XFILE.", 26);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = out + 26 - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -148,20 +152,11 @@ static int targa_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
return 0;
}
-static av_cold int targa_encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame->key_frame = 1;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
-
- return 0;
-}
-
AVCodec ff_targa_encoder = {
.name = "targa",
.long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_TARGA,
- .init = targa_encode_init,
.encode2 = targa_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_BGR24, AV_PIX_FMT_BGRA, AV_PIX_FMT_RGB555LE,
AV_PIX_FMT_GRAY8,
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index fbdb824..5157ddd 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -35,6 +35,7 @@
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bytestream.h"
+#include "internal.h"
#include "lzw.h"
#include "put_bits.h"
#include "rle.h"
@@ -477,6 +478,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
bytestream_put_buffer(&ptr, s->entries, s->num_entries * 12);
bytestream_put_le32(&ptr, 0);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = ptr - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -488,14 +493,6 @@ fail:
return ret;
}
-static av_cold int encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-
- return 0;
-}
-
#define OFFSET(x) offsetof(TiffEncoderContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
@@ -522,7 +519,6 @@ AVCodec ff_tiff_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_TIFF,
.priv_data_size = sizeof(TiffEncoderContext),
- .init = encode_init,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48LE, AV_PIX_FMT_PAL8,
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index c22f488..f12a34d 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -615,8 +615,9 @@ static int utvideo_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
* At least currently Ut Video is IDR only.
* Set flags accordingly.
*/
- avctx->coded_frame->key_frame = 1;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
pkt->size = bytestream2_tell_p(&pb);
pkt->flags |= AV_PKT_FLAG_KEY;
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 375236c..7f5547d 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -91,8 +91,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
-
s->pack_line_8 = v210_planar_pack_8_c;
s->pack_line_10 = v210_planar_pack_10_c;
@@ -204,6 +202,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
}
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c
index ffbdc7d..0cc7161 100644
--- a/libavcodec/v410enc.c
+++ b/libavcodec/v410enc.c
@@ -49,9 +49,6 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
}
dst = pkt->data;
- avctx->coded_frame->key_frame = 1;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
-
y = (uint16_t *)pic->data[0];
u = (uint16_t *)pic->data[1];
v = (uint16_t *)pic->data[2];
@@ -69,6 +66,10 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
v += pic->linesize[2] >> 1;
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index 41456cb..dd78c02 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -24,13 +24,6 @@
#include "internal.h"
#include "mathops.h"
-static av_cold int xbm_encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
-
- return 0;
-}
-
static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet)
{
@@ -58,6 +51,10 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
}
buf += snprintf(buf, 5, " };\n");
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->size = buf - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -69,7 +66,6 @@ AVCodec ff_xbm_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_XBM,
- .init = xbm_encode_init,
.encode2 = xbm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE,
AV_PIX_FMT_NONE },
diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c
index 97a3eb8..054e807 100644
--- a/libavcodec/xwdenc.c
+++ b/libavcodec/xwdenc.c
@@ -146,9 +146,6 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
}
buf = pkt->data;
- avctx->coded_frame->key_frame = 1;
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
-
bytestream_put_be32(&buf, header_size);
bytestream_put_be32(&buf, XWD_VERSION); // file version
bytestream_put_be32(&buf, XWD_Z_PIXMAP); // pixmap format
@@ -199,6 +196,10 @@ static int xwd_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
ptr += p->linesize[0];
}
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
index ea63b94..330c124 100644
--- a/libavcodec/zmbvenc.c
+++ b/libavcodec/zmbvenc.c
@@ -128,13 +128,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
int work_size = 0, pkt_size;
int bw, bh;
int i, j, ret;
+ AVPacketCodingParams *params;
keyframe = !c->curfrm;
c->curfrm++;
if(c->curfrm == c->keyint)
c->curfrm = 0;
- avctx->coded_frame->pict_type = keyframe ? AV_PICTURE_TYPE_I :
AV_PICTURE_TYPE_P;
- avctx->coded_frame->key_frame = keyframe;
chpal = !keyframe && memcmp(p->data[1], c->pal2, 1024);
palptr = (uint32_t*)p->data[1];
@@ -245,6 +244,14 @@ static int encode_frame(AVCodecContext *avctx, AVPacket
*pkt,
}
memcpy(buf, c->comp_buf, c->zstream.total_out);
+ ret = ff_packet_default_coding_params(pkt);
+ if (ret < 0)
+ return ret;
+
+ params = (AVPacketCodingParams *)
+ av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+ params->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+
pkt->flags |= AV_PKT_FLAG_KEY*keyframe;
*got_packet = 1;
--
1.9.5 (Apple Git-50.3)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel