static void prepare (GeglOperation *operation) { /* TODO: move input format detection code here */ gegl_operation_set_format (operation, "output", babl_format ("RGBA float")); }
static void prepare (GeglOperation *operation) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); Priv *p= (Priv*)o->chant_data; if (p == NULL) init (o); p = (Priv*)o->chant_data; gegl_operation_set_format (operation, "output", babl_format_new ( babl_model ("R'G'B'"), babl_type ("u8"), babl_component ("B'"), babl_component ("G'"), babl_component ("R'"), NULL)); p->w = o->width; p->h = o->height; if (!p->vd) { p->vd = g_malloc0 (sizeof (v4ldevice)); if (v4lopen (o->path, p->vd)) return; p->active = 1; if (v4lmmap (p->vd)) return; v4lsetdefaultnorm (p->vd, VIDEO_MODE_PAL); v4lgetcapability (p->vd); if (!(p->vd->capability.type & VID_TYPE_CAPTURE)) { g_warning ( "video_init: This device seems not to support video capturing.\n"); return; } } if (p->w != p->w_stored || p->h != p->h_stored) { if (p->w > p->vd->capability.maxwidth || p->h > p->vd->capability.maxheight) { p->w = p->vd->capability.maxwidth; p->h = p->vd->capability.maxheight; o->width = p->w; o->height = p->h; g_warning ( "capturing size is set to %dx%d.\n", p->w, p->h); } else if (p->w < p->vd->capability.minwidth || p->h < p->vd->capability.minheight) { p->w = p->vd->capability.minwidth; p->h = p->vd->capability.minheight; o->width = p->w; o->height = p->h; g_warning ( "capturing size is set to %dx%d.\n", p->w, p->h); } p->w_stored = p->w; p->h_stored = p->h; /* FIXME: try other palettes as well, do some profiling on the spca * based cameras to see what is the ideal format wrt performance */ if (!v4lsetpalette (p->vd, VIDEO_PALETTE_RGB24)) { p->decode=0; } else if (!v4lsetpalette (p->vd, VIDEO_PALETTE_YUV420P)) { p->decode=1; } else { g_warning ( "oops,. no usable v4l format found\n"); return; } v4lgrabinit (p->vd, p->w, p->h); v4lgrabf (p->vd); } }
static void prepare (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); Priv *p = (o->user_data) ? o->user_data : g_new0 (Priv, 1); GError *error = NULL; GFile *file = NULL; guchar *buffer; gsize read; g_assert (p != NULL); if (p->file != NULL && (o->uri || o->path)) { if (o->uri && strlen (o->uri) > 0) file = g_file_new_for_uri (o->uri); else if (o->path && strlen (o->path) > 0) file = g_file_new_for_path (o->path); if (file != NULL) { if (!g_file_equal (p->file, file)) cleanup (operation); g_object_unref (file); } } o->user_data = (void*) p; if (p->config == NULL) { p->stream = gegl_gio_open_input_stream (o->uri, o->path, &p->file, &error); if (p->stream == NULL) { g_warning (error->message); g_error_free (error); cleanup (operation); return; } p->config = g_try_new (WebPDecoderConfig, 1); p->decoder = WebPINewDecoder (&p->config->output); g_assert (p->config != NULL); if (!WebPInitDecoderConfig (p->config)) { g_warning ("could not initialise WebP decoder configuration"); cleanup (operation); return; } read = read_from_stream (p->stream, &buffer, IO_BUFFER_SIZE); if (WebPGetFeatures (buffer, read, &p->config->input) != VP8_STATUS_OK) { g_warning ("failed reading WebP image file"); cleanup (operation); g_free (buffer); return; } if (!query_webp (operation)) { g_warning ("could not query WebP image file"); cleanup (operation); g_free (buffer); return; } WebPIAppend (p->decoder, buffer, read); g_free (buffer); } gegl_operation_set_format (operation, "output", p->format); }
static void gegl_color_op_prepare (GeglOperation *operation) { gegl_operation_set_format (operation, "output", babl_format ("RGBA float")); }
static void prepare (GeglOperation *operation) { gegl_operation_set_format (operation, "input", babl_format ("YA float")); gegl_operation_set_format (operation, "aux", babl_format ("Y float")); gegl_operation_set_format (operation, "output", babl_format ("YA float")); }
static void gegl_operation_temporal_prepare (GeglOperation *operation) { gegl_operation_set_format (operation, "output", babl_format ("RGB u8")); gegl_operation_set_format (operation, "input", babl_format ("RGB u8")); }
static void prepare (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); Priv *p = (Priv*)o->user_data; if (p == NULL) init (o); p = (Priv*)o->user_data; g_assert (o->user_data != NULL); gegl_operation_set_format (operation, "output", babl_format ("R'G'B' u8")); if (!p->loadedfilename || strcmp (p->loadedfilename, o->path) || p->prevframe > o->frame /* a bit heavy handed, but improves consistency */ ) { gint i; gint err; ff_cleanup (o); err = avformat_open_input(&p->video_fcontext, o->path, NULL, 0); if (err < 0) { print_error (o->path, err); } err = avformat_find_stream_info (p->video_fcontext, NULL); if (err < 0) { g_warning ("ff-load: error finding stream info for %s", o->path); return; } err = avformat_open_input(&p->audio_fcontext, o->path, NULL, 0); if (err < 0) { print_error (o->path, err); } err = avformat_find_stream_info (p->audio_fcontext, NULL); if (err < 0) { g_warning ("ff-load: error finding stream info for %s", o->path); return; } for (i = 0; i< p->video_fcontext->nb_streams; i++) { AVCodecContext *c = p->video_fcontext->streams[i]->codec; if (c->codec_type == AVMEDIA_TYPE_VIDEO) { p->video_stream = p->video_fcontext->streams[i]; p->video_index = i; } if (c->codec_type == AVMEDIA_TYPE_AUDIO) { p->audio_stream = p->audio_fcontext->streams[i]; p->audio_index = i; } } p->video_codec = avcodec_find_decoder (p->video_stream->codec->codec_id); if (p->audio_stream) { p->audio_codec = avcodec_find_decoder (p->audio_stream->codec->codec_id); if (p->audio_codec == NULL) g_warning ("audio codec not found"); else if (avcodec_open2 (p->audio_stream->codec, p->audio_codec, NULL) < 0) { g_warning ("error opening codec %s", p->audio_stream->codec->codec->name); } else { o->audio_sample_rate = p->audio_stream->codec->sample_rate; o->audio_channels = MIN(p->audio_stream->codec->channels, GEGL_MAX_AUDIO_CHANNELS); } } p->video_stream->codec->err_recognition = AV_EF_IGNORE_ERR | AV_EF_BITSTREAM | AV_EF_BUFFER; p->video_stream->codec->workaround_bugs = FF_BUG_AUTODETECT; if (p->video_codec == NULL) g_warning ("video codec not found"); if (avcodec_open2 (p->video_stream->codec, p->video_codec, NULL) < 0) { g_warning ("error opening codec %s", p->video_stream->codec->codec->name); return; } p->width = p->video_stream->codec->width; p->height = p->video_stream->codec->height; p->lavc_frame = av_frame_alloc (); if (o->video_codec) g_free (o->video_codec); if (p->video_codec->name) o->video_codec = g_strdup (p->video_codec->name); else o->video_codec = g_strdup (""); if (o->audio_codec) g_free (o->audio_codec); if (p->audio_codec && p->audio_codec->name) o->audio_codec = g_strdup (p->audio_codec->name); else o->audio_codec = g_strdup (""); if (p->loadedfilename) g_free (p->loadedfilename); p->loadedfilename = g_strdup (o->path); p->prevframe = -1; p->a_prevframe = -1; o->frames = p->video_stream->nb_frames; o->frame_rate = av_q2d (av_guess_frame_rate (p->video_fcontext, p->video_stream, NULL)); if (!o->frames) { /* this is a guesstimate of frame-count */ o->frames = p->video_fcontext->duration * o->frame_rate / AV_TIME_BASE; /* make second guess for things like luxo */ if (o->frames < 1) o->frames = 23; } #if 0 { int m ,h; int s = o->frames / o->frame_rate; m = s / 60; s -= m * 60; h = m / 60; m -= h * 60; fprintf (stdout, "duration: %02i:%02i:%02i\n", h, m, s); } #endif p->codec_delay = p->video_stream->codec->delay; if (!strcmp (o->video_codec, "mpeg1video")) p->codec_delay = 1; else if (!strcmp (o->video_codec, "h264")) { if (strstr (p->video_fcontext->filename, ".mp4") || strstr (p->video_fcontext->filename, ".MP4")) /* XXX: too hacky, isn't there an avformat thing to use?, or perhaps we can measure this when decoding the first frame. */ p->codec_delay = 3; else p->codec_delay = 0; } clear_audio_track (o); } }
static void prepare (GeglOperation *operation) { gegl_operation_set_format (operation, "output", babl_format ("R'G'B'A float")); }
static void reinhard05_prepare (GeglOperation *operation) { gegl_operation_set_format (operation, "input", babl_format (OUTPUT_FORMAT)); gegl_operation_set_format (operation, "output", babl_format (OUTPUT_FORMAT)); }
static void prepare (GeglOperation *operation) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); Priv *p = (Priv*)o->chant_data; if (p == NULL) init (o); p = (Priv*)o->chant_data; g_assert (o->chant_data != NULL); gegl_operation_set_format (operation, "output", babl_format ("R'G'B'A u8")); if (!p->loadedfilename || strcmp (p->loadedfilename, o->path)) { gint i; gint err; ff_cleanup (o); err = av_open_input_file (&p->ic, o->path, NULL, 0, NULL); if (err < 0) { print_error (o->path, err); } err = av_find_stream_info (p->ic); if (err < 0) { g_warning ("ff-load: error finding stream info for %s", o->path); return; } for (i = 0; i< p->ic->nb_streams; i++) { AVCodecContext *c = p->ic->streams[i]->codec; #if LIBAVFORMAT_VERSION_MAJOR >= 53 if (c->codec_type == AVMEDIA_TYPE_VIDEO) #else if (c->codec_type == CODEC_TYPE_VIDEO) #endif { p->video_st = p->ic->streams[i]; p->video_stream = i; } } p->enc = p->video_st->codec; p->codec = avcodec_find_decoder (p->enc->codec_id); /* p->enc->error_resilience = 2; */ p->enc->error_concealment = 3; p->enc->workaround_bugs = FF_BUG_AUTODETECT; if (p->codec == NULL) { g_warning ("codec not found"); } if (p->codec->capabilities & CODEC_CAP_TRUNCATED) p->enc->flags |= CODEC_FLAG_TRUNCATED; if (avcodec_open (p->enc, p->codec) < 0) { g_warning ("error opening codec %s", p->enc->codec->name); return; } p->width = p->enc->width; p->height = p->enc->height; p->frames = 10000000; p->lavc_frame = avcodec_alloc_frame (); if (p->fourcc) g_free (p->fourcc); p->fourcc = g_strdup ("none"); p->fourcc[0] = (p->enc->codec_tag) & 0xff; p->fourcc[1] = (p->enc->codec_tag >> 8) & 0xff; p->fourcc[2] = (p->enc->codec_tag >> 16) & 0xff; p->fourcc[3] = (p->enc->codec_tag >> 24) & 0xff; if (p->codec_name) g_free (p->codec_name); if (p->codec->name) { p->codec_name = g_strdup (p->codec->name); } else { p->codec_name = g_strdup (""); } if (p->loadedfilename) g_free (p->loadedfilename); p->loadedfilename = g_strdup (o->path); p->prevframe = -1; p->coded_bytes = 0; p->coded_buf = NULL; }
static void prepare (GeglOperation *operation) { /* set the babl format this operation prefers to work on */ gegl_operation_set_format (operation, "input", babl_format ("RGBA float")); gegl_operation_set_format (operation, "output", babl_format ("YA float")); }
static void prepare (GeglOperation *operation) { const Babl *format = gegl_babl_rgba_linear_float (); gegl_operation_set_format (operation, "input", format); gegl_operation_set_format (operation, "output", format); }
static void gimp_operation_histogram_sink_prepare (GeglOperation *operation) { /* XXX gegl_operation_set_format (operation, "input", babl_format ("Y u8")); */ gegl_operation_set_format (operation, "aux", babl_format ("Y float")); }
static void bilateral_prepare (GeglOperation *operation) { gegl_operation_set_format (operation, "input", babl_format ("RGBA float")); gegl_operation_set_format (operation, "output", babl_format ("RGBA float")); }
static void prepare (GeglOperation *operation) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); gegl_operation_set_format (operation, "output", babl_format(gdk_pixbuf_get_has_alpha(o->pixbuf)?"R'G'B'A u8":"R'G'B' u8")); }
static void prepare (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); const Babl *output_format = (o->linear) ? babl_format ("Y float") : babl_format ("Y' float"); switch (o->component) { case GEGL_COMPONENT_EXTRACT_ALPHA: { gegl_operation_set_format (operation, "input", babl_format ("YA float")); } break; case GEGL_COMPONENT_EXTRACT_RGB_RED: case GEGL_COMPONENT_EXTRACT_RGB_GREEN: case GEGL_COMPONENT_EXTRACT_RGB_BLUE: { gegl_operation_set_format (operation, "input", babl_format ("R'G'B' float")); } break; case GEGL_COMPONENT_EXTRACT_HUE: case GEGL_COMPONENT_EXTRACT_HSV_SATURATION: case GEGL_COMPONENT_EXTRACT_HSV_VALUE: { gegl_operation_set_format (operation, "input", babl_format ("HSV float")); } break; case GEGL_COMPONENT_EXTRACT_HSL_LIGHTNESS: case GEGL_COMPONENT_EXTRACT_HSL_SATURATION: { gegl_operation_set_format (operation, "input", babl_format ("HSL float")); } break; case GEGL_COMPONENT_EXTRACT_CMYK_CYAN: case GEGL_COMPONENT_EXTRACT_CMYK_MAGENTA: case GEGL_COMPONENT_EXTRACT_CMYK_YELLOW: case GEGL_COMPONENT_EXTRACT_CMYK_KEY: { gegl_operation_set_format (operation, "input", babl_format ("CMYK float")); } break; case GEGL_COMPONENT_EXTRACT_YCBCR_Y: case GEGL_COMPONENT_EXTRACT_YCBCR_CB: case GEGL_COMPONENT_EXTRACT_YCBCR_CR: { gegl_operation_set_format (operation, "input", babl_format ("Y'CbCr float")); } break; case GEGL_COMPONENT_EXTRACT_LAB_L: case GEGL_COMPONENT_EXTRACT_LAB_A: case GEGL_COMPONENT_EXTRACT_LAB_B: { gegl_operation_set_format (operation, "input", babl_format ("CIE Lab float")); } break; } gegl_operation_set_format (operation, "output", output_format); }
static void prepare (GeglOperation *operation) { Babl *format = babl_format ("Y'CbCrA float"); gegl_operation_set_format (operation, "input", format); gegl_operation_set_format (operation, "output", format); }
static void prepare (GeglOperation *operation) { gegl_operation_set_format (operation, "input", babl_format ("RGBA u16")); gegl_operation_set_format (operation, "output", babl_format ("RGBA u16")); }
static void prepare (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); gegl_operation_set_format (operation, "output", babl_format(gdk_pixbuf_get_has_alpha(GDK_PIXBUF(o->pixbuf))?"R'G'B'A u8":"R'G'B' u8")); }