| 67 | |
| 68 | |
| 69 | void RecVolumes5::ProcessRS(RAROptions *Cmd,uint DataNum,const byte *Data,uint MaxRead,bool Encode) |
| 70 | { |
| 71 | /* |
| 72 | RSCoder16 RS; |
| 73 | RS.Init(DataCount,RecCount,Encode ? NULL:ValidFlags); |
| 74 | uint Count=Encode ? RecCount : MissingVolumes; |
| 75 | for (uint I=0;I<Count;I++) |
| 76 | RS.UpdateECC(DataNum, I, Data, Buf+I*RecBufferSize, MaxRead); |
| 77 | */ |
| 78 | |
| 79 | uint ThreadNumber=MaxUserThreads; |
| 80 | |
| 81 | const uint MinThreadBlock=0x1000; |
| 82 | ThreadNumber=Min(ThreadNumber,MaxRead/MinThreadBlock); |
| 83 | |
| 84 | if (ThreadNumber<1) |
| 85 | ThreadNumber=1; |
| 86 | uint ThreadDataSize=MaxRead/ThreadNumber; |
| 87 | ThreadDataSize+=(ThreadDataSize&1); // Must be even for 16-bit RS coder. |
| 88 | #ifdef USE_SSE |
| 89 | ThreadDataSize=ALIGN_VALUE(ThreadDataSize,SSE_ALIGNMENT); // Alignment for SSE operations. |
| 90 | #endif |
| 91 | if (ThreadDataSize<MinThreadBlock) |
| 92 | ThreadDataSize=MinThreadBlock; |
| 93 | |
| 94 | for (size_t I=0,CurPos=0;I<ThreadNumber && CurPos<MaxRead;I++) |
| 95 | { |
| 96 | RecRSThreadData *td=ThreadData+I; |
| 97 | if (td->RS==NULL) |
| 98 | { |
| 99 | td->RS=new RSCoder16; |
| 100 | td->RS->Init(DataCount,RecCount,Encode ? NULL:ValidFlags); |
| 101 | } |
| 102 | td->DataNum=DataNum; |
| 103 | td->Data=Data; |
| 104 | td->Encode=Encode; |
| 105 | td->StartPos=CurPos; |
| 106 | |
| 107 | size_t EndPos=CurPos+ThreadDataSize; |
| 108 | if (EndPos>MaxRead || I==ThreadNumber-1) |
| 109 | EndPos=MaxRead; |
| 110 | |
| 111 | td->Size=EndPos-CurPos; |
| 112 | |
| 113 | CurPos=EndPos; |
| 114 | |
| 115 | #ifdef RAR_SMP |
| 116 | if (ThreadNumber>1) |
| 117 | RecThreadPool->AddTask(RecThreadRS,(void*)td); |
| 118 | else |
| 119 | ProcessAreaRS(td); |
| 120 | #else |
| 121 | ProcessAreaRS(td); |
| 122 | #endif |
| 123 | } |
| 124 | #ifdef RAR_SMP |
| 125 | RecThreadPool->WaitDone(); |
| 126 | #endif // RAR_SMP |