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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_uspp.c+10−6
@@ -51,6 +51,7 @@ typedef struct USPPContext { · 50 unmodified lines
51 int outbuf_size;51 int outbuf_size;
52 uint8_t *outbuf;52 uint8_t *outbuf;
53 AVCodecContext *avctx_enc[BLOCK*BLOCK];53 AVCodecContext *avctx_enc[BLOCK*BLOCK];
54 AVPacket *pkt;
54 AVFrame *frame;55 AVFrame *frame;
55 AVFrame *frame_dec;56 AVFrame *frame_dec;
56 int8_t *non_b_qp_table;57 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
240 const int y1c = y1 >> p->vsub;241 const int y1c = y1 >> p->vsub;
241 const int BLOCKc = BLOCK >> p->hsub;242 const int BLOCKc = BLOCK >> p->hsub;
242 int offset;243 int offset;
243 AVPacket pkt = {0};244 AVPacket *pkt = p->pkt;
244 int got_pkt_ptr;245 int got_pkt_ptr;
245 246
246 av_init_packet(&pkt);247 av_packet_unref(pkt);
247 pkt.data = p->outbuf;248 pkt->data = p->outbuf;
248 pkt.size = p->outbuf_size;249 pkt->size = p->outbuf_size;
249 250
250 p->frame->data[0] = p->src[0] + x1 + y1 * p->frame->linesize[0];251 p->frame->data[0] = p->src[0] + x1 + y1 * p->frame->linesize[0];
251 p->frame->data[1] = p->src[1] + x1c + y1c * p->frame->linesize[1];252 p->frame->data[1] = p->src[1] + x1c + y1c * p->frame->linesize[1];
252 p->frame->data[2] = p->src[2] + x1c + y1c * p->frame->linesize[2];253 p->frame->data[2] = p->src[2] + x1c + y1c * p->frame->linesize[2];
253 p->frame->format = p->avctx_enc[i]->pix_fmt;254 p->frame->format = p->avctx_enc[i]->pix_fmt;
254 255
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);
256 if (ret < 0) {257 if (ret < 0) {
257 av_log(p->avctx_enc[i], AV_LOG_ERROR, "Encoding failed\n");258 av_log(p->avctx_enc[i], AV_LOG_ERROR, "Encoding failed\n");
258 continue;259 continue;
259 }260 }
260 av_packet_unref(&pkt);261 av_packet_unref(pkt);
261 262
262 p->frame_dec = p->avctx_enc[i]->coded_frame;263 p->frame_dec = p->avctx_enc[i]->coded_frame;
263 264
@@ -374,6 +375,8 @@ static int config_input(AVFilterLink *inlink) · 110 unmodified lines
374 uspp->outbuf_size = (width + BLOCK) * (height + BLOCK) * 10;375 uspp->outbuf_size = (width + BLOCK) * (height + BLOCK) * 10;
375 if (!(uspp->frame = av_frame_alloc()))376 if (!(uspp->frame = av_frame_alloc()))
376 return AVERROR(ENOMEM);377 return AVERROR(ENOMEM);
378 if (!(uspp->pkt = av_packet_alloc()))
379 return AVERROR(ENOMEM);
377 if (!(uspp->outbuf = av_malloc(uspp->outbuf_size)))380 if (!(uspp->outbuf = av_malloc(uspp->outbuf_size)))
378 return AVERROR(ENOMEM);381 return AVERROR(ENOMEM);
379 382
@@ -468,6 +471,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 88 unmodified lines
468 471
469 av_freep(&uspp->non_b_qp_table);472 av_freep(&uspp->non_b_qp_table);
470 av_freep(&uspp->outbuf);473 av_freep(&uspp->outbuf);
474 av_packet_free(&uspp->pkt);
471 av_frame_free(&uspp->frame);475 av_frame_free(&uspp->frame);
472}476}
473 477

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