static gboolean process (GeglOperation *operation, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); Priv *p = (Priv*) o->user_data; if (p->config != NULL) { if (p->decoder != NULL) { if (decode_from_stream (p->stream, p->decoder) < 0) { g_warning ("failed decoding WebP image file"); cleanup (operation); return FALSE; } g_input_stream_close (G_INPUT_STREAM (p->stream), NULL, NULL); g_clear_object (&p->stream); WebPIDelete (p->decoder); p->decoder = NULL; } gegl_buffer_set (output, result, 0, p->format, p->config->output.u.RGBA.rgba, p->config->output.u.RGBA.stride); } return FALSE; }
inline PyObject* decode_cmd_from_stream(hu::InStream& stream) { int code; try { code = deserializeInt(stream); } catch (hu::Error& e) { // FIXME raise EOF if relevant... PyErr_SetString(DummyError, e.getMessage().c_str()); return NULL; } if (_rules.find(code) == _rules.end()) { PyErr_SetString(DummyError, "Unknown command code."); return NULL; } PyObject* args = decode_from_stream(_rules.at(code), stream); if (args == NULL) { return NULL; } PyObject* res = PyTuple_New(2); PyTuple_SET_ITEM(res, 0, PyInt_FromLong(code)); PyTuple_SET_ITEM(res, 1, args); return res; }
inline PyObject* decode_from_buffer(const std::string& enc_rule, const std::string buffer) { hu::StringInStream sis(buffer); return decode_from_stream(enc_rule, sis); }