ncvisual: fix the major memory leak in streaming #241

This commit is contained in:
nick black 2020-01-01 07:18:25 -05:00
parent bc1f9bfb43
commit e05ec51629
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -95,7 +95,6 @@ AVFrame* ncvisual_decode(ncvisual* nc, int* averr){
break; break;
} }
if(unref){ if(unref){
//fprintf(stderr, "stream index %d != %d\n", nc->packet->stream_index, nc->stream_index);
av_packet_unref(nc->packet); av_packet_unref(nc->packet);
} }
if((*averr = av_read_frame(nc->fmtctx, nc->packet)) < 0){ if((*averr = av_read_frame(nc->fmtctx, nc->packet)) < 0){
@ -113,6 +112,7 @@ AVFrame* ncvisual_decode(ncvisual* nc, int* averr){
return ncvisual_decode(nc, averr); return ncvisual_decode(nc, averr);
} }
--nc->packet_outstanding; --nc->packet_outstanding;
av_packet_unref(nc->packet);
*averr = avcodec_receive_frame(nc->codecctx, nc->frame); *averr = avcodec_receive_frame(nc->codecctx, nc->frame);
if(*averr >= 0){ if(*averr >= 0){
have_frame = true; have_frame = true;