From: Steve Underwood Date: Fri, 15 Mar 2013 15:17:47 +0000 (+0800) Subject: Small cleanup of image handling X-Git-Tag: v1.3.17-final~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efaa3a6d3de8f1ddca7f5c0a953118be0cdc16f1;p=thirdparty%2Ffreeswitch.git Small cleanup of image handling --- diff --git a/libs/spandsp/src/msvc/spandsp.h b/libs/spandsp/src/msvc/spandsp.h index 31e0affc1c..fbdfac8e49 100644 --- a/libs/spandsp/src/msvc/spandsp.h +++ b/libs/spandsp/src/msvc/spandsp.h @@ -98,7 +98,6 @@ #include #include #include -/*#include not sure why this is here I cant find it in the filesystem */ #include #include #include diff --git a/libs/spandsp/src/spandsp/t42.h b/libs/spandsp/src/spandsp/t42.h index fe2c83aeab..b864b17536 100644 --- a/libs/spandsp/src/spandsp/t42.h +++ b/libs/spandsp/src/spandsp/t42.h @@ -104,26 +104,60 @@ SPAN_DECLARE(int) t42_encode_set_row_read_handler(t42_encode_state_t *s, \return A pointer to the logging context */ SPAN_DECLARE(logging_state_t *) t42_encode_get_logging_state(t42_encode_state_t *s); +/*! \brief Restart a T.42 encode context. + \param s The T.42 context. + \param image image_width The image width, in pixels. + \param image image_width The image length, in pixels. + \return 0 for success, otherwise -1. */ SPAN_DECLARE(int) t42_encode_restart(t42_encode_state_t *s, uint32_t image_width, uint32_t image_length); +/*! \brief Prepare to encode an image in T.42 format. + \param s The T.42 context. + \param image_width Image width, in pixels. + \param image_length Image length, in pixels. + \param handler A callback routine to handle encoded image rows. + \param user_data An opaque pointer passed to handler. + \return A pointer to the context, or NULL if there was a problem. */ SPAN_DECLARE(t42_encode_state_t *) t42_encode_init(t42_encode_state_t *s, uint32_t image_width, uint32_t image_length, t4_row_read_handler_t handler, void *user_data); +/*! \brief Release a T.42 encode context. + \param s The T.42 encode context. + \return 0 for OK, else -1. */ SPAN_DECLARE(int) t42_encode_release(t42_encode_state_t *s); +/*! \brief Free a T.42 encode context. + \param s The T.42 encode context. + \return 0 for OK, else -1. */ SPAN_DECLARE(int) t42_encode_free(t42_encode_state_t *s); SPAN_DECLARE(void) t42_decode_rx_status(t42_decode_state_t *s, int status); +/*! \brief Decode a chunk of T.42 data. + \param s The T.42 context. + \param data The data to be decoded. + \param len The length of the data to be decoded. + \return 0 for OK. */ SPAN_DECLARE(int) t42_decode_put(t42_decode_state_t *s, const uint8_t data[], size_t len); +/*! \brief Set the row handler routine. + \param s The T.42 context. + \param handler A callback routine to handle decoded image rows. + \param user_data An opaque pointer passed to handler. + \return 0 for OK. */ SPAN_DECLARE(int) t42_decode_set_row_write_handler(t42_decode_state_t *s, t4_row_write_handler_t handler, void *user_data); +/*! \brief Set the comment handler routine. + \param s The T.42 context. + \param max_comment_len The maximum length of comment to be passed to the handler. + \param handler A callback routine to handle decoded comment. + \param user_data An opaque pointer passed to handler. + \return 0 for OK. */ SPAN_DECLARE(int) t42_decode_set_comment_handler(t42_decode_state_t *s, uint32_t max_comment_len, t4_row_write_handler_t handler, @@ -133,14 +167,18 @@ SPAN_DECLARE(int) t42_decode_set_image_size_constraints(t42_decode_state_t *s, uint32_t max_xd, uint32_t max_yd); +/*! \brief Get the width of the image. + \param s The T.42 context. + \return The width of the image, in pixels. */ SPAN_DECLARE(uint32_t) t42_decode_get_image_width(t42_decode_state_t *s); +/*! \brief Get the length of the image. + \param s The T.42 context. + \return The length of the image, in pixels. */ SPAN_DECLARE(uint32_t) t42_decode_get_image_length(t42_decode_state_t *s); SPAN_DECLARE(int) t42_decode_get_compressed_image_size(t42_decode_state_t *s); -SPAN_DECLARE(int) t42_decode_new_plane(t42_decode_state_t *s); - /*! Get the logging context associated with a T.42 decode context. \brief Get the logging context associated with a T.42 decode context. \param s The T.42 decode context. @@ -149,12 +187,23 @@ SPAN_DECLARE(logging_state_t *) t42_decode_get_logging_state(t42_decode_state_t SPAN_DECLARE(int) t42_decode_restart(t42_decode_state_t *s); +/*! \brief Prepare to decode an image in T.42 format. + \param s The T.42 context. + \param handler A callback routine to handle decoded image rows. + \param user_data An opaque pointer passed to handler. + \return A pointer to the context, or NULL if there was a problem. */ SPAN_DECLARE(t42_decode_state_t *) t42_decode_init(t42_decode_state_t *s, t4_row_write_handler_t handler, void *user_data); +/*! \brief Release a T.42 decode context. + \param s The T.42 decode context. + \return 0 for OK, else -1. */ SPAN_DECLARE(int) t42_decode_release(t42_decode_state_t *s); +/*! \brief Free a T.42 decode context. + \param s The T.42 decode context. + \return 0 for OK, else -1. */ SPAN_DECLARE(int) t42_decode_free(t42_decode_state_t *s); #if defined(__cplusplus) diff --git a/libs/spandsp/src/spandsp/t85.h b/libs/spandsp/src/spandsp/t85.h index 29bd6ad7c1..d229026197 100644 --- a/libs/spandsp/src/spandsp/t85.h +++ b/libs/spandsp/src/spandsp/t85.h @@ -93,31 +93,6 @@ SPAN_DECLARE(int) t85_encode_set_row_read_handler(t85_encode_state_t *s, \return A pointer to the logging context */ SPAN_DECLARE(logging_state_t *) t85_encode_get_logging_state(t85_encode_state_t *s); -/*! \brief Prepare to encode an image in T.85 format. - \param s The T.85 context. - \param image_width Image width, in pixels. - \param image_length Image length, in pixels. - \param handler A callback routine to handle encoded image rows. - \param user_data An opaque pointer passed to handler. - \return A pointer to the context, or NULL if there was a problem. */ -SPAN_DECLARE(t85_encode_state_t *) t85_encode_init(t85_encode_state_t *s, - uint32_t image_width, - uint32_t image_length, - t4_row_read_handler_t handler, - void *user_data); - -/*! \brief Restart a T.85 encode context. - \param s The T.85 context. - \param image width The image width, in pixels. - \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t85_encode_restart(t85_encode_state_t *s, - uint32_t image_width, - uint32_t image_length); - -SPAN_DECLARE(int) t85_encode_release(t85_encode_state_t *s); - -SPAN_DECLARE(int) t85_encode_free(t85_encode_state_t *s); - /*! \brief Set the T.85 options \param s The T.85 context. \brief l0 ??? @@ -138,7 +113,7 @@ SPAN_DECLARE(void) t85_encode_comment(t85_encode_state_t *s, /*! \brief Set the image width. \param s The T.85 context. - \param width The width of the image. + \param image_width The width of the image. \return 0 for success, otherwise -1. */ SPAN_DECLARE(int) t85_encode_set_image_width(t85_encode_state_t *s, uint32_t image_width); @@ -147,9 +122,9 @@ SPAN_DECLARE(int) t85_encode_set_image_width(t85_encode_state_t *s, uint32_t ima will be silently adjusted to the current length. Therefore, adjust the length to 1 will make the currently encoded length the final length. \param s The T.85 context. - \param length The new image length, in pixels. + \param image_length The new image length, in pixels. \return 0 if OK, or -1 if the request was not valid. */ -SPAN_DECLARE(int) t85_encode_set_image_length(t85_encode_state_t *s, uint32_t length); +SPAN_DECLARE(int) t85_encode_set_image_length(t85_encode_state_t *s, uint32_t image_length); /*! \brief Get the width of the image. \param s The T.85 context. @@ -170,28 +145,43 @@ SPAN_DECLARE(int) t85_encode_get_compressed_image_size(t85_encode_state_t *s); \param s The T.85 context. */ SPAN_DECLARE(void) t85_encode_abort(t85_encode_state_t *s); -/*! Get the logging context associated with a T.85 decode context. - \brief Get the logging context associated with a T.85 decode context. - \param s The T.85 decode context. - \return A pointer to the logging context */ -SPAN_DECLARE(logging_state_t *) t85_decode_get_logging_state(t85_decode_state_t *s); +/*! \brief Restart a T.85 encode context. + \param s The T.85 context. + \param image_width The image width, in pixels. + \param image_length The image length, in pixels. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t85_encode_restart(t85_encode_state_t *s, + uint32_t image_width, + uint32_t image_length); -/*! \brief Prepare to decode an image in T.85 format. +/*! \brief Prepare to encode an image in T.85 format. \param s The T.85 context. - \param handler A callback routine to handle decoded image rows. + \param image_width The image width, in pixels. + \param image_length The image length, in pixels. + \param handler A callback routine to handle encoded image rows. \param user_data An opaque pointer passed to handler. \return A pointer to the context, or NULL if there was a problem. */ -SPAN_DECLARE(t85_decode_state_t *) t85_decode_init(t85_decode_state_t *s, - t4_row_write_handler_t handler, +SPAN_DECLARE(t85_encode_state_t *) t85_encode_init(t85_encode_state_t *s, + uint32_t image_width, + uint32_t image_length, + t4_row_read_handler_t handler, void *user_data); -SPAN_DECLARE(int) t85_decode_new_plane(t85_decode_state_t *s); - -SPAN_DECLARE(int) t85_decode_restart(t85_decode_state_t *s); +/*! \brief Release a T.85 encode context. + \param s The T.85 encode context. + \return 0 for OK, else -1. */ +SPAN_DECLARE(int) t85_encode_release(t85_encode_state_t *s); -SPAN_DECLARE(int) t85_decode_release(t85_decode_state_t *s); +/*! \brief Free a T.85 encode context. + \param s The T.85 encode context. + \return 0 for OK, else -1. */ +SPAN_DECLARE(int) t85_encode_free(t85_encode_state_t *s); -SPAN_DECLARE(int) t85_decode_free(t85_decode_state_t *s); +/*! Get the logging context associated with a T.85 decode context. + \brief Get the logging context associated with a T.85 decode context. + \param s The T.85 decode context. + \return A pointer to the logging context */ +SPAN_DECLARE(logging_state_t *) t85_decode_get_logging_state(t85_decode_state_t *s); /*! \brief Get the width of the image. \param s The T.85 context. @@ -208,6 +198,8 @@ SPAN_DECLARE(uint32_t) t85_decode_get_image_length(t85_decode_state_t *s); \return The size of the compressed image, in bits. */ SPAN_DECLARE(int) t85_decode_get_compressed_image_size(t85_decode_state_t *s); +SPAN_DECLARE(int) t85_decode_new_plane(t85_decode_state_t *s); + /*! \brief Set the row handler routine. \param s The T.85 context. \param handler A callback routine to handle decoded image rows. @@ -263,6 +255,27 @@ SPAN_DECLARE(void) t85_decode_rx_status(t85_decode_state_t *s, int status); \return 0 for OK. */ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], size_t len); +SPAN_DECLARE(int) t85_decode_restart(t85_decode_state_t *s); + +/*! \brief Prepare to decode an image in T.85 format. + \param s The T.85 context. + \param handler A callback routine to handle decoded image rows. + \param user_data An opaque pointer passed to handler. + \return A pointer to the context, or NULL if there was a problem. */ +SPAN_DECLARE(t85_decode_state_t *) t85_decode_init(t85_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data); + +/*! \brief Release a T.85 decode context. + \param s The T.85 decode context. + \return 0 for OK, else -1. */ +SPAN_DECLARE(int) t85_decode_release(t85_decode_state_t *s); + +/*! \brief Free a T.85 decode context. + \param s The T.85 decode context. + \return 0 for OK, else -1. */ +SPAN_DECLARE(int) t85_decode_free(t85_decode_state_t *s); + #if defined(__cplusplus) } #endif diff --git a/libs/spandsp/src/t42.c b/libs/spandsp/src/t42.c index c8ed0a0804..3028c03472 100644 --- a/libs/spandsp/src/t42.c +++ b/libs/spandsp/src/t42.c @@ -1361,12 +1361,6 @@ SPAN_DECLARE(int) t42_decode_get_compressed_image_size(t42_decode_state_t *s) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t42_decode_new_plane(t42_decode_state_t *s) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - SPAN_DECLARE(logging_state_t *) t42_decode_get_logging_state(t42_decode_state_t *s) { return &s->logging; diff --git a/libs/spandsp/src/t85_encode.c b/libs/spandsp/src/t85_encode.c index 6ce2cae6fb..ed8e47364f 100644 --- a/libs/spandsp/src/t85_encode.c +++ b/libs/spandsp/src/t85_encode.c @@ -529,13 +529,13 @@ SPAN_DECLARE(int) t85_encode_set_image_width(t85_encode_state_t *s, uint32_t ima } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t85_encode_set_image_length(t85_encode_state_t *s, uint32_t length) +SPAN_DECLARE(int) t85_encode_set_image_length(t85_encode_state_t *s, uint32_t image_length) { /* We must have variable length enabled. We do not allow the length to be changed multiple times. We only allow an image to be shrunk, and not stretched. We do not allow the length to become zero. */ - if (!(s->options & T85_VLENGTH) || s->newlen == NEWLEN_HANDLED || length >= s->yd || length < 1) + if (!(s->options & T85_VLENGTH) || s->newlen == NEWLEN_HANDLED || image_length >= s->yd || image_length < 1) { /* Invalid parameter */ return -1; @@ -544,12 +544,12 @@ SPAN_DECLARE(int) t85_encode_set_image_length(t85_encode_state_t *s, uint32_t le { /* TODO: If we are already beyond the new length, we scale back the new length silently. Is there any downside to this? */ - if (length < s->y) - length = s->y; - if (s->yd != length) + if (image_length < s->y) + image_length = s->y; + if (s->yd != image_length) s->newlen = NEWLEN_PENDING; } - s->yd = length; + s->yd = image_length; if (s->y == s->yd) { /* We are already at the end of the image, so finish it off. */