00001 00002 /*===================================================================== 00003 ======= COPYRIGHT NOTICE ======= 00004 Copyright (C) 1996, Carnegie Mellon University, Cambridge University, 00005 Ronald Rosenfeld and Philip Clarkson. 00006 00007 All rights reserved. 00008 00009 This software is made available for research purposes only. It may be 00010 redistributed freely for this purpose, in full or in part, provided 00011 that this entire copyright notice is included on any copies of this 00012 software and applications and derivations thereof. 00013 00014 This software is provided on an "as is" basis, without warranty of any 00015 kind, either expressed or implied, as to any matter including, but not 00016 limited to warranty of fitness of purpose, or merchantability, or 00017 results obtained from use of this software. 00018 ======================================================================*/ 00019 00020 #include <math.h> 00021 #include <stdio.h> 00022 00023 /* 00024 * PWP: coding change. Numbers were previously coded base-3. 00025 * Now base-4, since (int) pow(4,i) == 1 << (2*i) 00026 */ 00027 00028 void decode_bo_case(int bo_case, 00029 int context_length, 00030 FILE *annotation_fp) { 00031 00032 int i; 00033 int current_bo_case; 00034 00035 for(i=context_length-1;i>=0;i--) { 00036 00037 fprintf(annotation_fp,"%d",i+2); 00038 00039 current_bo_case = bo_case / (1 << (2*i)); 00040 00041 if (current_bo_case == 1) { 00042 fprintf(annotation_fp,"-"); 00043 } 00044 else { 00045 if (current_bo_case == 2) { 00046 fprintf(annotation_fp,"x"); 00047 } 00048 else { 00049 i=-2; 00050 } 00051 } 00052 bo_case -= (current_bo_case * (1 << (2*i))); 00053 00054 } 00055 00056 if (i>-2) { 00057 fprintf(annotation_fp,"1"); 00058 } 00059 00060 fprintf(annotation_fp,"\n"); 00061 00062 }