00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #include "avcodec.h"
00025
00026 int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
00027 {
00028 dst->pts = src->pts;
00029 dst->pos = src->pkt_pos;
00030 dst->format = src->format;
00031
00032 switch (dst->type) {
00033 case AVMEDIA_TYPE_VIDEO:
00034 dst->video->w = src->width;
00035 dst->video->h = src->height;
00036 dst->video->sample_aspect_ratio = src->sample_aspect_ratio;
00037 dst->video->interlaced = src->interlaced_frame;
00038 dst->video->top_field_first = src->top_field_first;
00039 dst->video->key_frame = src->key_frame;
00040 dst->video->pict_type = src->pict_type;
00041 }
00042
00043 return 0;
00044 }
00045
00046 AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame,
00047 int perms)
00048 {
00049 AVFilterBufferRef *picref =
00050 avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize, perms,
00051 frame->width, frame->height,
00052 frame->format);
00053 if (!picref)
00054 return NULL;
00055 avfilter_copy_frame_props(picref, frame);
00056 return picref;
00057 }
00058
00059 int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
00060 const AVFilterBufferRef *picref)
00061 {
00062 if (!picref || !picref->video || !frame)
00063 return AVERROR(EINVAL);
00064
00065 memcpy(frame->data, picref->data, sizeof(frame->data));
00066 memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
00067 frame->pkt_pos = picref->pos;
00068 frame->interlaced_frame = picref->video->interlaced;
00069 frame->top_field_first = picref->video->top_field_first;
00070 frame->key_frame = picref->video->key_frame;
00071 frame->pict_type = picref->video->pict_type;
00072 frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
00073
00074 return 0;
00075 }