From faf285775f99a0411da8e35a2c7974373586eaf0 Mon Sep 17 00:00:00 2001 From: nuknal Date: Tue, 21 May 2024 18:05:10 +0800 Subject: [PATCH] xlsx --- cmd/extract.go | 4 +++- extract/aux.go | 3 +++ extract/process.go | 2 +- extract/trans_frame.go | 5 ----- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/extract.go b/cmd/extract.go index c0e37fd..8fcff86 100644 --- a/cmd/extract.go +++ b/cmd/extract.go @@ -28,6 +28,7 @@ var extractCmd = &cobra.Command{ for i, d := range dats { e.SeprateAuxAndImgData(d, i) } + e.Cleanup() } } else { p := &extract.Params{ @@ -43,6 +44,7 @@ var extractCmd = &cobra.Command{ for i, d := range dats { e.SeprateAuxAndImgData(d, i) } + e.Cleanup() } }, } @@ -58,7 +60,7 @@ func init() { func params() []*extract.Params { var params []*extract.Params datas := []string{"051622", "051712", "051721", - "051813", "051821", "051823", + "051814", "051821", "051823", "051921", "051922", "052022"} for _, d := range datas { params = append(params, &extract.Params{ diff --git a/extract/aux.go b/extract/aux.go index 9e3132a..f6f8a86 100644 --- a/extract/aux.go +++ b/extract/aux.go @@ -34,6 +34,9 @@ func (e Extractor) ExtractAux(auxfile, xlsxfile string) error { row := 2 col := 1 for i := 0; i < len(data); i += 24 + 128 + 512 { + if i+24+128+512 > len(data) { + break + } var head AuxFrameHead head.Decode(data[i : i+24]) l0, _ := head.SaveXlsx(f, col, row) diff --git a/extract/process.go b/extract/process.go index de0f714..cf3ef40 100644 --- a/extract/process.go +++ b/extract/process.go @@ -12,7 +12,7 @@ type Extractor struct { func NewExtractor(params *Params) *Extractor { os.MkdirAll(params.OutputPath, 0755) os.MkdirAll(params.TempPath, 0755) - return &Extractor{params: params} + return &Extractor{params: params, Clean: true} } func (e *Extractor) Cleanup() error { diff --git a/extract/trans_frame.go b/extract/trans_frame.go index 7c3053c..5202d94 100644 --- a/extract/trans_frame.go +++ b/extract/trans_frame.go @@ -59,9 +59,6 @@ func (p *Extractor) ExtractOriginalImageData(aosDataFile string) ([]string, erro snRange := map[int][]uint32{} datSet := map[int][]byte{} - fsn, _ := os.Create("demo/temp/tf_sn.txt") - defer fsn.Close() - var i int for i < len(aosData) { if i+4 > len(aosData) { @@ -79,8 +76,6 @@ func (p *Extractor) ExtractOriginalImageData(aosDataFile string) ([]string, erro tf.Decode(aosData[i : i+TransImageFrameLength]) fileno := int(tf.FileNo) snRange[fileno] = append(snRange[fileno], tf.SNo) - fsn.WriteString(fmt.Sprintf("%d %d %d\n", i, tf.SNo, fileno)) - if tf.SecretFlag == 0xAA { log.Info("secret frame is not supported") break