## schroencoder

schroencoder

## Synopsis

                        SchroEncoder;
                        SchroEncoderFrame;
    enum                SchroEncoderFrameStateEnum;
    enum                SchroEncoderPerceptualEnum;
    struct              SchroEncoderSettings;
    enum                SchroQuantiserEngineEnum;
    enum                SchroStateEnum;
    enum                SchroEncoderGOPEnum;
    enum                SchroEncoderRateControlEnum;
                        SchroEncoderSetting;
    int                 (*SchroEngineIterateFunc)           (SchroEncoder *encoder);
    SchroEncoder*       schro_encoder_new                   (void);
    void                schro_encoder_free                  (SchroEncoder *encoder);
    SchroVideoFormat*   schro_encoder_get_video_format      (SchroEncoder *encoder);
    void                schro_encoder_set_video_format      (SchroEncoder *encoder,
                                                             SchroVideoFormat *video_format);
    void                schro_encoder_end_of_stream         (SchroEncoder *encoder);
    void                schro_encoder_push_frame            (SchroEncoder *encoder,
                                                             SchroFrame *frame);
    void                schro_encoder_encode_access_unit_header
                                                            (SchroEncoder *encoder,
                                                             SchroPack *bits);
    void                schro_encoder_encode_parse_info     (SchroPack *bits,
                                                             int parse_code);
    SchroBuffer*        schro_encoder_pull                  (SchroEncoder *encoder,
                                                             int *n_decodable_frames);
    void                schro_encoder_analyse_picture       (SchroEncoderFrame *frame);
    void                schro_encoder_calculate_subband_weights
                                                            (SchroEncoder *encoder,
                                                             double (perceptual_weightdouble) ());
    void                schro_encoder_calculate_test_info   (SchroEncoderFrame *frame);
    void                schro_encoder_choose_quantisers     (SchroEncoderFrame *frame);
    void                schro_encoder_clean_up_transform    (SchroEncoderFrame *frame);
    SchroBuffer*        schro_encoder_encode_auxiliary_data (SchroEncoder *encoder,
                                                             SchroAuxiliaryDataID id,
                                                             void *data,
                                                             int size);
    SchroBuffer*        schro_encoder_encode_end_of_stream  (SchroEncoder *encoder);
    void                schro_encoder_encode_lowdelay_transform_data
                                                            (SchroEncoderFrame *frame);
    void                schro_encoder_encode_picture        (SchroEncoderFrame *frame);
    void                schro_encoder_encode_picture_all    (SchroEncoderFrame *frame);
    void                schro_encoder_encode_picture_header (SchroEncoderFrame *frame);
    void                schro_encoder_encode_subband        (SchroEncoderFrame *frame,
                                                             int component,
                                                             int index);
    void                schro_encoder_encode_subband_noarith
                                                            (SchroEncoderFrame *frame,
                                                             int component,
                                                             int index);
    int                 schro_encoder_engine_backref        (SchroEncoder *encoder);
    int                 schro_encoder_engine_backtest       (SchroEncoder *encoder);
    int                 schro_encoder_engine_intra_only     (SchroEncoder *encoder);
    int                 schro_encoder_engine_lossless       (SchroEncoder *encoder);
    int                 schro_encoder_engine_lowdelay       (SchroEncoder *encoder);
    int                 schro_encoder_engine_test_intra     (SchroEncoder *encoder);
    void                schro_encoder_estimate_entropy      (SchroEncoderFrame *frame);
    void                schro_encoder_frame_analyse         (SchroEncoderFrame *frame);
    void                schro_encoder_frame_downsample      (SchroEncoderFrame *frame);
    void                schro_encoder_frame_insert_buffer   (SchroEncoderFrame *frame,
                                                             SchroBuffer *buffer);
    SchroEncoderFrame*  schro_encoder_frame_new             (SchroEncoder *encoder);
    SchroFrame*         schro_encoder_frame_queue_get       (SchroEncoder *encoder,
                                                             SchroPictureNumber frame_number);
    void                schro_encoder_frame_queue_remove    (SchroEncoder *encoder,
                                                             SchroPictureNumber frame_number);
    void                schro_encoder_frame_ref             (SchroEncoderFrame *frame);
    void                schro_encoder_frame_unref           (SchroEncoderFrame *frame);
    void                schro_encoder_init_subbands         (SchroEncoderFrame *frame);
    void                schro_encoder_insert_buffer         (SchroEncoder *encoder,
                                                             SchroBuffer *buffer);
    void                schro_encoder_output_push           (SchroEncoder *encoder,
                                                             SchroBuffer *buffer,
                                                             int slot,
                                                             int presentation_frame);
    double              schro_encoder_perceptual_weight_ccir959
                                                            (double cpd);
    double              schro_encoder_perceptual_weight_constant
                                                            (double cpd);
    double              schro_encoder_perceptual_weight_moo (double cpd);
    void                schro_encoder_postanalyse_picture   (SchroEncoderFrame *frame);
    void                schro_encoder_predict_picture       (SchroEncoderFrame *frame);
    int                 schro_encoder_push_ready            (SchroEncoder *encoder);
    void                schro_encoder_recalculate_allocations
                                                            (SchroEncoder *encoder);
    void                schro_encoder_reconstruct_picture   (SchroEncoderFrame *frame);
    SchroEncoderFrame*  schro_encoder_reference_get         (SchroEncoder *encoder,
                                                             SchroPictureNumber frame_number);
    void                schro_encoder_set_default_subband_weights
                                                            (SchroEncoder *encoder);
    void                schro_encoder_start                 (SchroEncoder *encoder);
    SchroStateEnum      schro_encoder_wait                  (SchroEncoder *encoder);
    int                 schro_encoder_get_n_settings        (void);
    const SchroEncoderSetting* schro_encoder_get_setting_info
                                                            (int i);
    void                schro_encoder_global_estimation     (SchroMotionEst *me);
    void                schro_encoder_init_error_tables     (SchroEncoder *encoder);
    void                schro_encoder_phasecorr_estimation  (SchroMotionEst *me);
    double              schro_encoder_setting_get_double    (SchroEncoder *encoder,
                                                             const char *name);
    void                schro_encoder_setting_set_double    (SchroEncoder *encoder,
                                                             const char *name,
                                                             double d);

