It seems, the memory leak is in the part, parsing the System Information of the 
MPEG TS.

If I change input format from "mpegts" to "mpegtsraw" and add compute_pcr, the 
leak disappears.

Again, this is the minimum case, causing failures.
 
AVFormatContext *input;
AVPacket pkt;
AVFormatParameters ap;
int bio_buffer_size=188;
 
input=av_alloc_format_context();
input->iformat=av_find_input_format("mpegts");

bio_buffer=(unsigned char *)malloc(bio_buffer_size);
input->pb=av_alloc_put_byte(bio_buffer,bio_buffer_size,
            0,this,linsys_read,NULL,NULL);
input->pb->is_streamed=1;
input->pb->max_packet_size=188;
input->flags|=AVFMT_NOFILE|AVFMT_FLAG_IGNIDX;
input->max_index_size=1024*50;
input->max_picture_buffer=1024*100;
 
memset(&ap, 0, sizeof(ap));
ap.prealloced_context=1;
        
int r=av_open_input_stream(&input,input->pb,"linsys",input->iformat,&ap);
r=av_find_stream_info(input);

while(!is_exiting()){
  av_read_frame(input,&pkt);
 
  av_free_packet(&pkt);
}

 
And this code does not cause any growths in memory consumption. Changed lines 
are marked.

AVFormatContext *input;
AVPacket pkt;
AVFormatParameters ap;
int bio_buffer_size=188;
 
input=av_alloc_format_context();
input->iformat=av_find_input_format("mpegtsraw"); // !! changed

bio_buffer=(unsigned char *)malloc(bio_buffer_size);
input->pb=av_alloc_put_byte(bio_buffer,bio_buffer_size,
            0,this,linsys_read,NULL,NULL);
input->pb->is_streamed=1;
input->pb->max_packet_size=188;
input->flags|=AVFMT_NOFILE|AVFMT_FLAG_IGNIDX;
input->max_index_size=1024*50;
input->max_picture_buffer=1024*100;
 
memset(&ap, 0, sizeof(ap));
ap.prealloced_context=1;
ap.mpeg2ts_compute_pcr=1;  // !! changed

int r=av_open_input_stream(&input,input->pb,"linsys",input->iformat,&ap);
r=av_find_stream_info(input);

while(!is_exiting()){
  av_read_frame(input,&pkt);
 
  av_free_packet(&pkt);
}

I've seen messages about the memory leak in mpegts.c, but they are dated with 
2006, lots of changes since that.


_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to