]> sigrok.org Git - libsigrok.git/blobdiff - src/transform/scale.c
license: remove FSF postal address from boiler plate license text
[libsigrok.git] / src / transform / scale.c
index 47937be9e8985dfa5a84f5431e8da453cce88e4b..c7c60dd2b456ac5bfa317bf76592a28fc2e84c38 100644 (file)
@@ -14,8 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
@@ -49,37 +48,17 @@ static int receive(const struct sr_transform *t,
                struct sr_datafeed_packet **packet_out)
 {
        struct context *ctx;
-       const struct sr_datafeed_analog_old *analog_old;
-       const struct sr_datafeed_analog2 *analog2;
-       struct sr_channel *ch;
-       GSList *l;
-       float *fdata;
-       float factor;
-       int i, num_channels, c;
+       const struct sr_datafeed_analog *analog;
 
        if (!t || !t->sdi || !packet_in || !packet_out)
                return SR_ERR_ARG;
        ctx = t->priv;
 
        switch (packet_in->type) {
-       case SR_DF_ANALOG_OLD:
-               analog_old = packet_in->payload;
-               fdata = (float *)analog_old->data;
-               num_channels = g_slist_length(analog_old->channels);
-               factor = (float) ctx->factor.p / ctx->factor.q;
-               for (i = 0; i < analog_old->num_samples; i++) {
-                       /* For now scale all values in all channels. */
-                       for (l = analog_old->channels, c = 0; l; l = l->next, c++) {
-                               ch = l->data;
-                               (void)ch;
-                               fdata[i * num_channels + c] *= factor;
-                       }
-               }
-               break;
-       case SR_DF_ANALOG2:
-               analog2 = packet_in->payload;
-               analog2->encoding->scale.p *= ctx->factor.p;
-               analog2->encoding->scale.q *= ctx->factor.q;
+       case SR_DF_ANALOG:
+               analog = packet_in->payload;
+               analog->encoding->scale.p *= ctx->factor.p;
+               analog->encoding->scale.q *= ctx->factor.q;
                break;
        default:
                sr_spew("Unsupported packet type %d, ignoring.", packet_in->type);
@@ -118,7 +97,7 @@ static const struct sr_option *get_options(void)
 
        /* Default to a scaling factor of 1.0. */
        if (!options[0].def)
-               options[0].def = g_variant_ref_sink(g_variant_new(("(xt"), &p, &q));
+               options[0].def = g_variant_ref_sink(g_variant_new("(xt)", &p, &q));
 
        return options;
 }