Hello to all, and sorry for my bad English. I hope you understand me
(I'm brazilian)

I'm writting an aplication which get frames from a webcam (v4l2) and
store them into a size-fixed circular list (c++ vector) in memory.

It works with a FIFO behavior: the oldest frame is replaced by newest
frame grabbed from webcam.

If my array size is less than 32, everything works fine, but when is
greater then 32 (I need keep on memory hundreds of frames), the frames
content repeats every 32 frames.  Always 32. I can change the
framerate or the size of array. But the number is always 32.

Its an multithread OO textbased application.

Firstly each frame on vector is allocated () and the device is
initialized. So now I can start the capture.

The mail loop of the program is:

get the next free (non-locked) frame (usually the next).
Read a frame from webcam and put into it. source->put(frames[currentPosition])

When receive an external event, locks the last n (n < sizeof vector)
valid frames and encode (by now save as separeted files) them.

The class which capture the frames is called Source and the capture method is:

/*
 frame is a Frame*, object having a AVFrame*
 put needs a prealocated frame and put the "image" inside it.
 frame->getFrame() returns this AVFrame*
*/
void Source::put(Frame *frame)
{
  int frameFinished;

  while (av_read_frame(formatCtx,&packet)>=0) {

    if (packet.stream_index == videoStream) {
      // Decode the video
      avcodec_decode_video2(codecCtx,frame->getFrame(),&frameFinished,&packet);

      av_free_packet(&packet);

      if (frameFinished) {
        break;
      }
    }
  }
}

When I take a look the array (thx gdb!), I can see each frame has a
different memory address, as expected: AVFrame* in position 0 is
different to AVFrame* in position 32, but the data field
(AVFrame.data) is the same in both (and in 1-33, 2-34..., 32-64...).
If I save these frames into files, they will have the same data
(tested via md5).

So I need to know if there is in ffmpeg any "maximum number" of
AVFrames allocated in memory.

All the time I use a common AVCodecContext* for all frames.

I'm using the last ffmpeg version from git repo. (I've compiled it
last tuesday).

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

Reply via email to