]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Small cleanup of image handling
authorSteve Underwood <steveu@coppice.org>
Fri, 15 Mar 2013 15:17:47 +0000 (23:17 +0800)
committerSteve Underwood <steveu@coppice.org>
Fri, 15 Mar 2013 15:17:47 +0000 (23:17 +0800)
libs/spandsp/src/msvc/spandsp.h
libs/spandsp/src/spandsp/t42.h
libs/spandsp/src/spandsp/t85.h
libs/spandsp/src/t42.c
libs/spandsp/src/t85_encode.c

index 31e0affc1c3c279433739491916b7848d6851e1d..fbdfac8e49f6a362db996e7dd91401c09b2f0eea 100644 (file)
@@ -98,7 +98,6 @@
 #include <spandsp/v29tx.h>
 #include <spandsp/v17rx.h>
 #include <spandsp/v17tx.h>
-/*#include <spandsp/v32bis.h> not sure why this is here I cant find it in the filesystem */
 #include <spandsp/v22bis.h>
 #include <spandsp/v27ter_rx.h>
 #include <spandsp/v27ter_tx.h>
index fe2c83aeab24f27c7877288ff2f32fbae276cc33..b864b175360793b00109c60b81148a108f9287c0 100644 (file)
@@ -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)
index 29bd6ad7c1e7002565833953a2c2699f0db84115..d229026197a4b2399fd3ab30b596c792d03497ae 100644 (file)
@@ -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
index c8ed0a08046216cefa74774e27eb4c29a00c1036..3028c03472a9f85c6caf388c3c9e968282d48ad2 100644 (file)
@@ -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;
index 6ce2cae6fb225ca01a0e60e0e45b3aa3ab659ccc..ed8e47364ffff90885d0e2cdf7c618e67354b287 100644 (file)
@@ -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. */