mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-25 16:52:31 +00:00
avconv: avoid memcpy in vsrc_buffer when possible.
Decoding Sintel.2010.1080p.mkv with 4 threads on an i7 2600K goes from 260s to 244s.
This commit is contained in:
parent
64dca32cdf
commit
04a14d4d25
52
avconv.c
52
avconv.c
@ -50,6 +50,7 @@
|
|||||||
#if CONFIG_AVFILTER
|
#if CONFIG_AVFILTER
|
||||||
# include "libavfilter/avfilter.h"
|
# include "libavfilter/avfilter.h"
|
||||||
# include "libavfilter/avfiltergraph.h"
|
# include "libavfilter/avfiltergraph.h"
|
||||||
|
# include "libavfilter/buffersrc.h"
|
||||||
# include "libavfilter/vsrc_buffer.h"
|
# include "libavfilter/vsrc_buffer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -529,6 +530,13 @@ static void codec_release_buffer(AVCodecContext *s, AVFrame *frame)
|
|||||||
unref_buffer(ist, buf);
|
unref_buffer(ist, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void filter_release_buffer(AVFilterBuffer *fb)
|
||||||
|
{
|
||||||
|
FrameBuffer *buf = fb->priv;
|
||||||
|
av_free(fb);
|
||||||
|
unref_buffer(buf->ist, buf);
|
||||||
|
}
|
||||||
|
|
||||||
#if CONFIG_AVFILTER
|
#if CONFIG_AVFILTER
|
||||||
|
|
||||||
static int configure_video_filters(InputStream *ist, OutputStream *ost)
|
static int configure_video_filters(InputStream *ist, OutputStream *ost)
|
||||||
@ -1915,21 +1923,35 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if CONFIG_AVFILTER
|
#if CONFIG_AVFILTER
|
||||||
if (ost->input_video_filter) {
|
if (ist->st->sample_aspect_ratio.num)
|
||||||
AVRational sar;
|
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
|
||||||
if (ist->st->sample_aspect_ratio.num)
|
if (ist->st->codec->codec->capabilities & CODEC_CAP_DR1) {
|
||||||
sar = ist->st->sample_aspect_ratio;
|
FrameBuffer *buf = decoded_frame->opaque;
|
||||||
else
|
AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays(
|
||||||
sar = ist->st->codec->sample_aspect_ratio;
|
decoded_frame->data, decoded_frame->linesize,
|
||||||
av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, ist->pts, sar);
|
AV_PERM_READ | AV_PERM_PRESERVE,
|
||||||
if (!ist->filtered_frame && !(ist->filtered_frame = avcodec_alloc_frame())) {
|
ist->st->codec->width, ist->st->codec->height,
|
||||||
av_free(buffer_to_free);
|
ist->st->codec->pix_fmt);
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
} else
|
avfilter_copy_frame_props(fb, decoded_frame);
|
||||||
avcodec_get_frame_defaults(ist->filtered_frame);
|
fb->pts = ist->pts;
|
||||||
filtered_frame = ist->filtered_frame;
|
fb->buf->priv = buf;
|
||||||
frame_available = avfilter_poll_frame(ost->output_video_filter->inputs[0]);
|
fb->buf->free = filter_release_buffer;
|
||||||
}
|
|
||||||
|
buf->refcount++;
|
||||||
|
av_buffersrc_buffer(ost->input_video_filter, fb);
|
||||||
|
} else
|
||||||
|
av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame,
|
||||||
|
ist->pts, decoded_frame->sample_aspect_ratio);
|
||||||
|
|
||||||
|
if (!ist->filtered_frame && !(ist->filtered_frame = avcodec_alloc_frame())) {
|
||||||
|
av_free(buffer_to_free);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
} else
|
||||||
|
avcodec_get_frame_defaults(ist->filtered_frame);
|
||||||
|
filtered_frame = ist->filtered_frame;
|
||||||
|
|
||||||
|
frame_available = avfilter_poll_frame(ost->output_video_filter->inputs[0]);
|
||||||
while (frame_available) {
|
while (frame_available) {
|
||||||
AVRational ist_pts_tb;
|
AVRational ist_pts_tb;
|
||||||
if (ost->output_video_filter)
|
if (ost->output_video_filter)
|
||||||
|
Loading…
Reference in New Issue
Block a user