summaryrefslogtreecommitdiff
path: root/libavfilter/vf_uspp.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-01-29 13:54:05 -0300
committerJames Almer <jamrial@gmail.com>2021-03-17 15:19:36 -0300
commitb76ff693f6034463e33b8a92d2b04bdcb93a0216 (patch)
tree50ab607af6f30a21650bffb83e11b4be13c02998 /libavfilter/vf_uspp.c
parent79c6e040f8884d58119a7ac891e709754f4ed961 (diff)
downloadffmpeg-b76ff693f6034463e33b8a92d2b04bdcb93a0216.tar.gz
avfilter/vf_uspp: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavfilter/vf_uspp.c')
-rw-r--r--libavfilter/vf_uspp.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index 523e47c811..ba07181e74 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -51,6 +51,7 @@ typedef struct USPPContext {
int outbuf_size;
uint8_t *outbuf;
AVCodecContext *avctx_enc[BLOCK*BLOCK];
+ AVPacket *pkt;
AVFrame *frame;
AVFrame *frame_dec;
int8_t *non_b_qp_table;
@@ -240,24 +241,24 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
const int y1c = y1 >> p->vsub;
const int BLOCKc = BLOCK >> p->hsub;
int offset;
- AVPacket pkt = {0};
+ AVPacket *pkt = p->pkt;
int got_pkt_ptr;
- av_init_packet(&pkt);
- pkt.data = p->outbuf;
- pkt.size = p->outbuf_size;
+ av_packet_unref(pkt);
+ pkt->data = p->outbuf;
+ pkt->size = p->outbuf_size;
p->frame->data[0] = p->src[0] + x1 + y1 * p->frame->linesize[0];
p->frame->data[1] = p->src[1] + x1c + y1c * p->frame->linesize[1];
p->frame->data[2] = p->src[2] + x1c + y1c * p->frame->linesize[2];
p->frame->format = p->avctx_enc[i]->pix_fmt;
- ret = avcodec_encode_video2(p->avctx_enc[i], &pkt, p->frame, &got_pkt_ptr);
+ ret = avcodec_encode_video2(p->avctx_enc[i], pkt, p->frame, &got_pkt_ptr);
if (ret < 0) {
av_log(p->avctx_enc[i], AV_LOG_ERROR, "Encoding failed\n");
continue;
}
- av_packet_unref(&pkt);
+ av_packet_unref(pkt);
p->frame_dec = p->avctx_enc[i]->coded_frame;
@@ -374,6 +375,8 @@ static int config_input(AVFilterLink *inlink)
uspp->outbuf_size = (width + BLOCK) * (height + BLOCK) * 10;
if (!(uspp->frame = av_frame_alloc()))
return AVERROR(ENOMEM);
+ if (!(uspp->pkt = av_packet_alloc()))
+ return AVERROR(ENOMEM);
if (!(uspp->outbuf = av_malloc(uspp->outbuf_size)))
return AVERROR(ENOMEM);
@@ -468,6 +471,7 @@ static av_cold void uninit(AVFilterContext *ctx)
av_freep(&uspp->non_b_qp_table);
av_freep(&uspp->outbuf);
+ av_packet_free(&uspp->pkt);
av_frame_free(&uspp->frame);
}