]> git.tuebingen.mpg.de Git - paraslash.git/blob - mood.c
Simplify and improve activate_mood_or_playlist().
[paraslash.git] / mood.c
1 /* Copyright (C) 2007 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2
3 /** \file mood.c Paraslash's mood handling functions. */
4
5 #include <regex.h>
6 #include <osl.h>
7 #include <lopsub.h>
8
9 #include "para.h"
10 #include "error.h"
11 #include "string.h"
12 #include "afh.h"
13 #include "afs.h"
14 #include "list.h"
15
16 /*
17  * Mood parser API. It's overkill to have an own header file for
18  * these declarations as they are only needed in this .c file.
19  */
20 struct mp_context;
21 int mp_init(const char *definition, int nbytes, struct mp_context **result,
22                  char **errmsg);
23 bool mp_eval_row(const struct osl_row *aft_row, struct mp_context *ctx);
24 void mp_shutdown(struct mp_context *ctx);
25
26 /**
27  * Contains statistical data of the currently admissible audio files.
28  *
29  * It is used to assign normalized score values to each admissible audio file.
30  */
31 struct afs_statistics {
32         /** Sum of num played over all admissible files. */
33         int64_t num_played_sum;
34         /** Sum of last played times over all admissible files. */
35         int64_t last_played_sum;
36         /** Quadratic deviation of num played count. */
37         int64_t num_played_qd;
38         /** Quadratic deviation of last played time. */
39         int64_t last_played_qd;
40         /** Correction factor for the num played score. */
41         int64_t num_played_correction;
42         /** Correction factor for the last played score. */
43         int64_t last_played_correction;
44         /** Common divisor of the correction factors. */
45         int64_t normalization_divisor;
46         /** Number of admissible files */
47         unsigned num;
48 };
49
50 /**
51  * Stores an instance of an open mood (parser and statistics).
52  *
53  * A structure of this type is allocated and initialized at mood open time.
54  */
55 struct mood {
56         /** NULL means that this is the "dummy" mood. */
57         char *name;
58         /** Bison's abstract syntax tree, used to determine admissibility. */
59         struct mp_context *parser_context;
60         /** To compute the score. */
61         struct afs_statistics stats;
62 };
63
64 /*
65  * If current_mood is NULL then no mood is currently open. If
66  * current_mood->name is NULL, the dummy mood is currently open.
67  *
68  * The statistics are adjusted dynamically through this pointer as files are
69  * added, removed or played.
70  */
71 static struct mood *current_mood;
72
73 /*
74  * Find the position of the most-significant set bit.
75  *
76  * Copied and slightly adapted from the linux source tree, version 4.9.39
77  * (2017-07).
78  */
79 __a_const static uint32_t fls64(uint64_t v)
80 {
81         int n = 63;
82         const uint64_t ones = ~(uint64_t)0U;
83
84         if ((v & (ones << 32)) == 0) {
85                 n -= 32;
86                 v <<= 32;
87         }
88         if ((v & (ones << (64 - 16))) == 0) {
89                 n -= 16;
90                 v <<= 16;
91         }
92         if ((v & (ones << (64 - 8))) == 0) {
93                 n -= 8;
94                 v <<= 8;
95         }
96         if ((v & (ones << (64 - 4))) == 0) {
97                 n -= 4;
98                 v <<= 4;
99         }
100         if ((v & (ones << (64 - 2))) == 0) {
101                 n -= 2;
102                 v <<= 2;
103         }
104         if ((v & (ones << (64 - 1))) == 0)
105                 n -= 1;
106         return n;
107 }
108
109 /*
110  * Compute the integer square root floor(sqrt(x)).
111  *
112  * Taken 2007 from the linux source tree.
113  */
114 __a_const static uint64_t int_sqrt(uint64_t x)
115 {
116         uint64_t op = x, res = 0, one = 1;
117
118         one = one << (fls64(x) & ~one);
119         while (one != 0) {
120                 if (op >= res + one) {
121                         op = op - (res + one);
122                         res = res + 2 * one;
123                 }
124                 res /= 2;
125                 one /= 4;
126         }
127         return res;
128 }
129
130 static void destroy_mood(struct mood *m)
131 {
132         if (!m)
133                 return;
134         mp_shutdown(m->parser_context);
135         free(m->name);
136         free(m);
137 }
138
139 static struct mood *alloc_new_mood(const char *name)
140 {
141         struct mood *m = zalloc(sizeof(struct mood));
142         if (name)
143                 m->name = para_strdup(name);
144         m->stats.normalization_divisor = 1;
145         return m;
146 }
147
148 static int init_mood_parser(const char *mood_name, struct mood **m, char **err)
149 {
150         struct osl_object mood_def;
151         int ret;
152
153         if (!*mood_name) {
154                 if (err)
155                         *err = make_message("empty mood name\n");
156                 return -ERRNO_TO_PARA_ERROR(EINVAL);
157         }
158         ret = mood_get_def_by_name(mood_name, &mood_def);
159         if (ret < 0) {
160                 if (err)
161                         *err = make_message("could not read mood definition\n");
162                 return ret;
163         }
164         *m = alloc_new_mood(mood_name);
165         PARA_INFO_LOG("opening mood %s\n", mood_name);
166         ret = mp_init(mood_def.data, mood_def.size, &(*m)->parser_context, err);
167         osl_close_disk_object(&mood_def);
168         if (ret < 0)
169                 destroy_mood(*m);
170         return ret;
171 }
172
173 static int check_mood(struct osl_row *mood_row, void *data)
174 {
175         struct para_buffer *pb = data;
176         char *mood_name, *errmsg;
177         struct osl_object mood_def;
178         struct mood *m;
179         int ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
180
181         if (ret < 0) {
182                 para_printf(pb, "cannot read mood\n");
183                 return ret;
184         }
185         if (!*mood_name) /* ignore dummy row */
186                 goto out;
187         m = alloc_new_mood("check");
188         ret = mp_init(mood_def.data, mood_def.size, &m->parser_context,
189                 &errmsg);
190         if (ret < 0) {
191                 para_printf(pb, "%s: %s\n", mood_name, errmsg);
192                 free(errmsg);
193                 para_printf(pb, "%s\n", para_strerror(-ret));
194         } else
195                 destroy_mood(m);
196         ret = 1; /* don't fail the loop on invalid mood definitions */
197 out:
198         osl_close_disk_object(&mood_def);
199         return ret;
200 }
201
202 /**
203  * Check all moods for syntax errors.
204  *
205  * \param aca Only ->pbout is used for diagnostics.
206  *
207  * \return Negative on fatal errors. Inconsistent mood definitions are not
208  * considered an error.
209  */
210 int mood_check_callback(struct afs_callback_arg *aca)
211 {
212         para_printf(&aca->pbout, "checking moods...\n");
213         return osl(osl_rbtree_loop(moods_table, BLOBCOL_ID, &aca->pbout,
214                 check_mood));
215 }
216
217 /*
218  * The normalized num_played and last_played values are defined as
219  *
220  *      nn := -(np - mean_n) / sigma_n and nl := -(lp - mean_l) / sigma_l
221  *
222  *  For a (hypothetical) file with np = 0 and lp = now we thus have
223  *
224  *      nn =  mean_n / sigma_n =: hn > 0
225  *      nl = -(now - mean_l) / sigma_l =: hl < 0
226  *
227  * We design the score function so that both contributions get the same
228  * weight. Define the np and lp score of an arbitrary file as
229  *
230  *      sn := nn * -hl and sl := nl * hn
231  *
232  * Example:
233  *      num_played mean/sigma: 87/14
234  *      last_played mean/sigma: 45/32 days
235  *
236  *      We have hn = 87 / 14 = 6.21 and hl = -45 / 32 = -1.41. Multiplying
237  *      nn of every file with the correction factor 1.41 and nl with
238  *      6.21 makes the weight of the two contributions equal.
239  *
240  * The total score s := sn + sl has the representation
241  *
242  *      s = -cn * (np - mean_n) - cl * (lp - mean_l)
243  *
244  * with positive correction factors
245  *
246  *      cn = (now - mean_l) / (sqrt(ql) * sqrt(qn) / n)
247  *      cl = mean_n / (sqrt(ql) * sqrt(qn) / n)
248  *
249  * where ql and qn are the quadratic deviations stored in the statistics
250  * structure and n is the number of admissible files. To avoid integer
251  * overflows and rounding errors we store the common divisor of the
252  * correction factors separately.
253  */
254 static int64_t normalized_value(int64_t x, int64_t n, int64_t sum, int64_t qd)
255 {
256         if (!n || !qd)
257                 return 0;
258         return 100 * (n * x - sum) / (int64_t)int_sqrt(n) / (int64_t)int_sqrt(qd);
259 }
260
261 static long compute_score(struct afs_info *afsi,
262                 const struct afs_statistics *stats)
263 {
264         long score = -normalized_value(afsi->num_played, stats->num,
265                 stats->num_played_sum, stats->num_played_qd);
266         score -= normalized_value(afsi->last_played, stats->num,
267                 stats->last_played_sum, stats->last_played_qd);
268         return score / 2;
269 }
270
271 static int add_afs_statistics(const struct osl_row *row,
272                 struct afs_statistics *stats)
273 {
274         uint64_t n, x, s, q;
275         struct afs_info afsi;
276         int ret;
277
278         ret = get_afsi_of_row(row, &afsi);
279         if (ret < 0)
280                 return ret;
281         n = stats->num;
282         x = afsi.last_played;
283         s = stats->last_played_sum;
284         if (n > 0) {
285                 q = (x > s / n)? x - s / n : s / n - x;
286                 stats->last_played_qd += q * q * n / (n + 1);
287         }
288         stats->last_played_sum += x;
289
290         x = afsi.num_played;
291         s = stats->num_played_sum;
292         if (n > 0) {
293                 q = (x > s / n)? x - s / n : s / n - x;
294                 stats->num_played_qd += q * q * n / (n + 1);
295         }
296         stats->num_played_sum += x;
297         stats->num++;
298         return 1;
299 }
300
301 static int del_afs_statistics(const struct osl_row *row)
302 {
303         struct afs_statistics *stats = &current_mood->stats;
304         uint64_t n, s, q, a, new_s;
305         struct afs_info afsi;
306         int ret;
307         ret = get_afsi_of_row(row, &afsi);
308         if (ret < 0)
309                 return ret;
310         n = stats->num;
311         assert(n);
312         if (n == 1) {
313                 memset(stats, 0, sizeof(*stats));
314                 stats->normalization_divisor = 1;
315                 return 1;
316         }
317
318         s = stats->last_played_sum;
319         q = stats->last_played_qd;
320         a = afsi.last_played;
321         new_s = s - a;
322         stats->last_played_sum = new_s;
323         stats->last_played_qd = q + s * s / n - a * a
324                 - new_s * new_s / (n - 1);
325
326         s = stats->num_played_sum;
327         q = stats->num_played_qd;
328         a = afsi.num_played;
329         new_s = s - a;
330         stats->num_played_sum = new_s;
331         stats->num_played_qd = q + s * s / n - a * a
332                 - new_s * new_s / (n - 1);
333
334         stats->num--;
335         return 1;
336 }
337
338 /*
339  * At mood open time we determine the set of admissible files for the given
340  * mood where each file is identified by a pointer to a row of the audio file
341  * table. In the first pass the pointers are added to a temporary array and
342  * statistics are computed. When all admissible files have been processed in
343  * this way, the score of each admissible file is computed and the (row, score)
344  * pair is added to the score table. This has to be done in a second pass
345  * since the score depends on the statistics. Finally, the array is freed.
346  */
347 struct admissible_array {
348         /** Files are admissible wrt. this mood. */
349         struct mood *m;
350         /** The size of the array */
351         unsigned size;
352         /** Pointer to the array of admissible files. */
353         struct osl_row **array;
354 };
355
356 /*
357  * Check whether the given audio file is admissible. If it is, add it to array
358  * of admissible files.
359  */
360 static int add_if_admissible(struct osl_row *aft_row, void *data)
361 {
362         struct admissible_array *aa = data;
363         struct afs_statistics *stats = &aa->m->stats;
364
365         if (!mp_eval_row(aft_row, aa->m->parser_context))
366                 return 0;
367         if (stats->num >= aa->size) {
368                 aa->size *= 2;
369                 aa->size += 100;
370                 aa->array = arr_realloc(aa->array, aa->size,
371                         sizeof(struct osl_row *));
372         }
373         aa->array[stats->num] = aft_row;
374         return add_afs_statistics(aft_row, stats);
375 }
376
377 /**
378  * Compute the new quadratic deviation in case one element changes.
379  *
380  * \param n Number of elements.
381  * \param old_qd The quadratic deviation before the change.
382  * \param old_val The value that was replaced.
383  * \param new_val The replacement value.
384  * \param old_sum The sum of all elements before the update.
385  *
386  * \return The new quadratic deviation resulting from replacing old_val
387  * by new_val.
388  *
389  * Given n real numbers a_1, ..., a_n, their sum S = a_1 + ... + a_n,
390  * their quadratic deviation
391  *
392  * q = (a_1 - S/n)^2 + ... + (a_n - S/n)^2,
393  *
394  * and a real number b, the quadratic deviation q' of a_1,...a_{n-1}, b (ie.
395  * the last number a_n was replaced by b) may be computed in O(1) time in terms
396  * of n, q, a_n, b, and S as
397  *
398  *      q' = q + d * s - (2 * S + d) * d / n
399  *         = q + d * (s - 2 * S / n - d /n),
400  *
401  * where d = b - a_n, and s = b + a_n.
402  *
403  * Example: n = 3, a_1 = 3, a_2 = 5, a_3 = 7, b = 10. Then S = 15, q = 8, d = 3,
404  * s = 17, so
405  *
406  *      q + d * s - (2 * S + d) * d / n = 8 + 51 - 33 = 26,
407  *
408  * which equals q' = (3 - 6)^2 + (5 - 6)^2 + (10 - 6)^2.
409  *
410  */
411 _static_inline_ int64_t update_quadratic_deviation(int64_t n, int64_t old_qd,
412                 int64_t old_val, int64_t new_val, int64_t old_sum)
413 {
414         int64_t delta = new_val - old_val;
415         int64_t sigma = new_val + old_val;
416         return old_qd + delta * (sigma - 2 * old_sum / n - delta / n);
417 }
418
419 static void update_afs_statistics(struct afs_info *old_afsi,
420                 struct afs_info *new_afsi)
421 {
422         struct afs_statistics *stats = &current_mood->stats;
423
424         assert(stats->num > 0);
425         stats->last_played_qd = update_quadratic_deviation(stats->num,
426                 stats->last_played_qd, old_afsi->last_played,
427                 new_afsi->last_played, stats->last_played_sum);
428         stats->last_played_sum += new_afsi->last_played - old_afsi->last_played;
429
430         stats->num_played_qd = update_quadratic_deviation(stats->num,
431                 stats->num_played_qd, old_afsi->num_played,
432                 new_afsi->num_played, stats->num_played_sum);
433         stats->num_played_sum += new_afsi->num_played - old_afsi->num_played;
434 }
435
436 static int add_to_score_table(const struct osl_row *aft_row,
437                 const struct afs_statistics *stats)
438 {
439         long score;
440         struct afs_info afsi;
441         int ret = get_afsi_of_row(aft_row, &afsi);
442
443         if (ret < 0)
444                 return ret;
445         score = compute_score(&afsi, stats);
446         return score_add(aft_row, score);
447 }
448
449 static int delete_from_statistics_and_score_table(const struct osl_row *aft_row)
450 {
451         int ret = del_afs_statistics(aft_row);
452         if (ret < 0)
453                 return ret;
454         return score_delete(aft_row);
455 }
456
457 /**
458  * Delete an audio file from the score table and update mood statistics.
459  *
460  * \param aft_row Identifies the row to delete.
461  *
462  * \return Standard.
463  *
464  * \sa \ref score_delete().
465  */
466 static int mood_delete_audio_file(const struct osl_row *aft_row)
467 {
468         if (!row_belongs_to_score_table(aft_row))
469                 return 0;
470         return delete_from_statistics_and_score_table(aft_row);
471 }
472
473 /**
474  * Compute the new score of an audio file wrt. the current mood.
475  *
476  * \param aft_row Determines the audio file.
477  * \param old_afsi The audio file selector info before updating.
478  *
479  * The \a old_afsi argument may be \p NULL which indicates that no changes to
480  * the audio file info were made.
481  *
482  * \return Positive on success, negative on errors.
483  */
484 static int mood_update_audio_file(const struct osl_row *aft_row,
485                 struct afs_info *old_afsi)
486 {
487         long score, percent;
488         int ret;
489         bool is_admissible, was_admissible;
490         struct afs_info afsi;
491
492         if (!current_mood)
493                 return 1; /* nothing to do */
494         was_admissible = row_belongs_to_score_table(aft_row);
495         is_admissible = mp_eval_row(aft_row, current_mood->parser_context);
496         if (!was_admissible && !is_admissible)
497                 return 1;
498         if (was_admissible && !is_admissible)
499                 return delete_from_statistics_and_score_table(aft_row);
500         if (!was_admissible && is_admissible) {
501                 ret = add_afs_statistics(aft_row, &current_mood->stats);
502                 if (ret < 0)
503                         return ret;
504                 return add_to_score_table(aft_row, &current_mood->stats);
505         }
506         /* update score */
507         ret = get_afsi_of_row(aft_row, &afsi);
508         if (ret < 0)
509                 return ret;
510         if (old_afsi)
511                 update_afs_statistics(old_afsi, &afsi);
512         score = compute_score(&afsi, &current_mood->stats);
513         PARA_DEBUG_LOG("score: %li\n", score);
514         percent = (score + 100) / 3;
515         if (percent > 100)
516                 percent = 100;
517         else if (percent < 0)
518                 percent = 0;
519         PARA_DEBUG_LOG("moving to %li%%\n", percent);
520         return score_update(aft_row, percent);
521 }
522
523 /* sse: seconds since epoch. */
524 static char *get_statistics(struct mood *m, int64_t sse)
525 {
526         unsigned n = m->stats.num;
527         int mean_days, sigma_days;
528
529         mean_days = (sse - m->stats.last_played_sum / n) / 3600 / 24;
530         sigma_days = int_sqrt(m->stats.last_played_qd / n) / 3600 / 24;
531         return make_message(
532                 "loaded mood %s (%u files)\n"
533                 "last_played mean/sigma: %d/%d days\n"
534                 "num_played mean/sigma: %" PRId64 "/%" PRIu64 "\n"
535         ,
536                 m->name? m->name : "(dummy)",
537                 n,
538                 mean_days, sigma_days,
539                 m->stats.num_played_sum / n,
540                         int_sqrt(m->stats.num_played_qd / n)
541         );
542 }
543
544 /**
545  * Close the current mood.
546  *
547  * Frees all resources of the current mood.
548  */
549 void close_current_mood(void)
550 {
551         destroy_mood(current_mood);
552         current_mood = NULL;
553 }
554
555 static void compute_correction_factors(int64_t sse, struct afs_statistics *s)
556 {
557         if (s->num > 0) {
558                 s->normalization_divisor = int_sqrt(s->last_played_qd)
559                         * int_sqrt(s->num_played_qd) / s->num / 100;
560                 s->num_played_correction = sse - s->last_played_sum / s->num;
561                 s->last_played_correction = s->num_played_sum / s->num;
562         }
563         if (s->num_played_correction == 0)
564                 s->num_played_correction = 1;
565         if (s->normalization_divisor == 0)
566                 s->normalization_divisor = 1;
567         if (s->last_played_correction == 0)
568                 s->last_played_correction = 1;
569 }
570
571 /**
572  * Change the current mood.
573  *
574  * If there is already an open mood, it will be closed first.
575  *
576  * \param mood_name The name of the mood to open.
577  * \param msg Error message or mood info is returned here.
578  *
579  * If \a mood_name is \a NULL, load the dummy mood that accepts every audio file
580  * and uses a scoring method based only on the \a last_played information.
581  *
582  * If the message pointer is not NULL, a suitable message is returned there in
583  * all cases. The caller must free this string.
584  *
585  * \return The number of admissible files on success, negative on errors. It is
586  * not considered an error if no files are admissible.
587  *
588  * \sa struct \ref afs_info::last_played, \ref mp_eval_row().
589  */
590 int mood_switch(const char *mood_name, char **msg)
591 {
592         int i, ret;
593         struct admissible_array aa = {.size = 0};
594         /*
595          * We can not use the "now" pointer from sched.c here because we are
596          * called before schedule(), which initializes "now".
597          */
598         struct timeval rnow;
599
600         if (mood_name) {
601                 ret = init_mood_parser(mood_name, &aa.m, msg);
602                 if (ret < 0)
603                         return ret;
604         } else /* load dummy mood */
605                 aa.m = alloc_new_mood(NULL);
606         PARA_NOTICE_LOG("computing statistics of admissible files\n");
607         ret = audio_file_loop(&aa, add_if_admissible);
608         if (ret < 0) {
609                 if (msg) /* false if we are called via the event handler */
610                         *msg = make_message("audio file loop failed\n");
611                 goto out;
612         }
613         clock_get_realtime(&rnow);
614         compute_correction_factors(rnow.tv_sec, &aa.m->stats);
615         if (aa.m->stats.num == 0) {
616                 if (msg)
617                         *msg = make_message("no admissible files\n");
618                 ret = 0;
619                 goto out;
620         }
621         for (i = 0; i < aa.m->stats.num; i++) {
622                 ret = add_to_score_table(aa.array[i], &aa.m->stats);
623                 if (ret < 0) {
624                         if (msg)
625                                 *msg = make_message(
626                                         "could not add row to score table\n");
627                         goto out;
628                 }
629         }
630         /* success */
631         if (msg)
632                 *msg = get_statistics(aa.m, rnow.tv_sec);
633         ret = aa.m->stats.num;
634         close_current_mood();
635         current_mood = aa.m;
636 out:
637         free(aa.array);
638         if (ret < 0)
639                 destroy_mood(aa.m);
640         return ret;
641 }
642
643 /*
644  * Close and re-open the current mood.
645  *
646  * This function is called on events which render the current list of
647  * admissible files useless, for example if an attribute is removed from the
648  * attribute table.
649  */
650 static int reload_current_mood(void)
651 {
652         int ret;
653         char *mood_name = NULL;
654
655         assert(current_mood);
656         ret = clear_score_table();
657         if (ret < 0)
658                 return ret;
659         PARA_NOTICE_LOG("reloading %s\n", current_mood->name?
660                 current_mood->name : "(dummy)");
661         if (current_mood->name)
662                 mood_name = para_strdup(current_mood->name);
663         close_current_mood();
664         ret = mood_switch(mood_name, NULL);
665         free(mood_name);
666         return ret;
667 }
668
669 /**
670  * Notification callback for the moods table.
671  *
672  * \param event Type of the event just occurred.
673  * \param pb Unused.
674  * \param data Its type depends on the event.
675  *
676  * This function updates the score table according to the event that has
677  * occurred. Two actions are possible: (a) reload the current mood, or (b)
678  * add/remove/update the row of the score table which corresponds to the audio
679  * file that has been modified or whose afs info has been changed. It depends
680  * on the type of the event which action (if any) is performed.
681  *
682  * The callbacks of command handlers such as com_add() or com_touch() which
683  * modify the audio file table call this function. The virtual streaming system
684  * also calls this after it has updated the afs info of the file it is about to
685  * stream (the one with the highest score). If the file stays admissible, its
686  * score is recomputed so that a different file is picked next time.
687  *
688  * \return Standard.
689  */
690 int moods_event_handler(enum afs_events event, __a_unused struct para_buffer *pb,
691                 void *data)
692 {
693         if (!current_mood)
694                 return 0;
695         switch (event) {
696         /*
697          * The three blob events might change the set of admissible files,
698          * so we must reload the score list.
699          */
700         case BLOB_RENAME:
701         case BLOB_REMOVE:
702         case BLOB_ADD:
703                 if (data == moods_table || data == playlists_table)
704                         return 1; /* no reload necessary for these */
705                 return reload_current_mood();
706         /* these also require reload of the score table */
707         case ATTRIBUTE_ADD:
708         case ATTRIBUTE_REMOVE:
709         case ATTRIBUTE_RENAME:
710                 return reload_current_mood();
711         /* changes to the aft only require to re-examine the audio file */
712         case AFSI_CHANGE: {
713                 struct afsi_change_event_data *aced = data;
714                 return mood_update_audio_file(aced->aft_row, aced->old_afsi);
715                 }
716         case AFHI_CHANGE:
717         case AUDIO_FILE_RENAME:
718         case AUDIO_FILE_ADD:
719                 return mood_update_audio_file(data, NULL);
720         case AUDIO_FILE_REMOVE:
721                 return mood_delete_audio_file(data);
722         default:
723                 return 1;
724         }
725 }