00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #include "avcodec.h"
00025
00026 void 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
00044 AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame,
00045 int perms)
00046 {
00047 AVFilterBufferRef *picref =
00048 avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize, perms,
00049 frame->width, frame->height,
00050 frame->format);
00051 if (!picref)
00052 return NULL;
00053 avfilter_copy_frame_props(picref, frame);
00054 return picref;
00055 }
00056
00057 int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
00058 const AVFilterBufferRef *picref)
00059 {
00060 if (!picref || !picref->video || !frame)
00061 return AVERROR(EINVAL);
00062
00063 memcpy(frame->data, picref->data, sizeof(frame->data));
00064 memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
00065 frame->pkt_pos = picref->pos;
00066 frame->interlaced_frame = picref->video->interlaced;
00067 frame->top_field_first = picref->video->top_field_first;
00068 frame->key_frame = picref->video->key_frame;
00069 frame->pict_type = picref->video->pict_type;
00070 frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
00071
00072 return 0;
00073 }