[FFmpeg-devel] [PATCH 2/2] ffmpeg: use AV_BUFFERSRC_FLAG_PUSH.
Michael Niedermayer
michaelni at gmx.at
Tue Aug 21 02:07:14 CEST 2012
On Sun, Aug 19, 2012 at 06:35:59PM +0200, Nicolas George wrote:
> It reduces the lifespan of buffers in filter graphs,
> and therefore the memory consumption.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> ffmpeg.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
>
> It fixes the accumulation problem right now. The frames are still being
> processed for nothing, but it will require a little more work, and that is
> part of it.
>
> Also, I wanted to propose it for some time, before noticing the accumulation
> problem.
>
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index bace20c..ec40237 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -193,7 +193,8 @@ static void sub2video_push_ref(InputStream *ist, int64_t pts)
> av_buffersrc_add_ref(ist->filters[i]->filter,
> avfilter_ref_buffer(ref, ~0),
> AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT |
> - AV_BUFFERSRC_FLAG_NO_COPY);
> + AV_BUFFERSRC_FLAG_NO_COPY |
> + AV_BUFFERSRC_FLAG_PUSH);
> }
>
> static void sub2video_update(InputStream *ist, AVSubtitle *sub, int64_t pts)
> @@ -1509,7 +1510,8 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
> decoded_frame_tb,
> (AVRational){1, ist->st->codec->sample_rate});
> for (i = 0; i < ist->nb_filters; i++)
> - av_buffersrc_add_frame(ist->filters[i]->filter, decoded_frame, 0);
> + av_buffersrc_add_frame(ist->filters[i]->filter, decoded_frame,
> + AV_BUFFERSRC_FLAG_PUSH);
>
> decoded_frame->pts = AV_NOPTS_VALUE;
>
> @@ -1620,9 +1622,10 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
> buf->refcount++;
> av_buffersrc_add_ref(ist->filters[i]->filter, fb,
> AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT |
> - AV_BUFFERSRC_FLAG_NO_COPY);
> + AV_BUFFERSRC_FLAG_NO_COPY |
> + AV_BUFFERSRC_FLAG_PUSH);
> } else
> - if(av_buffersrc_add_frame(ist->filters[i]->filter, decoded_frame, 0)<0) {
> + if(av_buffersrc_add_frame(ist->filters[i]->filter, decoded_frame, AV_BUFFERSRC_FLAG_PUSH)<0) {
> av_log(NULL, AV_LOG_FATAL, "Failed to inject frame into filter network\n");
> exit_program(1);
> }
Maybe i misunderstand the code but cant this break filters like
overlay ?
i mean if there would be 2 video streams in a file and a overlay
filter combining them. Then demuxing from this file would push frames
up to the overlay filter and if the 2 streams are not interleaved
correctly then the overlay filter would get input with mismatching
timestamps. Before this patch there would be buffering in the source
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120821/082ba913/attachment.asc>
More information about the ffmpeg-devel
mailing list