[FFmpeg-cvslog] lavfi/avcodec: make avfilter_fill_frame_from*() functions use avfilter_copy_buf_props()

Stefano Sabatini git at videolan.org
Tue Jun 19 17:00:58 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Sun Jun 10 18:08:12 2012 +0200| [db142a839520a57e049dd8d6f86bf02807ea9081] | committer: Stefano Sabatini

lavfi/avcodec: make avfilter_fill_frame_from*() functions use avfilter_copy_buf_props()

The code in avfilter_copy_buf_props() is more generic, allow code
factorization.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db142a839520a57e049dd8d6f86bf02807ea9081
---

 libavfilter/avcodec.c |   37 +++----------------------------------
 1 file changed, 3 insertions(+), 34 deletions(-)

diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
index aa98334..ce53ed9 100644
--- a/libavfilter/avcodec.c
+++ b/libavfilter/avcodec.c
@@ -134,48 +134,17 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
 int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
                                               const AVFilterBufferRef *samplesref)
 {
-    if (!samplesref || !samplesref->audio || !frame)
-        return AVERROR(EINVAL);
-
-    memcpy(frame->data, samplesref->data, sizeof(frame->data));
-    memcpy(frame->linesize, samplesref->linesize, sizeof(frame->linesize));
-    av_frame_set_pkt_pos(frame, samplesref->pos);
-    frame->format         = samplesref->format;
-    frame->nb_samples     = samplesref->audio->nb_samples;
-    frame->pts            = samplesref->pts;
-    frame->sample_rate    = samplesref->audio->sample_rate;
-    frame->channel_layout = samplesref->audio->channel_layout;
-
-    return 0;
+    return avfilter_copy_buf_props(frame, samplesref);
 }
 
 int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
                                               const AVFilterBufferRef *picref)
 {
-    if (!picref || !picref->video || !frame)
-        return AVERROR(EINVAL);
-
-    memcpy(frame->data,     picref->data,     sizeof(frame->data));
-    memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
-    av_frame_set_pkt_pos(frame, picref->pos);
-    frame->interlaced_frame = picref->video->interlaced;
-    frame->top_field_first  = picref->video->top_field_first;
-    frame->key_frame        = picref->video->key_frame;
-    frame->pict_type        = picref->video->pict_type;
-    frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
-    frame->width            = picref->video->w;
-    frame->height           = picref->video->h;
-    frame->format           = picref->format;
-    frame->pts              = picref->pts;
-
-    return 0;
+    return avfilter_copy_buf_props(frame, picref);
 }
 
 int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
                                         const AVFilterBufferRef *ref)
 {
-    if (!ref)
-        return AVERROR(EINVAL);
-    return ref->video ? avfilter_fill_frame_from_video_buffer_ref(frame, ref)
-                      : avfilter_fill_frame_from_audio_buffer_ref(frame, ref);
+    return avfilter_copy_buf_props(frame, ref);
 }



More information about the ffmpeg-cvslog mailing list