added soft dec support
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 13 Sep 2016 02:51:13 +0000 (02:51 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 13 Sep 2016 02:51:13 +0000 (02:51 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2859 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/ldpc_enc.c

index a371c59ced0b55a5cb5b741ce7246d467b0dceda..f648860336782b10a0b907c60308aab16e52f0ed 100644 (file)
@@ -41,9 +41,11 @@ int main(int argc, char *argv[])
     unsigned char ibits[NUMBERROWSHCOLS];
     unsigned char pbits[NUMBERPARITYBITS];
     FILE         *fin, *fout;
+    int           sd, i;
+    double        sdout[NUMBERROWSHCOLS+NUMBERPARITYBITS];
 
-    if (argc < 2) {
-        fprintf(stderr, "usage: %s InputOneBytePerBit OuputOneBytePerBit\n", argv[0]);
+    if (argc < 3) {
+        fprintf(stderr, "usage: %s InputOneBytePerBit OuputFile [--sd]\n", argv[0]);
         exit(0);
     }
 
@@ -60,13 +62,27 @@ int main(int argc, char *argv[])
                 argv[2], strerror(errno));
         exit(1);
     }
+    
+    sd = 0;
+    if (argc == 4) 
+        if (strcmp(argv[3], "--sd") == 0)
+            sd = 1;
 
     while (fread(ibits, sizeof(char), NUMBERROWSHCOLS, fin) == NUMBERROWSHCOLS) {
 
         encode(ibits, pbits);  
         
-        fwrite(ibits, sizeof(char), NUMBERROWSHCOLS, fout); 
-        fwrite(pbits, sizeof(char), NUMBERPARITYBITS, fout); 
+        if (sd) {
+            for (i=0; i<NUMBERROWSHCOLS; i++)
+                sdout[i] = 1.0 - 2.0 * ibits[i];
+            for (i=0; i<NUMBERPARITYBITS; i++)
+                sdout[i+NUMBERROWSHCOLS] = 1.0 - 2.0 * pbits[i];
+            fwrite(sdout, sizeof(double), NUMBERROWSHCOLS+NUMBERPARITYBITS, fout); 
+        }
+        else {
+            fwrite(ibits, sizeof(char), NUMBERROWSHCOLS, fout); 
+            fwrite(pbits, sizeof(char), NUMBERPARITYBITS, fout); 
+        }
     }
 
     fclose(fin);