Exemplo n.º 1
0
SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s)
{
    int length;

    length = 0;

    if (s->image_put_handler)
        s->image_put_handler((void *) &s->decoder, NULL, 0);

    switch (s->current_decoder)
    {
    case 0:
        length = s->decoder.no_decoder.buf_ptr;
        break;
    case T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6:
        length = t4_t6_decode_get_image_length(&s->decoder.t4_t6);
        break;
    case T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0:
        length = t85_decode_get_image_length(&s->decoder.t85);
        break;
#if defined(SPANDSP_SUPPORT_T88)
    case T4_COMPRESSION_T88:
        length = t88_decode_get_image_length(&s->decoder.t88);
        break;
#endif
    case T4_COMPRESSION_T42_T81:
        length = t42_decode_get_image_length(&s->decoder.t42);
        if (s->decoder.t42.samples_per_pixel == 3)
            s->tiff.image_type = T4_IMAGE_TYPE_COLOUR_8BIT;
        else
            s->tiff.image_type = T4_IMAGE_TYPE_GRAY_8BIT;
        break;
    case T4_COMPRESSION_T43:
        length = t43_decode_get_image_length(&s->decoder.t43);
        break;
#if defined(SPANDSP_SUPPORT_T45)
    case T4_COMPRESSION_T45:
        length = t45_decode_get_image_length(&s->decoder.t45);
        break;
#endif
    }

    if (length == 0)
        return -1;

    if (s->tiff.tiff_file)
    {
        if (write_tiff_image(s) == 0)
            s->current_page++;
        s->tiff.image_size = 0;
    }
    else
    {
        s->current_page++;
    }
    return 0;
}
Exemplo n.º 2
0
SPAN_DECLARE(int) t4_rx_end_page(t4_state_t *s)
{
    int row;
    int i;

    if (s->line_encoding == T4_COMPRESSION_ITU_T6)
    {
        /* Push enough zeros through the decoder to flush out any remaining codes */
        for (i = 0;  i < 13;  i++)
            t4_rx_put_bit(s, 0);
    }
    if (s->t4_t6_rx.curr_bad_row_run)
    {
        if (s->t4_t6_rx.curr_bad_row_run > s->t4_t6_rx.longest_bad_row_run)
            s->t4_t6_rx.longest_bad_row_run = s->t4_t6_rx.curr_bad_row_run;
        s->t4_t6_rx.curr_bad_row_run = 0;
    }

    if (s->image_size == 0)
        return -1;

    if (s->t4_t6_rx.row_write_handler)
    {
        for (row = 0;  row < s->image_length;  row++)
        {
            if (s->t4_t6_rx.row_write_handler(s->t4_t6_rx.row_write_user_data, s->image_buffer + row*s->bytes_per_row, s->bytes_per_row) < 0)
            {
                span_log(&s->logging, SPAN_LOG_WARNING, "Write error at row %d.\n", row);
                break;
            }
        }
        /* Write a blank row to indicate the end of the image. */
        if (s->t4_t6_rx.row_write_handler(s->t4_t6_rx.row_write_user_data, NULL, 0) < 0)
            span_log(&s->logging, SPAN_LOG_WARNING, "Write error at row %d.\n", row);
    }
    else
    {
        write_tiff_image(s);
    }
    s->t4_t6_rx.rx_bits = 0;
    s->t4_t6_rx.rx_skip_bits = 0;
    s->t4_t6_rx.rx_bitstream = 0;
    s->t4_t6_rx.consecutive_eols = EOLS_TO_END_ANY_RX_PAGE;

    s->image_size = 0;
    return 0;
}
Exemplo n.º 3
0
SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s)
{
    int length;

    length = 0;
    switch (s->line_encoding)
    {
    case T4_COMPRESSION_ITU_T4_1D:
    case T4_COMPRESSION_ITU_T4_2D:
    case T4_COMPRESSION_ITU_T6:
        t4_t6_decode_put(&s->decoder.t4_t6, NULL, 0);
        length = t4_t6_decode_get_image_length(&s->decoder.t4_t6);
        break;
    case T4_COMPRESSION_ITU_T42:
        t42_decode_put(&s->decoder.t42, NULL, 0);
        length = t42_decode_get_image_length(&s->decoder.t42);
        break;
#if defined(SPANDSP_SUPPORT_T43)
    case T4_COMPRESSION_ITU_T43:
        t43_decode_put(&s->decoder.t43, NULL, 0);
        length = t43_decode_get_image_length(&s->decoder.t43);
        break;
#endif
    case T4_COMPRESSION_ITU_T85:
    case T4_COMPRESSION_ITU_T85_L0:
        t85_decode_put(&s->decoder.t85, NULL, 0);
        length = t85_decode_get_image_length(&s->decoder.t85);
        break;
    }

    if (length == 0)
        return -1;

    if (s->tiff.tiff_file)
    {
        if (write_tiff_image(s) == 0)
            s->current_page++;
        s->tiff.image_size = 0;
    }
    else
    {
        s->current_page++;
    }
    return 0;
}
Exemplo n.º 4
0
SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s)
{
    int length;

    length = 0;
    switch (s->metadata.compression)
    {
    case T4_COMPRESSION_T4_1D:
    case T4_COMPRESSION_T4_2D:
    case T4_COMPRESSION_T6:
        t4_t6_decode_put(&s->decoder.t4_t6, NULL, 0);
        length = t4_t6_decode_get_image_length(&s->decoder.t4_t6);
        break;
    case T4_COMPRESSION_T85:
    case T4_COMPRESSION_T85_L0:
        t85_decode_put(&s->decoder.t85, NULL, 0);
        length = t85_decode_get_image_length(&s->decoder.t85);
        break;
#if defined(SPANDSP_SUPPORT_T88)
    case T4_COMPRESSION_T88:
        t88_decode_put(&s->decoder.t88, NULL, 0);
        length = t88_decode_get_image_length(&s->decoder.t88);
        break;
#endif
    case T4_COMPRESSION_T42_T81:
        t42_decode_put(&s->decoder.t42, NULL, 0);
        length = t42_decode_get_image_length(&s->decoder.t42);
        if (s->decoder.t42.samples_per_pixel == 3)
            select_tiff_compression(s, T4_IMAGE_TYPE_COLOUR_8BIT);
        else
            select_tiff_compression(s, T4_IMAGE_TYPE_GRAY_8BIT);
        break;
#if defined(SPANDSP_SUPPORT_T43)
    case T4_COMPRESSION_T43:
        t43_decode_put(&s->decoder.t43, NULL, 0);
        length = t43_decode_get_image_length(&s->decoder.t43);
        break;
#endif
#if defined(SPANDSP_SUPPORT_T45)
    case T4_COMPRESSION_T45:
        t45_decode_put(&s->decoder.t45, NULL, 0);
        length = t45_decode_get_image_length(&s->decoder.t45);
        break;
#endif
    }

    if (length == 0)
        return -1;

    if (s->tiff.tiff_file)
    {
        if (write_tiff_image(s) == 0)
            s->current_page++;
        s->tiff.image_size = 0;
    }
    else
    {
        s->current_page++;
    }
    return 0;
}