X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Ftransform%2Fscale.c;h=c7c60dd2b456ac5bfa317bf76592a28fc2e84c38;hb=797c8d9034213296dacf1b3fe2044138f623f4d6;hp=b4dd13cb90e028423cd11b5e959db8a2b0d0ceb3;hpb=2d237f3ce88eacbaf6ff84a38fd99f2ed6ed0f8f;p=libsigrok.git
diff --git a/src/transform/scale.c b/src/transform/scale.c
index b4dd13cb..c7c60dd2 100644
--- a/src/transform/scale.c
+++ b/src/transform/scale.c
@@ -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 .
*/
#include
@@ -50,11 +49,6 @@ static int receive(const struct sr_transform *t,
{
struct context *ctx;
const struct sr_datafeed_analog *analog;
- struct sr_channel *ch;
- GSList *l;
- float *fdata;
- float factor;
- int i, num_channels, c;
if (!t || !t->sdi || !packet_in || !packet_out)
return SR_ERR_ARG;
@@ -63,17 +57,8 @@ static int receive(const struct sr_transform *t,
switch (packet_in->type) {
case SR_DF_ANALOG:
analog = packet_in->payload;
- fdata = (float *)analog->data;
- num_channels = g_slist_length(analog->channels);
- factor = (float) ctx->factor.p / ctx->factor.q;
- for (i = 0; i < analog->num_samples; i++) {
- /* For now scale all values in all channels. */
- for (l = analog->channels, c = 0; l; l = l->next, c++) {
- ch = l->data;
- (void)ch;
- fdata[i * num_channels + c] *= factor;
- }
- }
+ 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);
@@ -112,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;
}