Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
return 0;
}
static void null_end_frame(AVFilterLink *inlink) { }
static int ffsink_query_formats(AVFilterContext *ctx)
{
FFSinkContext *priv = ctx->priv;
enum PixelFormat pix_fmts[] = { priv->pix_fmt, PIX_FMT_NONE };
avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
return 0;
}
AVFilter ffsink = {
.name = "ffsink",
.priv_size = sizeof(FFSinkContext),
.init = ffsink_init,
.query_formats = ffsink_query_formats,
.inputs = (AVFilterPad[]) {{ .name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.end_frame = null_end_frame,
.min_perms = AV_PERM_READ, },
{ .name = NULL }},
.outputs = (AVFilterPad[]) {{ .name = NULL }},
};
int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
AVFilterBufferRef **picref_ptr, AVRational *tb)
{
int ret;
AVFilterBufferRef *picref;
if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
return ret;
if (!(picref = ctx->inputs[0]->cur_buf))
return AVERROR(ENOENT);
*picref_ptr = picref;
ctx->inputs[0]->cur_buf = NULL;
*tb = ctx->inputs[0]->time_base;
memcpy(frame->data, picref->data, sizeof(frame->data));
memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
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->pixel_aspect;
return 1;
}
#endif /* CONFIG_AVFILTER */
void *grow_array(void *array, int elem_size, int *size, int new_size)
{
if (new_size >= INT_MAX / elem_size) {
av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
exit_program(1);
}
if (*size < new_size) {
uint8_t *tmp = av_realloc(array, new_size*elem_size);
if (!tmp) {
av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n");
exit_program(1);
}
memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
*size = new_size;
return tmp;
}
return array;
}