/
image_and_video_preview.go
618 lines (559 loc) · 17.3 KB
/
image_and_video_preview.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
package main
import (
. "github.com/SilentGopherLnx/easygolang"
. "github.com/SilentGopherLnx/easygolang/easygtk"
. "github.com/SilentGopherLnx/GopherFileManager/pkg_fileicon"
. "github.com/SilentGopherLnx/GopherFileManager/pkg_filetools"
"github.com/gotk3/gotk3/gdk"
"os"
"os/exec"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
"golang.org/x/image/math/fixed"
"image"
"image/color"
"image/jpeg"
"github.com/disintegration/imageorient"
_ "github.com/biessek/golang-ico"
_ "golang.org/x/image/webp"
)
var MIME_IMAGE = []string{"jpg", "jpeg", "png", "gif", "webp", "ico", "bmp"}
var MIME_VIDEO = []string{"mp4", "avi", "mkv", "mov", "mpg", "mpeg", "flv", "wmv", "webm", "3gp"}
var MIME_PREVIEW = []string{}
var colorText color.RGBA
func init() {
MIME_PREVIEW = append(MIME_IMAGE, MIME_VIDEO...)
colorText = color.RGBA{200, 255, 255, 255}
}
func FileIsPreviewAbble(tfile string) bool {
return StringInArray(tfile, MIME_PREVIEW) > -1
}
func getConfigValue(allinfo []string, name string, skip string) string {
skip_down := StringDown(skip)
for j := 0; j < len(allinfo); j++ {
if StringFind(allinfo[j], name) == 1 {
value := StringTrim(StringPart(allinfo[j], StringLength(name)+1, 0))
if StringDown(value) != skip_down {
return value
}
}
}
return ""
}
// sudo apt install ffmpeg
// sudo apt install ffprobe
func GetVideoPreviewBytes(filename string, zoom_size int, killchan chan *exec.Cmd) (*[]byte, int, int) {
info, _, _ := ExecCommand("ffprobe", "-i", filename, "-show_format", "-show_streams")
//Prln("[" + filename + "]:" + info)
info_arr := StringSplitLines(info)
w_old := S2I(getConfigValue(info_arr, "width=", "0"))
h_old := S2I(getConfigValue(info_arr, "height=", "0"))
if w_old == 0 || h_old == 0 {
w_old = S2I(getConfigValue(info_arr, "coded_width=", "0"))
h_old = S2I(getConfigValue(info_arr, "coded_height=", "0"))
}
seconds_str1 := getConfigValue(info_arr, "duration=", "N/A")
seconds_str2 := seconds_str1
ind := StringFind(seconds_str2, ".")
if ind > 0 {
seconds_str2 = StringPart(seconds_str2, 1, ind-1)
}
duration := S2I(seconds_str2)
seconds := MINI(MAXI(1, duration*opt.GetVideoPercent()/100), 5000) //40*60=1800
if w_old == 0 || h_old == 0 {
w_old = 16
h_old = 9
}
max_old := MAXI(w_old, h_old)
max_new := zoom_size - 4
w_new := MAXI(1, max_new*w_old/max_old)
h_new := MAXI(1, max_new*h_old/max_old)
ss := I2S(seconds/60) + ":" + StringEnd("0"+I2S(seconds%60), 2) + ".0"
wh := I2S(w_new) + "x" + I2S(h_new)
//Prln("[" + wh + "/" + I2S(w_old) + ":" + I2S(h_old) + "] [" + ss + "/" + seconds_str1 + "] " + filename)
//"-r", "10"
//"-preset", "ultrafast"
//"-vcodec", "libx264"
// -ss before -i is quicker !!!!!!
bb, _, _ := ExecCommandBytes([]byte{}, opt.GetFfmpegTimeout()*1000, killchan, "ffmpeg",
"-ss", ss,
"-i", filename,
"-vframes", "1",
"-s", wh,
"-preset", "ultrafast",
"-tune", "fastdecode",
"-crf", "80",
//"-vcodec", "libx264",
"-f", "singlejpeg", "-")
//Prln("BYTES:" + string(bb))
return &bb, duration, h_old
}
func GetPreview_VideoPixBuf(filename string, zoom_size int, killchan chan *exec.Cmd, req int64, save_hash bool) (*gdk.Pixbuf, bool) {
img2, ok2 := GetPreview_VideoImage(filename, zoom_size, killchan, req, save_hash)
if ok2 {
return GTK_PixBuf_From_RGBA(img2), true
}
return nil, false
}
func GetPreview_VideoImage(filename string, zoom_size int, killchan chan *exec.Cmd, req int64, save_hash bool) (image.Image, bool) {
gr := uint8(RoundF(float64(255) * BACK_GRAY_VISIBLE))
colorTransp := color.RGBA{gr, gr, gr, 0}
zoom_max := Constant_ZoomMax()
fbytes, dur, height := GetVideoPreviewBytes(filename, zoom_max, killchan)
if len(*fbytes) == 0 {
return nil, false
}
if req_id.Get() != req {
Prln(">>>>>>>>> SKIP VIDEO: " + filename)
return nil, false
}
img := ImageDecodeRGBA(fbytes, colorTransp)
//txt := "~" + I2S(RoundF(float64(dur)/60.0)) + "m"
txt := "" + I2S(dur/60) + ":" + StringEnd("00"+I2S(dur%60), 2)
ImageText7x13_Bold(img, 4, 8, colorText, txt, false)
if height > 0 {
ImageText7x13_Bold(img, img.Bounds().Max.X-4, img.Bounds().Max.Y-8, colorText, I2S(height)+"p", true)
}
if save_hash && !InterfaceNil(img) {
info, err := FileInfo(filename, false)
if err == nil {
CachePreview_WriteImage(&info, 0, img, false)
}
}
return GetPreview_ImageImage(img, zoom_size)
}
func ImageText7x13_Bold(img *image.RGBA, x, y int, col color.RGBA, label string, right_align bool) {
colorBlack := color.RGBA{0, 0, 0, 255}
for j := y - 1; j <= y+1; j++ {
for i := x - 1; i <= x+1; i++ {
if !(i == x && j == y) {
ImageText7x13(img, i, j, colorBlack, label, right_align)
}
}
}
ImageText7x13(img, x, y, col, label, right_align)
}
// https://progi.pro/kak-dobavit-prostuyu-tekstovuyu-metku-k-izobrazheniyu-v-go-6297209
func ImageText7x13(img *image.RGBA, x, y int, col color.RGBA, label string, right_align bool) {
yd := 5
point := fixed.Point26_6{fixed.Int26_6(x * 64), fixed.Int26_6((y + yd) * 64)}
d := &font.Drawer{
Dst: img,
Src: image.NewUniform(col),
Face: basicfont.Face7x13,
Dot: point,
}
if !right_align {
d.DrawString(label)
} else {
m := d.MeasureString(label)
point2 := fixed.Point26_6{fixed.Int26_6((x - m.Round()) * 64), fixed.Int26_6((y + yd) * 64)}
d2 := &font.Drawer{
Dst: img,
Src: image.NewUniform(col),
Face: basicfont.Face7x13,
Dot: point2,
}
d2.DrawString(label)
}
}
/*func ImageText52x12(img *image.RGBA, x, y int, col color.RGBA, label string) {
point := fixed.Point52_12{fixed.Int52_12(x * 64), fixed.Point52_12((y + 10) * 64)}
d := &font.Drawer{
Dst: img,
Src: image.NewUniform(col),
Face: basicfont.Face7x13,
Dot: point,
}
d.DrawString(label)
}*/
func GetPreview_ImagePixBuf(filename string, zoom_size int) (*gdk.Pixbuf, bool) {
ftype := FileExtension(filename)
if ftype == "jpg" {
ftype = "jpeg"
}
fbytes, ok := FileBytesRead(filename)
if ok {
fr := imageorient.Decode
if !opt.GetExifRot() {
fr = nil
}
img := ImageDecodeCustom(fbytes, fr)
img2, ok2 := GetPreview_ImageImage(img, zoom_size)
if ok2 {
return GTK_PixBuf_From_RGBA(img2), true
}
} else {
Prln(filename + "//") //+ err.Error())
}
return nil, false
}
func GetPreview_ImageImage(img image.Image, zoom_size int) (*image.RGBA, bool) {
if InterfaceNil(img) {
return nil, false
}
w := img.Bounds().Max.X
h := img.Bounds().Max.Y
max_wh := MAXI(w, h)
if max_wh <= zoom_size {
img22 := image.NewRGBA(image.Rect(0, 0, zoom_size, zoom_size))
ImageAddOver(img22, img, (zoom_size-w)/2, (zoom_size-h)/2)
return img22, true
}
size_up := 2
if max_wh >= zoom_size*4 {
size_up = 4
}
max_new := (zoom_size - 4) * size_up
zoom_size_up := zoom_size * size_up
w2 := MAXI(1, max_new*w/max_wh)
h2 := MAXI(1, max_new*h/max_wh)
img2 := ImageResizeNearest(img, w2, h2)
img22 := image.NewRGBA(image.Rect(0, 0, zoom_size_up, zoom_size_up))
ImageAddOver(img22, img2, (zoom_size_up-w2)/2, (zoom_size_up-h2)/2)
img3 := ImageResizeHalfNice(img22)
if size_up == 4 {
img3 = ImageResizeHalfNice(img3)
}
//img3 := ImageResizeNearest(img22, zoom_size, zoom_size)
return img3, true
}
// func EmptyIcon(w int, h int) *gdk.Pixbuf {
// pixbuf, _ := gdk.PixbufNew(gdk.COLORSPACE_RGB, true, 8, w, h)
// return pixbuf
// }
func CachePreview_Function(info *FileReport, zoom_size int) string {
hash_str := ""
if info.IsDir() {
hash_str = FilePathEndSlashRemove(info.FullName)
//Prln("[[[[" + info.FullName + "]]]]")
} else {
hash_str = I2S64(info.Size()) + "/" + TimeStr(Time(info.ModTime()), true) + "/" + info.Name()
}
md5 := Crypto_MD5([]byte(hash_str))
//md5 = StringReplace(hash_str, "/", "_")
//Prln("md5:" + md5)
//Prln("sha1:" + Crypto_SHA1([]byte(hash_str)))
if info.IsDir() {
return "D-" + I2S(zoom_size) + "_" + md5
} else {
return "F-" + StringUp(FileExtension(info.Name())) + "_" + md5
}
}
func CachePreview_ReadPixbuf(info *FileReport, zoom_size int, alphamask *image.RGBA) *gdk.Pixbuf {
return GTK_PixBuf_From_RGBA(CachePreview_ReadImage(info, zoom_size, alphamask))
}
func CachePreview_ReadImage(info *FileReport, zoom_size int, alphamask *image.RGBA) *image.RGBA {
hash_str := CachePreview_Function(info, zoom_size)
data, ok := FileBytesRead(opt.GetHashFolder() + hash_str + ".jpg")
var img *image.RGBA
img = nil
if ok {
if alphamask == nil {
//return GTK_PixBuf_From_Bytes(data, "jpeg")
gr := uint8(RoundF(float64(255) * BACK_GRAY_VISIBLE))
colorT := color.RGBA{gr, gr, gr, 0}
img = ImageDecodeRGBA(data, colorT)
// nomask := ImageDecode(data)
// img := image.NewRGBA(image.Rect(0, 0, zoom_size, zoom_size))
// ImageAddOver(img, nomask, 0, 0)
// return img
} else {
nomask := ImageDecode(data)
img = image.NewRGBA(image.Rect(0, 0, zoom_size, zoom_size))
ImageAddOver(img, nomask, 0, 0)
for y := 0; y < zoom_size; y++ {
for x := 0; x < zoom_size; x++ {
col_nomask := img.RGBAAt(x, y)
col_amask := alphamask.RGBAAt(x, y)
col_nomask.A = col_amask.A
img.SetRGBA(x, y, col_nomask)
}
}
}
}
if img != nil {
if !info.IsDir() && img.Rect.Max.X != zoom_size {
//return ImageResizeNearest(img, zoom_size, zoom_size)
img2, ok2 := GetPreview_ImageImage(img, zoom_size)
if ok2 {
return img2
}
}
return img
} else {
return nil
}
}
func CachePreview_WriteImage(info *FileReport, zoom_size int, img image.Image, delete_mode bool) bool {
hash_str := CachePreview_Function(info, zoom_size)
cname := opt.GetHashFolder() + hash_str + ".jpg"
if delete_mode {
FileDelete(cname)
return true
} else {
f, err1 := os.Create(cname)
if err1 == nil {
err2 := jpeg.Encode(f, img, &jpeg.Options{Quality: 50})
if err2 == nil {
return true
}
}
return false
}
}
func GetPixBufGTK_Folder(folderpath string, zoom_size int, basic_mode bool, qu *SyncQueue, killchan chan *exec.Cmd, req int64, skip_cached bool) (*gdk.Pixbuf, bool) { // icon_msg *IconUpdateable
folderpath2 := FolderPathEndSlash(folderpath)
imgRGBA := GetIcon_ImageFolder(zoom_size)
scale := zoom_size / 64
xy := [][]int{
[]int{2 * scale, 17 * scale},
[]int{28 * scale, 17 * scale},
[]int{12 * scale, 31 * scale},
[]int{38 * scale, 31 * scale},
}
imgs := []image.Image{}
total_icons := 4 //len(xy)
numdirs := 0
numfiles := 0
files, err := Folder_ListFiles(folderpath, false)
if err == nil {
for _, f := range files {
if f.IsDir() {
numdirs++
} else {
numfiles++
}
}
icondirs := 0
iconfiles := 0
if numdirs > 0 {
icondirs = MINI(numdirs, MAXI(1, total_icons-numfiles))
iconfiles = MINI(total_icons-icondirs, numfiles)
} else {
iconfiles = MINI(total_icons, numfiles)
}
imgs1 := []image.Image{}
if icondirs > 0 {
dicon := GetIcon_ImageRGBA(zoom_size, "", true)
for j := 0; j < icondirs; j++ {
imgs1 = append(imgs1, dicon)
}
}
var imgs2 []image.Image
var mimetypes []string
changed := false
if iconfiles > 0 {
imgs2, mimetypes = best_file_icons(folderpath2, files, iconfiles, zoom_size, basic_mode)
if !basic_mode {
imgs2, changed = replace_mime_images(folderpath2, files, imgs2, mimetypes, zoom_size, killchan, req, skip_cached)
}
mimetypes[0] = mimetypes[0] //used for compile
}
imgs = append(imgs1, imgs2...)
imlen := MINI(len(imgs), total_icons)
for j := 0; j < imlen; j++ {
ImageAddOver(imgRGBA, imgs[j], xy[j][0], xy[j][1])
if j == 0 && numdirs > icondirs && icondirs == 1 {
ImageAddOver(imgRGBA, imgs[0], xy[j][0]+scale*2, xy[j][1]+scale*3)
}
}
if numdirs > 2 {
ImageText7x13_Bold(imgRGBA, zoom_size/10, zoom_size*5/10, colorText, I2S(numdirs), false)
//ImageText52x12(imgRGBA, zoom_size/8, zoom_size*2/5, colorText, I2S(numdirs))
}
if numfiles > 3 {
ImageText7x13_Bold(imgRGBA, zoom_size*9/10, zoom_size*8/10, colorText, I2S(numfiles), true)
}
changed = changed
/*go func() {
if iconfiles > 0 && !basic_mode {
imgs2, changed = replace_mime_images(folderpath2, files, imgs2, mimetypes, zoom_size)
if changed {
imgs = append(imgs1, imgs2...)
imgRGBA := GetIcon_ImageFolder(zoom_size)
imlen := MINI(len(imgs), total_icons)
for j := 0; j < imlen; j++ {
ImageAddOver(imgRGBA, imgs[j], xy[j][0], xy[j][1])
}
qu.Append(IconUpdateable{icon: msg.icon, fullname: msg.fullname, fname: msg.fname, tfile: msg.tfile, basic_mode: false, folder: true, pixbuf_preview})
}
}
}()*/
} else {
if Image_LoadingError != nil {
ImageAddOver(imgRGBA, Image_LoadingError,
(imgRGBA.Bounds().Max.X-Image_LoadingError.Bounds().Max.X)/2,
(imgRGBA.Bounds().Max.Y-Image_LoadingError.Bounds().Max.Y)/2)
}
}
if numfiles > 0 || numdirs > 0 {
if req_id.Get() != req {
Prln(">>>>>>>>> SKIP FOLDER CACHE PIC: " + folderpath2)
} else {
CachePreview_WriteImage(&FileReport{FullName: FilePathEndSlashRemove(folderpath2), IsDirectory: true}, zoom_size, imgRGBA, false)
}
} else {
CachePreview_WriteImage(&FileReport{FullName: FilePathEndSlashRemove(folderpath2), IsDirectory: true}, zoom_size, imgRGBA, true)
}
pixbuf := GTK_PixBuf_From_RGBA(imgRGBA)
if pixbuf != nil {
return pixbuf, true
}
return nil, false
}
func best_file_icons(folderpath string, files []FileReport, maxicons int, zoom_size int, basic_mode bool) ([]image.Image, []string) {
type pair struct {
mime string
count int
}
pairs := []*pair{}
numfiles := 0
for _, f := range files {
if !f.IsDir() {
numfiles++
mime_new := ""
mime_system := ""
if !basic_mode {
mime_system = FileMIME(folderpath + f.Name())
}
if mime_system == APP_EXEC_TYPE {
mime_new = PREFIX_EXTRA + FILE_TYPE_BIN
} else {
tfile := FileExtension(f.Name())
mime_new = GetExtensionIconName(tfile, false)
if f.Size() == 0 {
if f.Mode().IsRegular() {
mime_new = PREFIX_DRAWONME + FILE_TYPE_ZERO
} else {
mime_new = PREFIX_DRAWONME + FILE_TYPE_NOTFILE
}
//Prln("zero")
}
}
exist := false
for _, p := range pairs {
if mime_new == p.mime {
p.count++
exist = true
}
}
if !exist {
pairs = append(pairs, &pair{mime_new, 1})
}
}
}
sort_pairs := func() {
SortArray(pairs, func(i, j int) bool {
return pairs[i].count > pairs[j].count
})
}
minlen := MINI(maxicons, len(pairs))
maxlen := MINI(maxicons, numfiles)
sort_pairs()
if minlen < maxicons && numfiles > minlen {
for len(pairs) < maxlen {
pairs[0].count--
pairs = append(pairs, pairs[0])
sort_pairs()
}
minlen = MINI(maxicons, len(pairs))
}
imgs := []image.Image{}
mimes := []string{}
for j := 0; j < minlen; j++ {
imgs = append(imgs, GetIcon_ImageRGBA_OF(zoom_size, pairs[j].mime))
mimes = append(mimes, pairs[j].mime)
}
return imgs, mimes
}
func replace_mime_images(folderpath string, files []FileReport, imgs []image.Image, mimes []string, zoom_size int, killchan chan *exec.Cmd, req int64, skip_cached bool) ([]image.Image, bool) {
mime_image := PREFIX_DRAWONME + FILE_TYPE_IMAGE
mime_video := PREFIX_DRAWONME + FILE_TYPE_MOVIE
imgs2 := []image.Image{}
file_j := 0
changed := false
fr := imageorient.Decode
if !opt.GetExifRot() {
fr = nil
}
for k := 0; k < len(imgs); k++ {
if mimes[k] != mime_image && mimes[k] != mime_video {
imgs2 = append(imgs2, imgs[k])
} else {
exist := false
for j := file_j; j < len(files); j++ {
if !exist {
file_j = j + 1
f := files[j]
if !f.IsDir() {
if req_id.Get() != req {
Prln("////////////////// SKIP: " + f.Name())
} else {
tfile := FileExtension(f.Name())
if StringInArray(tfile, MIME_IMAGE) > -1 {
fbytes, ok := FileBytesRead(folderpath + f.Name())
if ok {
img_new := ImageDecodeCustom(fbytes, fr)
if img_new != nil {
zoom_size2 := ZoomSmall(zoom_size)
zoom_size3 := zoom_size2 - zoom_size/32
w := img_new.Bounds().Max.X
h := img_new.Bounds().Max.Y
if w > 1 && h > 1 {
max_old := MAXI(w, h)
w_new := w
h_new := h
var img_new2 *image.RGBA
if max_old > zoom_size3 {
w_new = MAXI(1, zoom_size3*w*2/max_old)
h_new = MAXI(1, zoom_size3*h*2/max_old)
img_new = ImageResizeNearest(img_new, w_new, h_new)
img_new2 = image.NewRGBA(image.Rect(0, 0, zoom_size2*2, zoom_size2*2))
ImageAddOver(img_new2, img_new, zoom_size2-w_new/2, zoom_size2-h_new/2)
img_new2 = ImageResizeHalfNice(img_new2)
} else {
img_new2 = image.NewRGBA(image.Rect(0, 0, zoom_size2, zoom_size2))
ImageAddOver(img_new2, img_new, (zoom_size2-w_new)/2, (zoom_size2-h_new)/2)
}
exist = true
imgs2 = append(imgs2, img_new2)
}
} else {
Prln("??" + f.Name())
}
}
}
if StringInArray(tfile, MIME_VIDEO) > -1 {
zoom_size2 := ZoomSmall(zoom_size)
skip_cached_ok := false
if skip_cached {
img_new := CachePreview_ReadImage(&f, zoom_size2, nil)
if img_new != nil {
exist = true
imgs2 = append(imgs2, img_new)
skip_cached_ok = true
Prln("not recashing: " + f.FullName)
}
}
if !skip_cached_ok {
img_new, ok2 := GetPreview_VideoImage(f.FullName, zoom_size2, killchan, req, true)
if ok2 {
exist = true
imgs2 = append(imgs2, img_new)
}
}
}
}
}
}
}
if exist {
changed = true
} else {
imgs2 = append(imgs2, imgs[k])
}
}
}
return imgs2, changed
}