コード例 #1
0
ファイル: vf_fps.c プロジェクト: DeHackEd/FFmpeg
/* Write a frame to the output */
static int write_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *outlink, int *again)
{
    AVFrame *frame;

    av_assert1(s->frames_count == 2 || (s->status && s->frames_count == 1));

    /* We haven't yet determined the pts of the first frame */
    if (s->next_pts == AV_NOPTS_VALUE) {
        if (s->frames[0]->pts != AV_NOPTS_VALUE) {
            s->next_pts = s->frames[0]->pts;
            av_log(ctx, AV_LOG_VERBOSE, "Set first pts to %"PRId64"\n", s->next_pts);
        } else {
            av_log(ctx, AV_LOG_WARNING, "Discarding initial frame(s) with no "
                   "timestamp.\n");
            frame = shift_frame(ctx, s);
            av_frame_free(&frame);
            *again = 1;
            return 0;
        }
    }

    /* There are two conditions where we want to drop a frame:
     * - If we have two buffered frames and the second frame is acceptable
     *   as the next output frame, then drop the first buffered frame.
     * - If we have status (EOF) set, drop frames when we hit the
     *   status timestamp. */
    if ((s->frames_count == 2 && s->frames[1]->pts <= s->next_pts) ||
        (s->status            && s->status_pts     <= s->next_pts)) {

        frame = shift_frame(ctx, s);
        av_frame_free(&frame);
        *again = 1;
        return 0;

    /* Output a copy of the first buffered frame */
    } else {
        frame = av_frame_clone(s->frames[0]);
        if (!frame)
            return AVERROR(ENOMEM);
        // Make sure Closed Captions will not be duplicated
        av_frame_remove_side_data(s->frames[0], AV_FRAME_DATA_A53_CC);
        frame->pts = s->next_pts++;

        av_log(ctx, AV_LOG_DEBUG, "Writing frame with pts %"PRId64" to pts %"PRId64"\n",
               s->frames[0]->pts, frame->pts);
        s->cur_frame_out++;

        return ff_filter_frame(outlink, frame);
    }
}
コード例 #2
0
ファイル: vf_fps.c プロジェクト: DeHackEd/FFmpeg
static av_cold void uninit(AVFilterContext *ctx)
{
    FPSContext *s = ctx->priv;

    AVFrame *frame;

    while (s->frames_count > 0) {
        frame = shift_frame(ctx, s);
        av_frame_free(&frame);
    }

    av_log(ctx, AV_LOG_VERBOSE, "%d frames in, %d frames out; %d frames dropped, "
           "%d frames duplicated.\n", s->frames_in, s->frames_out, s->drop, s->dup);
}
コード例 #3
0
ファイル: snake.cpp プロジェクト: idmit/snakes
/**
 *  Initiates snake instance from json config
 */
Snake::Snake(std::string json_file_path) {
  std::ifstream json_file(json_file_path);
  std::string json_string((std::istreambuf_iterator<char>(json_file)),
                          std::istreambuf_iterator<char>());
  std::string err_text;

  auto json = json11::Json::parse(json_string, err_text);

  std::string vid_path = json["vid_path"].string_value();

  tension     = json["tension"].number_value();
  stiffness   = json["stiffness"].number_value();
  atom        = json["atom"].number_value();
  closed      = json["closed"].bool_value();
  implicit    = json["implicit"].int_value();
  line_weight = json["line_weight"].number_value();
  edge_weight = json["edge_weight"].number_value();
  term_weight = json["term_weight"].number_value();
  tick        = json["tick"].number_value();
  fixed       = json["fixed"].bool_value();
  threshold   = json["threshold"].number_value();

  vid = cv::VideoCapture(vid_path);

  if (!vid.isOpened()) {
    std::cout << "Could not open or find the video specified in config.\n";
    std::exit(0);
  }

  img = cv::Mat(vid.get(CV_CAP_PROP_FRAME_HEIGHT),
                vid.get(CV_CAP_PROP_FRAME_WIDTH), vid.get(CV_CAP_PROP_FORMAT));

  raw_img_size = img.total() * 4;
  raw_img = std::vector<uchar>(raw_img_size);

  if (!shift_frame(true)) {
    std::cout << "Could not read the frame.\n";
    std::exit(0);
  }
}
コード例 #4
0
bool BlastEffect::behavior(float time)
{
	if(!shift_frame(time)) 
		return false;
	return true;
}