Skip to content
Snippets Groups Projects
cmdutils.c 34 KiB
Newer Older
  • Learn to ignore specific revisions
  • 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;
    
    #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;
    }