History

avfilter/vf_uspp: use av_packet_alloc() to allocate packets

James Almer committed 5 years ago

Commit b76ff691 parent 79c6e041 file · +10 −6Browse files

Unified · Split

libavfilter/vf_uspp.c+10−6
@@ -51,6 +51,7 @@ typedef struct USPPContext { · 50 unmodified lines
5151 int outbuf_size;
5252 uint8_t *outbuf;
5353 AVCodecContext *avctx_enc[BLOCK*BLOCK];
54+ AVPacket *pkt;
5455 AVFrame *frame;
5556 AVFrame *frame_dec;
5657 int8_t *non_b_qp_table;
@@ -240,24 +241,24 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3], · 183 unmodified lines
240241 const int y1c = y1 >> p->vsub;
241242 const int BLOCKc = BLOCK >> p->hsub;
242243 int offset;
243− AVPacket pkt = {0};
244+ AVPacket *pkt = p->pkt;
244245 int got_pkt_ptr;
245246
246− av_init_packet(&pkt);
247− pkt.data = p->outbuf;
248− pkt.size = p->outbuf_size;
247+ av_packet_unref(pkt);
248+ pkt->data = p->outbuf;
249+ pkt->size = p->outbuf_size;
249250
250251 p->frame->data[0] = p->src[0] + x1 + y1 * p->frame->linesize[0];
251252 p->frame->data[1] = p->src[1] + x1c + y1c * p->frame->linesize[1];
252253 p->frame->data[2] = p->src[2] + x1c + y1c * p->frame->linesize[2];
253254 p->frame->format = p->avctx_enc[i]->pix_fmt;
254255
255− ret = avcodec_encode_video2(p->avctx_enc[i], &pkt, p->frame, &got_pkt_ptr);
256+ ret = avcodec_encode_video2(p->avctx_enc[i], pkt, p->frame, &got_pkt_ptr);
256257 if (ret < 0) {
257258 av_log(p->avctx_enc[i], AV_LOG_ERROR, "Encoding failed\n");
258259 continue;
259260 }
260− av_packet_unref(&pkt);
261+ av_packet_unref(pkt);
261262
262263 p->frame_dec = p->avctx_enc[i]->coded_frame;
263264
@@ -374,6 +375,8 @@ static int config_input(AVFilterLink *inlink) · 110 unmodified lines
374375 uspp->outbuf_size = (width + BLOCK) * (height + BLOCK) * 10;
375376 if (!(uspp->frame = av_frame_alloc()))
376377 return AVERROR(ENOMEM);
378+ if (!(uspp->pkt = av_packet_alloc()))
379+ return AVERROR(ENOMEM);
377380 if (!(uspp->outbuf = av_malloc(uspp->outbuf_size)))
378381 return AVERROR(ENOMEM);
379382
@@ -468,6 +471,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 88 unmodified lines
468471
469472 av_freep(&uspp->non_b_qp_table);
470473 av_freep(&uspp->outbuf);
474+ av_packet_free(&uspp->pkt);
471475 av_frame_free(&uspp->frame);
472476 }
473477

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t