Generated by Cython 0.15.1 on Tue Jan 31 14:40:28 2012

Raw output: extract.cpp

 1: import numpy
  /* "vision/ffmpeg/extract.pyx":1
 * import numpy             # <<<<<<<<<<<<<<
 * import Image
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__numpy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vision/ffmpeg/extract.pyx":1
 * import numpy             # <<<<<<<<<<<<<<
 * import Image
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 2: import Image
  /* "vision/ffmpeg/extract.pyx":2
 * import numpy
 * import Image             # <<<<<<<<<<<<<<
 * 
 * cimport numpy
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__Image), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Image, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 3: 
 4: cimport numpy
 5: 
 6: cdef extern from "stdlib.h":
 7:     ctypedef unsigned long size_t
 8:     void free(void *ptr)
 9:     void *malloc(size_t size)
 10: 
 11: cdef extern from "_extract.h":
 12:     cdef struct video_stream:
 13:         void *format_context
 14:         void *codec_context
 15:         void *frame_reg
 16:         void *frame_rgb
 17:         void *buffer
 18:         int video_stream
 19:         int width
 20:         int height
 21: 
 22:     int extract_video(char *filename, video_stream *output)
 23:     int read_frame(video_stream *stream, unsigned char **output)
 24:     void cleanup_extraction(video_stream *stream)
 25: 
 26: cdef class extract(object):
 27:     """
 28:     Given a filename, extracts the video into frames. Use as an iterator:
 29: 
 30:     >>> for id, frame in enumerate(ffmpeg.extract("filename.mpg")):
 31:     ...     frame.save("frame{0}.jpg".format(id))
 32:     """
 33: 
 34:     cdef video_stream *vs
 35:     cdef int ready
 36: 
 37:     def __init__(self, filename):
/* "vision/ffmpeg/extract.pyx":37
 *     cdef int ready
 * 
 *     def __init__(self, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Builds the frame iterator. Filename must point to a valid video file.
 */

