57 return (
ui16)((v<<8) | (v>>8));
77 if (c ==
' ' || c ==
'\r' || c ==
'\n' || c ==
'\t')
81 while (c !=
'\n') c = fgetc(fh);
106 int max_val = (1 << bit_depth) - 1;
109 for ( ; count > 0; --count)
112 val = val >= 0 ? val : 0;
113 val = val <= max_val ? val : max_val;
122 int max_val = (1<<bit_depth) - 1;
127 for (; count > 0; --count)
131 val = val >= 0 ? val : 0;
132 val = val <= max_val ? val : max_val;
135 val = val >= 0 ? val : 0;
136 val = val <= max_val ? val : max_val;
139 val = val >= 0 ? val : 0;
140 val = val <= max_val ? val : max_val;
151 int max_val = (1<<bit_depth) - 1;
154 for (; count > 0; --count)
157 val = val >= 0 ? val : 0;
158 val = val <= max_val ? val : max_val;
167 int max_val = (1<<bit_depth) - 1;
172 for (; count > 0; --count)
176 val = val >= 0 ? val : 0;
177 val = val <= max_val ? val : max_val;
180 val = val >= 0 ? val : 0;
181 val = val <= max_val ? val : max_val;
184 val = val >= 0 ? val : 0;
185 val = val <= max_val ? val : max_val;
196 int max_val = (1<<bit_depth) - 1;
199 for (; count > 0; --count)
202 val = val >= 0 ? val : 0;
203 val = val <= max_val ? val : max_val;
212 int max_val = (1<<bit_depth) - 1;
217 for (; count > 0; --count)
221 val = val >= 0 ? val : 0;
222 val = val <= max_val ? val : max_val;
225 val = val >= 0 ? val : 0;
226 val = val <= max_val ? val : max_val;
229 val = val >= 0 ? val : 0;
230 val = val <= max_val ? val : max_val;
248 fh = fopen(filename,
"rb");
250 OJPH_ERROR(0x030000001,
"Unable to open file %s", filename);
255 if (fread(t, 1, 2,
fh) != 2)
258 OJPH_ERROR(0x030000002,
"Error reading file %s", filename);
262 if (t[0] !=
'P' || (t[1] !=
'5' && t[1] !=
'6'))
265 OJPH_ERROR(0x030000003,
"unknown file type for file %s", filename);
268 size_t len = strlen(filename);
269 if (t[1] ==
'5' && strncmp(filename + len - 4,
".pgm", 4) != 0)
272 OJPH_ERROR(0x030000004,
"wrong file extension, a file with "
273 "keyword P5 must have a .pgm extension for file %s", filename);
275 if (t[1] ==
'6' && strncmp(filename + len - 4,
".ppm", 4) != 0)
278 OJPH_ERROR(0x030000005,
"wrong file extension, a file with keyword P6 "
279 "must have a .ppm extension fir file %s", filename);
290 OJPH_ERROR(0x030000006,
"error in file format for file %s", filename);
312 OJPH_ERROR(0x030000007,
"error allocating mmeory");
343 if (
planar || comp_num == 0)
345 size_t result = fread(
388 assert(
fh == NULL &&
buffer == NULL);
391 size_t len = strlen(filename);
394 if (strncmp(
".ppm", filename + len - 4, 4) == 0)
396 filename[len - 2] =
'g';
397 OJPH_WARN(0x03000001,
"file was renamed %s\n", filename);
399 if (strncmp(
".PPM", filename + len - 4, 4) == 0)
401 filename[len - 2] =
'G';
402 OJPH_WARN(0x03000002,
"file was renamed %s\n", filename);
405 fh = fopen(filename,
"wb");
408 "unable to open file %s for writing", filename);
416 size_t len = strlen(filename);
419 if (strncmp(
".pgm", filename + len - 4, 4) == 0)
421 filename[len - 2] =
'p';
422 OJPH_WARN(0x03000003,
"file was renamed %s\n", filename);
424 if (strncmp(
".PGM", filename + len - 4, 4) == 0)
426 filename[len - 2] =
'P';
427 OJPH_WARN(0x03000004,
"file was renamed %s\n", filename);
430 fh = fopen(filename,
"wb");
433 "unable to open file %s for writing", filename);
437 OJPH_ERROR(0x030000023,
"error writing to file %s", filename);
452 "ppm supports 3 colour components, while pgm supports 1");
474#ifndef OJPH_DISABLE_INTEL_SIMD
514 lptr[comp_num] = line;
520 size_t result = fwrite(
buffer,
535#ifdef OJPH_ENABLE_TIFF_SUPPORT
537 void tif_in::open(
const char* filename)
540 if ((tiff_handle = TIFFOpen(filename,
"r")) == NULL)
541 OJPH_ERROR(0x0300000B1,
"Unable to open file %s", filename);
545 ui32 tiff_height = 0;
546 TIFFGetField(tiff_handle, TIFFTAG_IMAGEWIDTH, &tiff_width);
547 TIFFGetField(tiff_handle, TIFFTAG_IMAGELENGTH, &tiff_height);
549 ui16 tiff_bits_per_sample = 0;
550 ui16 tiff_samples_per_pixel = 0;
551 TIFFGetField(tiff_handle, TIFFTAG_BITSPERSAMPLE, &tiff_bits_per_sample);
552 TIFFGetField(tiff_handle, TIFFTAG_SAMPLESPERPIXEL, &tiff_samples_per_pixel);
555 tiff_samples_per_pixel =
556 (tiff_samples_per_pixel < 1) ? 1 : tiff_samples_per_pixel;
558 ui16 tiff_planar_configuration = 0;
559 ui16 tiff_photometric = 0;
560 TIFFGetField(tiff_handle, TIFFTAG_PLANARCONFIG, &tiff_planar_configuration);
561 TIFFGetField(tiff_handle, TIFFTAG_PHOTOMETRIC, &tiff_photometric);
563 planar_configuration = tiff_planar_configuration;
565 ui16 tiff_compression = 0;
566 ui32 tiff_rows_per_strip = 0;
567 TIFFGetField(tiff_handle, TIFFTAG_COMPRESSION, &tiff_compression);
568 TIFFGetField(tiff_handle, TIFFTAG_ROWSPERSTRIP, &tiff_rows_per_strip);
570 if (tiff_planar_configuration == PLANARCONFIG_SEPARATE)
572 bytes_per_line = tiff_samples_per_pixel * TIFFScanlineSize64(tiff_handle);
576 bytes_per_line = TIFFScanlineSize64(tiff_handle);
579 line_buffer = malloc(bytes_per_line);
580 if (NULL == line_buffer)
581 OJPH_ERROR(0x0300000B2,
"Unable to allocate %d bytes for line_buffer[] "
582 "for file %s", bytes_per_line, filename);
587 if( tiff_bits_per_sample != 8 && tiff_bits_per_sample != 16 )
589 OJPH_ERROR(0x0300000B3,
"\nTIFF IO is currently limited to file limited"
590 " to files with TIFFTAG_BITSPERSAMPLE=8 and TIFFTAG_BITSPERSAMPLE=16 \n"
591 "input file = %s has TIFFTAG_BITSPERSAMPLE=%d",
592 filename, tiff_bits_per_sample);
595 if( TIFFIsTiled( tiff_handle ) )
597 OJPH_ERROR(0x0300000B4,
"\nTIFF IO is currently limited to TIF files "
598 "without tiles. \nInput file %s has been detected as tiled", filename);
601 if(PHOTOMETRIC_RGB != tiff_photometric &&
602 PHOTOMETRIC_MINISBLACK != tiff_photometric )
604 OJPH_ERROR(0x0300000B5,
"\nTIFF IO is currently limited to "
605 "TIFFTAG_PHOTOMETRIC=PHOTOMETRIC_MINISBLACK=%d and "
606 "PHOTOMETRIC_RGB=%d. \nInput file %s has been detected "
607 "TIFFTAG_PHOTOMETRIC=%d",
608 PHOTOMETRIC_MINISBLACK, PHOTOMETRIC_RGB, filename, tiff_photometric);
611 if( tiff_samples_per_pixel > 4 )
613 OJPH_ERROR(0x0300000B6,
"\nTIFF IO is currently limited to "
614 "TIFFTAG_SAMPLESPERPIXEL=4 \nInput file %s has been detected with "
615 "TIFFTAG_SAMPLESPERPIXEL=%d",
616 filename, tiff_samples_per_pixel);
621 height = tiff_height;
622 num_comps = tiff_samples_per_pixel;
623 bytes_per_sample = (tiff_bits_per_sample + 7) / 8;
624 for (
ui32 comp_num = 0; comp_num < num_comps; comp_num++)
625 bit_depth[comp_num] = tiff_bits_per_sample;
629 if (tiff_planar_configuration == PLANARCONFIG_SEPARATE &&
630 bytes_per_sample == 1)
632 line_buffer_for_planar_support_uint8 =
633 (uint8_t*)calloc(width,
sizeof(uint8_t));
634 if (NULL == line_buffer_for_planar_support_uint8)
635 OJPH_ERROR(0x0300000B7,
"Unable to allocate %d bytes for "
636 "line_buffer_for_planar_support_uint8[] for file %s",
637 width *
sizeof(uint8_t), filename);
639 if (tiff_planar_configuration == PLANARCONFIG_SEPARATE &&
640 bytes_per_sample == 2)
642 line_buffer_for_planar_support_uint16 =
643 (uint16_t*)calloc(width,
sizeof(uint16_t));
644 if (NULL == line_buffer_for_planar_support_uint16)
645 OJPH_ERROR(0x0300000B8,
"Unable to allocate %d bytes for "
646 "line_buffer_for_planar_support_uint16[] for file %s",
647 width *
sizeof(uint16_t), filename);
654 void tif_in::set_bit_depth(
ui32 num_bit_depths,
ui32* bit_depth)
656 if (num_bit_depths < 1)
657 OJPH_ERROR(0x030000B9,
"one or more bit_depths must be provided");
658 ui32 last_bd_idx = 0;
659 for (
ui32 i = 0; i < 4; ++i)
661 ui32 bd = bit_depth[i < num_bit_depths ? i : last_bd_idx];
662 last_bd_idx += last_bd_idx + 1 < num_bit_depths ? 1 : 0;
664 if (bd > 32 || bd < 1)
667 "bit_depth = %d, this must be an integer from 1-32", bd);
669 this->bit_depth[i] = bd;
674 ui32 tif_in::read(
const line_buf* line,
ui32 comp_num)
676 assert(bytes_per_line != 0 && tiff_handle != 0 && comp_num < num_comps);
677 assert((
ui32)line->size >= width);
681 if (PLANARCONFIG_SEPARATE == planar_configuration && 0 == comp_num )
683 for (
unsigned short color = 0; color < num_comps; color++)
685 if (bytes_per_sample == 1)
687 TIFFReadScanline(tiff_handle, line_buffer_for_planar_support_uint8,
690 uint8_t* line_buffer_of_interleaved_components =
691 (uint8_t*)line_buffer;
692 for (
ui32 i = 0; i < width; i++, x += num_comps)
694 line_buffer_of_interleaved_components[x] =
695 line_buffer_for_planar_support_uint8[i];
698 else if (bytes_per_sample == 2)
700 TIFFReadScanline(tiff_handle, line_buffer_for_planar_support_uint16,
703 ui16* line_buffer_of_interleaved_components = (
ui16*)line_buffer;
704 for (
ui32 i = 0; i < width; i++, x += num_comps)
706 line_buffer_of_interleaved_components[x] =
707 line_buffer_for_planar_support_uint16[i];
714 else if (planar_configuration == PLANARCONFIG_CONTIG && 0 == comp_num)
716 TIFFReadScanline(tiff_handle, line_buffer, cur_line++);
718 if (cur_line >= height)
723 if (bytes_per_sample == 1)
725 const ui8* sp = (
ui8*)line_buffer + comp_num;
726 si32* dp = line->i32;
727 if (bit_depth[comp_num] == 8)
729 for (
ui32 i = width; i > 0; --i, sp += num_comps)
732 else if (bit_depth[comp_num] < 8)
735 const int bits_to_shift = 8 - (int)bit_depth[comp_num];
736 const int bit_mask = (1 << bit_depth[comp_num]) - 1;
737 for (
ui32 i = width; i > 0; --i, sp += num_comps)
738 *dp++ = (
si32) (((*sp) >> bits_to_shift) & bit_mask);
740 else if (bit_depth[comp_num] > 8)
742 const int bits_to_shift = (int)bit_depth[comp_num] - 8;
743 const int bit_mask = (1 << bit_depth[comp_num]) - 1;
744 for (
ui32 i = width; i > 0; --i, sp += num_comps)
745 *dp++ = (
si32)(((*sp) << bits_to_shift) & bit_mask);
748 else if(bytes_per_sample == 2)
750 if (bit_depth[comp_num] == 16)
752 const ui16* sp = (
ui16*)line_buffer + comp_num;
753 si32* dp = line->i32;
754 for (
ui32 i = width; i > 0; --i, sp += num_comps)
757 else if (bit_depth[comp_num] < 16)
760 const int bits_to_shift = 16 - (int)bit_depth[comp_num];
761 const int bit_mask = (1 << bit_depth[comp_num]) - 1;
762 const ui16* sp = (
ui16*)line_buffer + comp_num;
763 si32* dp = line->i32;
764 for (
ui32 i = width; i > 0; --i, sp += num_comps)
765 *dp++ = (
si32)(((*sp) >> bits_to_shift) & bit_mask);
767 else if (bit_depth[comp_num] > 16)
769 const int bits_to_shift = (int)bit_depth[comp_num] - 16;
770 const int bit_mask = (1 << bit_depth[comp_num]) - 1;
771 const ui16* sp = (
ui16*)line_buffer + comp_num;
772 si32* dp = line->i32;
773 for (
ui32 i = width; i > 0; --i, sp += num_comps)
774 *dp++ = (
si32)(((*sp) << bits_to_shift) & bit_mask);
791 void tif_out::open(
char* filename)
794 ui32 max_bitdepth = 0;
795 for (
ui32 c = 0; c < num_components; c++)
797 if (bit_depth_of_data[c] > max_bitdepth)
798 max_bitdepth = bit_depth_of_data[c];
800 if (max_bitdepth > 16)
802 OJPH_WARN(0x0300000C2,
"TIFF output is currently limited to files "
803 "with max_bitdepth = 16, the source codestream has max_bitdepth=%d"
804 ", the decoded data will be truncated to 16 bits", max_bitdepth);
806 if (num_components > 4)
808 OJPH_ERROR(0x0300000C3,
"TIFF IO is currently limited to files with "
809 "num_components=1 to 4");
812 assert(tiff_handle == NULL && buffer == NULL);
813 if ((tiff_handle = TIFFOpen(filename,
"w")) == NULL)
815 OJPH_ERROR(0x0300000C1,
"unable to open file %s for writing", filename);
818 buffer_size = width * num_components * bytes_per_sample;
819 buffer = (
ui8*)malloc(buffer_size);
826 TIFFSetField(tiff_handle, TIFFTAG_IMAGEWIDTH, width);
827 TIFFSetField(tiff_handle, TIFFTAG_IMAGELENGTH, height);
829 TIFFSetField(tiff_handle, TIFFTAG_BITSPERSAMPLE, bytes_per_sample * 8);
830 TIFFSetField(tiff_handle, TIFFTAG_SAMPLESPERPIXEL, num_components);
832 planar_configuration = PLANARCONFIG_CONTIG;
833 TIFFSetField(tiff_handle, TIFFTAG_PLANARCONFIG, planar_configuration);
835 if (num_components == 1)
837 TIFFSetField(tiff_handle, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
839 else if (num_components == 2)
841 TIFFSetField(tiff_handle, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
844 const ui16 extra_samples_description[1] = { EXTRASAMPLE_ASSOCALPHA };
845 TIFFSetField(tiff_handle, TIFFTAG_EXTRASAMPLES, (uint16_t)1,
846 &extra_samples_description);
848 else if (num_components == 3)
850 TIFFSetField(tiff_handle, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
852 else if (num_components == 4)
854 TIFFSetField(tiff_handle, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
857 const ui16 extra_samples_description[1] = { EXTRASAMPLE_ASSOCALPHA };
858 TIFFSetField(tiff_handle, TIFFTAG_EXTRASAMPLES, (uint16_t)1,
859 &extra_samples_description);
862 TIFFSetField(tiff_handle, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
863 TIFFSetField(tiff_handle, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
865 TIFFSetField(tiff_handle, TIFFTAG_ROWSPERSTRIP, height);
870 void tif_out::configure(
ui32 width,
ui32 height,
ui32 num_components,
873 assert(tiff_handle == NULL);
876 this->height = height;
877 this->num_components = num_components;
878 ui32 max_bitdepth = 0;
879 for (
ui32 c = 0; c < num_components; c++)
881 this->bit_depth_of_data[c] = bit_depth[c];
882 if (bit_depth[c] > max_bitdepth)
883 max_bitdepth = bit_depth[c];
886 bytes_per_sample = (max_bitdepth + 7) / 8;
887 if (bytes_per_sample > 2)
891 bytes_per_sample = 2;
893 samples_per_line = num_components * width;
894 bytes_per_line = bytes_per_sample * samples_per_line;
899 ui32 tif_out::write(
const line_buf* line,
ui32 comp_num)
903 if (bytes_per_sample == 1)
905 int max_val = (1 << bit_depth_of_data[comp_num]) - 1;
906 const si32* sp = line->i32;
907 ui8* dp = buffer + comp_num;
908 if (bit_depth_of_data[comp_num] == 8)
910 for (
ui32 i = width; i > 0; --i, dp += num_components)
914 val = val >= 0 ? val : 0;
915 val = val <= max_val ? val : max_val;
919 else if (bit_depth_of_data[comp_num] < 8)
921 const int bits_to_shift = 8 - (int)bit_depth_of_data[comp_num];
922 const int bit_mask = (1 << bit_depth_of_data[comp_num]) - 1;
923 for (
ui32 i = width; i > 0; --i, dp += num_components)
927 val = val >= 0 ? val : 0;
928 val = val <= max_val ? val : max_val;
931 *dp = (
ui8)((val & bit_mask) << bits_to_shift);
934 else if (bit_depth_of_data[comp_num] > 8)
936 const int bits_to_shift = (int)bit_depth_of_data[comp_num] - 8;
937 const int bit_mask = (1 << bit_depth_of_data[comp_num]) - 1;
938 for (
ui32 i = width; i > 0; --i, dp += num_components)
942 val = val >= 0 ? val : 0;
943 val = val <= max_val ? val : max_val;
946 *dp = (
ui8)((val >> bits_to_shift) & bit_mask);
951 else if(bytes_per_sample == 2)
953 int max_val = (1 << bit_depth_of_data[comp_num]) - 1;
954 const si32* sp = line->i32;
955 ui16* dp = (
ui16*)buffer + comp_num;
957 if (bit_depth_of_data[comp_num] == 16)
959 for (
ui32 i = width; i > 0; --i, dp += num_components)
963 val = val >= 0 ? val : 0;
964 val = val <= max_val ? val : max_val;
968 else if (bit_depth_of_data[comp_num] < 16)
970 const int bits_to_shift = 16 - (int)bit_depth_of_data[comp_num];
971 const int bit_mask = (1 << bit_depth_of_data[comp_num]) - 1;
972 for (
ui32 i = width; i > 0; --i, dp += num_components)
976 val = val >= 0 ? val : 0;
977 val = val <= max_val ? val : max_val;
981 *dp = (
ui16)((val & bit_mask) << bits_to_shift);
984 else if (bit_depth_of_data[comp_num] > 16)
986 const int bits_to_shift = (int)bit_depth_of_data[comp_num] - 16;
987 const int bit_mask = (1 << bit_depth_of_data[comp_num]) - 1;
988 for (
ui32 i = width; i > 0; --i, dp += num_components)
992 val = val >= 0 ? val : 0;
993 val = val <= max_val ? val : max_val;
997 *dp = (
ui16)((val >> bits_to_shift) & bit_mask);
1003 if (comp_num == num_components-1)
1005 int result = TIFFWriteScanline(tiff_handle, buffer, cur_line++);
1007 OJPH_ERROR(0x0300000C4,
"error writing to file %s", fname);
1025 fh = fopen(filename,
"rb");
1027 OJPH_ERROR(0x03000051,
"Unable to open file %s", filename);
1052 if (result !=
width[comp_num])
1062 for (
ui32 i =
width[comp_num]; i > 0; --i, ++sp)
1069 for (
ui32 i =
width[comp_num]; i > 0; --i, ++sp)
1073 return width[comp_num];
1078 ui32 num_downsamplings,
const point *subsampling)
1080 if (num_components != 1 && num_components !=3)
1081 OJPH_ERROR(0x03000071,
"yuv_in support 1 or 3 components");
1082 this->
num_com = num_components;
1084 if (num_downsamplings < 1)
1085 OJPH_ERROR(0x03000072,
"one or more downsampling must be provided");
1087 ui32 last_downsamp_idx = 0;
1088 for (
ui32 i = 0; i < num_components; ++i)
1091 last_downsamp_idx += last_downsamp_idx + 1 < num_downsamplings ? 1 : 0;
1093 this->subsampling[i] = cp_ds;
1096 for (
ui32 i = 0; i < num_components; ++i)
1106 if (num_bit_depths < 1)
1107 OJPH_ERROR(0x03000081,
"one or more bit_depths must be provided");
1108 ui32 last_bd_idx = 0;
1109 for (
ui32 i = 0; i < 3; ++i)
1112 last_bd_idx += last_bd_idx + 1 < num_bit_depths ? 1 : 0;
1114 this->bit_depth[i] = bd;
1147 fh = fopen(filename,
"wb");
1149 OJPH_ERROR(0x03000091,
"Unable to open file %s", filename);
1165 tw =
ojph_max(tw, this->comp_width[i]);
1184 for (
ui32 i = w; i > 0; --i)
1187 val = val >= 0 ? val : 0;
1188 val = val <= max_val ? val : max_val;
1198 for (
ui32 i = w; i > 0; --i)
1201 val = val >= 0 ? val : 0;
1202 val = val <= max_val ? val : max_val;
1224 fh = fopen(filename,
"rb");
1226 OJPH_ERROR(0x030000C1,
"Unable to open file %s", filename);
1239 assert(comp_num == 0);
1241 if (result !=
width)
1268 si32 val = *sp & 0xFFFFFF;
1269 val |= (val & 0x800000) ? 0xFF000000 : 0;
1278 *dp++ = (
si32)(*sp & 0xFFFFFFu);
1351 fh = fopen(filename,
"wb");
1353 OJPH_ERROR(0x03000091,
"Unable to open file %s", filename);
1363 this->width =
width;
1383 assert(comp_num == 0);
1463 OJPH_ERROR(0x0300000D1,
"Unable to open file %s", filename);
1471 OJPH_ERROR(0x0300000D2,
"Error reading file %s", filename);
1475 const ui32 dpx_magic_number = 0x53445058;
1476 if (dpx_magic_number == magic_number)
1481 else if (dpx_magic_number ==
be2le(magic_number))
1490 OJPH_ERROR(0x0300000D3,
"Error reading file %s - this does not appear "
1491 "to be a valid DPX file. It has magic number = 0x%08X. The magic "
1492 "number of a DPX file is 0x%08X.", filename, magic_number,
1501 OJPH_ERROR(0x0300000D4,
"Error reading file %s", filename);
1509 OJPH_ERROR(0x0300000D5,
"Error reading file %s", filename);
1516 OJPH_ERROR(0x0300000D6,
"Error reading file %s", filename);
1525 OJPH_ERROR(0x0300000D7,
"Error reading file %s", filename);
1532 OJPH_ERROR(0x0300000D8,
"Error reading file %s", filename);
1542 OJPH_ERROR(0x0300000D9,
"Error reading file %s", filename);
1551 OJPH_ERROR(0x0300000DA,
"Error reading file %s", filename);
1560 OJPH_ERROR(0x0300000DB,
"Error reading file %s", filename);
1569 OJPH_ERROR(0x0300000DC,
"Error reading file %s", filename);
1577 OJPH_ERROR(0x0300000DE,
"Error reading file %s", filename);
1586 OJPH_ERROR(0x0300000DF,
"Error reading file %s", filename);
1594 OJPH_ERROR(0x0300000E0,
"Error reading file %s", filename);
1602 OJPH_ERROR(0x0300000E1,
"Error reading file %s", filename);
1610 OJPH_ERROR(0x0300000E2,
"Error reading file %s", filename);
1618 OJPH_ERROR(0x0300000E3,
"Error reading file %s", filename);
1626 OJPH_ERROR(0x0300000E4,
"Error reading file %s", filename);
1636 OJPH_ERROR(0x0300000E5,
"Error reading file %s", filename);
1646 OJPH_ERROR(0x0300000E6,
"Error reading file %s", filename);
1656 OJPH_ERROR(0x0300000E7,
"Error reading file %s", filename);
1675 / number_of_samples_per_32_bit_word;
1682 OJPH_ERROR(0x0300000E8,
"Unable to allocate %d bytes for line_buffer[] "
1690 OJPH_ERROR(0x0300000E9,
"Unable to allocate %d bytes for "
1691 "line_buffer_16bit_samples[] for file %s",
1722 line_buffer_ptr[i] =
be2le(line_buffer_ptr[i]);
1730 line_buffer_ptr[i] =
be2le(line_buffer_ptr[i]);
1737 ui32 word_index = 0;
1746 (
ui16) ((line_buffer_ptr[word_index] & 0xFFC00000) >> 22);
1749 (
ui16) ((line_buffer_ptr[word_index] & 0x003FF000) >> 12);
1752 (
ui16) ((line_buffer_ptr[word_index] & 0x00000FFC) >> 2);
1766 OJPH_ERROR(0x0300000F2,
"file %s uses DPX image formats that are not "
1767 "yet supported by this software\n bitdepth_for_image_element_1 = "
1768 "%d\n num_comps=%d\npacking_for_image_element_1=%d\n "
1769 "descriptor_for_image_element_1=%d",
fname,
ui32 get_num_components()
size_t number_of_32_bit_words_per_line
void open(const char *filename)
ui16 packing_for_image_element_1
ui8 descriptor_for_image_element_1
ui32 offset_to_data_for_image_element_1
ui32 total_image_file_size_in_bytes
ui16 number_of_image_elements
ui8 bitdepth_for_image_element_1
virtual ui32 read(const line_buf *line, ui32 comp_num)
ui16 * line_buffer_16bit_samples
ui32 offset_to_image_data_in_bytes
ui16 encoding_for_image_element_1
ui32 number_of_samples_per_line
ui8 transfer_characteristic_for_image_element_1
ui8 colormetric_specification_for_image_element_1
ui32 lines_per_image_element
bool is_byte_swapping_necessary
ui32 data_sign_for_image_element_1
void pre_alloc_data(size_t num_ele, ui32 pre_size)
T * post_alloc_data(size_t num_ele, ui32 pre_size)
void open(const char *filename)
mem_fixed_allocator * alloc_p
virtual ui32 read(const line_buf *line, ui32 comp_num)
void open(char *filename)
virtual ui32 write(const line_buf *line, ui32 comp_num)
void configure(ui32 width, ui32 height, ui32 num_components, ui32 bit_depth)
void set_img_props(const size &s, ui32 bit_depth, bool is_signed)
void open(const char *filename)
virtual ui32 read(const line_buf *line, ui32 comp_num=0)
void open(char *filename)
void configure(bool is_signed, ui32 bit_depth, ui32 width)
virtual ui32 write(const line_buf *line, ui32 comp_num=0)
virtual ui32 read(const line_buf *line, ui32 comp_num)
void open(const char *filename)
void set_img_props(const size &s, ui32 num_components, ui32 num_downsampling, const point *downsampling)
void set_bit_depth(ui32 num_bit_depths, ui32 *bit_depth)
void open(char *filename)
void configure(ui32 bit_depth, ui32 num_components, ui32 *comp_width)
virtual ui32 write(const line_buf *line, ui32 comp_num)
void sse41_cvrt_32b3c_to_8ub3c(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
int ojph_fseek(FILE *stream, si64 offset, int origin)
static void eat_white_spaces(FILE *fh)
si64 ojph_ftell(FILE *stream)
void gen_cvrt_32b3c_to_16ub3c_le(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void avx2_cvrt_32b3c_to_8ub3c(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
@ X86_CPU_EXT_LEVEL_SSE41
void gen_cvrt_32b1c_to_16ub1c_le(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void sse41_cvrt_32b1c_to_16ub1c_be(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void avx2_cvrt_32b1c_to_16ub1c_be(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void sse41_cvrt_32b1c_to_8ub1c(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void avx2_cvrt_32b1c_to_8ub1c(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void gen_cvrt_32b3c_to_16ub3c_be(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
static ui16 be2le(const ui16 v)
OJPH_EXPORT int get_cpu_ext_level()
static ui32 count_leading_zeros(ui32 val)
void gen_cvrt_32b1c_to_8ub1c(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void sse41_cvrt_32b3c_to_16ub3c_be(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void gen_cvrt_32b1c_to_16ub1c_be(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
void gen_cvrt_32b3c_to_8ub3c(const line_buf *ln0, const line_buf *ln1, const line_buf *ln2, void *dp, ui32 bit_depth, ui32 count)
#define ojph_div_ceil(a, b)
#define OJPH_ERROR(t,...)