## Description

## Details

### SchroEncoder

    typedef struct {
    } SchroEncoder;

### SchroEncoderFrame

    typedef struct {
    } SchroEncoderFrame;

### enum SchroEncoderFrameStateEnum

    typedef enum {
      SCHRO_ENCODER_FRAME_STATE_NEW = 0,
      SCHRO_ENCODER_FRAME_STATE_ANALYSE = (1<<1),
      SCHRO_ENCODER_FRAME_STATE_HAVE_GOP = (1<<7),
      SCHRO_ENCODER_FRAME_STATE_HAVE_PARAMS = (1<<8),
      SCHRO_ENCODER_FRAME_STATE_PREDICT = (1<<2),
      SCHRO_ENCODER_FRAME_STATE_HAVE_REFS = (1<<10),
      SCHRO_ENCODER_FRAME_STATE_HAVE_QUANTS = (1<<11),
      SCHRO_ENCODER_FRAME_STATE_ENCODING = (1<<3),
      SCHRO_ENCODER_FRAME_STATE_RECONSTRUCT = (1<<4),
      SCHRO_ENCODER_FRAME_STATE_POSTANALYSE = (1<<5),
      SCHRO_ENCODER_FRAME_STATE_DONE = (1<<6),
      SCHRO_ENCODER_FRAME_STATE_FREE = (1<<9)
    } SchroEncoderFrameStateEnum;

### enum SchroEncoderPerceptualEnum

    typedef enum {
      SCHRO_ENCODER_PERCEPTUAL_CONSTANT,
      SCHRO_ENCODER_PERCEPTUAL_CCIR959,
      SCHRO_ENCODER_PERCEPTUAL_MOO,
      SCHRO_ENCODER_PERCEPTUAL_MANOS_SAKRISON
    } SchroEncoderPerceptualEnum;

