Lines Matching refs:ec

121 {  ecc_closure *ec = (ecc_closure*)data;  in ecc_cleanup()  local
129 if(ec->abortImmediately) in ecc_cleanup()
133 g_mutex_lock(ec->lock); in ecc_cleanup()
134 g_cond_broadcast(ec->ioCond); in ecc_cleanup()
135 g_mutex_unlock(ec->lock); in ecc_cleanup()
140 { g_thread_join(ec->thread[i]); in ecc_cleanup()
146 { if(ec->earlyTermination) in ecc_cleanup()
147 SetLabelText(GTK_LABEL(ec->wl->encFootline), in ecc_cleanup()
161 if(ec->image) CloseImage(ec->image); in ecc_cleanup()
162 if(ec->lock) in ecc_cleanup()
163 { g_mutex_clear(ec->lock); in ecc_cleanup()
164 g_free(ec->lock); in ecc_cleanup()
166 if(ec->ioCond) in ecc_cleanup()
167 { g_cond_clear(ec->ioCond); in ecc_cleanup()
168 g_free(ec->ioCond); in ecc_cleanup()
170 if(ec->eh) g_free(ec->eh); in ecc_cleanup()
171 if(ec->eh_le) g_free(ec->eh_le); in ecc_cleanup()
172 if(ec->rt) FreeReedSolomonTables(ec->rt); in ecc_cleanup()
173 if(ec->gt) FreeGaloisTables(ec->gt); in ecc_cleanup()
174 if(ec->paritybase) g_free(ec->paritybase); in ecc_cleanup()
175 if(ec->msg) g_free(ec->msg); in ecc_cleanup()
176 if(ec->avgTimer) g_timer_destroy(ec->avgTimer); in ecc_cleanup()
177 if(ec->contTimer) g_timer_destroy(ec->contTimer); in ecc_cleanup()
178 if(ec->firstCrc) g_free(ec->firstCrc); in ecc_cleanup()
182 { if(ec->lay) in ecc_cleanup()
183 { for(i=0; i<ec->lay->ndata-1; i++) in ecc_cleanup()
184 { if(ec->ioMmapBase && ec->ioMmapBase[i]) in ecc_cleanup()
185 { if(munmap(ec->ioMmapBase[i], ec->ioMmapSize[i]) == -1) in ecc_cleanup()
187 ec->ioData[i] = NULL; in ecc_cleanup()
188 ec->ioMmapBase[i] = NULL; in ecc_cleanup()
191 if(ec->encoderMmapBase && ec->encoderMmapBase[i]) in ecc_cleanup()
192 { if(munmap(ec->encoderMmapBase[i], ec->encoderMmapSize[i]) == -1) in ecc_cleanup()
194 ec->encoderData[i] = NULL; in ecc_cleanup()
195 ec->encoderMmapBase[i] = NULL; in ecc_cleanup()
199 g_free(ec->ioMmapBase); in ecc_cleanup()
200 g_free(ec->ioMmapSize); in ecc_cleanup()
201 g_free(ec->encoderMmapBase); in ecc_cleanup()
202 g_free(ec->encoderMmapSize); in ecc_cleanup()
206 if(ec->lay) g_free(ec->lay); in ecc_cleanup()
209 { if(ec->slice && ec->slice[i]) in ecc_cleanup()
210 g_free(ec->slice[i]); in ecc_cleanup()
211 if(ec->ioData && ec->ioData[i]) in ecc_cleanup()
212 g_free(ec->ioData[i]); in ecc_cleanup()
213 if(ec->encoderData && ec->encoderData[i]) in ecc_cleanup()
214 g_free(ec->encoderData[i]); in ecc_cleanup()
217 if(ec->slice) g_free(ec->slice); in ecc_cleanup()
218 if(ec->ioData) g_free(ec->ioData); in ecc_cleanup()
219 if(ec->encoderData) g_free(ec->encoderData); in ecc_cleanup()
220 g_free(ec); in ecc_cleanup()
234 static void abort_encoding(ecc_closure *ec, int truncate) in abort_encoding() argument
235 { RS03Widgets *wl = ec->wl; in abort_encoding()
237 if(truncate && ec->lay) in abort_encoding()
240 else if(!LargeTruncate(ec->image->file, (gint64)(2048*ec->lay->dataSectors))) in abort_encoding()
255 ec->earlyTermination = FALSE; /* suppress respective error message */ in abort_encoding()
257 ecc_cleanup((gpointer)ec); in abort_encoding()
265 static void remove_old_ecc(ecc_closure *ec) in remove_old_ecc() argument
276 { SetLabelText(GTK_LABEL(ec->wl->encFootline), in remove_old_ecc()
279 ec->earlyTermination = FALSE; in remove_old_ecc()
280 ecc_cleanup((gpointer)ec); in remove_old_ecc()
288 if(ec->image->eccHeader) in remove_old_ecc()
289 { gint64 data_sectors = uchar_to_gint64(ec->image->eccHeader->sectors); in remove_old_ecc()
301 abort_encoding(ec, FALSE); in remove_old_ecc()
303 if(ec->image->eccHeader->inLast != 2048) in remove_old_ecc()
305 data_bytes = (gint64)(2048*(data_sectors-1)+ec->image->eccHeader->inLast); in remove_old_ecc()
306 ec->image->sectorSize = data_sectors; in remove_old_ecc()
307 ec->image->inLast = ec->image->eccHeader->inLast; in remove_old_ecc()
312 ec->image->sectorSize = data_sectors; in remove_old_ecc()
313 ec->image->inLast = 2048; in remove_old_ecc()
316 g_free(ec->image->eccHeader); /* get rid of old header! */ in remove_old_ecc()
317 ec->image->eccHeader = NULL; in remove_old_ecc()
319 if(!LargeTruncate(ec->image->file, data_bytes)) in remove_old_ecc()
323 if(ec->image->inLast == 2048) in remove_old_ecc()
324 PrintLog(_(": %lld medium sectors.\n"), ec->image->sectorSize); in remove_old_ecc()
326 ec->image->sectorSize-1, ec->image->inLast); in remove_old_ecc()
334 static void prepare_header(ecc_closure *ec) in prepare_header() argument
336 RS03Layout *lay = ec->lay; in prepare_header()
337 Image *image = ec->image; in prepare_header()
339 ec->eh = g_malloc0(sizeof(EccHeader)); in prepare_header()
340 ec->eh_le = g_malloc0(sizeof(EccHeader)); in prepare_header()
341 eh = lay->eh = ec->eh; in prepare_header()
360 memcpy(ec->eh_le, eh, sizeof(EccHeader)); in prepare_header()
363 SwapEccHeaderBytes(ec->eh_le); in prepare_header()
364 ec->eh_le->selfCRC = 0x47504c00; in prepare_header()
368 ec->eh_le->selfCRC = Crc32((unsigned char*)ec->eh_le, 4096); in prepare_header()
376 static void expand_image(ecc_closure *ec) in expand_image() argument
377 { RS03Layout *lay = ec->lay; in expand_image()
378 Image *image = ec->image; in expand_image()
423 prepare_header(ec); in expand_image()
424 n = LargeWrite(ecc_out, ec->eh_le, 4096); in expand_image()
472 abort_encoding(ec, TRUE); in expand_image()
487 SetProgress(ec->wl->encPBar1, percent, 100); in expand_image()
497 SetProgress(ec->wl->encPBar1, 100, 100); in expand_image()
504 static void prepare_crc_block(ecc_closure *ec, CrcBlock *cb) in prepare_crc_block() argument
505 { RS03Layout *lay = ec->lay; in prepare_crc_block()
506 Image *image = ec->image; in prepare_crc_block()
540 static void flip_buffers(ecc_closure *ec) in flip_buffers() argument
545 ctmp = ec->ioCrc; ec->ioCrc = ec->encoderCrc; ec->encoderCrc = ctmp; in flip_buffers()
546 dtmp = ec->ioData; ec->ioData = ec->encoderData; ec->encoderData = dtmp; in flip_buffers()
547 dtmp = ec->ioMmapBase; ec->ioMmapBase = ec->encoderMmapBase; ec->encoderMmapBase = dtmp; in flip_buffers()
548 etmp = ec->ioMmapSize; ec->ioMmapSize = ec->encoderMmapSize; ec->encoderMmapSize = etmp; in flip_buffers()
551 static void read_next_chunk(ecc_closure *ec, guint64 chunk) in read_next_chunk() argument
552 { RS03Layout *lay = ec->lay; in read_next_chunk()
557 ec->ioChunk = chunk; in read_next_chunk()
558 if(ec->ioChunk+ec->chunkSize < lay->sectorsPerLayer) in read_next_chunk()
559 ec->ioLayerSectors = ec->chunkSize; in read_next_chunk()
561 { ec->ioLayerSectors = lay->sectorsPerLayer-ec->ioChunk; in read_next_chunk()
562 verbose("NOTE: actual_layer_sectors %d\n", ec->ioLayerSectors); in read_next_chunk()
565 memset(ec->ioCrc, 0, ec->chunkBytes); in read_next_chunk()
570 { guint64 first_sec = layer*lay->sectorsPerLayer+ec->ioChunk; in read_next_chunk()
579 { ec->abortImmediately = TRUE; in read_next_chunk()
580 abort_encoding(ec, TRUE); in read_next_chunk()
588 { if(ec->ioMmapBase[layer]) in read_next_chunk()
589 { if(munmap(ec->ioMmapBase[layer], ec->ioMmapSize[layer]) == -1) in read_next_chunk()
591 ec->ioMmapBase[layer] = NULL; in read_next_chunk()
592 ec->ioData[layer] = NULL; in read_next_chunk()
604 && RS03SectorIndex(lay, layer, ec->ioChunk+ec->ioLayerSectors) in read_next_chunk()
606 { guint64 n_sectors = ec->ioLayerSectors; in read_next_chunk()
608 if(!ec->ioData[layer]) in read_next_chunk()
609 ec->ioData[layer] = g_malloc(ec->chunkBytes+2048); in read_next_chunk()
611 if(ec->ioChunk+ec->ioLayerSectors < lay->sectorsPerLayer) in read_next_chunk()
614 RS03ReadSectors(ec->image, lay, ec->ioData[layer], in read_next_chunk()
615 layer, ec->ioChunk, n_sectors, RS03_READ_DATA); in read_next_chunk()
619 page_offset = 2048*RS03SectorIndex(lay, layer, ec->ioChunk); in read_next_chunk()
620 shift = page_offset % ec->pageSize; in read_next_chunk()
623 if(ec->ioLayerSectors == ec->chunkSize) in read_next_chunk()
624 ec->ioMmapSize[layer] = 2048*ec->ioLayerSectors + 2048 + shift; in read_next_chunk()
625 else ec->ioMmapSize[layer] = 2048*ec->ioLayerSectors + shift; in read_next_chunk()
627 ec->ioMmapBase[layer] = mmap(NULL, ec->ioMmapSize[layer], in read_next_chunk()
629 ec->image->file->fileHandle, in read_next_chunk()
631 if(ec->ioMmapBase[layer] == MAP_FAILED) in read_next_chunk()
634 ec->ioData[layer] = ec->ioMmapBase[layer]+shift; in read_next_chunk()
640 RS03ReadSectors(ec->image, lay, ec->ioData[layer], in read_next_chunk()
641 layer, ec->ioChunk, ec->ioLayerSectors, RS03_READ_DATA); in read_next_chunk()
644 err = CheckForMissingSectors(ec->ioData[layer], first_sec, in read_next_chunk()
646 ec->ioLayerSectors, &error_sec); in read_next_chunk()
651 { LargeClose(ec->image->eccFile); in read_next_chunk()
652 ec->image->eccFile = ec->writeHandle = NULL; in read_next_chunk()
656 { LargeTruncate(ec->writeHandle, (gint64)(2048*lay->dataSectors)); in read_next_chunk()
659 ec->abortImmediately = TRUE; in read_next_chunk()
679 if(ec->ioChunk+ec->ioLayerSectors < lay->sectorsPerLayer) in read_next_chunk()
681 RS03ReadSectors(ec->image, lay, ec->ioData[layer]+ec->chunkBytes, in read_next_chunk()
682 layer, ec->ioChunk+ec->ioLayerSectors, 1, RS03_READ_DATA); in read_next_chunk()
688 static void flush_crc(ecc_closure *ec, LargeFile *file_out) in flush_crc() argument
689 { RS03Layout *lay = ec->lay; in flush_crc()
696 crc_sect = 2048*(ec->encoderChunk+lay->firstCrcPos); in flush_crc()
698 { ec->abortImmediately = TRUE; in flush_crc()
702 for(i=0; i<ec->encoderLayerSectors; i++) in flush_crc()
703 if(LargeWrite(file_out, ec->encoderCrc+512*i, 2048) != 2048) in flush_crc()
704 { ec->abortImmediately = TRUE; in flush_crc()
709 static void flush_parity(ecc_closure *ec, LargeFile *file_out) in flush_parity() argument
710 { RS03Layout *lay = ec->lay; in flush_parity()
720 for(i=0; i<ec->flushLayerSectors; i++, idx+=2048) in flush_parity()
721 { gint64 s = RS03SectorIndex(lay, k+lay->ndata, ec->flushChunk+i); in flush_parity()
724 { ec->abortImmediately = TRUE; in flush_parity()
727 if(LargeWrite(file_out, ec->slice[k]+idx, 2048) != 2048) in flush_parity()
728 { ec->abortImmediately = TRUE; in flush_parity()
736 static gpointer io_thread(ecc_closure *ec) in io_thread() argument
737 { RS03Layout *lay = ec->lay; in io_thread()
738 LargeFile *file_out = ec->writeHandle; in io_thread()
742 guint64 n_parity_bytes = (guint64)nroots_aligned * ec->chunkBytes; in io_thread()
752 ec->paritybase = g_malloc(n_parity_bytes+16); /* output buffer */ in io_thread()
753 ec->parity = ec->paritybase + (16- ((unsigned long)ec->paritybase & 15)); in io_thread()
760 ec->ioData = g_malloc0(256*sizeof(unsigned char*)); in io_thread()
761 ec->encoderData = g_malloc0(256*sizeof(unsigned char*)); in io_thread()
764 { ec->ioMmapBase = g_malloc0(256*sizeof(unsigned char*)); in io_thread()
765 ec->encoderMmapBase = g_malloc0(256*sizeof(unsigned char*)); in io_thread()
766 ec->ioMmapSize = g_malloc0(256*sizeof(guint64)); in io_thread()
767 ec->encoderMmapSize = g_malloc0(256*sizeof(guint64)); in io_thread()
768 ec->ioData[ndata-1] = g_malloc(ec->chunkBytes); in io_thread()
769 ec->encoderData[ndata-1] = g_malloc(ec->chunkBytes); in io_thread()
774 { ec->ioData[i] = g_malloc(ec->chunkBytes+2048); in io_thread()
775 ec->encoderData[i] = g_malloc(ec->chunkBytes+2048); in io_thread()
779 ec->ioCrc = (guint32*)ec->ioData[ndata-1]; /* CRC layer */ in io_thread()
780 ec->encoderCrc = (guint32*)ec->encoderData[ndata-1]; in io_thread()
781 ec->firstCrc = g_malloc(256*sizeof(guint32)); in io_thread()
785 ec->slice = g_malloc0(256*sizeof(unsigned char*)); in io_thread()
787 ec->slice[i] = g_malloc(ec->chunkBytes); in io_thread()
790 (long long)((2*ec->chunkBytes*ndata)/1024), in io_thread()
792 (long long)((ec->chunkBytes*nroots)/1024), in io_thread()
793 (long long)((2*ec->chunkBytes*ndata+n_parity_bytes+ec->chunkBytes*nroots)/(1024*1024))); in io_thread()
802 verbose("NOTE: ndata = %d, chunk size = %d\n", ndata, ec->chunkSize); in io_thread()
805 for(chunk=0; chunk<lay->sectorsPerLayer; chunk+=ec->chunkSize) in io_thread()
813 { read_next_chunk(ec, chunk); in io_thread()
822 flush_crc(ec, file_out); in io_thread()
824 flip_buffers(ec); in io_thread()
826 g_mutex_lock(ec->lock); in io_thread()
827 ec->buffersToEncode = ec->ioLayerSectors; in io_thread()
828 ec->encoderLayerSectors = ec->ioLayerSectors; in io_thread()
829 ec->nextBufferIndex = 0; in io_thread()
830 ec->encoderChunk = ec->ioChunk; in io_thread()
831 ec->slicesFree = FALSE; in io_thread()
832 g_cond_broadcast(ec->ioCond); in io_thread()
833 g_mutex_unlock(ec->lock); in io_thread()
839 flush_parity(ec, file_out); in io_thread()
842 g_mutex_lock(ec->lock); in io_thread()
843 ec->slicesFree = TRUE; /* we have saved the slices; go ahead */ in io_thread()
844 g_cond_broadcast(ec->ioCond); in io_thread()
845 g_mutex_unlock(ec->lock); in io_thread()
849 read_next_chunk(ec, chunk); in io_thread()
854 ec->flushLayerSectors = ec->encoderLayerSectors; in io_thread()
855 ec->flushChunk = ec->encoderChunk; in io_thread()
860 g_mutex_lock(ec->lock); in io_thread()
861 cpu_bound = ec->buffersToEncode; in io_thread()
862 while(ec->buffersToEncode) in io_thread()
864 g_cond_wait(ec->ioCond, ec->lock); in io_thread()
866 g_mutex_unlock(ec->lock); in io_thread()
870 verbose("IO: chunk %d finished\n", ec->ioChunk); in io_thread()
874 { SetLabelText(GTK_LABEL(ec->wl->encBottleneck), _("CPU bound")); in io_thread()
875 ec->cpuBound++; in io_thread()
878 { SetLabelText(GTK_LABEL(ec->wl->encBottleneck), _("I/O bound")); in io_thread()
879 ec->ioBound++; in io_thread()
886 flush_crc(ec, file_out); in io_thread()
887 flush_parity(ec, file_out); in io_thread()
888 flip_buffers(ec); in io_thread()
890 g_mutex_lock(ec->lock); in io_thread()
891 ec->buffersToEncode = ec->ioLayerSectors; in io_thread()
892 ec->encoderLayerSectors = ec->ioLayerSectors; in io_thread()
893 ec->nextBufferIndex = 0; in io_thread()
894 ec->encoderChunk = ec->ioChunk; in io_thread()
895 ec->slicesFree = FALSE; in io_thread()
896 g_cond_broadcast(ec->ioCond); in io_thread()
897 g_mutex_unlock(ec->lock); in io_thread()
901 g_mutex_lock(ec->lock); in io_thread()
902 ec->slicesFree = TRUE; /* we have saved the slices; go ahead */ in io_thread()
903 g_cond_broadcast(ec->ioCond); in io_thread()
904 while(ec->buffersToEncode) in io_thread()
906 g_cond_wait(ec->ioCond, ec->lock); in io_thread()
908 g_mutex_unlock(ec->lock); in io_thread()
912 ec->flushLayerSectors = ec->encoderLayerSectors; in io_thread()
913 ec->flushChunk = ec->encoderChunk; in io_thread()
915 flush_crc(ec, file_out); in io_thread()
916 flush_parity(ec, file_out); in io_thread()
923 static gpointer encoder_thread(ecc_closure *ec) in encoder_thread() argument
928 int nroots = ec->lay->nroots; in encoder_thread()
929 int ndata = ec->lay->ndata; in encoder_thread()
942 g_mutex_lock(ec->lock); in encoder_thread()
944 if(ec->thread[i] == self) in encoder_thread()
946 g_mutex_unlock(ec->lock); in encoder_thread()
958 shift[0] = ec->rt->shiftInit; in encoder_thread()
968 g_mutex_lock(ec->lock); in encoder_thread()
969 while( ec->sectorsToEncode in encoder_thread()
970 && !ec->abortImmediately in encoder_thread()
971 && ec->nextBufferIndex >= ec->encoderLayerSectors) in encoder_thread()
973 g_cond_wait(ec->ioCond, ec->lock); in encoder_thread()
975 layer_offset = ec->nextBufferIndex; in encoder_thread()
982 if(!ec->sectorsToEncode || ec->abortImmediately) in encoder_thread()
983 { g_mutex_unlock(ec->lock); in encoder_thread()
987 ec->nextBufferIndex +=enc_size; in encoder_thread()
988 g_mutex_unlock(ec->lock); in encoder_thread()
993 { unsigned char *data = ec->encoderData[layer] + 2048*layer_offset; in encoder_thread()
994 unsigned char *parity = ec->parity + 2048*nroots_aligned*layer_offset; in encoder_thread()
1001 if(!ec->encoderChunk && !layer_offset) in encoder_thread()
1002 { ec->firstCrc[layer] = Crc32(data, 2048); in encoder_thread()
1007 if(ec->encoderChunk+layer_offset < ec->lay->sectorsPerLayer-1) in encoder_thread()
1008 { ec->encoderCrc[512*layer_offset+layer] = Crc32(data+2048, 2048); in encoder_thread()
1011 { ec->encoderCrc[512*layer_offset+layer] = ec->firstCrc[layer]; in encoder_thread()
1016 prepare_crc_block(ec, (CrcBlock*)&ec->encoderCrc[512*layer_offset]); in encoder_thread()
1024 EncodeNextLayer(ec->rt, data, parity, 2048*enc_size, shift[layer]); in encoder_thread()
1032 g_mutex_lock(ec->lock); in encoder_thread()
1033 while(!ec->slicesFree && !ec->abortImmediately) in encoder_thread()
1034 { g_cond_wait(ec->ioCond, ec->lock); in encoder_thread()
1036 g_mutex_unlock(ec->lock); in encoder_thread()
1038 if(ec->abortImmediately) in encoder_thread()
1042 par_ptr = ec->parity + 2048*nroots_aligned*layer_offset; in encoder_thread()
1055 unsigned char *slice = &ec->slice[k][idx]; in encoder_thread()
1071 g_mutex_lock(ec->lock); in encoder_thread()
1072 ec->progress+=enc_size; in encoder_thread()
1073 percent = (1000*ec->progress)/ec->lay->sectorsPerLayer; in encoder_thread()
1074 if(ec->lastPercent != percent) in encoder_thread()
1076 ec->lastPercent = percent; in encoder_thread()
1077 g_mutex_unlock(ec->lock); in encoder_thread()
1082 elapsed=g_timer_elapsed(ec->contTimer, &ignore); in encoder_thread()
1084 { gdouble mbs = ((double)ndata*(ec->progress-ec->lastProgress))/(512.0*elapsed); in encoder_thread()
1085 SetLabelText(GTK_LABEL(ec->wl->encPerformance), in encoder_thread()
1087 ec->lastProgress = ec->progress; in encoder_thread()
1088 g_timer_reset(ec->contTimer); in encoder_thread()
1090 SetProgress(ec->wl->encPBar2, percent, 1000); in encoder_thread()
1094 else g_mutex_unlock(ec->lock); in encoder_thread()
1099 my_number, layer_offset, ec->encoderChunk); in encoder_thread()
1100 g_mutex_lock(ec->lock); in encoder_thread()
1101 ec->sectorsToEncode-=enc_size*ndata; in encoder_thread()
1102 ec->buffersToEncode-=enc_size; in encoder_thread()
1103 if(!ec->buffersToEncode) in encoder_thread()
1104 { g_cond_broadcast(ec->ioCond); in encoder_thread()
1108 g_mutex_unlock(ec->lock); in encoder_thread()
1112 static void create_reed_solomon(ecc_closure *ec) in create_reed_solomon() argument
1113 { int nroots = ec->lay->nroots; in create_reed_solomon()
1114 int ndata = ec->lay->ndata; in create_reed_solomon()
1122 { ShowWidget(ec->wl->encPBar2); in create_reed_solomon()
1123 ShowWidget(ec->wl->encLabel2); in create_reed_solomon()
1124 ShowWidget(ec->wl->encLabel3); in create_reed_solomon()
1125 ShowWidget(ec->wl->encLabel4); in create_reed_solomon()
1126 ShowWidget(ec->wl->encLabel5); in create_reed_solomon()
1127 ShowWidget(ec->wl->encThreads); in create_reed_solomon()
1128 ShowWidget(ec->wl->encPerformance); in create_reed_solomon()
1129 ShowWidget(ec->wl->encBottleneck); in create_reed_solomon()
1133 SetLabelText(GTK_LABEL(ec->wl->encThreads), in create_reed_solomon()
1136 SetLabelText(GTK_LABEL(ec->wl->encPerformance), ""); in create_reed_solomon()
1137 SetLabelText(GTK_LABEL(ec->wl->encBottleneck), ""); in create_reed_solomon()
1155 ec->chunkBytes = 2048*Closure->prefetchSectors; in create_reed_solomon()
1156 ec->chunkSize = Closure->prefetchSectors; in create_reed_solomon()
1158 ec->pageSize = sysconf(_SC_PAGE_SIZE); in create_reed_solomon()
1162 ec->lock = g_malloc(sizeof(GMutex)); g_mutex_init(ec->lock); in create_reed_solomon()
1163 ec->ioCond = g_malloc(sizeof(GCond)); g_cond_init(ec->ioCond); in create_reed_solomon()
1164 ec->sectorsToEncode = ndata*ec->lay->sectorsPerLayer; in create_reed_solomon()
1166 ec->writeHandle = ec->image->eccFile; in create_reed_solomon()
1168 ec->writeHandle = ec->image->file; in create_reed_solomon()
1169 ec->lastPercent = -1; in create_reed_solomon()
1170 ec->cpuBound = ec->ioBound = 0; in create_reed_solomon()
1174 ec->gt = CreateGaloisTables(RS_GENERATOR_POLY); in create_reed_solomon()
1175 ec->rt = CreateReedSolomonTables(ec->gt, RS_FIRST_ROOT, RS_PRIM_ELEM, nroots); in create_reed_solomon()
1179 g_mutex_lock(ec->lock); /* ec->thread[i] = ... may produce race condition */ in create_reed_solomon()
1184 ec->thread[i] = g_thread_try_new("encoder", (GThreadFunc)encoder_thread, (gpointer)ec, &err); in create_reed_solomon()
1185 if(!ec->thread[i]) in create_reed_solomon()
1186 { g_mutex_unlock(ec->lock); in create_reed_solomon()
1187 ec->abortImmediately = TRUE; in create_reed_solomon()
1191 g_mutex_unlock(ec->lock); in create_reed_solomon()
1196 io_thread(ec); in create_reed_solomon()
1201 { g_thread_join(ec->thread[i]); in create_reed_solomon()
1217 ecc_closure *ec = g_malloc0(sizeof(ecc_closure)); in RS03Create() local
1224 ec->self = method; in RS03Create()
1225 ec->wl = wl; in RS03Create()
1226 ec->earlyTermination = TRUE; in RS03Create()
1228 RegisterCleanup(_("Error correction data creation aborted"), ecc_cleanup, ec); in RS03Create()
1249 ec->image = image; in RS03Create()
1258 remove_old_ecc(ec); in RS03Create()
1274 lay = ec->lay = CalcRS03Layout(image, Closure->eccTarget); in RS03Create()
1280 …{ ec->msg = g_strdup_printf(_("Encoding with Method RS03: %lld MiB data, %lld MiB ecc (%d roots; … in RS03Create()
1286 ec->msg); in RS03Create()
1290 ec->msg); in RS03Create()
1298 ec->msg = g_strdup_printf(_("Augmenting image with Method RS03 [%d threads, %s, %s I/O]:\n" in RS03Create()
1303ec->msg = g_strdup_printf(_("Creating the error correction file with Method RS03 [%d threads, %s, … in RS03Create()
1308 PrintLog("%s\n",ec->msg); in RS03Create()
1328 abort_encoding(ec, FALSE); in RS03Create()
1333 expand_image(ec); in RS03Create()
1337 ec->avgTimer = g_timer_new(); in RS03Create()
1338 ec->contTimer = g_timer_new(); in RS03Create()
1339 create_reed_solomon(ec); in RS03Create()
1340 g_timer_stop(ec->avgTimer); in RS03Create()
1341 g_timer_stop(ec->contTimer); in RS03Create()
1356 elapsed=g_timer_elapsed(ec->avgTimer, &ignore); in RS03Create()
1362 SetLabelText(GTK_LABEL(ec->wl->encBottleneck), in RS03Create()
1364 ec->cpuBound, ec->ioBound); in RS03Create()
1385 ec->earlyTermination = FALSE; in RS03Create()
1386 ecc_cleanup((gpointer)ec); in RS03Create()