SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int supported_output_compressions) { bool alloced; alloced = false; if (s == NULL) { if ((s = (t4_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; alloced = true; } #if defined(SPANDSP_SUPPORT_TIFF_FX) TIFF_FX_init(); #endif memset(s, 0, sizeof(*s)); span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "T.4"); span_log(&s->logging, SPAN_LOG_FLOW, "Start rx document\n"); s->supported_tiff_compressions = supported_output_compressions; #if !defined(SPANDSP_SUPPORT_T88) s->supported_tiff_compressions &= ~T4_COMPRESSION_T88; #endif #if !defined(SPANDSP_SUPPORT_T43) s->supported_tiff_compressions &= ~T4_COMPRESSION_T43; #endif #if !defined(SPANDSP_SUPPORT_T45) s->supported_tiff_compressions &= ~T4_COMPRESSION_T45; #endif /* Set some default values */ s->metadata.x_resolution = T4_X_RESOLUTION_R8; s->metadata.y_resolution = T4_Y_RESOLUTION_FINE; s->current_page = 0; s->current_decoder = 0; /* Default handler */ s->row_handler = tiff_row_write_handler; s->row_handler_user_data = s; if (file) { s->tiff.pages_in_file = 0; if (open_tiff_output_file(s, file) < 0) { if (alloced) span_free(s); return NULL; } /* Save the file name for logging reports. */ s->tiff.file = strdup(file); } return s; }
SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int output_encoding) { int allocated; allocated = FALSE; if (s == NULL) { if ((s = (t4_rx_state_t *) malloc(sizeof(*s))) == NULL) return NULL; allocated = TRUE; } #if defined(SPANDSP_SUPPORT_TIFF_FX) TIFF_FX_init(); #endif memset(s, 0, sizeof(*s)); span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "T.4"); span_log(&s->logging, SPAN_LOG_FLOW, "Start rx document\n"); /* Only provide for one form of coding throughout the file, even though the coding on the wire could change between pages. */ s->tiff.output_encoding = output_encoding; /* Set some default values */ s->metadata.x_resolution = T4_X_RESOLUTION_R8; s->metadata.y_resolution = T4_Y_RESOLUTION_FINE; s->current_page = 0; /* Default handler */ s->row_handler = tiff_row_write_handler; s->row_handler_user_data = s; if (file) { s->tiff.pages_in_file = 0; if (open_tiff_output_file(s, file) < 0) { if (allocated) free(s); return NULL; } /* Save the file name for logging reports. */ s->tiff.file = strdup(file); } return s; }