### struct SchroEncoderSettings

    struct SchroEncoderSettings {
      int transform_depth;
      int wavelet_filter_index;

      /* stuff we don't handle yet */
      int profile;
      int level;

      int xbsep_luma;
      int ybsep_luma;
      int xblen_luma;
      int yblen_luma;
    };
    #endif

    enum {
      SCHRO_MOTION_FIELD_HIER_REF0,
      SCHRO_MOTION_FIELD_HIER1_REF0,
      SCHRO_MOTION_FIELD_HIER2_REF0,
      SCHRO_MOTION_FIELD_HIER3_REF0,
      SCHRO_MOTION_FIELD_HIER_REF1,
      SCHRO_MOTION_FIELD_HIER1_REF1,
      SCHRO_MOTION_FIELD_HIER2_REF1,
      SCHRO_MOTION_FIELD_HIER3_REF1,
      SCHRO_MOTION_FIELD_PHASECORR_REF0,
      SCHRO_MOTION_FIELD_PHASECORR_REF1,
      SCHRO_MOTION_FIELD_DC,
      SCHRO_MOTION_FIELD_GLOBAL_REF0,
      SCHRO_MOTION_FIELD_GLOBAL_REF1,
      SCHRO_MOTION_FIELD_ZERO_REF0,
      SCHRO_MOTION_FIELD_ZERO_REF1,
      SCHRO_MOTION_FIELD_FULLSCAN_REF0,
      SCHRO_MOTION_FIELD_FULLSCAN_REF1,
      SCHRO_MOTION_FIELD_LAST
    };

### enum SchroQuantiserEngineEnum

    typedef enum {
      SCHRO_QUANTISER_ENGINE_SIMPLE,
      SCHRO_QUANTISER_ENGINE_RATE_DISTORTION,
      SCHRO_QUANTISER_ENGINE_LOSSLESS,
      SCHRO_QUANTISER_ENGINE_LOWDELAY,
      SCHRO_QUANTISER_ENGINE_CONSTANT_LAMBDA,
      SCHRO_QUANTISER_ENGINE_CONSTANT_ERROR
    } SchroQuantiserEngineEnum;

### enum SchroStateEnum

    typedef enum {
      SCHRO_STATE_NEED_FRAME,
      SCHRO_STATE_HAVE_BUFFER,
      SCHRO_STATE_AGAIN,
      SCHRO_STATE_END_OF_STREAM
    } SchroStateEnum;

### enum SchroEncoderGOPEnum

    typedef enum {
      SCHRO_ENCODER_GOP_ADAPTIVE,
      SCHRO_ENCODER_GOP_INTRA_ONLY,
      SCHRO_ENCODER_GOP_BACKREF,
      SCHRO_ENCODER_GOP_CHAINED_BACKREF,
      SCHRO_ENCODER_GOP_BIREF,
      SCHRO_ENCODER_GOP_CHAINED_BIREF,
    } SchroEncoderGOPEnum;

### enum SchroEncoderRateControlEnum

    typedef enum {
      SCHRO_ENCODER_RATE_CONTROL_CONSTANT_NOISE_THRESHOLD,
      SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE,
      SCHRO_ENCODER_RATE_CONTROL_LOW_DELAY,
      SCHRO_ENCODER_RATE_CONTROL_LOSSLESS,
      SCHRO_ENCODER_RATE_CONTROL_CONSTANT_LAMBDA,
      SCHRO_ENCODER_RATE_CONTROL_CONSTANT_ERROR
    } SchroEncoderRateControlEnum;

### SchroEncoderSetting

    typedef struct {
      char *name;
      SchroEncoderSettingTypeEnum type;

      double min;
      double max;
      double default_value;

      char **enum_list;
    } SchroEncoderSetting;

