]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/avcodec.c
lavf: minor bump for avformat_queue_attached_pictures()
[ffmpeg] / libavfilter / avcodec.c
index f6e25bdc30556a74ddc9de217efa3ed658c012e6..f452303bb4e4b55dafbc4df330181b14d1473d4e 100644 (file)
@@ -70,14 +70,28 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame
 AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame,
                                                             int perms)
 {
-    AVFilterBufferRef *picref =
+    AVFilterBufferRef *samplesref =
         avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, frame->linesize[0], perms,
                                                   frame->nb_samples, frame->format,
                                                   av_frame_get_channel_layout(frame));
-    if (!picref)
+    if (!samplesref)
         return NULL;
-    avfilter_copy_frame_props(picref, frame);
-    return picref;
+    avfilter_copy_frame_props(samplesref, frame);
+    return samplesref;
+}
+
+AVFilterBufferRef *avfilter_get_buffer_ref_from_frame(enum AVMediaType type,
+                                                      const AVFrame *frame,
+                                                      int perms)
+{
+    switch (type) {
+    case AVMEDIA_TYPE_VIDEO:
+        return avfilter_get_video_buffer_ref_from_frame(frame, perms);
+    case AVMEDIA_TYPE_AUDIO:
+        return avfilter_get_audio_buffer_ref_from_frame(frame, perms);
+    default:
+        return NULL;
+    }
 }
 
 int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
@@ -94,6 +108,7 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
 
     dst->pts     = src->pts;
     dst->format  = src->format;
+    av_frame_set_pkt_pos(dst, src->pos);
 
     switch (src->type) {
     case AVMEDIA_TYPE_VIDEO:
@@ -119,10 +134,9 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
                    planes * sizeof(dst->extended_data));
         } else
             dst->extended_data = dst->data;
-
-        dst->sample_rate         = src->audio->sample_rate;
-        dst->channel_layout      = src->audio->channel_layout;
         dst->nb_samples          = src->audio->nb_samples;
+        av_frame_set_sample_rate   (dst, src->audio->sample_rate);
+        av_frame_set_channel_layout(dst, src->audio->channel_layout);
         break;
     default:
         return AVERROR(EINVAL);
@@ -131,51 +145,22 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
     return 0;
 }
 
+#ifdef FF_API_FILL_FRAME
 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);
 }
+#endif