static int __pyx_pf_6vision_6ffmpeg_7extract_7extract___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6vision_6ffmpeg_7extract_7extract___init__[] = "\n        Builds the frame iterator. Filename must point to a valid video file. \n        Almost every common video codec is supported.\n        ";
struct wrapperbase __pyx_wrapperbase_6vision_6ffmpeg_7extract_7extract___init__;
static int __pyx_pf_6vision_6ffmpeg_7extract_7extract___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_v_code;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,0};
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__");
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_filename = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("vision.ffmpeg.extract.extract.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
 38:         """
 39:         Builds the frame iterator. Filename must point to a valid video file.
 40:         Almost every common video codec is supported.
 41:         """
 42:         self.ready = 0
  /* "vision/ffmpeg/extract.pyx":42
 *         Almost every common video codec is supported.
 *         """
 *         self.ready = 0             # <<<<<<<<<<<<<<
 *         self.vs = <video_stream*> malloc(sizeof(video_stream))
 *         cdef int code = extract_video(filename, self.vs)
 */
  ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->ready = 0;
 43:         self.vs = <video_stream*> malloc(sizeof(video_stream))
  /* "vision/ffmpeg/extract.pyx":43
 *         """
 *         self.ready = 0
 *         self.vs = <video_stream*> malloc(sizeof(video_stream))             # <<<<<<<<<<<<<<
 *         cdef int code = extract_video(filename, self.vs)
 *         if code == 1:
 */
  ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs = ((struct video_stream *)malloc((sizeof(struct video_stream))));
 44:         cdef int code = extract_video(filename, self.vs)
  /* "vision/ffmpeg/extract.pyx":44
 *         self.ready = 0
 *         self.vs = <video_stream*> malloc(sizeof(video_stream))
 *         cdef int code = extract_video(filename, self.vs)             # <<<<<<<<<<<<<<
 *         if code == 1:
 *             raise IOError("File not found or not readable")
 */
  __pyx_t_1 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_code = extract_video(__pyx_t_1, ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs);
 45:         if code == 1:
  /* "vision/ffmpeg/extract.pyx":45
 *         self.vs = <video_stream*> malloc(sizeof(video_stream))
 *         cdef int code = extract_video(filename, self.vs)
 *         if code == 1:             # <<<<<<<<<<<<<<
 *             raise IOError("File not found or not readable")
 *         elif code == 2:
 */
  __pyx_t_2 = (__pyx_v_code == 1);
  if (__pyx_t_2) {
 46:             raise IOError("File not found or not readable")
    /* "vision/ffmpeg/extract.pyx":46
 *         cdef int code = extract_video(filename, self.vs)
 *         if code == 1:
 *             raise IOError("File not found or not readable")             # <<<<<<<<<<<<<<
 *         elif code == 2:
 *             raise FFmpegError("Unable to find video stream in file")
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }

  /* "vision/ffmpeg/extract.pyx":46
 *         cdef int code = extract_video(filename, self.vs)
 *         if code == 1:
 *             raise IOError("File not found or not readable")             # <<<<<<<<<<<<<<
 *         elif code == 2:
 *             raise FFmpegError("Unable to find video stream in file")
 */
  __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_2));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
  PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_s_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));
 47:         elif code == 2:
  /* "vision/ffmpeg/extract.pyx":47
 *         if code == 1:
 *             raise IOError("File not found or not readable")
 *         elif code == 2:             # <<<<<<<<<<<<<<
 *             raise FFmpegError("Unable to find video stream in file")
 *         elif code != 0:
 */
  __pyx_t_2 = (__pyx_v_code == 2);
  if (__pyx_t_2) {
 48:             raise FFmpegError("Unable to find video stream in file")
    /* "vision/ffmpeg/extract.pyx":48
 *             raise IOError("File not found or not readable")
 *         elif code == 2:
 *             raise FFmpegError("Unable to find video stream in file")             # <<<<<<<<<<<<<<
 *         elif code != 0:
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FFmpegError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }

  /* "vision/ffmpeg/extract.pyx":48
 *             raise IOError("File not found or not readable")
 *         elif code == 2:
 *             raise FFmpegError("Unable to find video stream in file")             # <<<<<<<<<<<<<<
 *         elif code != 0:
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))
 */
  __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));
 49:         elif code != 0:
  /* "vision/ffmpeg/extract.pyx":49
 *         elif code == 2:
 *             raise FFmpegError("Unable to find video stream in file")
 *         elif code != 0:             # <<<<<<<<<<<<<<
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))
 *         self.ready = 1
 */
  __pyx_t_2 = (__pyx_v_code != 0);
  if (__pyx_t_2) {
 50:             raise FFmpegError("libvideoextract returned error {0}".format(code))
    /* "vision/ffmpeg/extract.pyx":50
 *             raise FFmpegError("Unable to find video stream in file")
 *         elif code != 0:
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))             # <<<<<<<<<<<<<<
 *         self.ready = 1
 * 
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__FFmpegError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyInt_FromLong(__pyx_v_code); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;
 51:         self.ready = 1
  /* "vision/ffmpeg/extract.pyx":51
 *         elif code != 0:
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))
 *         self.ready = 1             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->ready = 1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("vision.ffmpeg.extract.extract.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 52: 
 53:     def __dealloc__(self):
/* "vision/ffmpeg/extract.pyx":53
 *         self.ready = 1
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         """
 *         Perform memory cleanup from libvideoextract.
 */

static void __pyx_pf_6vision_6ffmpeg_7extract_7extract_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_6vision_6ffmpeg_7extract_7extract_1__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__");
 54:         """
 55:         Perform memory cleanup from libvideoextract.
 56:         """
 57:         if self.ready:
  /* "vision/ffmpeg/extract.pyx":57
 *         Perform memory cleanup from libvideoextract.
 *         """
 *         if self.ready:             # <<<<<<<<<<<<<<
 *             cleanup_extraction(self.vs)
 *         free(self.vs)
 */
  if (((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->ready) {
 58:             cleanup_extraction(self.vs)
    /* "vision/ffmpeg/extract.pyx":58
 *         """
 *         if self.ready:
 *             cleanup_extraction(self.vs)             # <<<<<<<<<<<<<<
 *         free(self.vs)
 * 
 */
    cleanup_extraction(((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs);
    goto __pyx_L5;
  }
  __pyx_L5:;
 59:         free(self.vs)
  /* "vision/ffmpeg/extract.pyx":59
 *         if self.ready:
 *             cleanup_extraction(self.vs)
 *         free(self.vs)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  free(((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs);

  __Pyx_RefNannyFinishContext();
}
 60: 
 61:     def __iter__(self):
/* "vision/ffmpeg/extract.pyx":61
 *         free(self.vs)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the iterator.
 */

static PyObject *__pyx_pf_6vision_6ffmpeg_7extract_7extract_2__iter__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_6vision_6ffmpeg_7extract_7extract_2__iter__[] = "\n        Returns the iterator.\n        ";
struct wrapperbase __pyx_wrapperbase_6vision_6ffmpeg_7extract_7extract_2__iter__;
static PyObject *__pyx_pf_6vision_6ffmpeg_7extract_7extract_2__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__");
 62:         """
 63:         Returns the iterator.
 64:         """
 65:         return self
  /* "vision/ffmpeg/extract.pyx":65
 *         Returns the iterator.
 *         """
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 66: 
 67:     def __next__(self):
/* "vision/ffmpeg/extract.pyx":67
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns a Python Image Library image of the next frame. If no frame
 */

static PyObject *__pyx_pf_6vision_6ffmpeg_7extract_7extract_3__next__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_6vision_6ffmpeg_7extract_7extract_3__next__[] = "\n        Returns a Python Image Library image of the next frame. If no frame \n        exists, then throws a StopIteration exception.\n        ";
struct wrapperbase __pyx_wrapperbase_6vision_6ffmpeg_7extract_7extract_3__next__;
static PyObject *__pyx_pf_6vision_6ffmpeg_7extract_7extract_3__next__(PyObject *__pyx_v_self) {
  unsigned char *__pyx_v_buffer;
  int __pyx_v_code;
  PyArrayObject *__pyx_v_matrix = 0;
  int __pyx_v_i;
  int __pyx_v_j;
  Py_buffer __pyx_bstruct_matrix;
  Py_ssize_t __pyx_bstride_0_matrix = 0;
  Py_ssize_t __pyx_bstride_1_matrix = 0;
  Py_ssize_t __pyx_bstride_2_matrix = 0;
  Py_ssize_t __pyx_bshape_0_matrix = 0;
  Py_ssize_t __pyx_bshape_1_matrix = 0;
  Py_ssize_t __pyx_bshape_2_matrix = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__");
  __pyx_bstruct_matrix.buf = NULL;
 68:         """
 69:         Returns a Python Image Library image of the next frame. If no frame
 70:         exists, then throws a StopIteration exception.
 71:         """
 72:         cdef unsigned char *buffer
 73:         cdef int code = read_frame(self.vs, &buffer)
  /* "vision/ffmpeg/extract.pyx":73
 *         """
 *         cdef unsigned char *buffer
 *         cdef int code = read_frame(self.vs, &buffer)             # <<<<<<<<<<<<<<
 *         if code == -1:
 *             raise StopIteration()
 */
  __pyx_v_code = read_frame(((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs, (&__pyx_v_buffer));
 74:         if code == -1:
  /* "vision/ffmpeg/extract.pyx":74
 *         cdef unsigned char *buffer
 *         cdef int code = read_frame(self.vs, &buffer)
 *         if code == -1:             # <<<<<<<<<<<<<<
 *             raise StopIteration()
 *         elif code != 0:
 */
  __pyx_t_1 = (__pyx_v_code == -1);
  if (__pyx_t_1) {
 75:             raise StopIteration()
    /* "vision/ffmpeg/extract.pyx":75
 *         cdef int code = read_frame(self.vs, &buffer)
 *         if code == -1:
 *             raise StopIteration()             # <<<<<<<<<<<<<<
 *         elif code != 0:
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_StopIteration, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
 76:         elif code != 0:
  /* "vision/ffmpeg/extract.pyx":76
 *         if code == -1:
 *             raise StopIteration()
 *         elif code != 0:             # <<<<<<<<<<<<<<
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))
 *         cdef numpy.ndarray[numpy.uint8_t, ndim=3] matrix
 */
  __pyx_t_1 = (__pyx_v_code != 0);
  if (__pyx_t_1) {
 77:             raise FFmpegError("libvideoextract returned error {0}".format(code))
    /* "vision/ffmpeg/extract.pyx":77
 *             raise StopIteration()
 *         elif code != 0:
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))             # <<<<<<<<<<<<<<
 *         cdef numpy.ndarray[numpy.uint8_t, ndim=3] matrix
 *         matrix = numpy.empty((self.vs.height, self.vs.width, 3),
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__FFmpegError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_code); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;
 78:         cdef numpy.ndarray[numpy.uint8_t, ndim=3] matrix
 79:         matrix = numpy.empty((self.vs.height, self.vs.width, 3),
  /* "vision/ffmpeg/extract.pyx":79
 *             raise FFmpegError("libvideoextract returned error {0}".format(code))
 *         cdef numpy.ndarray[numpy.uint8_t, ndim=3] matrix
 *         matrix = numpy.empty((self.vs.height, self.vs.width, 3),             # <<<<<<<<<<<<<<
 *                              dtype=numpy.uint8)
 *         for i in range(self.vs.width):
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__empty); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs->height); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs->width); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 80:                              dtype=numpy.uint8)
  /* "vision/ffmpeg/extract.pyx":80
 *         cdef numpy.ndarray[numpy.uint8_t, ndim=3] matrix
 *         matrix = numpy.empty((self.vs.height, self.vs.width, 3),
 *                              dtype=numpy.uint8)             # <<<<<<<<<<<<<<
 *         for i in range(self.vs.width):
 *             for j in range(self.vs.height):
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__uint8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_5, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_matrix);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_matrix, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_matrix, (PyObject*)__pyx_v_matrix, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_bstride_0_matrix = __pyx_bstruct_matrix.strides[0]; __pyx_bstride_1_matrix = __pyx_bstruct_matrix.strides[1]; __pyx_bstride_2_matrix = __pyx_bstruct_matrix.strides[2];
    __pyx_bshape_0_matrix = __pyx_bstruct_matrix.shape[0]; __pyx_bshape_1_matrix = __pyx_bstruct_matrix.shape[1]; __pyx_bshape_2_matrix = __pyx_bstruct_matrix.shape[2];
    if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = 0;
  __pyx_v_matrix = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;
 81:         for i in range(self.vs.width):
  /* "vision/ffmpeg/extract.pyx":81
 *         matrix = numpy.empty((self.vs.height, self.vs.width, 3),
 *                              dtype=numpy.uint8)
 *         for i in range(self.vs.width):             # <<<<<<<<<<<<<<
 *             for j in range(self.vs.height):
 *                 matrix[j,i,0] = buffer[j * 3 * self.vs.width + i * 3]
 */
  __pyx_t_8 = ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs->width;
  for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_8; __pyx_t_12+=1) {
    __pyx_v_i = __pyx_t_12;
 82:             for j in range(self.vs.height):
    /* "vision/ffmpeg/extract.pyx":82
 *                              dtype=numpy.uint8)
 *         for i in range(self.vs.width):
 *             for j in range(self.vs.height):             # <<<<<<<<<<<<<<
 *                 matrix[j,i,0] = buffer[j * 3 * self.vs.width + i * 3]
 *                 matrix[j,i,1] = buffer[j * 3 * self.vs.width + i * 3 + 1]
 */
    __pyx_t_13 = ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs->height;
    for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
      __pyx_v_j = __pyx_t_14;
 83:                 matrix[j,i,0] = buffer[j * 3 * self.vs.width + i * 3]
      /* "vision/ffmpeg/extract.pyx":83
 *         for i in range(self.vs.width):
 *             for j in range(self.vs.height):
 *                 matrix[j,i,0] = buffer[j * 3 * self.vs.width + i * 3]             # <<<<<<<<<<<<<<
 *                 matrix[j,i,1] = buffer[j * 3 * self.vs.width + i * 3 + 1]
 *                 matrix[j,i,2] = buffer[j * 3 * self.vs.width + i * 3 + 2]
 */
      __pyx_t_15 = __pyx_v_j;
      __pyx_t_16 = __pyx_v_i;
      __pyx_t_17 = 0;
      if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_0_matrix;
      if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_bshape_1_matrix;
      if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_bshape_2_matrix;
      *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_uint8_t *, __pyx_bstruct_matrix.buf, __pyx_t_15, __pyx_bstride_0_matrix, __pyx_t_16, __pyx_bstride_1_matrix, __pyx_t_17, __pyx_bstride_2_matrix) = (__pyx_v_buffer[(((__pyx_v_j * 3) * ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs->width) + (__pyx_v_i * 3))]);
 84:                 matrix[j,i,1] = buffer[j * 3 * self.vs.width + i * 3 + 1]
      /* "vision/ffmpeg/extract.pyx":84
 *             for j in range(self.vs.height):
 *                 matrix[j,i,0] = buffer[j * 3 * self.vs.width + i * 3]
 *                 matrix[j,i,1] = buffer[j * 3 * self.vs.width + i * 3 + 1]             # <<<<<<<<<<<<<<
 *                 matrix[j,i,2] = buffer[j * 3 * self.vs.width + i * 3 + 2]
 *         return Image.fromarray(matrix)
 */
      __pyx_t_18 = __pyx_v_j;
      __pyx_t_19 = __pyx_v_i;
      __pyx_t_20 = 1;
      if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_bshape_0_matrix;
      if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_1_matrix;
      if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_bshape_2_matrix;
      *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_uint8_t *, __pyx_bstruct_matrix.buf, __pyx_t_18, __pyx_bstride_0_matrix, __pyx_t_19, __pyx_bstride_1_matrix, __pyx_t_20, __pyx_bstride_2_matrix) = (__pyx_v_buffer[((((__pyx_v_j * 3) * ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs->width) + (__pyx_v_i * 3)) + 1)]);
 85:                 matrix[j,i,2] = buffer[j * 3 * self.vs.width + i * 3 + 2]
      /* "vision/ffmpeg/extract.pyx":85
 *                 matrix[j,i,0] = buffer[j * 3 * self.vs.width + i * 3]
 *                 matrix[j,i,1] = buffer[j * 3 * self.vs.width + i * 3 + 1]
 *                 matrix[j,i,2] = buffer[j * 3 * self.vs.width + i * 3 + 2]             # <<<<<<<<<<<<<<
 *         return Image.fromarray(matrix)
 * 
 */
      __pyx_t_21 = __pyx_v_j;
      __pyx_t_22 = __pyx_v_i;
      __pyx_t_23 = 2;
      if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_bshape_0_matrix;
      if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_bshape_1_matrix;
      if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_bshape_2_matrix;
      *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_uint8_t *, __pyx_bstruct_matrix.buf, __pyx_t_21, __pyx_bstride_0_matrix, __pyx_t_22, __pyx_bstride_1_matrix, __pyx_t_23, __pyx_bstride_2_matrix) = (__pyx_v_buffer[((((__pyx_v_j * 3) * ((struct __pyx_obj_6vision_6ffmpeg_7extract_extract *)__pyx_v_self)->vs->width) + (__pyx_v_i * 3)) + 2)]);
    }
  }
 86:         return Image.fromarray(matrix)
  /* "vision/ffmpeg/extract.pyx":86
 *                 matrix[j,i,1] = buffer[j * 3 * self.vs.width + i * 3 + 1]
 *                 matrix[j,i,2] = buffer[j * 3 * self.vs.width + i * 3 + 2]
 *         return Image.fromarray(matrix)             # <<<<<<<<<<<<<<
 * 
 * class FFmpegError(RuntimeError):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__Image); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__fromarray); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __Pyx_INCREF(((PyObject *)__pyx_v_matrix));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_matrix));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_matrix));
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_matrix);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("vision.ffmpeg.extract.extract.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_matrix);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_matrix);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 87: 
 88: class FFmpegError(RuntimeError):
  /* "vision/ffmpeg/extract.pyx":88
 *         return Image.fromarray(matrix)
 * 
 * class FFmpegError(RuntimeError):             # <<<<<<<<<<<<<<
 *     """
 *     An error caused by the FFmpeg library.
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "vision/ffmpeg/extract.pyx":88
 *         return Image.fromarray(matrix)
 * 
 * class FFmpegError(RuntimeError):             # <<<<<<<<<<<<<<
 *     """
 *     An error caused by the FFmpeg library.
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_builtin_RuntimeError);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_RuntimeError);
  __Pyx_GIVEREF(__pyx_builtin_RuntimeError);
  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_19)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__FFmpegError, __pyx_n_s_18); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__FFmpegError, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 89:     """
 90:     An error caused by the FFmpeg library.
 91:     """
 92:     def __init__(self, message):
/* "vision/ffmpeg/extract.pyx":92
 *     An error caused by the FFmpeg library.
 *     """
 *     def __init__(self, message):             # <<<<<<<<<<<<<<
 *         RuntimeError.__init__(self, message)
 */

static PyObject *__pyx_pf_6vision_6ffmpeg_7extract_11FFmpegError___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6vision_6ffmpeg_7extract_11FFmpegError___init__[] = "FFmpegError.__init__(self, message)";
static PyMethodDef __pyx_mdef_6vision_6ffmpeg_7extract_11FFmpegError___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_6vision_6ffmpeg_7extract_11FFmpegError___init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6vision_6ffmpeg_7extract_11FFmpegError___init__)};
static PyObject *__pyx_pf_6vision_6ffmpeg_7extract_11FFmpegError___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_r = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__message,0};
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__");
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__message);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_message = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("vision.ffmpeg.extract.FFmpegError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "vision/ffmpeg/extract.pyx":92
 *     An error caused by the FFmpeg library.
 *     """
 *     def __init__(self, message):             # <<<<<<<<<<<<<<
 *         RuntimeError.__init__(self, message)
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_6vision_6ffmpeg_7extract_11FFmpegError___init__, NULL, __pyx_n_s_18); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 93:         RuntimeError.__init__(self, message)
  /* "vision/ffmpeg/extract.pyx":93
 *     """
 *     def __init__(self, message):
 *         RuntimeError.__init__(self, message)             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_builtin_RuntimeError, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __Pyx_INCREF(__pyx_v_message);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_message);
  __Pyx_GIVEREF(__pyx_v_message);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("vision.ffmpeg.extract.FFmpegError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}