[Pyrex] when pyrex gets tough

Stefan Behnel stefan_ml at behnel.de
Sun Sep 2 16:42:20 CEST 2007


David McNab wrote:
> I'm in the process of generating a python wrapper for the 'yuv4mpeg' API
> in mjpegtools.
> 
> All was going smoothly until I hit on the framerate ratios:
> 
>         typedef struct _y4m_ratio {
>           int n;  /* numerator   */
>           int d;  /* denominator */
>         } y4m_ratio_t;
> 
> That's no problem as it stands. What makes it tricky is:
> 
>         1. several functions require a pointer to a y4m_ratio_t, and
>         
>         2. the header file has numerous externs to canned structs, such
>         as:
>         
>                 /* 24000/1001 film (in NTSC)  */
>                 extern const y4m_ratio_t y4m_fps_NTSC_FILM;
>                 
>                 /* 24fps film                 */
>                 extern const y4m_ratio_t y4m_fps_FILM;
>                 
>                 /* 25fps PAL                  */
>                 extern const y4m_ratio_t y4m_fps_PAL;
>         
> For a python wrapper, it's reasonable to require:
> 
>         * a quick/easy way to pass in ratios as tuples, or create
>           and use a ratio object
>         * easy way to access the externed 'canned ratios' above
>         * easy way to access the ratios as tuples

Any reason you're requiring tuple access and not using a wrapper class?

Stefan



More information about the Pyrex mailing list