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