### SchroEngineIterateFunc ()

    int                 (*SchroEngineIterateFunc)           (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_new ()

    SchroEncoder*       schro_encoder_new                   (void);

Returns : |

### schro_encoder_free ()

    void                schro_encoder_free                  (SchroEncoder *encoder);

`encoder` : |

### schro_encoder_get_video_format ()

    SchroVideoFormat*   schro_encoder_get_video_format      (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_set_video_format ()

    void                schro_encoder_set_video_format      (SchroEncoder *encoder,
                                                             SchroVideoFormat *video_format);

`encoder` : |
`video_format` : |

### schro_encoder_end_of_stream ()

    void                schro_encoder_end_of_stream         (SchroEncoder *encoder);

`encoder` : |

### schro_encoder_push_frame ()

    void                schro_encoder_push_frame            (SchroEncoder *encoder,
                                                             SchroFrame *frame);

`encoder` : |
`frame` : |

### schro_encoder_encode_access_unit_header ()

    void                schro_encoder_encode_access_unit_header
                                                            (SchroEncoder *encoder,
                                                             SchroPack *bits);

`encoder` : |
`bits` : |

### schro_encoder_encode_parse_info ()

    void                schro_encoder_encode_parse_info     (SchroPack *bits,
                                                             int parse_code);

`bits` : |
`parse_code` : |

### schro_encoder_pull ()

    SchroBuffer*        schro_encoder_pull                  (SchroEncoder *encoder,
                                                             int *n_decodable_frames);

`encoder` : |
`n_decodable_frames` : |
Returns : |

### schro_encoder_analyse_picture ()

    void                schro_encoder_analyse_picture       (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_calculate_subband_weights ()

    void                schro_encoder_calculate_subband_weights
                                                            (SchroEncoder *encoder,
                                                             double (perceptual_weightdouble) ());

`encoder` : |
`perceptual_weight` : |

### schro_encoder_calculate_test_info ()

    void                schro_encoder_calculate_test_info   (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_choose_quantisers ()

    void                schro_encoder_choose_quantisers     (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_clean_up_transform ()

    void                schro_encoder_clean_up_transform    (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_encode_auxiliary_data ()

    SchroBuffer*        schro_encoder_encode_auxiliary_data (SchroEncoder *encoder,
                                                             SchroAuxiliaryDataID id,
                                                             void *data,
                                                             int size);

`encoder` : |
`id` : |
`data` : |
`size` : |
Returns : |

### schro_encoder_encode_end_of_stream ()

    SchroBuffer*        schro_encoder_encode_end_of_stream  (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_encode_lowdelay_transform_data ()

    void                schro_encoder_encode_lowdelay_transform_data
                                                            (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_encode_picture ()

    void                schro_encoder_encode_picture        (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_encode_picture_all ()

    void                schro_encoder_encode_picture_all    (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_encode_picture_header ()

    void                schro_encoder_encode_picture_header (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_encode_subband ()

    void                schro_encoder_encode_subband        (SchroEncoderFrame *frame,
                                                             int component,
                                                             int index);

`frame` : |
`component` : |
`index` : |

### schro_encoder_encode_subband_noarith ()

    void                schro_encoder_encode_subband_noarith
                                                            (SchroEncoderFrame *frame,
                                                             int component,
                                                             int index);

`frame` : |
`component` : |
`index` : |

### schro_encoder_engine_backref ()

    int                 schro_encoder_engine_backref        (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_engine_backtest ()

    int                 schro_encoder_engine_backtest       (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_engine_intra_only ()

    int                 schro_encoder_engine_intra_only     (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_engine_lossless ()

    int                 schro_encoder_engine_lossless       (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_engine_lowdelay ()

    int                 schro_encoder_engine_lowdelay       (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_engine_test_intra ()

    int                 schro_encoder_engine_test_intra     (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_estimate_entropy ()

    void                schro_encoder_estimate_entropy      (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_frame_analyse ()

    void                schro_encoder_frame_analyse         (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_frame_downsample ()

    void                schro_encoder_frame_downsample      (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_frame_insert_buffer ()

    void                schro_encoder_frame_insert_buffer   (SchroEncoderFrame *frame,
                                                             SchroBuffer *buffer);

`frame` : |
`buffer` : |

### schro_encoder_frame_new ()

    SchroEncoderFrame*  schro_encoder_frame_new             (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_frame_queue_get ()

    SchroFrame*         schro_encoder_frame_queue_get       (SchroEncoder *encoder,
                                                             SchroPictureNumber frame_number);

`encoder` : |
`frame_number` : |
Returns : |

### schro_encoder_frame_queue_remove ()

    void                schro_encoder_frame_queue_remove    (SchroEncoder *encoder,
                                                             SchroPictureNumber frame_number);

`encoder` : |
`frame_number` : |

### schro_encoder_frame_ref ()

    void                schro_encoder_frame_ref             (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_frame_unref ()

    void                schro_encoder_frame_unref           (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_init_subbands ()

    void                schro_encoder_init_subbands         (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_insert_buffer ()

    void                schro_encoder_insert_buffer         (SchroEncoder *encoder,
                                                             SchroBuffer *buffer);

`encoder` : |
`buffer` : |

### schro_encoder_output_push ()

    void                schro_encoder_output_push           (SchroEncoder *encoder,
                                                             SchroBuffer *buffer,
                                                             int slot,
                                                             int presentation_frame);

`encoder` : |
`buffer` : |
`slot` : |
`presentation_frame` : |

### schro_encoder_perceptual_weight_ccir959 ()

    double              schro_encoder_perceptual_weight_ccir959
                                                            (double cpd);

`cpd` : |
Returns : |

### schro_encoder_perceptual_weight_constant ()

    double              schro_encoder_perceptual_weight_constant
                                                            (double cpd);

`cpd` : |
Returns : |

### schro_encoder_perceptual_weight_moo ()

    double              schro_encoder_perceptual_weight_moo (double cpd);

`cpd` : |
Returns : |

### schro_encoder_postanalyse_picture ()

    void                schro_encoder_postanalyse_picture   (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_predict_picture ()

    void                schro_encoder_predict_picture       (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_push_ready ()

    int                 schro_encoder_push_ready            (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_recalculate_allocations ()

    void                schro_encoder_recalculate_allocations
                                                            (SchroEncoder *encoder);

`encoder` : |

### schro_encoder_reconstruct_picture ()

    void                schro_encoder_reconstruct_picture   (SchroEncoderFrame *frame);

`frame` : |

### schro_encoder_reference_get ()

    SchroEncoderFrame*  schro_encoder_reference_get         (SchroEncoder *encoder,
                                                             SchroPictureNumber frame_number);

`encoder` : |
`frame_number` : |
Returns : |

### schro_encoder_set_default_subband_weights ()

    void                schro_encoder_set_default_subband_weights
                                                            (SchroEncoder *encoder);

`encoder` : |

### schro_encoder_start ()

    void                schro_encoder_start                 (SchroEncoder *encoder);

`encoder` : |

### schro_encoder_wait ()

    SchroStateEnum      schro_encoder_wait                  (SchroEncoder *encoder);

`encoder` : |
Returns : |

### schro_encoder_get_n_settings ()

    int                 schro_encoder_get_n_settings        (void);

Returns : |

### schro_encoder_get_setting_info ()

    const SchroEncoderSetting* schro_encoder_get_setting_info
                                                            (int i);

`i` : |
Returns : |

### schro_encoder_global_estimation ()

    void                schro_encoder_global_estimation     (SchroMotionEst *me);

`me` : |

### schro_encoder_init_error_tables ()

    void                schro_encoder_init_error_tables     (SchroEncoder *encoder);

`encoder` : |

### schro_encoder_phasecorr_estimation ()

    void                schro_encoder_phasecorr_estimation  (SchroMotionEst *me);

`me` : |

### schro_encoder_setting_get_double ()

    double              schro_encoder_setting_get_double    (SchroEncoder *encoder,
                                                             const char *name);

`encoder` : |
`name` : |
Returns : |

### schro_encoder_setting_set_double ()

    void                schro_encoder_setting_set_double    (SchroEncoder *encoder,
                                                             const char *name,
                                                             double d);

`encoder` : |
`name` : |
`d` : |