12 Commits 936f242fc1 ... 5333e42811

Autor SHA1 Nachricht Datum
  gjh 5333e42811 1.0.9版本 vor 2 Wochen
  gjh 0fe8f92461 日志初始化优化,只有android版有文件日志 vor 2 Wochen
  gjh 1cd19c214e 去除项目中无用的C++代码 vor 2 Wochen
  gjh 71093b2a04 更新SDK vor 2 Wochen
  gjh 131bf0d3e2 代码优化 vor 3 Wochen
  gjh 01111f9e5c 增加webview用的进度条 vor 3 Wochen
  gjh 456375e08e 增加RSA加密解密方法,增加国康RAS公钥配置信息 vor 3 Wochen
  gjh cb51615392 Merge branch 'master' into develop vor 3 Wochen
  gjh 7bf4bca45a 照片视频选择页面 vor 3 Wochen
  gjh 6d4290d01c loading和无数据widget vor 3 Wochen
  gjh 6087631821 Merge branch 'develop' into future_照片视频选择页面 vor 3 Wochen
  gjh 003f755b5c 选择历史记录页面 vor 3 Wochen
47 geänderte Dateien mit 902 neuen und 2474 gelöschten Zeilen
  1. 0 7
      android/app/build.gradle
  2. 0 48
      android/app/src/main/cpp/CMakeLists.txt
  3. 0 192
      android/app/src/main/cpp/Ffmpeg_codec_formater.c
  4. BIN
      android/app/src/main/cpp/Ffmpeg_codec_formater.o
  5. 0 210
      android/app/src/main/cpp/Media_Encode_decode.c
  6. BIN
      android/app/src/main/cpp/Media_Encode_decode.o
  7. 0 122
      android/app/src/main/cpp/PCode.c
  8. 0 173
      android/app/src/main/cpp/SKP_Silk_LPC_inv_pred_gain.c
  9. BIN
      android/app/src/main/cpp/SKP_Silk_LPC_inv_pred_gain.o
  10. 0 706
      android/app/src/main/cpp/SKP_Silk_NSQ_del_dec.c
  11. BIN
      android/app/src/main/cpp/SKP_Silk_NSQ_del_dec.o
  12. 0 13
      android/app/src/main/cpp/common/coomon_utils.h
  13. 0 18
      android/app/src/main/cpp/common/message_handler.cpp
  14. 0 23
      android/app/src/main/cpp/common/message_handler.h
  15. 0 154
      android/app/src/main/cpp/common/message_queue.cpp
  16. 0 81
      android/app/src/main/cpp/common/message_queue.h
  17. 0 340
      android/app/src/main/cpp/controller.cpp
  18. 0 156
      android/app/src/main/cpp/controller.h
  19. 0 10
      android/app/src/main/cpp/native-lib.cpp
  20. 0 2
      android/app/src/main/java/com/eitchsyh/instrument/Video.java
  21. BIN
      android/app/src/main/jniLibs/arm64-v8a/libfacecv.so
  22. BIN
      android/app/src/main/jniLibs/arm64-v8a/libffmpeg.so
  23. BIN
      android/app/src/main/jniLibs/arm64-v8a/libiMVR.so
  24. BIN
      android/app/src/main/jniLibs/arm64-v8a/libopencv_java3.so
  25. BIN
      android/app/src/main/jniLibs/armeabi-v7a/libfacecv.so
  26. BIN
      android/app/src/main/jniLibs/armeabi-v7a/libffmpeg.so
  27. BIN
      android/app/src/main/jniLibs/armeabi-v7a/libiMVR.so
  28. BIN
      android/app/src/main/jniLibs/armeabi-v7a/libopencv_java3.so
  29. 1 0
      lib/app_router.dart
  30. 183 117
      lib/app_router.gr.dart
  31. 3 0
      lib/entity/history_item_info.dart
  32. 104 8
      lib/funcs.dart
  33. 18 8
      lib/generated/intl/messages_en.dart
  34. 16 8
      lib/generated/intl/messages_zh.dart
  35. 50 0
      lib/generated/l10n.dart
  36. 11 0
      lib/global.dart
  37. 6 1
      lib/l10n/intl_en.arb
  38. 6 1
      lib/l10n/intl_zh.arb
  39. 8 44
      lib/pages/history/history_page.dart
  40. 304 0
      lib/pages/history/select_history_page.dart
  41. 1 1
      lib/pages/history/vm/history_view_model.g.dart
  42. 43 29
      lib/pages/web/webview_page.dart
  43. 36 0
      lib/widget/empty_widget.dart
  44. 36 0
      lib/widget/loading_widget.dart
  45. 73 0
      lib/widget/webview_progress_bar.dart
  46. 1 1
      pubspec.lock
  47. 2 1
      pubspec.yaml

+ 0 - 7
android/app/build.gradle

@@ -42,13 +42,6 @@ android {
42 42
         }
43 43
     }
44 44
 
45
-    externalNativeBuild {
46
-        cmake {
47
-            path file('src/main/cpp/CMakeLists.txt')
48
-            version '3.22.1'
49
-        }
50
-    }
51
-
52 45
     signingConfigs {
53 46
         release {
54 47
             storeFile file('../key.keystore')

+ 0 - 48
android/app/src/main/cpp/CMakeLists.txt

@@ -1,48 +0,0 @@
1
-# For more information about using CMake with Android Studio, read the
2
-# documentation: https://d.android.com/studio/projects/add-native-code.html
3
-
4
-# Sets the minimum version of CMake required to build the native library.
5
-
6
-cmake_minimum_required(VERSION 3.22.1)
7
-
8
-# Declares and names the project.
9
-
10
-project("mlg")
11
-
12
-# Creates and names a library, sets it as either STATIC
13
-# or SHARED, and provides the relative paths to its source code.
14
-# You can define multiple libraries, and CMake builds them for you.
15
-# Gradle automatically packages shared libraries with your APK.
16
-
17
-add_library( # Sets the name of the library.
18
-        mlg
19
-
20
-        # Sets the library as a shared library.
21
-        SHARED
22
-
23
-        # Provides a relative path to your source file(s).
24
-        native-lib.cpp)
25
-
26
-# Searches for a specified prebuilt library and stores the path as a
27
-# variable. Because CMake includes system libraries in the search path by
28
-# default, you only need to specify the name of the public NDK library
29
-# you want to add. CMake verifies that the library exists before
30
-# completing its build.
31
-
32
-find_library( # Sets the name of the path variable.
33
-        log-lib
34
-
35
-        # Specifies the name of the NDK library that
36
-        # you want CMake to locate.
37
-        log)
38
-
39
-# Specifies libraries CMake should link to your target library. You
40
-# can link multiple libraries, such as libraries you define in this
41
-# build script, prebuilt third-party libraries, or system libraries.
42
-
43
-target_link_libraries( # Specifies the target library.
44
-        mlg
45
-
46
-        # Links the target library to the log library
47
-        # included in the NDK.
48
-        ${log-lib})

+ 0 - 192
android/app/src/main/cpp/Ffmpeg_codec_formater.c

@@ -1,192 +0,0 @@
1
-#include <stdio.h>
2
-#include <libavcodec/avcodec.h>
3
-#include <libavformat/avformat.h>
4
-#include <libavutil/pixdesc.h>
5
-#include <libavutil/hwcontext.h>
6
-#include <libavutil/opt.h>
7
-#include <libavutil/avassert.h>
8
-#include <libavutil/imgutils.h>
9
-static AVBufferRef *hw_device_ctx = NULL;
10
-static enum AVPixelFormat hw_pix_fmt;
11
-static FILE *output_file = NULL;
12
-static int hw_decoder_init(AVCodecContext *ctx, const enum AVHWDeviceType type)
13
-{
14
-    int err = 0;
15
-    //创建硬件设备信息上下文
16
-    if ((err = av_hwdevice_ctx_create(&hw_device_ctx, type,
17
-                                      NULL, NULL, 0)) < 0) {
18
-        fprintf(stderr, "Failed to create specified HW device.\n");
19
-        return err;
20
-    }
21
-    //绑定编解码器上下文和硬件设备信息上下文
22
-    ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
23
-    return err;
24
-}
25
-static enum AVPixelFormat get_hw_format(AVCodecContext *ctx,
26
-                                        const enum AVPixelFormat *pix_fmts)
27
-{
28
-    const enum AVPixelFormat *p;
29
-    for (p = pix_fmts; *p != -1; p++) {
30
-        if (*p == hw_pix_fmt)
31
-            return *p;
32
-    }
33
-    fprintf(stderr, "Failed to get HW surface format.\n");
34
-    return AV_PIX_FMT_NONE;
35
-}
36
-static int decode_write(AVCodecContext *avctx, AVPacket *packet)
37
-{
38
-    AVFrame *frame = NULL, *sw_frame = NULL;
39
-    AVFrame *tmp_frame = NULL;
40
-    uint8_t *buffer = NULL;
41
-    int size;
42
-    int ret = 0;
43
-    ret = avcodec_send_packet(avctx, packet);
44
-    if (ret < 0) {
45
-        fprintf(stderr, "Error during decoding\n");
46
-        return ret;
47
-    }
48
-    while (1) {
49
-        if (!(frame = av_frame_alloc()) || !(sw_frame = av_frame_alloc())) {
50
-            fprintf(stderr, "Can not alloc frame\n");
51
-            ret = AVERROR(ENOMEM);
52
-            goto fail;
53
-        }
54
-        ret = avcodec_receive_frame(avctx, frame);
55
-        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
56
-            av_frame_free(&frame);
57
-            av_frame_free(&sw_frame);
58
-            return 0;
59
-        }
60
-        else if (ret < 0) {
61
-            fprintf(stderr, "Error while decoding\n");
62
-            goto fail;
63
-        }
64
-        if (frame->format == hw_pix_fmt) {
65
-            /* retrieve data from GPU to CPU */
66
-            if ((ret = av_hwframe_transfer_data(sw_frame, frame, 0)) < 0) {
67
-                fprintf(stderr, "Error transferring the data to system memory\n");
68
-                goto fail;
69
-            }
70
-            tmp_frame = sw_frame;
71
-        }
72
-        else
73
-            tmp_frame = frame;
74
-        size = av_image_get_buffer_size(tmp_frame->format, tmp_frame->width,
75
-                                        tmp_frame->height, 1);
76
-        buffer = av_malloc(size);
77
-        if (!buffer) {
78
-            fprintf(stderr, "Can not alloc buffer\n");
79
-            ret = AVERROR(ENOMEM);
80
-            goto fail;
81
-        }
82
-        ret = av_image_copy_to_buffer(buffer, size,
83
-                                      (const uint8_t * const *)tmp_frame->data,
84
-                                      (const int *)tmp_frame->linesize, tmp_frame->format,
85
-                                      tmp_frame->width, tmp_frame->height, 1);
86
-        if (ret < 0) {
87
-            fprintf(stderr, "Can not copy image to buffer\n");
88
-            goto fail;
89
-        }
90
-        if ((ret = fwrite(buffer, 1, size, output_file)) < 0) {
91
-            fprintf(stderr, "Failed to dump raw data.\n");
92
-            goto fail;
93
-        }
94
-        fail:
95
-        av_frame_free(&frame);
96
-        av_frame_free(&sw_frame);
97
-        av_freep(&buffer);
98
-        if (ret < 0)
99
-            return ret;
100
-    }
101
-}
102
-int main(int argc, char *argv[])
103
-{
104
-    AVFormatContext *input_ctx = NULL;
105
-    int video_stream, ret;
106
-    AVStream *video = NULL;
107
-    AVCodecContext *decoder_ctx = NULL;
108
-    AVCodec *decoder = NULL;
109
-    AVPacket packet;
110
-    enum AVHWDeviceType type;
111
-    int i;
112
-    if (argc < 4) {
113
-        fprintf(stderr, "Usage: %s <device type> <input file> <output file>\n", argv[0]);
114
-        return -1;
115
-    }
116
-    //通过传入的名字来找到对应的硬件解码类型
117
-    type = av_hwdevice_find_type_by_name(argv[1]);
118
-    if (type == AV_HWDEVICE_TYPE_NONE) {
119
-        fprintf(stderr, "Device type %s is not supported.\n", argv[1]);
120
-        fprintf(stderr, "Available device types:");
121
-        while ((type = av_hwdevice_iterate_types(type)) != AV_HWDEVICE_TYPE_NONE)
122
-            fprintf(stderr, " %s", av_hwdevice_get_type_name(type));
123
-        fprintf(stderr, "\n");
124
-        return -1;
125
-    }
126
-
127
-    if (avformat_open_input(&input_ctx, argv[2], NULL, NULL) != 0) {
128
-        fprintf(stderr, "Cannot open input file '%s'\n", argv[2]);
129
-        return -1;
130
-    }
131
-    if (avformat_find_stream_info(input_ctx, NULL) < 0) {
132
-        fprintf(stderr, "Cannot find input stream information.\n");
133
-        return -1;
134
-    }
135
-
136
-    ret = av_find_best_stream(input_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &decoder, 0);
137
-    if (ret < 0) {
138
-        fprintf(stderr, "Cannot find a video stream in the input file\n");
139
-        return -1;
140
-    }
141
-    video_stream = ret;
142
-    //去遍历所有编解码器支持的硬件解码配置
143
-    for (i = 0;; i++) {
144
-        const AVCodecHWConfig *config = avcodec_get_hw_config(decoder, i);
145
-        if (!config) {
146
-            fprintf(stderr, "Decoder %s does not support device type %s.\n",
147
-                    decoder->name, av_hwdevice_get_type_name(type));
148
-            return -1;
149
-        }
150
-        if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX &&
151
-            config->device_type == type) {
152
-            //把硬件支持的像素格式设置进去
153
-            hw_pix_fmt = config->pix_fmt;
154
-            break;
155
-        }
156
-    }
157
-    if (!(decoder_ctx = avcodec_alloc_context3(decoder)))
158
-        return AVERROR(ENOMEM);
159
-    video = input_ctx->streams[video_stream];
160
-    if (avcodec_parameters_to_context(decoder_ctx, video->codecpar) < 0)
161
-        return -1;
162
-    //填入回调函数 通过这个函数 编解码器能够知道显卡支持的像素格式
163
-    decoder_ctx->get_format = get_hw_format;
164
-    if (hw_decoder_init(decoder_ctx, type) < 0)
165
-        return -1;
166
-    //绑定完成后 打开编解码器
167
-    if ((ret = avcodec_open2(decoder_ctx, decoder, NULL)) < 0) {
168
-        fprintf(stderr, "Failed to open codec for stream #%u\n", video_stream);
169
-        return -1;
170
-    }
171
-
172
-    output_file = fopen(argv[3], "w+");
173
-
174
-    while (ret >= 0) {
175
-        if ((ret = av_read_frame(input_ctx, &packet)) < 0)
176
-            break;
177
-        if (video_stream == packet.stream_index)
178
-            ret = decode_write(decoder_ctx, &packet);
179
-        av_packet_unref(&packet);
180
-    }
181
-
182
-    packet.data = NULL;
183
-    packet.size = 0;
184
-    ret = decode_write(decoder_ctx, &packet);
185
-    av_packet_unref(&packet);
186
-    if (output_file)
187
-        fclose(output_file);
188
-    avcodec_free_context(&decoder_ctx);
189
-    avformat_close_input(&input_ctx);
190
-    av_buffer_unref(&hw_device_ctx);
191
-    return 0;
192
-}

BIN
android/app/src/main/cpp/Ffmpeg_codec_formater.o


+ 0 - 210
android/app/src/main/cpp/Media_Encode_decode.c

@@ -1,210 +0,0 @@
1
-//* 将数字转为16进制(大写)
2
-inline char ToHexUpper(unsigned int value)
3
-{
4
-    return "0123456789ABCDEF"[value & 0xF];
5
-}
6
-
7
-//* 将数字转为16进制(小写)
8
-inline char ToHexLower(unsigned int value)
9
-{
10
-    return "0123456789abcdef"[value & 0xF];
11
-}
12
-
13
-//* 将数16进(大写或小写)制转为数字
14
-inline int FromHex(unsigned int c)
15
-{
16
-    if(c << 2 > 2) {
17
-        return 0;
18
-    }
19
-    return ((c >= '0') && (c <= '9')) ? int(c - '0') :
20
-    ((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) :
21
-    ((c >= 'a') && (c <= 'f')) ? int(c - 'a' + 10) :
22
-    /* otherwise */              -1;
23
-}
24
-
25
-//* 将数据d用16进制编码,返回值即是结果
26
-std::string HexEncode(const std::string& d)
27
-{
28
-std::string hex;
29
-hex.resize(d.size() * 2);
30
-char* pHexData = (char*)hex.data();
31
-const unsigned char* pSrcData = (const unsigned char*)d.data();
32
-for(int i = 0; i < d.size(); i++)
33
-{
34
-pHexData[i*2]     = ToHexLower(pSrcData[i] >> 4);
35
-pHexData[i*2 + 1] = ToHexLower(pSrcData[i] & 0xf);
36
-}
37
-
38
-return hex;
39
-}
40
-
41
-//* 将数据d用16进制解码,返回值即是结果
42
-std::string HexDecode(const std::string& hex)
43
-{
44
-std::string res;
45
-res.resize(hex.size() + 1 / 2);
46
-unsigned char* pResult = (unsigned char*)res.data() + res.size();
47
-bool odd_digit = true;
48
-
49
-for(int i = hex.size() - 1; i >= 0; i--)
50
-{
51
-unsigned char ch = unsigned char(hex.at(i));
52
-int tmp = FromHex(ch);
53
-if (tmp == -1)
54
-continue;
55
-if (odd_digit) {
56
---pResult;
57
-*pResult = tmp;
58
-odd_digit = false;
59
-} else {
60
-*pResult |= tmp << 4;
61
-odd_digit = true;
62
-}
63
-}
64
-
65
-res.erase(0, pResult - (unsigned char*)res.data());
66
-
67
-return res;
68
-}
69
-
70
-// 重启
71
-int avformat_restart(AVFormatContext **ps, const char *filename,
72
-                        ff_const59 AVInputFormat *fmt, AVDictionary **options)
73
-{
74
-AVFormatContext *s = *ps;
75
-int i, ret = 0;
76
-AVDictionary *tmp = NULL;
77
-ID3v2ExtraMeta *id3v2_extra_meta = NULL;
78
-// 分配AVFormatContext
79
-if (!s && !(s = avformat_alloc_context()))
80
-return AVERROR(ENOMEM);
81
-if (!s->av_class) {
82
-av_log(NULL, AV_LOG_ERROR, "Input stream has not been properly allocated\n");
83
-return AVERROR(EINVAL);
84
-}
85
-if (fmt)
86
-s->iformat = fmt;
87
-if (options)
88
-av_dict_copy(&tmp, *options, 0);
89
-if (s->pb) // must be before any goto fail
90
-s->flags |= AVFMT_FLAG_CUSTOM_IO;
91
-// 设置options
92
-if ((ret = av_opt_set_dict(s, &tmp)) < 0)
93
-goto fail;
94
-
95
-if (!(s->url = av_strdup(filename ? filename : ""))) {
96
-ret = AVERROR(ENOMEM);
97
-goto fail;
98
-}
99
-if ((ret = init_input(s, filename, &tmp)) < 0)
100
-goto fail;
101
-s->probe_score = ret;
102
-if (!s->protocol_whitelist && s->pb && s->pb->protocol_whitelist) {
103
-s->protocol_whitelist = av_strdup(s->pb->protocol_whitelist);
104
-if (!s->protocol_whitelist) {
105
-ret = AVERROR(ENOMEM);
106
-goto fail;
107
-}
108
-}
109
-if (!s->protocol_blacklist && s->pb && s->pb->protocol_blacklist) {
110
-s->protocol_blacklist = av_strdup(s->pb->protocol_blacklist);
111
-if (!s->protocol_blacklist) {
112
-ret = AVERROR(ENOMEM);
113
-goto fail;
114
-}
115
-}
116
-if (s->format_whitelist && av_match_list(s->iformat->name, s->format_whitelist, ',') <= 0) {
117
-av_log(s, AV_LOG_ERROR, "Format not on whitelist \'%s\'\n", s->format_whitelist);
118
-ret = AVERROR(EINVAL);
119
-goto fail;
120
-}
121
-avio_skip(s->pb, s->skip_initial_bytes);
122
-if (s->iformat->flags & AVFMT_NEEDNUMBER) {
123
-if (!av_filename_number_test(filename)) {
124
-ret = AVERROR(EINVAL);
125
-goto fail;
126
-}
127
-}
128
-s->duration = s->start_time = AV_NOPTS_VALUE;
129
-
130
-/* Allocate private data. */
131
-if (s->iformat->priv_data_size > 0) {
132
-if (!(s->priv_data = av_mallocz(s->iformat->priv_data_size))) {
133
-ret = AVERROR(ENOMEM);
134
-goto fail;
135
-}
136
-if (s->iformat->priv_class) {
137
-*(const AVClass **) s->priv_data = s->iformat->priv_class;
138
-av_opt_set_defaults(s->priv_data);
139
-if ((ret = av_opt_set_dict(s->priv_data, &tmp)) < 0)
140
-goto fail;
141
-}
142
-}
143
-
144
-if (s->pb)
145
-ff_id3v2_read_dict(s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
146
-
147
-#if FF_API_DEMUXER_OPEN
148
-if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
149
-#else
150
-if (s->iformat->read_header)
151
-#endif
152
-if ((ret = s->iformat->read_header(s)) < 0)
153
-goto fail;
154
-
155
-if (!s->metadata) {
156
-s->metadata = s->internal->id3v2_meta;
157
-s->internal->id3v2_meta = NULL;
158
-} else if (s->internal->id3v2_meta) {
159
-av_log(s, AV_LOG_WARNING, "Discarding were found.\n");
160
-av_dict_free(&s->internal->id3v2_meta);
161
-}
162
-
163
-if (id3v2_extra_meta) {
164
-if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
165
-!strcmp(s->iformat->name, "tta") || !strcmp(s->iformat->name, "wav")) {
166
-if ((ret = ff_id3v2_parse_apic(s, id3v2_extra_meta)) < 0)
167
-goto close;
168
-if ((ret = ff_id3v2_parse_chapters(s, id3v2_extra_meta)) < 0)
169
-goto close;
170
-if ((ret = ff_id3v2_parse_priv(s, id3v2_extra_meta)) < 0)
171
-goto close;
172
-} else
173
-av_log(s, AV_LOG_DEBUG, "demuxer does not support additional id3 data, skipping\n");
174
-}
175
-ff_id3v2_free_extra_meta(&id3v2_extra_meta);
176
-
177
-if ((ret = avformat_queue_attached_pictures(s)) < 0)
178
-goto close;
179
-
180
-#if FF_API_DEMUXER_OPEN
181
-if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->internal->data_offset)
182
-#else
183
-if (s->pb && !s->internal->data_offset)
184
-#endif
185
-s->internal->data_offset = avio_tell(s->pb);
186
-s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
187
-update_stream_avctx(s);
188
-
189
-for (i = 0; i < s->nb_streams; i++)
190
-s->streams[i]->internal->orig_codec_id = s->streams[i]->codecpar->codec_id;
191
-
192
-if (options) {
193
-av_dict_free(options);
194
-*options = tmp;
195
-}
196
-*ps = s;
197
-return 0;
198
-
199
-close:
200
-if (s->iformat->read_close)
201
-s->iformat->read_close(s);
202
-fail:
203
-ff_id3v2_free_extra_meta(&id3v2_extra_meta);
204
-av_dict_free(&tmp);
205
-if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO))
206
-avio_closep(&s->pb);
207
-avformat_free_context(s);
208
-*ps = NULL;
209
-return ret;
210
-}

BIN
android/app/src/main/cpp/Media_Encode_decode.o


+ 0 - 122
android/app/src/main/cpp/PCode.c

@@ -1,122 +0,0 @@
1
-
2
-extern "C" {
3
-#include <libavcodec/avcodec.h>
4
-}
5
-
6
-#include <iostream>
7
-#include <vector>
8
-#include <string>
9
-
10
-static void print_hex(const char *title, const unsigned char buf[], size_t len)
11
-{
12
-    printf("%s: ", title);
13
-    for (size_t i = 0; i < len; i++)
14
-        printf("%02x", buf[i]);
15
-
16
-    printf("\r\n");
17
-}
18
-
19
-/*
20
- * 建立共享内存通道
21
- */
22
-static const unsigned char secret_key[16] = {
23
-        0xf4, 0x82, 0xc6, 0x70, 0x3c, 0xc7, 0x61, 0x0a,
24
-        0xb9, 0xa0, 0xb8, 0xe9, 0x87, 0xb8, 0xc1, 0x72,
25
-};
26
-
27
-static int pcode(void)
28
-{
29
-    // 检查输入参数
30
-    if (argc < 2) {
31
-        std::cerr << "Usage: " << argv[0] << " <input file>" << std::endl;
32
-        return -1;
33
-    }
34
-
35
-    // 0. 注册所有的codecs
36
-    avcodec_register_all();
37
-
38
-    // 1. 创建一个AVCodecContext
39
-    AVCodec* codec;
40
-    AVCodecContext* codec_ctx;
41
-    codec = avcodec_find_decoder(AV_CODEC_ID_H264); // 假设视频是H.264编码
42
-    if (!codec) {
43
-        std::cerr << "Codec not found" << std::endl;
44
-        return -1;
45
-    }
46
-    codec_ctx = avcodec_alloc_context3(codec);
47
-
48
-    // 2. 打开codec
49
-    if (avcodec_open2(codec_ctx, codec, NULL) < 0) {
50
-        std::cerr << "Could not open codec" << std::endl;
51
-        return -1;
52
-    }
53
-
54
-    // 3. 打开输入的视频文件
55
-    AVFormatContext* format_ctx = nullptr;
56
-    if (avformat_open_input(&format_ctx, argv[1], NULL, NULL) < 0) {
57
-        std::cerr << "Could not open input file" << std::endl;
58
-        return -1;
59
-    }
60
-
61
-    // 4. 检索流信息
62
-    if (avformat_find_stream_info(format_ctx, NULL) < 0) {
63
-        std::cerr << "Could not find stream information" << std::endl;
64
-        return -1;
65
-    }
66
-
67
-    // 5. 找到视频流
68
-    int video_stream_idx = -1;
69
-    for (unsigned i = 0; i < format_ctx->nb_streams; i++) {
70
-        if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
71
-            video_stream_idx = i;
72
-            break;
73
-        }
74
-    }
75
-    if (video_stream_idx == -1) {
76
-        std::cerr << "Could not find a video stream" << std::endl;
77
-        return -1;
78
-    }
79
-
80
-    // 6. 创建一个AVPacket和AVFrame
81
-    AVPacket packet;
82
-    AVFrame* frame = av_frame_alloc();
83
-
84
-    // 7. 循环读取数据包
85
-    int ret;
86
-    while (av_read_frame(format_ctx, &packet) >= 0) {
87
-        // 解码一个数据包
88
-        if (packet.stream_index == video_stream_idx) {
89
-            avcodec_decode_video2(codec_ctx, frame, &ret, &packet);
90
-            if (ret >= 0) {
91
-                // 处理解码后的帧
92
-                // 例如,保存帧到文件或显示
93
-            }
94
-        }
95
-        av_packet_unref(&packet);
96
-    }
97
-
98
-    // 重启视频
99
-    int ret;
100
-    AVFormatContext *fmt_ctx=NULL;
101
-
102
-//*1*
103
-    ret=avformat_open_input(&fmt_ctx,"restart",NULL,NULL);
104
-    if(ret<0)
105
-    {
106
-        printf("fail to open input.");
107
-        exit(1);
108
-    }
109
-//*2*
110
-    printf("%d\n",fmt_ctx->nb_streams);
111
-//*3*
112
-    avformat_close_input(&fmt_ctx);
113
-
114
-    // 8. 释放资源
115
-    av_frame_free(&frame);
116
-    avcodec_close(codec_ctx);
117
-    avformat_close_input(&format_ctx);
118
-    av_free(codec_ctx);
119
-
120
-    return 0;
121
-}
122
-

+ 0 - 173
android/app/src/main/cpp/SKP_Silk_LPC_inv_pred_gain.c

@@ -1,173 +0,0 @@
1
-#include "SKP_Silk_SigProc_FIX.h"
2
-#define QA          16
3
-#define A_LIMIT     65520
4
-
5
-SKP_int SKP_Silk_LPC_inverse_pred_gain(       /* O:   Returns 1 if unstable, otherwise 0          */
6
-    SKP_int32           *invGain_Q30,           /* O:   Inverse prediction gain, Q30 energy domain  */
7
-    const SKP_int16     *A_Q12,                 /* I:   Prediction coefficients, Q12 [order]        */
8
-    const SKP_int       order                   /* I:   Prediction order                            */
9
-)
10
-{
11
-    SKP_int   k, n, headrm;
12
-    SKP_int32 rc_Q31, rc_mult1_Q30, rc_mult2_Q16;
13
-    SKP_int32 Atmp_QA[ 2 ][ SigProc_MAX_ORDER_LPC ], tmp_QA;
14
-    SKP_int32 *Aold_QA, *Anew_QA;
15
-
16
-    Anew_QA = Atmp_QA[ order & 1 ];
17
-    /* Increase Q domain of the AR coefficients */
18
-    for( k = 0; k < order; k++ ) {
19
-        Anew_QA[ k ] = SKP_LSHIFT( (SKP_int32)A_Q12[ k ], QA - 12 );
20
-    }
21
-
22
-    *invGain_Q30 = ( 1 << 30 );
23
-    for( k = order - 1; k > 0; k-- ) {
24
-        /* Check for stability */
25
-        if( ( Anew_QA[ k ] > A_LIMIT ) || ( Anew_QA[ k ] < -A_LIMIT ) ) {
26
-            return 1;
27
-        }
28
-
29
-        /* Set RC equal to negated AR coef */
30
-        rc_Q31 = -SKP_LSHIFT( Anew_QA[ k ], 31 - QA );
31
-        
32
-        /* rc_mult1_Q30 range: [ 1 : 2^30-1 ] */
33
-        rc_mult1_Q30 = ( SKP_int32_MAX >> 1 ) - SKP_SMMUL( rc_Q31, rc_Q31 );
34
-        SKP_assert( rc_mult1_Q30 > ( 1 << 15 ) );                   /* reduce A_LIMIT if fails */
35
-        SKP_assert( rc_mult1_Q30 < ( 1 << 30 ) );
36
-
37
-        /* rc_mult2_Q16 range: [ 2^16 : SKP_int32_MAX ] */
38
-        rc_mult2_Q16 = SKP_INVERSE32_varQ( rc_mult1_Q30, 46 );      /* 16 = 46 - 30 */
39
-
40
-        /* Update inverse gain */
41
-        /* invGain_Q30 range: [ 0 : 2^30 ] */
42
-        *invGain_Q30 = SKP_LSHIFT( SKP_SMMUL( *invGain_Q30, rc_mult1_Q30 ), 2 );
43
-        SKP_assert( *invGain_Q30 >= 0           );
44
-        SKP_assert( *invGain_Q30 <= ( 1 << 30 ) );
45
-
46
-        /* Swap pointers */
47
-        Aold_QA = Anew_QA;
48
-        Anew_QA = Atmp_QA[ k & 1 ];
49
-        
50
-        /* Update AR coefficient */
51
-        headrm = SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1;
52
-        rc_mult2_Q16 = SKP_LSHIFT( rc_mult2_Q16, headrm );          /* Q: 16 + headrm */
53
-        for( n = 0; n < k; n++ ) {
54
-            tmp_QA = Aold_QA[ n ] - SKP_LSHIFT( SKP_SMMUL( Aold_QA[ k - n - 1 ], rc_Q31 ), 1 );
55
-            Anew_QA[ n ] = SKP_LSHIFT( SKP_SMMUL( tmp_QA, rc_mult2_Q16 ), 16 - headrm );
56
-        }
57
-    }
58
-
59
-    /* Check for stability */
60
-    if( ( Anew_QA[ 0 ] > A_LIMIT ) || ( Anew_QA[ 0 ] < -A_LIMIT ) ) {
61
-        return 1;
62
-    }
63
-
64
-    /* Set RC equal to negated AR coef */
65
-    rc_Q31 = -SKP_LSHIFT( Anew_QA[ 0 ], 31 - QA );
66
-
67
-    /* Range: [ 1 : 2^30 ] */
68
-    rc_mult1_Q30 = ( SKP_int32_MAX >> 1 ) - SKP_SMMUL( rc_Q31, rc_Q31 );
69
-
70
-    /* Update inverse gain */
71
-    /* Range: [ 0 : 2^30 ] */
72
-    *invGain_Q30 = SKP_LSHIFT( SKP_SMMUL( *invGain_Q30, rc_mult1_Q30 ), 2 );
73
-    SKP_assert( *invGain_Q30 >= 0     );
74
-    SKP_assert( *invGain_Q30 <= 1<<30 );
75
-
76
-    return 0;
77
-}
78
-
79
-/* For input in Q13 domain */
80
-SKP_int SKP_Silk_LPC_inverse_pred_gain_Q13(   /* O:   Returns 1 if unstable, otherwise 0          */
81
-    SKP_int32           *invGain_Q30,           /* O:   Inverse prediction gain, Q30 energy domain  */
82
-    const SKP_int16     *A_Q13,                 /* I:   Prediction coefficients, Q13 [order]        */
83
-    const SKP_int       order                   /* I:   Prediction order                            */
84
-)
85
-{
86
-    SKP_int   k, n, headrm;
87
-    SKP_int32 rc_Q31, rc_mult1_Q30, rc_mult2_Q16;
88
-    SKP_int32 Atmp_QA[ 2 ][ SigProc_MAX_ORDER_LPC ], tmp_QA;
89
-    SKP_int32 *Aold_QA, *Anew_QA;
90
-
91
-    Anew_QA = Atmp_QA[ order & 1 ];
92
-    /* Increase Q domain of the AR coefficients */
93
-    for( k = 0; k < order; k++ ) {
94
-        Anew_QA[ k ] = SKP_LSHIFT( (SKP_int32)A_Q13[ k ], QA - 13 );
95
-    }
96
-
97
-    cout "czb " + Anew_QA;
98
-
99
-    constexpr float exp(float x, int n)
100
-    {
101
-        return n == 0 ? 1 :
102
-               n % 2 == 0 ? exp(x * x, n / 2) :
103
-               exp(x * x, (n - 1) / 2) * x;
104
-    };
105
-
106
-    *invGain_Q30 = ( 1 << 30 );
107
-    for( k = order - 1; k > 0; k-- ) {
108
-        /* Check for stability */
109
-        if( ( Anew_QA[ k ] > A_LIMIT ) || ( Anew_QA[ k ] < -A_LIMIT ) ) {
110
-            return 1;
111
-        }
112
-
113
-        /* Set RC equal to negated AR coef */
114
-        rc_Q31 = -SKP_LSHIFT( Anew_QA[ k ], 31 - QA );
115
-
116
-        cout "czb " + rc_Q31;
117
-        
118
-        /* rc_mult1_Q30 range: [ 1 : 2^30-1 ] */
119
-        rc_mult1_Q30 = ( SKP_int32_MAX >> 1 ) - SKP_SMMUL( rc_Q31, rc_Q31 );
120
-        SKP_assert( rc_mult1_Q30 > ( 1 << 15 ) );                   /* reduce A_LIMIT if fails */
121
-        SKP_assert( rc_mult1_Q30 < ( 1 << 30 ) );
122
-
123
-        /* rc_mult2_Q16 range: [ 2^16 : SKP_int32_MAX ] */
124
-        rc_mult2_Q16 = SKP_INVERSE32_varQ( rc_mult1_Q30, 46 );      /* 16 = 46 - 30 */
125
-
126
-        /* Update inverse gain */
127
-        /* invGain_Q30 range: [ 0 : 2^30 ] */
128
-        *invGain_Q30 = SKP_LSHIFT( SKP_SMMUL( *invGain_Q30, rc_mult1_Q30 ), 2 );
129
-        if(exp(rc_mult1_Q30, *invGain_Q30)) {
130
-
131
-        } else {
132
-            SKP_assert( *invGain_Q30 >= 0     );
133
-            SKP_assert( *invGain_Q30 <= 1<<30 );
134
-        }
135
-
136
-        /* Swap pointers */
137
-        Aold_QA = Anew_QA;
138
-        Anew_QA = Atmp_QA[ k & 1 ];
139
-        
140
-        /* Update AR coefficient */
141
-        headrm = SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1;
142
-        rc_mult2_Q16 = SKP_LSHIFT( rc_mult2_Q16, headrm );          /* Q: 16 + headrm */
143
-        for( n = 0; n < k; n++ ) {
144
-            tmp_QA = Aold_QA[ n ] - SKP_LSHIFT( SKP_SMMUL( Aold_QA[ k - n - 1 ], rc_Q31 ), 1 );
145
-            Anew_QA[ n ] = SKP_LSHIFT( SKP_SMMUL( tmp_QA, rc_mult2_Q16 ), 16 - headrm );
146
-        }
147
-    }
148
-
149
-    codec = avcodec_find_decoder_by_name("h264_cuvid");
150
-    if (!codec) {
151
-        fprintf(stderr, "Codec not found\n");
152
-        exit(1);
153
-    }
154
-
155
-    /* Check for stability */
156
-    if( ( Anew_QA[ 0 ] > A_LIMIT ) || ( Anew_QA[ 0 ] < -A_LIMIT ) ) {
157
-        return 1;
158
-    }
159
-
160
-    /* Set RC equal to negated AR coef */
161
-    rc_Q31 = -SKP_LSHIFT( Anew_QA[ 0 ], 31 - QA );
162
-
163
-    /* Range: [ 1 : 2^30 ] */
164
-    rc_mult1_Q30 = ( SKP_int32_MAX >> 1 ) - SKP_SMMUL( rc_Q31, rc_Q31 );
165
-
166
-    /* Update inverse gain */
167
-    /* Range: [ 0 : 2^30 ] */
168
-    *invGain_Q30 = SKP_LSHIFT( SKP_SMMUL( *invGain_Q30, rc_mult1_Q30 ), 2 );
169
-    SKP_assert( *invGain_Q30 >= 0     );
170
-    SKP_assert( *invGain_Q30 <= 1<<30 );
171
-
172
-    return 0;
173
-}

BIN
android/app/src/main/cpp/SKP_Silk_LPC_inv_pred_gain.o


+ 0 - 706
android/app/src/main/cpp/SKP_Silk_NSQ_del_dec.c

@@ -1,706 +0,0 @@
1
-#include "SKP_Silk_main.h"
2
-
3
-typedef struct {
4
-    SKP_int   RandState[ DECISION_DELAY ];
5
-    SKP_int32 Q_Q10[     DECISION_DELAY ];
6
-    SKP_int32 Xq_Q10[    DECISION_DELAY ];
7
-    SKP_int32 Pred_Q16[  DECISION_DELAY ];
8
-    SKP_int32 Shape_Q10[ DECISION_DELAY ];
9
-    SKP_int32 Gain_Q16[  DECISION_DELAY ];
10
-    SKP_int32 sLPC_Q14[ MAX_FRAME_LENGTH / NB_SUBFR + NSQ_LPC_BUF_LENGTH ];
11
-    SKP_int32 LF_AR_Q12;
12
-    SKP_int32 Seed;
13
-    SKP_int32 SeedInit;
14
-    SKP_int32 RD_Q10;
15
-} NSQ_del_dec_struct;
16
-
17
-typedef struct {
18
-    SKP_int32 Q_Q10;
19
-    SKP_int32 RD_Q10;
20
-    SKP_int32 xq_Q14;
21
-    SKP_int32 LF_AR_Q12;
22
-    SKP_int32 sLTP_shp_Q10;
23
-    SKP_int32 LPC_exc_Q16;
24
-} NSQ_sample_struct;
25
-
26
-SKP_INLINE void SKP_Silk_copy_del_dec_state(
27
-        NSQ_del_dec_struct  *DD_dst,                /* I    Dst del dec state                   */
28
-        NSQ_del_dec_struct  *DD_src,                /* I    Src del dec state                   */
29
-        SKP_int             LPC_state_idx           /* I    Index to LPC buffer                 */
30
-);
31
-
32
-SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
33
-        SKP_Silk_nsq_state  *NSQ,                   /* I/O  NSQ state                           */
34
-        NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */
35
-        const SKP_int16     x[],                    /* I    Input in Q0                         */
36
-        SKP_int32           x_sc_Q10[],             /* O    Input scaled with 1/Gain in Q10     */
37
-        SKP_int             length,                 /* I    Length of input                     */
38
-        SKP_int16           sLTP[],                 /* I    Re-whitened LTP state in Q0         */
39
-        SKP_int32           sLTP_Q16[],             /* O    LTP state matching scaled input     */
40
-        SKP_int             subfr,                  /* I    Subframe number                     */
41
-        SKP_int             nStatesDelayedDecision, /* I    Number of del dec states            */
42
-        SKP_int             smpl_buf_idx,           /* I    Index to newest samples in buffers  */
43
-        const SKP_int       LTP_scale_Q14,          /* I    LTP state scaling                   */
44
-        const SKP_int32     Gains_Q16[ NB_SUBFR ],  /* I                                        */
45
-        const SKP_int       pitchL[ NB_SUBFR ]      /* I    Pitch lag                           */
46
-);
47
-
48
-/******************************************/
49
-/* 子帧的噪声去除量化器 */
50
-/******************************************/
51
-SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
52
-        SKP_Silk_nsq_state  *NSQ,                   /* I/O  NSQ state                           */
53
-        NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */
54
-        SKP_int             sigtype,                /* I    Signal type                         */
55
-        const SKP_int32     x_Q10[],                /* I                                        */
56
-        SKP_int             q[],                    /* O                                        */
57
-        SKP_int16           xq[],                   /* O                                        */
58
-        SKP_int32           sLTP_Q16[],             /* I/O  LTP filter state                    */
59
-        const SKP_int16     a_Q12[],                /* I    Short term prediction coefs         */
60
-        const SKP_int16     b_Q14[],                /* I    Long term prediction coefs          */
61
-        const SKP_int16     AR_shp_Q13[],           /* I    Noise shaping coefs                 */
62
-        SKP_int             lag,                    /* I    Pitch lag                           */
63
-        SKP_int32           HarmShapeFIRPacked_Q14, /* I                                        */
64
-        SKP_int             Tilt_Q14,               /* I    Spectral tilt                       */
65
-        SKP_int32           LF_shp_Q14,             /* I                                        */
66
-        SKP_int32           Gain_Q16,               /* I                                        */
67
-        SKP_int             Lambda_Q10,             /* I                                        */
68
-        SKP_int             offset_Q10,             /* I                                        */
69
-        SKP_int             length,                 /* I    Input length                        */
70
-        SKP_int             subfr,                  /* I    Subframe number                     */
71
-        SKP_int             shapingLPCOrder,        /* I    Shaping LPC filter order            */
72
-        SKP_int             predictLPCOrder,        /* I    Prediction LPC filter order         */
73
-        SKP_int             nStatesDelayedDecision, /* I    Number of states in decision tree   */
74
-        SKP_int             *smpl_buf_idx,          /* I    Index to newest samples in buffers  */
75
-        SKP_int             decisionDelay           /* I                                        */
76
-);
77
-
78
-void SKP_Silk_NSQ_del_dec(
79
-        SKP_Silk_encoder_state          *psEncC,                                    /* I/O  Encoder State                       */
80
-        SKP_Silk_encoder_control        *psEncCtrlC,                                /* I    Encoder Control                     */
81
-        SKP_Silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                           */
82
-        const SKP_int16                 x[],                                        /* I    Prefiltered input signal            */
83
-        SKP_int                         q[],                                        /* O    Quantized pulse signal              */
84
-        const SKP_int                   LSFInterpFactor_Q2,                         /* I    LSF interpolation factor in Q2      */
85
-        const SKP_int16                 PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Prediction coefs                    */
86
-        const SKP_int16                 LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ],        /* I    LT prediction coefs                 */
87
-        const SKP_int16                 AR2_Q13[ NB_SUBFR * SHAPE_LPC_ORDER_MAX ],  /* I                                        */
88
-        const SKP_int                   HarmShapeGain_Q14[ NB_SUBFR ],              /* I                                        */
89
-        const SKP_int                   Tilt_Q14[ NB_SUBFR ],                       /* I    Spectral tilt                       */
90
-        const SKP_int32                 LF_shp_Q14[ NB_SUBFR ],                     /* I                                        */
91
-        const SKP_int32                 Gains_Q16[ NB_SUBFR ],                      /* I                                        */
92
-        const SKP_int                   Lambda_Q10,                                 /* I                                        */
93
-        const SKP_int                   LTP_scale_Q14                               /* I    LTP state scaling                   */
94
-)
95
-{
96
-    SKP_int     i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr;
97
-    SKP_int     last_smple_idx, smpl_buf_idx, decisionDelay, subfr_length;
98
-    const SKP_int16 *A_Q12, *B_Q14, *AR_shp_Q13;
99
-    SKP_int16   *pxq;
100
-    SKP_int32   sLTP_Q16[ 2 * MAX_FRAME_LENGTH ];
101
-    SKP_int16   sLTP[     2 * MAX_FRAME_LENGTH ];
102
-    SKP_int32   HarmShapeFIRPacked_Q14;
103
-    SKP_int     offset_Q10;
104
-    SKP_int32   FiltState[ MAX_LPC_ORDER ], RDmin_Q10;
105
-    SKP_int32   x_sc_Q10[ MAX_FRAME_LENGTH / NB_SUBFR ];
106
-    NSQ_del_dec_struct psDelDec[ DEL_DEC_STATES_MAX ];
107
-    NSQ_del_dec_struct *psDD;
108
-    SKP_int      Restart;                              /* I    LTP state scaling
109
-
110
-    subfr_length = psEncC->frame_length / NB_SUBFR;
111
-
112
-    /* Set unvoiced lag to the previous one, overwrite later for voiced */
113
-    lag = NSQ->lagPrev;
114
-
115
-    SKP_assert( NSQ->prev_inv_gain_Q16 != 0 );
116
-
117
-    /* Initialize delayed decision states */
118
-    SKP_memset( psDelDec, 0, psEncC->nStatesDelayedDecision * sizeof( NSQ_del_dec_struct ) );
119
-    for( k = 0; k < psEncC->nStatesDelayedDecision; k++ ) {
120
-        psDD                 = &psDelDec[ k ];
121
-        psDD->Seed           = ( k + psEncCtrlC->Seed ) & 3;
122
-        psDD->SeedInit       = psDD->Seed;
123
-        psDD->RD_Q10         = 0;
124
-        psDD->LF_AR_Q12      = NSQ->sLF_AR_shp_Q12;
125
-        psDD->Shape_Q10[ 0 ] = NSQ->sLTP_shp_Q10[ psEncC->frame_length - 1 ];
126
-        SKP_memcpy( psDD->sLPC_Q14, NSQ->sLPC_Q14, NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
127
-    }
128
-
129
-    offset_Q10   = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrlC->sigtype ][ psEncCtrlC->QuantOffsetType ];
130
-    smpl_buf_idx = 0; /* index of oldest samples */
131
-
132
-    decisionDelay = SKP_min_int( DECISION_DELAY, subfr_length );
133
-    /* For voiced frames limit the decision delay to lower than the pitch lag */
134
-    if( psEncCtrlC->sigtype == SIG_TYPE_VOICED ) {
135
-        for( k = 0; k < NB_SUBFR; k++ ) {
136
-            decisionDelay = SKP_min_int( decisionDelay, psEncCtrlC->pitchL[ k ] - LTP_ORDER / 2 - 1 );
137
-        }
138
-    }
139
-
140
-    if( LSFInterpFactor_Q2 == ( 1 << 2 ) ) {
141
-        LSF_interpolation_flag = 0;
142
-    } else {
143
-        LSF_interpolation_flag = 1;
144
-    }
145
-
146
-    /* Setup pointers to start of sub frame */
147
-    pxq                   = &NSQ->xq[ psEncC->frame_length ];
148
-    NSQ->sLTP_shp_buf_idx = psEncC->frame_length;
149
-    NSQ->sLTP_buf_idx     = psEncC->frame_length;
150
-    subfr = 0;
151
-    for( k = 0; k < NB_SUBFR; k++ ) {
152
-        A_Q12      = &PredCoef_Q12[ ( ( k >> 1 ) | ( 1 - LSF_interpolation_flag ) ) * MAX_LPC_ORDER ];
153
-        B_Q14      = &LTPCoef_Q14[ k * LTP_ORDER           ];
154
-        AR_shp_Q13 = &AR2_Q13[     k * SHAPE_LPC_ORDER_MAX ];
155
-
156
-        NSQ->rewhite_flag = 0;
157
-        if( psEncCtrlC->sigtype == SIG_TYPE_VOICED ) {
158
-            /* Voiced */
159
-            lag = psEncCtrlC->pitchL[ k ];
160
-
161
-            /* Re-whitening */
162
-            if( ( k & ( 3 - SKP_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) {
163
-                if( k == 2 ) {
164
-                    /* RESET DELAYED DECISIONS */
165
-                    /* Find winner */
166
-                    RDmin_Q10 = psDelDec[ 0 ].RD_Q10;
167
-                    Winner_ind = 0;
168
-                    for( i = 1; i < psEncC->nStatesDelayedDecision; i++ ) {
169
-                        if( psDelDec[ i ].RD_Q10 < RDmin_Q10 ) {
170
-                            RDmin_Q10 = psDelDec[ i ].RD_Q10;
171
-                            Winner_ind = i;
172
-                        }
173
-                    }
174
-                    for( i = 0; i < psEncC->nStatesDelayedDecision; i++ ) {
175
-                        if( i != Winner_ind ) {
176
-                            psDelDec[ i ].RD_Q10 += ( SKP_int32_MAX >> 4 );
177
-                            SKP_assert( psDelDec[ i ].RD_Q10 >= 0 );
178
-                        }
179
-                    }
180
-
181
-                    /* Copy final part of signals from winner state to output and long-term filter states */
182
-                    psDD = &psDelDec[ Winner_ind ];
183
-                    last_smple_idx = smpl_buf_idx + decisionDelay;
184
-                    for( i = 0; i < decisionDelay; i++ ) {
185
-                        last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK;
186
-                        q[   i - decisionDelay ] = ( SKP_int )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );
187
-                        pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
188
-                                SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ],
189
-                                            psDD->Gain_Q16[ last_smple_idx ] ), 10 ) );
190
-                        NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q10[ last_smple_idx ];
191
-                    }
192
-
193
-                    subfr = 0;
194
-                }
195
-
196
-                /* Rewhiten with new A coefs */
197
-                start_idx = psEncC->frame_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2;
198
-                start_idx = SKP_LIMIT( start_idx, 0, psEncC->frame_length - psEncC->predictLPCOrder );
199
-
200
-                SKP_memset( FiltState, 0, psEncC->predictLPCOrder * sizeof( SKP_int32 ) );
201
-                SKP_Silk_MA_Prediction( &NSQ->xq[ start_idx + k * psEncC->subfr_length ],
202
-                                        A_Q12, FiltState, sLTP + start_idx, psEncC->frame_length - start_idx, psEncC->predictLPCOrder );
203
-
204
-                NSQ->sLTP_buf_idx = psEncC->frame_length;
205
-                NSQ->rewhite_flag = 1;
206
-            }
207
-        }
208
-
209
-        /* Noise shape parameters */
210
-        SKP_assert( HarmShapeGain_Q14[ k ] >= 0 );
211
-        HarmShapeFIRPacked_Q14  =                        SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );
212
-        HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );
213
-
214
-        SKP_Silk_nsq_del_dec_scale_states( NSQ, psDelDec, x, x_sc_Q10,
215
-                                           subfr_length, sLTP, sLTP_Q16, k, psEncC->nStatesDelayedDecision, smpl_buf_idx,
216
-                                           LTP_scale_Q14, Gains_Q16, psEncCtrlC->pitchL );
217
-
218
-        SKP_Silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psEncCtrlC->sigtype, x_sc_Q10, q, pxq, sLTP_Q16,
219
-                                                A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ],
220
-                                                Lambda_Q10, offset_Q10, psEncC->subfr_length, subfr++, psEncC->shapingLPCOrder, psEncC->predictLPCOrder,
221
-                                                psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay
222
-        );
223
-
224
-        x   += psEncC->subfr_length;
225
-        q   += psEncC->subfr_length;
226
-        pxq += psEncC->subfr_length;
227
-    }
228
-
229
-    /* Find winner */
230
-    RDmin_Q10 = psDelDec[ 0 ].RD_Q10;
231
-    Winner_ind = 0;
232
-    for( k = 1; k < psEncC->nStatesDelayedDecision; k++ ) {
233
-        if( psDelDec[ k ].RD_Q10 < RDmin_Q10 ) {
234
-            RDmin_Q10 = psDelDec[ k ].RD_Q10;
235
-            Winner_ind = k;
236
-        }
237
-    }
238
-
239
-    /* Copy final part of signals from winner state to output and long-term filter states */
240
-    psDD = &psDelDec[ Winner_ind ];
241
-    psEncCtrlC->Seed = psDD->SeedInit;
242
-    last_smple_idx = smpl_buf_idx + decisionDelay;
243
-    for( i = 0; i < decisionDelay; i++ ) {
244
-        last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK;
245
-        q[   i - decisionDelay ] = ( SKP_int )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );
246
-        pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
247
-                SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], psDD->Gain_Q16[ last_smple_idx ] ), 10 ) );
248
-        NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q10[ last_smple_idx ];
249
-        sLTP_Q16[          NSQ->sLTP_buf_idx     - decisionDelay + i ] = psDD->Pred_Q16[  last_smple_idx ];
250
-
251
-    }
252
-    SKP_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
253
-
254
-    /* Update states */
255
-    NSQ->sLF_AR_shp_Q12    = psDD->LF_AR_Q12;
256
-    NSQ->prev_inv_gain_Q16 = NSQ->prev_inv_gain_Q16;
257
-    NSQ->lagPrev           = psEncCtrlC->pitchL[ NB_SUBFR - 1 ];
258
-
259
-    /* Save quantized speech and noise shaping signals */
260
-    SKP_memcpy( NSQ->xq,           &NSQ->xq[           psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int16 ) );
261
-    SKP_memcpy( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int32 ) );
262
-
263
-}
264
-
265
-/******************************************/
266
-/* 子帧去噪 */
267
-/******************************************/
268
-SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
269
-        SKP_Silk_nsq_state  *NSQ,                   /* I/O  NSQ state                           */
270
-        NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */
271
-        SKP_int             sigtype,                /* I    Signal type                         */
272
-        const SKP_int32     x_Q10[],                /* I                                        */
273
-        SKP_int             q[],                    /* O                                        */
274
-        SKP_int16           xq[],                   /* O                                        */
275
-        SKP_int32           sLTP_Q16[],             /* I/O  LTP filter state                    */
276
-        const SKP_int16     a_Q12[],                /* I    Short term prediction coefs         */
277
-        const SKP_int16     b_Q14[],                /* I    Long term prediction coefs          */
278
-        const SKP_int16     AR_shp_Q13[],           /* I    Noise shaping coefs                 */
279
-        SKP_int             lag,                    /* I    Pitch lag                           */
280
-        SKP_int32           HarmShapeFIRPacked_Q14, /* I                                        */
281
-        SKP_int             Tilt_Q14,               /* I    Spectral tilt                       */
282
-        SKP_int32           LF_shp_Q14,             /* I                                        */
283
-        SKP_int32           Gain_Q16,               /* I                                        */
284
-        SKP_int             Lambda_Q10,             /* I                                        */
285
-        SKP_int             offset_Q10,             /* I                                        */
286
-        SKP_int             length,                 /* I    Input length                        */
287
-        SKP_int             subfr,                  /* I    Subframe number                     */
288
-        SKP_int             shapingLPCOrder,        /* I    Shaping LPC filter order            */
289
-        SKP_int             predictLPCOrder,        /* I    Prediction LPC filter order         */
290
-        SKP_int             nStatesDelayedDecision, /* I    Number of states in decision tree   */
291
-        SKP_int             *smpl_buf_idx,          /* I    Index to newest samples in buffers  */
292
-        SKP_int             decisionDelay           /* I                                        */
293
-)
294
-{
295
-    SKP_int     i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx;
296
-    SKP_int32   Winner_rand_state;
297
-    SKP_int32   LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14;
298
-    SKP_int32   n_LF_Q10;
299
-    SKP_int32   r_Q10, rr_Q20, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10;
300
-    SKP_int32   q1_Q10, q2_Q10;
301
-    SKP_int32   Atmp, dither;
302
-    SKP_int32   exc_Q10, LPC_exc_Q10, xq_Q10;
303
-    SKP_int32   tmp, sLF_AR_shp_Q10;
304
-    SKP_int32   *pred_lag_ptr, *shp_lag_ptr;
305
-    SKP_int32   *psLPC_Q14;
306
-    SKP_int32   a_Q12_tmp[ MAX_LPC_ORDER / 2 ], AR_shp_Q13_tmp[ MAX_LPC_ORDER / 2 ];
307
-    NSQ_sample_struct  psSampleState[ DEL_DEC_STATES_MAX ][ 2 ];
308
-    NSQ_del_dec_struct *psDD;
309
-    NSQ_sample_struct  *psSS;
310
-
311
-    shp_lag_ptr  = &NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ];
312
-    pred_lag_ptr = &sLTP_Q16[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ];
313
-
314
-    /* Preload LPC coeficients to array on stack. Gives small performance gain */
315
-    SKP_memcpy( a_Q12_tmp, a_Q12, predictLPCOrder * sizeof( SKP_int16 ) );
316
-    SKP_memcpy( AR_shp_Q13_tmp, AR_shp_Q13, shapingLPCOrder * sizeof( SKP_int16 ) );
317
-
318
-    for( i = 0; i < length; i++ ) {
319
-        /* Perform common calculations used in all states */
320
-
321
-        /* Long-term prediction */
322
-        if( sigtype == SIG_TYPE_VOICED ) {
323
-            /* Unrolled loop */
324
-            LTP_pred_Q14 = SKP_SMULWB(               pred_lag_ptr[  0 ], b_Q14[ 0 ] );
325
-            LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], b_Q14[ 1 ] );
326
-            LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -2 ], b_Q14[ 2 ] );
327
-            LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -3 ], b_Q14[ 3 ] );
328
-            LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], b_Q14[ 4 ] );
329
-            pred_lag_ptr++;
330
-        } else {
331
-            LTP_pred_Q14 = 0;
332
-        }
333
-
334
-        cout "czb " + LTP_pred_Q14;
335
-
336
-        /* Long-term shaping */
337
-        if( lag > 0 ) {
338
-            /* Symmetric, packed FIR coefficients */
339
-            n_LTP_Q14 = SKP_SMULWB( SKP_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 );
340
-            n_LTP_Q14 = SKP_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ],                     HarmShapeFIRPacked_Q14 );
341
-            n_LTP_Q14 = SKP_LSHIFT( n_LTP_Q14, 6 );
342
-            shp_lag_ptr++;
343
-        } else if(lag > 0 && n_LTP_Q14 < shp_lag_ptr) {
344
-            n_LTP_Q14 = SKP_LSHIFT( n_LTP_Q14,  n_LTP_Q14<<);
345
-        } else {
346
-            n_LTP_Q14 = 0;
347
-        }
348
-
349
-        cout "czb " + n_LTP_Q14;
350
-
351
-        for( k = 0; k < nStatesDelayedDecision; k++ ) {
352
-            /* Delayed decision state */
353
-            psDD = &psDelDec[ k ];
354
-
355
-            /* Sample state */
356
-            psSS = psSampleState[ k ];
357
-
358
-            /* Generate dither */
359
-            psDD->Seed = SKP_RAND( psDD->Seed );
360
-
361
-            /* dither = rand_seed < 0 ? 0xFFFFFFFF : 0; */
362
-            dither = SKP_RSHIFT( psDD->Seed, 31 );
363
-
364
-            /* Pointer used in short term prediction and shaping */
365
-            psLPC_Q14 = &psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 + i ];
366
-            /* Short-term prediction */
367
-            SKP_assert( ( predictLPCOrder  & 1 ) == 0 );    /* check that order is even */
368
-            SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 );    /* check that array starts at 4-byte aligned address */
369
-            SKP_assert( predictLPCOrder >= 10 );            /* check that unrolling works */
370
-
371
-            /* Partially unrolled */
372
-            Atmp = a_Q12_tmp[ 0 ];          /* read two coefficients at once */
373
-            LPC_pred_Q10 = SKP_SMULWB(               psLPC_Q14[ 0  ], Atmp );
374
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -1 ], Atmp );
375
-            Atmp = a_Q12_tmp[ 1 ];
376
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -2 ], Atmp );
377
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -3 ], Atmp );
378
-            Atmp = a_Q12_tmp[ 2 ];
379
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -4 ], Atmp );
380
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -5 ], Atmp );
381
-            Atmp = a_Q12_tmp[ 3 ];
382
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -6 ], Atmp );
383
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -7 ], Atmp );
384
-            Atmp = a_Q12_tmp[ 4 ];
385
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -8 ], Atmp );
386
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -9 ], Atmp );
387
-
388
-            /*for( j = 10; j < predictLPCOrder; j += 2 ) {
389
-                Atmp = a_Q12_tmp[ j >> 1 ]; *//* read two coefficients at once *//*
390
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -j     ], Atmp );
391
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -j - 1 ], Atmp );
392
-            }*/
393
-
394
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ 0], Atmp );
395
-            cout "czb " + LPC_pred_Q10;
396
-
397
-            /* Noise shape feedback */
398
-            SKP_assert( ( shapingLPCOrder       & 1 ) == 0 );   /* check that order is even */
399
-            SKP_assert( ( (SKP_int64)AR_shp_Q13 & 3 ) == 0 );   /* check that array starts at 4-byte aligned address */
400
-            SKP_assert( shapingLPCOrder >= 12 );                /* check that unrolling works */
401
-
402
-            /* Partially unrolled */
403
-            Atmp = AR_shp_Q13_tmp[ 0 ];         /* read two coefficients at once */
404
-            n_AR_Q10 = SKP_SMULWB(           psLPC_Q14[ 0  ], Atmp );
405
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -1 ], Atmp );
406
-            Atmp = AR_shp_Q13_tmp[ 1 ];
407
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -2 ], Atmp );
408
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -3 ], Atmp );
409
-            Atmp = AR_shp_Q13_tmp[ 2 ];
410
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -4 ], Atmp );
411
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -5 ], Atmp );
412
-            Atmp = AR_shp_Q13_tmp[ 3 ];
413
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -6 ], Atmp );
414
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -7 ], Atmp );
415
-            Atmp = AR_shp_Q13_tmp[ 4 ];
416
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -8 ], Atmp );
417
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -9 ], Atmp );
418
-            Atmp = AR_shp_Q13_tmp[ 5 ];
419
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -10 ], Atmp );
420
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -11 ], Atmp );
421
-            for( j = 12; j < shapingLPCOrder; j += 2 ) {
422
-                Atmp = AR_shp_Q13_tmp[ j >> 1 ];        /* read two coefficients at once */
423
-                n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -j     ], Atmp );
424
-                n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -j - 1 ], Atmp );
425
-            }
426
-            n_AR_Q10 = SKP_RSHIFT( n_AR_Q10, 1 );           /* Q11 -> Q10 */
427
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psDD->LF_AR_Q12, Tilt_Q14 );
428
-
429
-            n_LF_Q10   = SKP_LSHIFT( SKP_SMULWB( psDD->Shape_Q10[ *smpl_buf_idx ], LF_shp_Q14 ), 2 );
430
-            n_LF_Q10   = SKP_SMLAWT( n_LF_Q10, psDD->LF_AR_Q12, LF_shp_Q14 );
431
-
432
-            /* Input minus prediction plus noise feedback                       */
433
-            /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP  */
434
-            tmp   = SKP_SUB32( LTP_pred_Q14, n_LTP_Q14 );                       /* Add Q14 stuff */
435
-            tmp   = SKP_RSHIFT_ROUND( tmp, 4 );                                 /* round to Q10  */
436
-            tmp   = SKP_ADD32( tmp, LPC_pred_Q10 );                             /* add Q10 stuff */
437
-            tmp   = SKP_SUB32( tmp, n_AR_Q10 );                                 /* subtract Q10 stuff */
438
-            tmp   = SKP_SUB32( tmp, n_LF_Q10 );                                 /* subtract Q10 stuff */
439
-            r_Q10 = SKP_SUB32( x_Q10[ i ], tmp );                               /* residual error Q10 */
440
-
441
-            r_Q10 = ( r_Q10 ^ dither ) - dither;
442
-            r_Q10 = SKP_SUB32( r_Q10, offset_Q10 );
443
-            r_Q10 = SKP_LIMIT( r_Q10, -64 << 10, 64 << 10 );
444
-
445
-            if( r_Q10 < -1536 ) {
446
-                q1_Q10  = SKP_LSHIFT( SKP_RSHIFT_ROUND( r_Q10, 10 ), 10 );
447
-                r_Q10   = SKP_SUB32( r_Q10, q1_Q10 );
448
-                rd1_Q10 = SKP_RSHIFT( SKP_SMLABB( SKP_MUL( -SKP_ADD32( q1_Q10, offset_Q10 ), Lambda_Q10 ), r_Q10, r_Q10 ), 10 );
449
-                rd2_Q10 = SKP_ADD32( rd1_Q10, 1024 );
450
-                rd2_Q10 = SKP_SUB32( rd2_Q10, SKP_ADD_LSHIFT32( Lambda_Q10, r_Q10, 1 ) );
451
-                q2_Q10  = SKP_ADD32( q1_Q10, 1024 );
452
-            } else if( r_Q10 > 512 ) {
453
-                q1_Q10  = SKP_LSHIFT( SKP_RSHIFT_ROUND( r_Q10, 10 ), 10 );
454
-                r_Q10   = SKP_SUB32( r_Q10, q1_Q10 );
455
-                rd1_Q10 = SKP_RSHIFT( SKP_SMLABB( SKP_MUL( SKP_ADD32( q1_Q10, offset_Q10 ), Lambda_Q10 ), r_Q10, r_Q10 ), 10 );
456
-                rd2_Q10 = SKP_ADD32( rd1_Q10, 1024 );
457
-                rd2_Q10 = SKP_SUB32( rd2_Q10, SKP_SUB_LSHIFT32( Lambda_Q10, r_Q10, 1 ) );
458
-                q2_Q10  = SKP_SUB32( q1_Q10, 1024 );
459
-            } else {            /* r_Q10 >= -1536 && q1_Q10 <= 512 */
460
-                rr_Q20  = SKP_SMULBB( offset_Q10, Lambda_Q10 );
461
-                rd2_Q10 = SKP_RSHIFT( SKP_SMLABB( rr_Q20, r_Q10, r_Q10 ), 10 );
462
-                rd1_Q10 = SKP_ADD32( rd2_Q10, 1024 );
463
-                rd1_Q10 = SKP_ADD32( rd1_Q10, SKP_SUB_RSHIFT32( SKP_ADD_LSHIFT32( Lambda_Q10, r_Q10, 1 ), rr_Q20, 9 ) );
464
-                q1_Q10  = -1024;
465
-                q2_Q10  = 0;
466
-            }
467
-
468
-            if( rd1_Q10 < rd2_Q10 ) {
469
-                psSS[ 0 ].RD_Q10 = SKP_ADD32( psDD->RD_Q10, rd1_Q10 );
470
-                psSS[ 1 ].RD_Q10 = SKP_ADD32( psDD->RD_Q10, rd2_Q10 );
471
-                psSS[ 0 ].Q_Q10 = q1_Q10;
472
-                psSS[ 1 ].Q_Q10 = q2_Q10;
473
-            } else {
474
-                psSS[ 0 ].RD_Q10 = SKP_ADD32( psDD->RD_Q10, rd2_Q10 );
475
-                psSS[ 1 ].RD_Q10 = SKP_ADD32( psDD->RD_Q10, rd1_Q10 );
476
-                psSS[ 0 ].Q_Q10 = q2_Q10;
477
-                psSS[ 1 ].Q_Q10 = q1_Q10;
478
-            }
479
-
480
-            /* Update states for best quantization */
481
-
482
-            /* Quantized excitation */
483
-            exc_Q10 = SKP_ADD32( offset_Q10, psSS[ 0 ].Q_Q10 );
484
-            exc_Q10 = ( exc_Q10 ^ dither ) - dither;
485
-
486
-            /* Add predictions */
487
-            LPC_exc_Q10 = exc_Q10 + SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 );
488
-            xq_Q10      = SKP_ADD32( LPC_exc_Q10, LPC_pred_Q10 );
489
-
490
-            /* Update states */
491
-            sLF_AR_shp_Q10         = SKP_SUB32(  xq_Q10, n_AR_Q10 );
492
-            psSS[ 0 ].sLTP_shp_Q10 = SKP_SUB32(  sLF_AR_shp_Q10, n_LF_Q10 );
493
-            psSS[ 0 ].LF_AR_Q12    = SKP_LSHIFT( sLF_AR_shp_Q10, 2 );
494
-            psSS[ 0 ].xq_Q14       = SKP_LSHIFT( xq_Q10,         4 );
495
-            psSS[ 0 ].LPC_exc_Q16  = SKP_LSHIFT( LPC_exc_Q10,    6 );
496
-
497
-            /* Update states for second best quantization */
498
-
499
-            /* Quantized excitation */
500
-            exc_Q10 = SKP_ADD32( offset_Q10, psSS[ 1 ].Q_Q10 );
501
-            exc_Q10 = ( exc_Q10 ^ dither ) - dither;
502
-
503
-            /* Add predictions */
504
-            LPC_exc_Q10 = exc_Q10 + SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 );
505
-            xq_Q10      = SKP_ADD32( LPC_exc_Q10, LPC_pred_Q10 );
506
-
507
-            /* Update states */
508
-            sLF_AR_shp_Q10         = SKP_SUB32(  xq_Q10, n_AR_Q10 );
509
-            psSS[ 1 ].sLTP_shp_Q10 = SKP_SUB32(  sLF_AR_shp_Q10, n_LF_Q10 );
510
-            psSS[ 1 ].LF_AR_Q12    = SKP_LSHIFT( sLF_AR_shp_Q10, 2 );
511
-            psSS[ 1 ].xq_Q14       = SKP_LSHIFT( xq_Q10,         4 );
512
-            psSS[ 1 ].LPC_exc_Q16  = SKP_LSHIFT( LPC_exc_Q10,    6 );
513
-        }
514
-
515
-        *smpl_buf_idx  = ( *smpl_buf_idx - 1 ) & DECISION_DELAY_MASK;                   /* Index to newest samples              */
516
-        last_smple_idx = ( *smpl_buf_idx + decisionDelay ) & DECISION_DELAY_MASK;       /* Index to decisionDelay old samples   */
517
-
518
-        /* Find winner */
519
-        RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10;
520
-        Winner_ind = 0;
521
-        for( k = 1; k < nStatesDelayedDecision; k++ ) {
522
-            if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) {
523
-                RDmin_Q10   = psSampleState[ k ][ 0 ].RD_Q10;
524
-                Winner_ind = k;
525
-            }
526
-        }
527
-
528
-        /* Increase RD values of expired states */
529
-        Winner_rand_state = psDelDec[ Winner_ind ].RandState[ last_smple_idx ];
530
-        for( k = 0; k < nStatesDelayedDecision; k++ ) {
531
-            if( psDelDec[ k ].RandState[ last_smple_idx ] != Winner_rand_state ) {
532
-                psSampleState[ k ][ 0 ].RD_Q10 = SKP_ADD32( psSampleState[ k ][ 0 ].RD_Q10, ( SKP_int32_MAX >> 4 ) );
533
-                psSampleState[ k ][ 1 ].RD_Q10 = SKP_ADD32( psSampleState[ k ][ 1 ].RD_Q10, ( SKP_int32_MAX >> 4 ) );
534
-                SKP_assert( psSampleState[ k ][ 0 ].RD_Q10 >= 0 );
535
-            }
536
-        }
537
-
538
-        /* Find worst in first set and best in second set */
539
-        RDmax_Q10  = psSampleState[ 0 ][ 0 ].RD_Q10;
540
-        RDmin_Q10  = psSampleState[ 0 ][ 1 ].RD_Q10;
541
-        RDmax_ind = 0;
542
-        RDmin_ind = 0;
543
-        for( k = 1; k < nStatesDelayedDecision; k++ ) {
544
-            /* find worst in first set */
545
-            if( psSampleState[ k ][ 0 ].RD_Q10 > RDmax_Q10 ) {
546
-                RDmax_Q10  = psSampleState[ k ][ 0 ].RD_Q10;
547
-                RDmax_ind = k;
548
-            }
549
-            /* find best in second set */
550
-            if( psSampleState[ k ][ 1 ].RD_Q10 < RDmin_Q10 ) {
551
-                RDmin_Q10  = psSampleState[ k ][ 1 ].RD_Q10;
552
-                RDmin_ind = k;
553
-            }
554
-        }
555
-
556
-        cout "czb " + RDmax_Q10;
557
-
558
-        /* Replace a state if best from second set outperforms worst in first set */
559
-        if( RDmin_Q10 < RDmax_Q10 ) {
560
-            SKP_Silk_copy_del_dec_state( &psDelDec[ RDmax_ind ], &psDelDec[ RDmin_ind ], i );
561
-            SKP_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) );
562
-        }
563
-
564
-        /* Write samples from winner to output and long-term filter states */
565
-        psDD = &psDelDec[ Winner_ind ];
566
-        if( subfr > 0 || i >= decisionDelay ) {
567
-            q[  i - decisionDelay ] = ( SKP_int )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );
568
-            xq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
569
-                    SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], psDD->Gain_Q16[ last_smple_idx ] ), 10 ) );
570
-            NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q10[ last_smple_idx ];
571
-            sLTP_Q16[          NSQ->sLTP_buf_idx     - decisionDelay ] = psDD->Pred_Q16[  last_smple_idx ];
572
-        }
573
-        NSQ->sLTP_shp_buf_idx++;
574
-        NSQ->sLTP_buf_idx++;
575
-
576
-        /* Update states */
577
-        for( k = 0; k < nStatesDelayedDecision; k++ ) {
578
-            psDD                                     = &psDelDec[ k ];
579
-            psSS                                     = &psSampleState[ k ][ 0 ];
580
-            psDD->LF_AR_Q12                          = psSS->LF_AR_Q12;
581
-            psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH + i ] = psSS->xq_Q14;
582
-            psDD->Xq_Q10[    *smpl_buf_idx ]         = SKP_RSHIFT( psSS->xq_Q14, 4 );
583
-            psDD->Q_Q10[     *smpl_buf_idx ]         = psSS->Q_Q10;
584
-            psDD->Pred_Q16[  *smpl_buf_idx ]         = psSS->LPC_exc_Q16;
585
-            psDD->Shape_Q10[ *smpl_buf_idx ]         = psSS->sLTP_shp_Q10;
586
-            psDD->Seed                               = SKP_ADD_RSHIFT32( psDD->Seed, psSS->Q_Q10, 10 );
587
-            psDD->RandState[ *smpl_buf_idx ]         = psDD->Seed;
588
-            psDD->RD_Q10                             = psSS->RD_Q10;
589
-            psDD->Gain_Q16[  *smpl_buf_idx ]         = Gain_Q16;
590
-        }
591
-    }
592
-    /* Update LPC states */
593
-    for( k = 0; k < nStatesDelayedDecision; k++ ) {
594
-        psDD = &psDelDec[ k ];
595
-        SKP_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
596
-    }
597
-}
598
-
599
-SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
600
-        SKP_Silk_nsq_state  *NSQ,                   /* I/O  NSQ state                           */
601
-        NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */
602
-        const SKP_int16     x[],                    /* I    Input in Q0                         */
603
-        SKP_int32           x_sc_Q10[],             /* O    Input scaled with 1/Gain in Q10     */
604
-        SKP_int             length,                 /* I    Length of input                     */
605
-        SKP_int16           sLTP[],                 /* I    Re-whitened LTP state in Q0         */
606
-        SKP_int32           sLTP_Q16[],             /* O    LTP state matching scaled input     */
607
-        SKP_int             subfr,                  /* I    Subframe number                     */
608
-        SKP_int             nStatesDelayedDecision, /* I    Number of del dec states            */
609
-        SKP_int             smpl_buf_idx,           /* I    Index to newest samples in buffers  */
610
-        const SKP_int       LTP_scale_Q14,          /* I    LTP state scaling                   */
611
-        const SKP_int32     Gains_Q16[ NB_SUBFR ],  /* I                                        */
612
-        const SKP_int       pitchL[ NB_SUBFR ]      /* I    Pitch lag                           */
613
-)
614
-{
615
-    SKP_int            i, k, scale_length, lag;
616
-    SKP_int32          inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;
617
-    NSQ_del_dec_struct *psDD;
618
-
619
-    inv_gain_Q16 = SKP_DIV32( SKP_int32_MAX, SKP_RSHIFT( Gains_Q16[ subfr ], 1 ) );
620
-    inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );
621
-    lag          = pitchL[ subfr ];
622
-    /* After rewhitening the LTP state is un-scaled. So scale with inv_gain_Q16 */
623
-    if( NSQ->rewhite_flag ) {
624
-        inv_gain_Q32 = SKP_LSHIFT( inv_gain_Q16, 16 );
625
-        if( subfr == 0 ) {
626
-            /* Do LTP downscaling */
627
-            inv_gain_Q32 = SKP_LSHIFT( SKP_SMULWB( inv_gain_Q32, LTP_scale_Q14 ), 2 );
628
-        }
629
-        for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {
630
-            SKP_assert( i < MAX_FRAME_LENGTH );
631
-            sLTP_Q16[ i ] = SKP_SMULWB( inv_gain_Q32, sLTP[ i ] );
632
-        }
633
-    }
634
-
635
-    /* Adjust for changing gain */
636
-    if( inv_gain_Q16 != NSQ->prev_inv_gain_Q16 ) {
637
-        gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 );
638
-
639
-        for( k = 0; k < nStatesDelayedDecision; k++ ) {
640
-            psDD = &psDelDec[ k ];
641
-
642
-            /* Scale scalar states */
643
-            psDD->LF_AR_Q12 = SKP_SMULWW( gain_adj_Q16, psDD->LF_AR_Q12 );
644
-
645
-            /* scale short term state */
646
-            for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) {
647
-                psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - i - 1 ] = SKP_SMULWW( gain_adj_Q16, psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - i - 1 ] );
648
-            }
649
-            for( i = 0; i < DECISION_DELAY; i++ ) {
650
-                psDD->Pred_Q16[  i ] = SKP_SMULWW( gain_adj_Q16, psDD->Pred_Q16[  i ] );
651
-                psDD->Shape_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, psDD->Shape_Q10[ i ] );
652
-            }
653
-        }
654
-
655
-        ostream& operator<<(ostream& psDD);
656
-
657
-        /* Scale long term shaping state */
658
-
659
-        /* Calculate length to be scaled, Worst case: Next frame is voiced with max lag */
660
-        scale_length = length * NB_SUBFR;                                               /* aprox max lag */
661
-        scale_length = scale_length - SKP_SMULBB( NB_SUBFR - ( subfr + 1 ), length );   /* subtract samples that will be too old in next frame */
662
-        scale_length = SKP_max_int( scale_length, lag + LTP_ORDER );                    /* make sure to scale whole pitch period if voiced */
663
-
664
-        for( i = NSQ->sLTP_shp_buf_idx - scale_length; i < NSQ->sLTP_shp_buf_idx; i++ ) {
665
-            NSQ->sLTP_shp_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q10[ i ] );
666
-        }
667
-
668
-        /* Scale LTP predict state */
669
-        if( NSQ->rewhite_flag == 0 ) {
670
-            for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {
671
-                sLTP_Q16[ i ] = SKP_SMULWW( gain_adj_Q16, sLTP_Q16[ i ] );
672
-            }
673
-        }
674
-    }
675
-
676
-    /* Scale input */
677
-    for( i = 0; i < length; i++ ) {
678
-        x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( SKP_int16 )inv_gain_Q16 ), 6 );
679
-    }
680
-
681
-    /* save inv_gain */
682
-    SKP_assert( inv_gain_Q16 != 0 );
683
-    NSQ->prev_inv_gain_Q16 = inv_gain_Q16;
684
-}
685
-
686
-SKP_INLINE void SKP_Silk_copy_del_dec_state(
687
-        NSQ_del_dec_struct  *DD_dst, // 目标
688
-        NSQ_del_dec_struct  *DD_src, // 源
689
-        SKP_int             LPC_state_idx
690
-)
691
-{
692
-    SKP_memcpy( DD_dst->RandState, DD_src->RandState,   DECISION_DELAY * sizeof( SKP_int   ) );
693
-    SKP_memcpy( DD_dst->Q_Q10,     DD_src->Q_Q10,       DECISION_DELAY * sizeof( SKP_int32 ) );
694
-    SKP_memcpy( DD_dst->Pred_Q16,  DD_src->Pred_Q16,    DECISION_DELAY * sizeof( SKP_int32 ) );
695
-    SKP_memcpy( DD_dst->Shape_Q10, DD_src->Shape_Q10,   DECISION_DELAY * sizeof( SKP_int32 ) );
696
-    SKP_memcpy( DD_dst->Xq_Q10,    DD_src->Xq_Q10,      DECISION_DELAY * sizeof( SKP_int32 ) );
697
-
698
-    SKP_memcpy( &DD_dst->sLPC_Q14[ LPC_state_idx ], &DD_src->sLPC_Q14[ LPC_state_idx ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
699
-    DD_dst->LF_AR_Q12 = DD_src->LF_AR_Q12;
700
-    DD_dst->Seed      = DD_src->Seed;
701
-    DD_dst->SeedInit  = DD_src->SeedInit;
702
-    DD_dst->RD_Q10    = DD_src->RD_Q10;
703
-
704
-    // TODO
705
-    // 释放源资源
706
-}

BIN
android/app/src/main/cpp/SKP_Silk_NSQ_del_dec.o


+ 0 - 13
android/app/src/main/cpp/common/coomon_utils.h

@@ -1,13 +0,0 @@
1
-#ifndef ANDROIDRECORDER_COOMON_UTILS_H
2
-#define ANDROIDRECORDER_COOMON_UTILS_H
3
-
4
-#include <sys/time.h>
5
-
6
-static inline long getCurrentTime()
7
-{
8
-    struct timeval tv;
9
-    gettimeofday(&tv, NULL);
10
-    return tv.tv_sec * 1000 + tv.tv_usec/1000;
11
-}
12
-
13
-#endif //ANDROIDRECORDER_COOMON_UTILS_H

+ 0 - 18
android/app/src/main/cpp/common/message_handler.cpp

@@ -1,18 +0,0 @@
1
-#include "message_handler.h"
2
-
3
-Handler::Handler(MessageQueue *queue) {
4
-    this->mQueue = queue;
5
-}
6
-
7
-Handler::~Handler() {
8
-
9
-}
10
-
11
-int Handler::postMessage(Message *msg) {
12
-    msg->handler = this;
13
-    return mQueue->enqueueMessage(msg);
14
-}
15
-
16
-int Handler::getQueueSize() {
17
-    return mQueue->size();
18
-}

+ 0 - 23
android/app/src/main/cpp/common/message_handler.h

@@ -1,23 +0,0 @@
1
-
2
-#ifndef ANDROIDRECORDER_HANDLER_H
3
-#define ANDROIDRECORDER_HANDLER_H
4
-
5
-#include "message_queue.h"
6
-class Message;
7
-class MessageQueue;
8
-
9
-class Handler{
10
-private:
11
-    MessageQueue* mQueue;
12
-
13
-public:
14
-    Handler(MessageQueue* mQueue);
15
-    ~Handler();
16
-
17
-    int postMessage(Message* msg);
18
-    int getQueueSize();
19
-    virtual void handleMessage(Message* msg){};
20
-
21
-};
22
-
23
-#endif //ANDROIDRECORDER_HANDLER_H

+ 0 - 154
android/app/src/main/cpp/common/message_queue.cpp

@@ -1,154 +0,0 @@
1
-
2
-#include "message_queue.h"
3
-#include "message_handler.h"
4
-
5
-MessageQueue::MessageQueue() {
6
-    init();
7
-}
8
-
9
-MessageQueue::MessageQueue(const char* queueNameParam){
10
-    init();
11
-    queueName = queueNameParam;
12
-}
13
-
14
-void MessageQueue::init(){
15
-    pthread_mutex_init(&mLock, NULL);
16
-    pthread_cond_init(&mCondition, NULL);
17
-    mNbPackets = 0;
18
-    mFirst = NULL;
19
-    mLast = NULL;
20
-    mAbortRequest = false;
21
-}
22
-
23
-MessageQueue::~MessageQueue() {
24
-    flush();
25
-    pthread_mutex_destroy(&mLock);
26
-    pthread_cond_destroy(&mCondition);
27
-}
28
-
29
-int MessageQueue::size() {
30
-    pthread_mutex_destroy(&mLock);
31
-    int size = mNbPackets;
32
-    pthread_mutex_unlock(&mLock);
33
-    return size;
34
-}
35
-
36
-void MessageQueue::flush() {
37
-    MessageNode *curNode, *nextNode;
38
-    Message *msg;
39
-    pthread_mutex_lock(&mLock);
40
-    for(curNode = mFirst; curNode != NULL; curNode = nextNode){
41
-        nextNode = curNode->next;
42
-        msg = curNode->msg;
43
-        if(NULL != msg){
44
-            delete msg;
45
-        }
46
-        delete curNode;
47
-        curNode = NULL;
48
-    }
49
-    mLast = NULL;
50
-    mFirst = NULL;
51
-    pthread_mutex_unlock(&mLock);
52
-}
53
-
54
-int MessageQueue::enqueueMessage(Message *msg) {
55
-    if(mAbortRequest){
56
-        delete msg;
57
-        return -1;
58
-    }
59
-
60
-    MessageNode *node = new MessageNode();
61
-    node->msg = msg;
62
-    node->next = NULL;
63
-
64
-    if(mLast == NULL){
65
-        mFirst = node;
66
-    }else{
67
-        mLast->next = node;
68
-    }
69
-    mLast = node;
70
-    mNbPackets++;
71
-    pthread_cond_signal(&mCondition);
72
-    pthread_mutex_unlock(&mLock);
73
-    return 0;
74
-}
75
-
76
-int MessageQueue::dequeueMessage(Message **msg, bool block) {
77
-    MessageNode *node;
78
-    int ret;
79
-    pthread_mutex_lock(&mLock);
80
-    for (;;) {
81
-        if (mAbortRequest) {
82
-            ret = -1;
83
-            break;
84
-        }
85
-        node = mFirst;
86
-        if (node) {
87
-            mFirst = node->next;
88
-            if (!mFirst)
89
-                mLast = NULL;
90
-            mNbPackets--;
91
-            *msg = node->msg;
92
-            delete node;
93
-            node = NULL;
94
-            ret = 1;
95
-            break;
96
-        } else if (!block) {
97
-            ret = 0;
98
-            break;
99
-        } else {
100
-            pthread_cond_wait(&mCondition, &mLock);
101
-        }
102
-    }
103
-    pthread_mutex_unlock(&mLock);
104
-    return ret;
105
-}
106
-
107
-void MessageQueue::abort() {
108
-    pthread_mutex_lock(&mLock);
109
-    mAbortRequest = true;
110
-    pthread_cond_signal(&mCondition);
111
-    pthread_mutex_unlock(&mLock);
112
-}
113
-
114
-
115
-/******************* Message class *******************/
116
-Message::Message() {
117
-    handler = NULL;
118
-}
119
-
120
-Message::Message(int what){
121
-    handler = NULL;
122
-    this->what = what;
123
-}
124
-Message::Message(int what, int arg1, int arg2) {
125
-    handler = NULL;
126
-    this->what = what;
127
-    this->arg1 = arg1;
128
-    this->arg2 = arg2;
129
-}
130
-Message::Message(int what, void* obj) {
131
-    handler = NULL;
132
-    this->what = what;
133
-    this->obj = obj;
134
-}
135
-Message::Message(int what, int arg1, int arg2, void* obj) {
136
-    handler = NULL;
137
-    this->what = what;
138
-    this->arg1 = arg1;
139
-    this->arg2 = arg2;
140
-    this->obj = obj;
141
-}
142
-Message::~Message() {
143
-}
144
-
145
-int Message::execute(){
146
-    if (MESSAGE_QUEUE_LOOP_QUIT_FLAG == what) {
147
-        return MESSAGE_QUEUE_LOOP_QUIT_FLAG;
148
-    } else if (handler) {
149
-        handler->handleMessage(this);
150
-        return 1;
151
-    }
152
-    return 0;
153
-};
154
-

+ 0 - 81
android/app/src/main/cpp/common/message_queue.h

@@ -1,81 +0,0 @@
1
-
2
-#ifndef ANDROIDRECORDER_MESSAGE_QUEUE_H
3
-#define ANDROIDRECORDER_MESSAGE_QUEUE_H
4
-
5
-#include <pthread.h>
6
-#include <sys/types.h>
7
-#include "message_handler.h"
8
-#include "../log_utils.h"
9
-
10
-#define MESSAGE_QUEUE_LOOP_QUIT_FLAG        19900909
11
-
12
-class Handler;
13
-
14
-class Message{
15
-private:
16
-    int what;
17
-    int arg1;
18
-    int arg2;
19
-    void *obj;
20
-
21
-public:
22
-    Message();
23
-    Message(int what);
24
-    Message(int what, int arg1, int arg2);
25
-    Message(int what, void *obj);
26
-    Message(int what, int arg1, int arg2, void *obj);
27
-    ~Message();
28
-
29
-    int execute();
30
-    int getWhat(){
31
-        return what;
32
-    }
33
-
34
-    int getArg1(){
35
-        return arg1;
36
-    }
37
-
38
-    int getArg2(){
39
-        return arg2;
40
-    }
41
-
42
-    void* getObj(){
43
-        return obj;
44
-    }
45
-
46
-    Handler *handler;
47
-};
48
-
49
-typedef struct MessageNode{
50
-    Message *msg;
51
-    struct MessageNode *next;
52
-    MessageNode(){
53
-        msg = NULL;
54
-        next = NULL;
55
-    }
56
-} MessageNode;
57
-
58
-class MessageQueue{
59
-private :
60
-    MessageNode* mFirst;
61
-    MessageNode* mLast;
62
-    int mNbPackets;
63
-    bool mAbortRequest;
64
-    pthread_mutex_t mLock;
65
-    pthread_cond_t mCondition;
66
-    const char * queueName;
67
-
68
-public:
69
-    MessageQueue();
70
-    MessageQueue(const char* queueNameParam);
71
-    ~MessageQueue();
72
-
73
-    void init();
74
-    void flush();
75
-    int enqueueMessage(Message* msg);
76
-    int dequeueMessage(Message **msg, bool block);
77
-    int size();
78
-    void abort();
79
-};
80
-
81
-#endif //ANDROIDRECORDER_MESSAGE_QUEUE_H

+ 0 - 340
android/app/src/main/cpp/controller.cpp

@@ -1,340 +0,0 @@
1
-#include "controller.h"
2
-#include "log_utils.h"
3
-
4
-Controller::Controller() {
5
-    facingId = CAMERA_FACING_FRONT;
6
-
7
-    startTime = -1;
8
-    eglCore= NULL;
9
-    _window = NULL;
10
-    isThreadCreateSucceed = false;
11
-    previewSurface = EGL_NO_SURFACE;
12
-    isEncoding = false;
13
-    queue = new MessageQueue("controller message queue");
14
-    handler = new PreviewHandler(this,queue);
15
-}
16
-
17
-Controller::~Controller() {
18
-
19
-}
20
-
21
-bool Controller::init() {
22
-    LOGI("Controller::init start!");
23
-
24
-    eglCore = new EGLCore();
25
-    eglCore->init();
26
-    createPreviewSurface();
27
-    buildRenderInstance();
28
-    configCamera();
29
-    render->init(degress, facingId == CAMERA_FACING_FRONT, textureWidth, textureHeight, cameraWidth, cameraHeight);
30
-    startCameraPreview();
31
-
32
-    isInSwitchingCamera = false;
33
-
34
-    LOGI("Controller::init finish!");
35
-    return true;
36
-}
37
-
38
-void Controller::destroyEGLContext()
39
-{
40
-    if(handler){
41
-        handler->postMessage(new Message(MSG_EGL_THREAD_EXIT));
42
-        handler->postMessage(new Message(MESSAGE_QUEUE_LOOP_QUIT_FLAG));
43
-    }
44
-
45
-    if(isThreadCreateSucceed){
46
-        pthread_join(_threadId, 0);
47
-    }
48
-
49
-    if(queue){
50
-        queue->abort();
51
-        delete queue;
52
-        queue = NULL;
53
-    }
54
-    if(handler){
55
-        delete handler;
56
-        handler = NULL;
57
-    }
58
-}
59
-
60
-void Controller::destroy(){
61
-    destroyPreviewSurface();
62
-    if(render){
63
-        render->dealloc();
64
-        delete render;
65
-        render = NULL;
66
-    }
67
-    releaseCamera();
68
-    eglCore->release();
69
-    delete eglCore;
70
-    eglCore = NULL;
71
-}
72
-
73
-void Controller::createPreviewSurface() {
74
-    previewSurface = eglCore->createWindowSurface(_window);
75
-    if(previewSurface != NULL){
76
-        eglCore->makeCurrent(previewSurface);
77
-    }
78
-}
79
-
80
-void Controller::destroyPreviewSurface(){
81
-
82
-}
83
-
84
-void Controller::switchCamera(){
85
-    isInSwitchingCamera = true;
86
-    if(facingId == CAMERA_FACING_BACK){
87
-        facingId = CAMERA_FACING_FRONT;
88
-    } else {
89
-        facingId = CAMERA_FACING_BACK;
90
-    }
91
-
92
-    if(handler){
93
-        handler->postMessage(new Message(MSG_SWITCH_CAMERA));
94
-    }
95
-}
96
-
97
-void Controller::switchCameraFromMessage()
98
-{
99
-    releaseCamera();
100
-    configCamera();
101
-    render->setDegress(degress, facingId == CAMERA_FACING_FRONT);
102
-    startCameraPreview();
103
-    isInSwitchingCamera = false;
104
-}
105
-
106
-void Controller::releaseCamera(){
107
-    JNIEnv *env;
108
-
109
-    if(jvm->AttachCurrentThread(&env, NULL) != JNI_OK){
110
-        return;
111
-    }
112
-
113
-    if(env == NULL){
114
-        return;
115
-    }
116
-
117
-    jclass jcls = env->GetObjectClass(obj);
118
-    if(NULL != jcls){
119
-        jmethodID  releaseCameraCallback = env->GetMethodID(jcls, "releaseCameraFromNative","()V");
120
-        if(NULL != releaseCameraCallback){
121
-            env->CallVoidMethod(obj, releaseCameraCallback);
122
-        }
123
-    }
124
-
125
-    jvm->DetachCurrentThread();
126
-}
127
-
128
-void Controller::startRecording(){
129
-
130
-}
131
-
132
-void Controller::stopRecording(){
133
-
134
-}
135
-
136
-void Controller::prepareEGLContext(ANativeWindow *window, JavaVM *jvm, jobject obj, int screenWidth,
137
-                                   int screenHeight, int cameraFacingId) {
138
-
139
-    LOGI("Controller::prepare start!");
140
-    this->jvm = jvm;
141
-    this->obj = obj;
142
-    this->_window = window;
143
-    this->screenWidth = screenWidth;
144
-    this->screenHeight = screenHeight;
145
-    this->facingId = cameraFacingId;
146
-
147
-    handler->postMessage(new Message(MSG_EGL_THREAD_CREATE));
148
-    int res_code = pthread_create(&_threadId, 0, threadStartCallBack, this);
149
-    if(res_code == 0){
150
-        isThreadCreateSucceed = true;
151
-    }
152
-
153
-    LOGI("Controller::prepare finish!");
154
-}
155
-
156
-void *Controller::threadStartCallBack(void *myself) {
157
-    LOGI("Controller::threadStartCallBack start");
158
-    Controller *controller = (Controller *) myself;
159
-    controller->processMessage();
160
-    pthread_exit(0);
161
-    LOGI("Controller::threadStartCallBack finish");
162
-}
163
-
164
-void Controller::processMessage() {
165
-    bool renderingEnabled = true;
166
-    while(renderingEnabled){
167
-        Message *msg = NULL;
168
-        if(queue->dequeueMessage(&msg, true) > 0){
169
-            if(MESSAGE_QUEUE_LOOP_QUIT_FLAG == msg->execute()){
170
-                renderingEnabled = false;
171
-            }
172
-            delete msg;
173
-        }
174
-    }
175
-}
176
-
177
-void Controller::configCamera() {
178
-    LOGI("Controller::configCamera enter");
179
-    JNIEnv *env;
180
-
181
-    if(env == NULL){
182
-        LOGE("getJNIEnv failed");
183
-        return;
184
-    }
185
-
186
-    if(jvm->AttachCurrentThread(&env, NULL) != JNI_OK){
187
-        LOGE("AttachCurrentThread failed");
188
-        return;
189
-    }
190
-
191
-    jclass jcls = env->GetObjectClass(obj);
192
-    if(NULL == jcls){
193
-        return;
194
-    }
195
-
196
-    //(I)Lcom/yeliang/recorder/CameraConfigInfo") ---> (I)是形参,后面的是返回值
197
-    jmethodID configCameraCallback = env->GetMethodID(jcls, "configCameraFromNative", "(I)Lcom/yeliang/recorder/CameraConfigInfo;");
198
-    if(configCameraCallback == NULL){
199
-        return;
200
-    }
201
-
202
-    //1 调用PreviewScheduler类中的configCameraFromNative方法 返回CameraConfigInfo对象
203
-    jobject  cameraConfigInfo = env->CallObjectMethod(obj, configCameraCallback, facingId);
204
-
205
-    //2 根据CameraConfigInfo对象,获取CameraConfigInfo类
206
-    jclass CameraConfigInfo_cls = env->GetObjectClass(cameraConfigInfo);
207
-
208
-    //3 通过CameraConfigInfo_cls 获取 CameraConfigInfo中的getDegress方法
209
-    jmethodID getDegress_method = env->GetMethodID(CameraConfigInfo_cls, "getDegress","()I");
210
-    degress = env->CallIntMethod(cameraConfigInfo, getDegress_method);
211
-
212
-    jmethodID getCamereFacingId_method = env->GetMethodID(CameraConfigInfo_cls, "getCameraFacingId","()I");
213
-    facingId = env->CallIntMethod(cameraConfigInfo, getCamereFacingId_method);
214
-    
215
-    jmethodID getTextureWidth_method = env->GetMethodID(CameraConfigInfo_cls, "getTextureWidth","()I");
216
-    int previewWidth = env->CallIntMethod(cameraConfigInfo, getTextureWidth_method);
217
-    cameraWidth = previewWidth;
218
-
219
-    jmethodID getTextureHeight_method = env->GetMethodID(CameraConfigInfo_cls, "getTextureHeight","()I");
220
-    int previewHeight = env->CallIntMethod(cameraConfigInfo, getTextureHeight_method);
221
-    cameraHeight = previewHeight;
222
-
223
-    cameraWidth = 1280;
224
-    cameraHeight = 720;
225
-
226
-    textureWidth = 720;
227
-    textureHeight = 1280;
228
-
229
-    LOGI("camera:{previewWidth = %d, previewHeight = %d}", cameraWidth, cameraHeight);
230
-    LOGI("Texture: {textureWidth = %d, textureHeight = %d}",textureWidth, textureHeight);
231
-
232
-    jvm->DetachCurrentThread();
233
-    LOGI("Controller::configCamera leave");
234
-}
235
-
236
-void Controller::startCameraPreview() {
237
-    JNIEnv *env;
238
-    if(jvm->AttachCurrentThread(&env, NULL) != JNI_OK){
239
-        return;
240
-    }
241
-
242
-    if(env == NULL){
243
-        return;
244
-    }
245
-
246
-    jclass jcls = env->GetObjectClass(obj);
247
-
248
-    if(NULL != jcls){
249
-        jmethodID  startPreviewMethod = env->GetMethodID(jcls, "startPreviewFromNative", "(I)V");
250
-        if(NULL != startPreviewMethod){
251
-            env->CallVoidMethod(obj, startPreviewMethod, render->getCameraTexId());
252
-        }
253
-    }
254
-
255
-    if(jvm->DetachCurrentThread() != JNI_OK){
256
-        LOGE("DetachCurrentThread Error!");
257
-        return;
258
-    }
259
-}
260
-
261
-void Controller::createWindowSurface(ANativeWindow *window) {
262
-    if(_window == NULL){
263
-        _window = window;
264
-        if(handler){
265
-            handler->postMessage(new Message(MSG_EGL_CREATE_PREVIEW_SURFACE));
266
-        }
267
-    }
268
-}
269
-
270
-void Controller::notifyFrameAvaliable()
271
-{
272
-        if(handler && !isInSwitchingCamera){
273
-            handler->postMessage(new Message(MSG_RENDER_FRAME));
274
-        }
275
-}
276
-
277
-void Controller::renderFrame()
278
-{
279
-        if(NULL != eglCore && !isInSwitchingCamera){
280
-                if(startTime == -1){
281
-                    startTime = getCurrentTime();
282
-                }
283
-
284
-            float position = ((float)(getCurrentTime() - startTime)) / 1000.0f;
285
-            processVideoFrame(position);
286
-            if(previewSurface != EGL_NO_SURFACE){
287
-                draw();
288
-            }
289
-
290
-            if(isEncoding){
291
-            }
292
-        }
293
-}
294
-
295
-void Controller::processVideoFrame(float position)
296
-{
297
-    updateTexImage();
298
-    render->processFrame(position);
299
-}
300
-
301
-void Controller::updateTexImage()
302
-{
303
-    JNIEnv *env;
304
-    if(jvm->AttachCurrentThread(&env, NULL) != JNI_OK){
305
-        return;
306
-    }
307
-
308
-    if(env == NULL){
309
-        return;
310
-    }
311
-
312
-    jclass jcls = env->GetObjectClass(obj);
313
-
314
-    printf("Controller::updateTexImage &jcls = %p", &jcls);
315
-    if(NULL != jcls){
316
-        jmethodID updateTexImageCallback = env->GetMethodID(jcls, "updateTexImageFromNative", "()V");
317
-        if(NULL != updateTexImageCallback){
318
-            env->CallVoidMethod(obj, updateTexImageCallback);
319
-        }
320
-    }
321
-
322
-    if(jvm->DetachCurrentThread() != JNI_OK){
323
-        LOGE("%s: DetachCurrentThread failed", __FUNCTION__);
324
-    }
325
-}
326
-
327
-void Controller::draw()
328
-{
329
-    eglCore->makeCurrent(previewSurface);
330
-    render->drawToViewWithAutofit(screenWidth, screenHeight, textureWidth, textureHeight);
331
-    if(!eglCore -> swapBuffers(previewSurface)){
332
-        LOGE("(eglCore -> swapBuffers(previewSurface) Error!");
333
-    }
334
-}
335
-
336
-void Controller::buildRenderInstance() {
337
-    render = new PreviewRender();
338
-}
339
-
340
-

+ 0 - 156
android/app/src/main/cpp/controller.h

@@ -1,156 +0,0 @@
1
-#ifndef ANDROIDRECORDER_CONTROLLER_H
2
-#define ANDROIDRECORDER_CONTROLLER_H
3
-
4
-#include <jni.h>
5
-#include <android/native_window_jni.h>
6
-#include <android/native_window_jni.h>
7
-#include <sys/types.h>
8
-#include "common/message_handler.h"
9
-#include "egl/egl_core.h"
10
-#include "opengl/opengl_render.h"
11
-#include "opengl/preview_render.h"
12
-#include "common/coomon_utils.h"
13
-
14
-#define CAMERA_FACING_BACK   0
15
-#define CAMERA_FACING_FRONT  1
16
-
17
-enum RenderThreadMessage {
18
-    MSG_RENDER_FRAME = 0,
19
-    MSG_EGL_THREAD_CREATE,
20
-    MSG_EGL_CREATE_PREVIEW_SURFACE,
21
-    MSG_SWITCH_CAMERA,
22
-    MSG_START_RECORDING,
23
-    MSG_STOP_RECORDING,
24
-    MSG_EGL_DESTROY_PREVIEW_SURFACE,
25
-    MSG_EGL_THREAD_EXIT
26
-};
27
-
28
-class Controller{
29
-public:
30
-
31
-    Controller();
32
-
33
-    virtual ~Controller();
34
-
35
-    void prepareEGLContext(ANativeWindow *window, JavaVM *jvm, jobject obj,
36
-                           int screenWidth, int screenHeight, int cameraFacingId);
37
-
38
-    void notifyFrameAvaliable();
39
-
40
-    void createWindowSurface(ANativeWindow *window);
41
-
42
-    virtual bool init();
43
-
44
-    virtual void destroy();
45
-
46
-    void createPreviewSurface();
47
-
48
-    void destroyEGLContext();
49
-
50
-    void destroyPreviewSurface();
51
-
52
-    void switchCamera();
53
-    void switchCameraFromMessage();
54
-
55
-    void startRecording();
56
-
57
-    void stopRecording();
58
-
59
-    void renderFrame();
60
-
61
-    void draw();
62
-
63
-
64
-protected:
65
-    ANativeWindow *_window;
66
-    JavaVM *jvm;
67
-    jobject  obj;
68
-    int screenWidth;
69
-    int screenHeight;
70
-
71
-    bool isInSwitchingCamera;
72
-
73
-    int64_t  startTime;
74
-
75
-    int facingId;
76
-    int degress;
77
-    int textureWidth;
78
-    int textureHeight;
79
-
80
-    int cameraWidth;
81
-    int cameraHeight;
82
-
83
-    Handler *handler;
84
-    MessageQueue *queue;
85
-    pthread_t _threadId;
86
-
87
-    static void *threadStartCallBack(void *myself);
88
-
89
-    void processMessage();
90
-
91
-    EGLCore *eglCore;
92
-    EGLSurface previewSurface;
93
-
94
-    PreviewRender *render;
95
-
96
-    virtual void buildRenderInstance();
97
-
98
-    virtual void processVideoFrame(float position);
99
-
100
-    void configCamera();
101
-
102
-    void startCameraPreview();
103
-
104
-    void updateTexImage();
105
-
106
-    void releaseCamera();
107
-
108
-    bool isThreadCreateSucceed;
109
-    bool isEncoding;
110
-};
111
-
112
-class PreviewHandler:public Handler{
113
-
114
-private:
115
-    Controller *controller;
116
-
117
-public:
118
-    PreviewHandler(Controller *controller,MessageQueue *queue):Handler(queue){
119
-        this->controller = controller;
120
-    };
121
-
122
-    void handleMessage(Message *msg){
123
-        int what = msg->getWhat();
124
-        switch (what) {
125
-            case MSG_EGL_THREAD_CREATE:
126
-                controller->init();
127
-                break;
128
-            case MSG_EGL_CREATE_PREVIEW_SURFACE:
129
-                controller->createPreviewSurface();
130
-                break;
131
-            case MSG_START_RECORDING:
132
-                controller->startRecording();
133
-                break;
134
-            case MSG_STOP_RECORDING:
135
-                controller->stopRecording();
136
-                break;
137
-            case MSG_EGL_DESTROY_PREVIEW_SURFACE:
138
-                controller->destroyPreviewSurface();
139
-                break;
140
-            case MSG_EGL_THREAD_EXIT:
141
-                controller->destroy();
142
-                break;
143
-            case MSG_RENDER_FRAME:
144
-                controller->renderFrame();
145
-                break;
146
-            case MSG_SWITCH_CAMERA:
147
-                controller->switchCameraFromMessage();
148
-                break;
149
-        }
150
-    }
151
-
152
-
153
-};
154
-
155
-
156
-#endif //ANDROIDRECORDER_CONTROLLER_H

+ 0 - 10
android/app/src/main/cpp/native-lib.cpp

@@ -1,10 +0,0 @@
1
-#include <jni.h>
2
-#include <string>
3
-
4
-extern "C" JNIEXPORT jstring JNICALL
5
-Java_com_cfmlg_mlg_MainActivity_stringFromJNI(
6
-        JNIEnv* env,
7
-        jobject /* this */) {
8
-    std::string hello = "口腔扫描仪";
9
-    return env->NewStringUTF(hello.c_str());
10
-}

+ 0 - 2
android/app/src/main/java/com/eitchsyh/instrument/Video.java

@@ -11,8 +11,6 @@ public class Video
11 11
 {
12 12
     static
13 13
     {
14
-        System.loadLibrary("mlg");
15
-        System.loadLibrary("ffmpeg");
16 14
         System.loadLibrary("iMVR");
17 15
     }
18 16
 

BIN
android/app/src/main/jniLibs/arm64-v8a/libfacecv.so


BIN
android/app/src/main/jniLibs/arm64-v8a/libffmpeg.so


BIN
android/app/src/main/jniLibs/arm64-v8a/libiMVR.so


BIN
android/app/src/main/jniLibs/arm64-v8a/libopencv_java3.so


BIN
android/app/src/main/jniLibs/armeabi-v7a/libfacecv.so


BIN
android/app/src/main/jniLibs/armeabi-v7a/libffmpeg.so


BIN
android/app/src/main/jniLibs/armeabi-v7a/libiMVR.so


BIN
android/app/src/main/jniLibs/armeabi-v7a/libopencv_java3.so


+ 1 - 0
lib/app_router.dart

@@ -25,5 +25,6 @@ class AppRouter extends RootStackRouter {
25 25
         AutoRoute(page: AddPatientRoute.page),
26 26
         AutoRoute(page: PhotoPreviewRoute.page),
27 27
         AutoRoute(page: VideoPreviewRoute.page),
28
+        AutoRoute(page: SelectHistoryRoute.page),
28 29
       ];
29 30
 }

+ 183 - 117
lib/app_router.gr.dart

@@ -8,18 +8,20 @@
8 8
 // coverage:ignore-file
9 9
 
10 10
 // ignore_for_file: no_leading_underscores_for_library_prefixes
11
-import 'dart:async' as _i24;
11
+import 'dart:async' as _i25;
12 12
 
13
-import 'package:auto_route/auto_route.dart' as _i18;
14
-import 'package:eitc_erm_dental_flutter/entity/clinic_info.dart' as _i23;
13
+import 'package:auto_route/auto_route.dart' as _i19;
14
+import 'package:eitc_erm_dental_flutter/entity/clinic_info.dart' as _i24;
15 15
 import 'package:eitc_erm_dental_flutter/entity/db/local_patient_info.dart'
16
-    as _i21;
17
-import 'package:eitc_erm_dental_flutter/entity/history_item_info.dart' as _i22;
16
+    as _i22;
17
+import 'package:eitc_erm_dental_flutter/entity/history_item_info.dart' as _i23;
18 18
 import 'package:eitc_erm_dental_flutter/pages/history/history_page.dart' as _i4;
19 19
 import 'package:eitc_erm_dental_flutter/pages/history/photo_view_page.dart'
20 20
     as _i9;
21
+import 'package:eitc_erm_dental_flutter/pages/history/select_history_page.dart'
22
+    as _i10;
21 23
 import 'package:eitc_erm_dental_flutter/pages/history/video_player_page.dart'
22
-    as _i14;
24
+    as _i15;
23 25
 import 'package:eitc_erm_dental_flutter/pages/login/login_page.dart' as _i5;
24 26
 import 'package:eitc_erm_dental_flutter/pages/main/main_page.dart' as _i6;
25 27
 import 'package:eitc_erm_dental_flutter/pages/patient/add_patient_page.dart'
@@ -30,26 +32,26 @@ import 'package:eitc_erm_dental_flutter/pages/settings/delay_shot_settings_page.
30 32
     as _i2;
31 33
 import 'package:eitc_erm_dental_flutter/pages/settings/faqs_page.dart' as _i3;
32 34
 import 'package:eitc_erm_dental_flutter/pages/settings/settings_page.dart'
33
-    as _i10;
34
-import 'package:eitc_erm_dental_flutter/pages/splash/splash_page.dart' as _i11;
35
-import 'package:eitc_erm_dental_flutter/pages/upload/upload_page.dart' as _i12;
35
+    as _i11;
36
+import 'package:eitc_erm_dental_flutter/pages/splash/splash_page.dart' as _i12;
37
+import 'package:eitc_erm_dental_flutter/pages/upload/upload_page.dart' as _i13;
36 38
 import 'package:eitc_erm_dental_flutter/pages/upload/upload_select_clinic_page.dart'
37
-    as _i13;
39
+    as _i14;
38 40
 import 'package:eitc_erm_dental_flutter/pages/view/photo_preview_page.dart'
39 41
     as _i8;
40 42
 import 'package:eitc_erm_dental_flutter/pages/view/video_preview_page.dart'
41
-    as _i15;
42
-import 'package:eitc_erm_dental_flutter/pages/view/video_view_page.dart'
43 43
     as _i16;
44
-import 'package:eitc_erm_dental_flutter/pages/web/webview_page.dart' as _i17;
45
-import 'package:flutter/foundation.dart' as _i19;
46
-import 'package:flutter/material.dart' as _i20;
47
-import 'package:retrofit/dio.dart' as _i25;
44
+import 'package:eitc_erm_dental_flutter/pages/view/video_view_page.dart'
45
+    as _i17;
46
+import 'package:eitc_erm_dental_flutter/pages/web/webview_page.dart' as _i18;
47
+import 'package:flutter/foundation.dart' as _i20;
48
+import 'package:flutter/material.dart' as _i21;
49
+import 'package:retrofit/dio.dart' as _i26;
48 50
 
49 51
 /// generated route for
50 52
 /// [_i1.AddPatientPage]
51
-class AddPatientRoute extends _i18.PageRouteInfo<void> {
52
-  const AddPatientRoute({List<_i18.PageRouteInfo>? children})
53
+class AddPatientRoute extends _i19.PageRouteInfo<void> {
54
+  const AddPatientRoute({List<_i19.PageRouteInfo>? children})
53 55
       : super(
54 56
           AddPatientRoute.name,
55 57
           initialChildren: children,
@@ -57,7 +59,7 @@ class AddPatientRoute extends _i18.PageRouteInfo<void> {
57 59
 
58 60
   static const String name = 'AddPatientRoute';
59 61
 
60
-  static _i18.PageInfo page = _i18.PageInfo(
62
+  static _i19.PageInfo page = _i19.PageInfo(
61 63
     name,
62 64
     builder: (data) {
63 65
       return const _i1.AddPatientPage();
@@ -67,8 +69,8 @@ class AddPatientRoute extends _i18.PageRouteInfo<void> {
67 69
 
68 70
 /// generated route for
69 71
 /// [_i2.DelayShotSettingsPage]
70
-class DelayShotSettingsRoute extends _i18.PageRouteInfo<void> {
71
-  const DelayShotSettingsRoute({List<_i18.PageRouteInfo>? children})
72
+class DelayShotSettingsRoute extends _i19.PageRouteInfo<void> {
73
+  const DelayShotSettingsRoute({List<_i19.PageRouteInfo>? children})
72 74
       : super(
73 75
           DelayShotSettingsRoute.name,
74 76
           initialChildren: children,
@@ -76,7 +78,7 @@ class DelayShotSettingsRoute extends _i18.PageRouteInfo<void> {
76 78
 
77 79
   static const String name = 'DelayShotSettingsRoute';
78 80
 
79
-  static _i18.PageInfo page = _i18.PageInfo(
81
+  static _i19.PageInfo page = _i19.PageInfo(
80 82
     name,
81 83
     builder: (data) {
82 84
       return const _i2.DelayShotSettingsPage();
@@ -86,8 +88,8 @@ class DelayShotSettingsRoute extends _i18.PageRouteInfo<void> {
86 88
 
87 89
 /// generated route for
88 90
 /// [_i3.FaqsPage]
89
-class FaqsRoute extends _i18.PageRouteInfo<void> {
90
-  const FaqsRoute({List<_i18.PageRouteInfo>? children})
91
+class FaqsRoute extends _i19.PageRouteInfo<void> {
92
+  const FaqsRoute({List<_i19.PageRouteInfo>? children})
91 93
       : super(
92 94
           FaqsRoute.name,
93 95
           initialChildren: children,
@@ -95,7 +97,7 @@ class FaqsRoute extends _i18.PageRouteInfo<void> {
95 97
 
96 98
   static const String name = 'FaqsRoute';
97 99
 
98
-  static _i18.PageInfo page = _i18.PageInfo(
100
+  static _i19.PageInfo page = _i19.PageInfo(
99 101
     name,
100 102
     builder: (data) {
101 103
       return const _i3.FaqsPage();
@@ -105,8 +107,8 @@ class FaqsRoute extends _i18.PageRouteInfo<void> {
105 107
 
106 108
 /// generated route for
107 109
 /// [_i4.HistoryPage]
108
-class HistoryRoute extends _i18.PageRouteInfo<void> {
109
-  const HistoryRoute({List<_i18.PageRouteInfo>? children})
110
+class HistoryRoute extends _i19.PageRouteInfo<void> {
111
+  const HistoryRoute({List<_i19.PageRouteInfo>? children})
110 112
       : super(
111 113
           HistoryRoute.name,
112 114
           initialChildren: children,
@@ -114,7 +116,7 @@ class HistoryRoute extends _i18.PageRouteInfo<void> {
114 116
 
115 117
   static const String name = 'HistoryRoute';
116 118
 
117
-  static _i18.PageInfo page = _i18.PageInfo(
119
+  static _i19.PageInfo page = _i19.PageInfo(
118 120
     name,
119 121
     builder: (data) {
120 122
       return const _i4.HistoryPage();
@@ -124,11 +126,11 @@ class HistoryRoute extends _i18.PageRouteInfo<void> {
124 126
 
125 127
 /// generated route for
126 128
 /// [_i5.LoginPage]
127
-class LoginRoute extends _i18.PageRouteInfo<LoginRouteArgs> {
129
+class LoginRoute extends _i19.PageRouteInfo<LoginRouteArgs> {
128 130
   LoginRoute({
129
-    _i19.Key? key,
131
+    _i20.Key? key,
130 132
     required bool cancelable,
131
-    List<_i18.PageRouteInfo>? children,
133
+    List<_i19.PageRouteInfo>? children,
132 134
   }) : super(
133 135
           LoginRoute.name,
134 136
           args: LoginRouteArgs(
@@ -140,7 +142,7 @@ class LoginRoute extends _i18.PageRouteInfo<LoginRouteArgs> {
140 142
 
141 143
   static const String name = 'LoginRoute';
142 144
 
143
-  static _i18.PageInfo page = _i18.PageInfo(
145
+  static _i19.PageInfo page = _i19.PageInfo(
144 146
     name,
145 147
     builder: (data) {
146 148
       final args = data.argsAs<LoginRouteArgs>();
@@ -158,7 +160,7 @@ class LoginRouteArgs {
158 160
     required this.cancelable,
159 161
   });
160 162
 
161
-  final _i19.Key? key;
163
+  final _i20.Key? key;
162 164
 
163 165
   final bool cancelable;
164 166
 
@@ -170,8 +172,8 @@ class LoginRouteArgs {
170 172
 
171 173
 /// generated route for
172 174
 /// [_i6.MainPage]
173
-class MainRoute extends _i18.PageRouteInfo<void> {
174
-  const MainRoute({List<_i18.PageRouteInfo>? children})
175
+class MainRoute extends _i19.PageRouteInfo<void> {
176
+  const MainRoute({List<_i19.PageRouteInfo>? children})
175 177
       : super(
176 178
           MainRoute.name,
177 179
           initialChildren: children,
@@ -179,7 +181,7 @@ class MainRoute extends _i18.PageRouteInfo<void> {
179 181
 
180 182
   static const String name = 'MainRoute';
181 183
 
182
-  static _i18.PageInfo page = _i18.PageInfo(
184
+  static _i19.PageInfo page = _i19.PageInfo(
183 185
     name,
184 186
     builder: (data) {
185 187
       return const _i6.MainPage();
@@ -189,11 +191,11 @@ class MainRoute extends _i18.PageRouteInfo<void> {
189 191
 
190 192
 /// generated route for
191 193
 /// [_i7.PatientListPage]
192
-class PatientListRoute extends _i18.PageRouteInfo<PatientListRouteArgs> {
194
+class PatientListRoute extends _i19.PageRouteInfo<PatientListRouteArgs> {
193 195
   PatientListRoute({
194
-    _i20.Key? key,
196
+    _i21.Key? key,
195 197
     bool selectable = true,
196
-    List<_i18.PageRouteInfo>? children,
198
+    List<_i19.PageRouteInfo>? children,
197 199
   }) : super(
198 200
           PatientListRoute.name,
199 201
           args: PatientListRouteArgs(
@@ -205,7 +207,7 @@ class PatientListRoute extends _i18.PageRouteInfo<PatientListRouteArgs> {
205 207
 
206 208
   static const String name = 'PatientListRoute';
207 209
 
208
-  static _i18.PageInfo page = _i18.PageInfo(
210
+  static _i19.PageInfo page = _i19.PageInfo(
209 211
     name,
210 212
     builder: (data) {
211 213
       final args = data.argsAs<PatientListRouteArgs>(
@@ -224,7 +226,7 @@ class PatientListRouteArgs {
224 226
     this.selectable = true,
225 227
   });
226 228
 
227
-  final _i20.Key? key;
229
+  final _i21.Key? key;
228 230
 
229 231
   final bool selectable;
230 232
 
@@ -236,17 +238,17 @@ class PatientListRouteArgs {
236 238
 
237 239
 /// generated route for
238 240
 /// [_i8.PhotoPreviewPage]
239
-class PhotoPreviewRoute extends _i18.PageRouteInfo<PhotoPreviewRouteArgs> {
241
+class PhotoPreviewRoute extends _i19.PageRouteInfo<PhotoPreviewRouteArgs> {
240 242
   PhotoPreviewRoute({
241
-    _i20.Key? key,
242
-    required _i21.LocalPatientInfo info,
243
+    _i21.Key? key,
244
+    required _i22.LocalPatientInfo info,
243 245
     required String path,
244 246
     required String area,
245 247
     required DateTime time,
246 248
     required String mobile,
247 249
     required String deviceModel,
248 250
     required String wifi,
249
-    List<_i18.PageRouteInfo>? children,
251
+    List<_i19.PageRouteInfo>? children,
250 252
   }) : super(
251 253
           PhotoPreviewRoute.name,
252 254
           args: PhotoPreviewRouteArgs(
@@ -264,7 +266,7 @@ class PhotoPreviewRoute extends _i18.PageRouteInfo<PhotoPreviewRouteArgs> {
264 266
 
265 267
   static const String name = 'PhotoPreviewRoute';
266 268
 
267
-  static _i18.PageInfo page = _i18.PageInfo(
269
+  static _i19.PageInfo page = _i19.PageInfo(
268 270
     name,
269 271
     builder: (data) {
270 272
       final args = data.argsAs<PhotoPreviewRouteArgs>();
@@ -294,9 +296,9 @@ class PhotoPreviewRouteArgs {
294 296
     required this.wifi,
295 297
   });
296 298
 
297
-  final _i20.Key? key;
299
+  final _i21.Key? key;
298 300
 
299
-  final _i21.LocalPatientInfo info;
301
+  final _i22.LocalPatientInfo info;
300 302
 
301 303
   final String path;
302 304
 
@@ -318,11 +320,11 @@ class PhotoPreviewRouteArgs {
318 320
 
319 321
 /// generated route for
320 322
 /// [_i9.PhotoViewPage]
321
-class PhotoViewRoute extends _i18.PageRouteInfo<PhotoViewRouteArgs> {
323
+class PhotoViewRoute extends _i19.PageRouteInfo<PhotoViewRouteArgs> {
322 324
   PhotoViewRoute({
323
-    _i20.Key? key,
324
-    required _i22.HistoryItemInfo? info,
325
-    List<_i18.PageRouteInfo>? children,
325
+    _i21.Key? key,
326
+    required _i23.HistoryItemInfo? info,
327
+    List<_i19.PageRouteInfo>? children,
326 328
   }) : super(
327 329
           PhotoViewRoute.name,
328 330
           args: PhotoViewRouteArgs(
@@ -334,7 +336,7 @@ class PhotoViewRoute extends _i18.PageRouteInfo<PhotoViewRouteArgs> {
334 336
 
335 337
   static const String name = 'PhotoViewRoute';
336 338
 
337
-  static _i18.PageInfo page = _i18.PageInfo(
339
+  static _i19.PageInfo page = _i19.PageInfo(
338 340
     name,
339 341
     builder: (data) {
340 342
       final args = data.argsAs<PhotoViewRouteArgs>();
@@ -352,9 +354,9 @@ class PhotoViewRouteArgs {
352 354
     required this.info,
353 355
   });
354 356
 
355
-  final _i20.Key? key;
357
+  final _i21.Key? key;
356 358
 
357
-  final _i22.HistoryItemInfo? info;
359
+  final _i23.HistoryItemInfo? info;
358 360
 
359 361
   @override
360 362
   String toString() {
@@ -363,9 +365,73 @@ class PhotoViewRouteArgs {
363 365
 }
364 366
 
365 367
 /// generated route for
366
-/// [_i10.SettingsPage]
367
-class SettingsRoute extends _i18.PageRouteInfo<void> {
368
-  const SettingsRoute({List<_i18.PageRouteInfo>? children})
368
+/// [_i10.SelectHistoryPage]
369
+class SelectHistoryRoute extends _i19.PageRouteInfo<SelectHistoryRouteArgs> {
370
+  SelectHistoryRoute({
371
+    _i21.Key? key,
372
+    required _i10.SelectHistoryType selectType,
373
+    required bool isFillterPatient,
374
+    bool isMultiSelect = false,
375
+    int maxCount = 0,
376
+    List<_i19.PageRouteInfo>? children,
377
+  }) : super(
378
+          SelectHistoryRoute.name,
379
+          args: SelectHistoryRouteArgs(
380
+            key: key,
381
+            selectType: selectType,
382
+            isFillterPatient: isFillterPatient,
383
+            isMultiSelect: isMultiSelect,
384
+            maxCount: maxCount,
385
+          ),
386
+          initialChildren: children,
387
+        );
388
+
389
+  static const String name = 'SelectHistoryRoute';
390
+
391
+  static _i19.PageInfo page = _i19.PageInfo(
392
+    name,
393
+    builder: (data) {
394
+      final args = data.argsAs<SelectHistoryRouteArgs>();
395
+      return _i10.SelectHistoryPage(
396
+        key: args.key,
397
+        selectType: args.selectType,
398
+        isFillterPatient: args.isFillterPatient,
399
+        isMultiSelect: args.isMultiSelect,
400
+        maxCount: args.maxCount,
401
+      );
402
+    },
403
+  );
404
+}
405
+
406
+class SelectHistoryRouteArgs {
407
+  const SelectHistoryRouteArgs({
408
+    this.key,
409
+    required this.selectType,
410
+    required this.isFillterPatient,
411
+    this.isMultiSelect = false,
412
+    this.maxCount = 0,
413
+  });
414
+
415
+  final _i21.Key? key;
416
+
417
+  final _i10.SelectHistoryType selectType;
418
+
419
+  final bool isFillterPatient;
420
+
421
+  final bool isMultiSelect;
422
+
423
+  final int maxCount;
424
+
425
+  @override
426
+  String toString() {
427
+    return 'SelectHistoryRouteArgs{key: $key, selectType: $selectType, isFillterPatient: $isFillterPatient, isMultiSelect: $isMultiSelect, maxCount: $maxCount}';
428
+  }
429
+}
430
+
431
+/// generated route for
432
+/// [_i11.SettingsPage]
433
+class SettingsRoute extends _i19.PageRouteInfo<void> {
434
+  const SettingsRoute({List<_i19.PageRouteInfo>? children})
369 435
       : super(
370 436
           SettingsRoute.name,
371 437
           initialChildren: children,
@@ -373,18 +439,18 @@ class SettingsRoute extends _i18.PageRouteInfo<void> {
373 439
 
374 440
   static const String name = 'SettingsRoute';
375 441
 
376
-  static _i18.PageInfo page = _i18.PageInfo(
442
+  static _i19.PageInfo page = _i19.PageInfo(
377 443
     name,
378 444
     builder: (data) {
379
-      return const _i10.SettingsPage();
445
+      return const _i11.SettingsPage();
380 446
     },
381 447
   );
382 448
 }
383 449
 
384 450
 /// generated route for
385
-/// [_i11.SplashPage]
386
-class SplashRoute extends _i18.PageRouteInfo<void> {
387
-  const SplashRoute({List<_i18.PageRouteInfo>? children})
451
+/// [_i12.SplashPage]
452
+class SplashRoute extends _i19.PageRouteInfo<void> {
453
+  const SplashRoute({List<_i19.PageRouteInfo>? children})
388 454
       : super(
389 455
           SplashRoute.name,
390 456
           initialChildren: children,
@@ -392,23 +458,23 @@ class SplashRoute extends _i18.PageRouteInfo<void> {
392 458
 
393 459
   static const String name = 'SplashRoute';
394 460
 
395
-  static _i18.PageInfo page = _i18.PageInfo(
461
+  static _i19.PageInfo page = _i19.PageInfo(
396 462
     name,
397 463
     builder: (data) {
398
-      return const _i11.SplashPage();
464
+      return const _i12.SplashPage();
399 465
     },
400 466
   );
401 467
 }
402 468
 
403 469
 /// generated route for
404
-/// [_i12.UploadPage]
405
-class UploadRoute extends _i18.PageRouteInfo<UploadRouteArgs> {
470
+/// [_i13.UploadPage]
471
+class UploadRoute extends _i19.PageRouteInfo<UploadRouteArgs> {
406 472
   UploadRoute({
407
-    _i20.Key? key,
408
-    required List<_i22.HistoryItemInfo> uploadList,
409
-    required _i23.ClinicInfo clinicInfo,
473
+    _i21.Key? key,
474
+    required List<_i23.HistoryItemInfo> uploadList,
475
+    required _i24.ClinicInfo clinicInfo,
410 476
     required bool isFromView,
411
-    List<_i18.PageRouteInfo>? children,
477
+    List<_i19.PageRouteInfo>? children,
412 478
   }) : super(
413 479
           UploadRoute.name,
414 480
           args: UploadRouteArgs(
@@ -422,11 +488,11 @@ class UploadRoute extends _i18.PageRouteInfo<UploadRouteArgs> {
422 488
 
423 489
   static const String name = 'UploadRoute';
424 490
 
425
-  static _i18.PageInfo page = _i18.PageInfo(
491
+  static _i19.PageInfo page = _i19.PageInfo(
426 492
     name,
427 493
     builder: (data) {
428 494
       final args = data.argsAs<UploadRouteArgs>();
429
-      return _i12.UploadPage(
495
+      return _i13.UploadPage(
430 496
         key: args.key,
431 497
         uploadList: args.uploadList,
432 498
         clinicInfo: args.clinicInfo,
@@ -444,11 +510,11 @@ class UploadRouteArgs {
444 510
     required this.isFromView,
445 511
   });
446 512
 
447
-  final _i20.Key? key;
513
+  final _i21.Key? key;
448 514
 
449
-  final List<_i22.HistoryItemInfo> uploadList;
515
+  final List<_i23.HistoryItemInfo> uploadList;
450 516
 
451
-  final _i23.ClinicInfo clinicInfo;
517
+  final _i24.ClinicInfo clinicInfo;
452 518
 
453 519
   final bool isFromView;
454 520
 
@@ -459,14 +525,14 @@ class UploadRouteArgs {
459 525
 }
460 526
 
461 527
 /// generated route for
462
-/// [_i13.UploadSelectClinicPage]
528
+/// [_i14.UploadSelectClinicPage]
463 529
 class UploadSelectClinicRoute
464
-    extends _i18.PageRouteInfo<UploadSelectClinicRouteArgs> {
530
+    extends _i19.PageRouteInfo<UploadSelectClinicRouteArgs> {
465 531
   UploadSelectClinicRoute({
466
-    _i20.Key? key,
467
-    required List<_i22.HistoryItemInfo> uploadList,
532
+    _i21.Key? key,
533
+    required List<_i23.HistoryItemInfo> uploadList,
468 534
     required bool isFromView,
469
-    List<_i18.PageRouteInfo>? children,
535
+    List<_i19.PageRouteInfo>? children,
470 536
   }) : super(
471 537
           UploadSelectClinicRoute.name,
472 538
           args: UploadSelectClinicRouteArgs(
@@ -479,11 +545,11 @@ class UploadSelectClinicRoute
479 545
 
480 546
   static const String name = 'UploadSelectClinicRoute';
481 547
 
482
-  static _i18.PageInfo page = _i18.PageInfo(
548
+  static _i19.PageInfo page = _i19.PageInfo(
483 549
     name,
484 550
     builder: (data) {
485 551
       final args = data.argsAs<UploadSelectClinicRouteArgs>();
486
-      return _i13.UploadSelectClinicPage(
552
+      return _i14.UploadSelectClinicPage(
487 553
         key: args.key,
488 554
         uploadList: args.uploadList,
489 555
         isFromView: args.isFromView,
@@ -499,9 +565,9 @@ class UploadSelectClinicRouteArgs {
499 565
     required this.isFromView,
500 566
   });
501 567
 
502
-  final _i20.Key? key;
568
+  final _i21.Key? key;
503 569
 
504
-  final List<_i22.HistoryItemInfo> uploadList;
570
+  final List<_i23.HistoryItemInfo> uploadList;
505 571
 
506 572
   final bool isFromView;
507 573
 
@@ -512,12 +578,12 @@ class UploadSelectClinicRouteArgs {
512 578
 }
513 579
 
514 580
 /// generated route for
515
-/// [_i14.VideoPlayerPage]
516
-class VideoPlayerRoute extends _i18.PageRouteInfo<VideoPlayerRouteArgs> {
581
+/// [_i15.VideoPlayerPage]
582
+class VideoPlayerRoute extends _i19.PageRouteInfo<VideoPlayerRouteArgs> {
517 583
   VideoPlayerRoute({
518
-    _i20.Key? key,
519
-    required _i22.HistoryItemInfo? info,
520
-    List<_i18.PageRouteInfo>? children,
584
+    _i21.Key? key,
585
+    required _i23.HistoryItemInfo? info,
586
+    List<_i19.PageRouteInfo>? children,
521 587
   }) : super(
522 588
           VideoPlayerRoute.name,
523 589
           args: VideoPlayerRouteArgs(
@@ -529,11 +595,11 @@ class VideoPlayerRoute extends _i18.PageRouteInfo<VideoPlayerRouteArgs> {
529 595
 
530 596
   static const String name = 'VideoPlayerRoute';
531 597
 
532
-  static _i18.PageInfo page = _i18.PageInfo(
598
+  static _i19.PageInfo page = _i19.PageInfo(
533 599
     name,
534 600
     builder: (data) {
535 601
       final args = data.argsAs<VideoPlayerRouteArgs>();
536
-      return _i14.VideoPlayerPage(
602
+      return _i15.VideoPlayerPage(
537 603
         key: args.key,
538 604
         info: args.info,
539 605
       );
@@ -547,9 +613,9 @@ class VideoPlayerRouteArgs {
547 613
     required this.info,
548 614
   });
549 615
 
550
-  final _i20.Key? key;
616
+  final _i21.Key? key;
551 617
 
552
-  final _i22.HistoryItemInfo? info;
618
+  final _i23.HistoryItemInfo? info;
553 619
 
554 620
   @override
555 621
   String toString() {
@@ -558,18 +624,18 @@ class VideoPlayerRouteArgs {
558 624
 }
559 625
 
560 626
 /// generated route for
561
-/// [_i15.VideoPreviewPage]
562
-class VideoPreviewRoute extends _i18.PageRouteInfo<VideoPreviewRouteArgs> {
627
+/// [_i16.VideoPreviewPage]
628
+class VideoPreviewRoute extends _i19.PageRouteInfo<VideoPreviewRouteArgs> {
563 629
   VideoPreviewRoute({
564
-    _i20.Key? key,
565
-    required _i21.LocalPatientInfo info,
630
+    _i21.Key? key,
631
+    required _i22.LocalPatientInfo info,
566 632
     required String path,
567 633
     required String area,
568 634
     required DateTime time,
569 635
     required String mobile,
570 636
     required String wifi,
571 637
     required String deviceModel,
572
-    List<_i18.PageRouteInfo>? children,
638
+    List<_i19.PageRouteInfo>? children,
573 639
   }) : super(
574 640
           VideoPreviewRoute.name,
575 641
           args: VideoPreviewRouteArgs(
@@ -587,11 +653,11 @@ class VideoPreviewRoute extends _i18.PageRouteInfo<VideoPreviewRouteArgs> {
587 653
 
588 654
   static const String name = 'VideoPreviewRoute';
589 655
 
590
-  static _i18.PageInfo page = _i18.PageInfo(
656
+  static _i19.PageInfo page = _i19.PageInfo(
591 657
     name,
592 658
     builder: (data) {
593 659
       final args = data.argsAs<VideoPreviewRouteArgs>();
594
-      return _i15.VideoPreviewPage(
660
+      return _i16.VideoPreviewPage(
595 661
         key: args.key,
596 662
         info: args.info,
597 663
         path: args.path,
@@ -617,9 +683,9 @@ class VideoPreviewRouteArgs {
617 683
     required this.deviceModel,
618 684
   });
619 685
 
620
-  final _i20.Key? key;
686
+  final _i21.Key? key;
621 687
 
622
-  final _i21.LocalPatientInfo info;
688
+  final _i22.LocalPatientInfo info;
623 689
 
624 690
   final String path;
625 691
 
@@ -640,9 +706,9 @@ class VideoPreviewRouteArgs {
640 706
 }
641 707
 
642 708
 /// generated route for
643
-/// [_i16.VideoViewPage]
644
-class VideoViewRoute extends _i18.PageRouteInfo<void> {
645
-  const VideoViewRoute({List<_i18.PageRouteInfo>? children})
709
+/// [_i17.VideoViewPage]
710
+class VideoViewRoute extends _i19.PageRouteInfo<void> {
711
+  const VideoViewRoute({List<_i19.PageRouteInfo>? children})
646 712
       : super(
647 713
           VideoViewRoute.name,
648 714
           initialChildren: children,
@@ -650,23 +716,23 @@ class VideoViewRoute extends _i18.PageRouteInfo<void> {
650 716
 
651 717
   static const String name = 'VideoViewRoute';
652 718
 
653
-  static _i18.PageInfo page = _i18.PageInfo(
719
+  static _i19.PageInfo page = _i19.PageInfo(
654 720
     name,
655 721
     builder: (data) {
656
-      return const _i16.VideoViewPage();
722
+      return const _i17.VideoViewPage();
657 723
     },
658 724
   );
659 725
 }
660 726
 
661 727
 /// generated route for
662
-/// [_i17.WebviewPage]
663
-class WebviewRoute extends _i18.PageRouteInfo<WebviewRouteArgs> {
728
+/// [_i18.WebviewPage]
729
+class WebviewRoute extends _i19.PageRouteInfo<WebviewRouteArgs> {
664 730
   WebviewRoute({
665
-    _i19.Key? key,
731
+    _i20.Key? key,
666 732
     required String url,
667 733
     String? title,
668
-    _i24.Future<_i25.HttpResponse<String>>? htmlFuture,
669
-    List<_i18.PageRouteInfo>? children,
734
+    _i25.Future<_i26.HttpResponse<String>>? htmlFuture,
735
+    List<_i19.PageRouteInfo>? children,
670 736
   }) : super(
671 737
           WebviewRoute.name,
672 738
           args: WebviewRouteArgs(
@@ -680,11 +746,11 @@ class WebviewRoute extends _i18.PageRouteInfo<WebviewRouteArgs> {
680 746
 
681 747
   static const String name = 'WebviewRoute';
682 748
 
683
-  static _i18.PageInfo page = _i18.PageInfo(
749
+  static _i19.PageInfo page = _i19.PageInfo(
684 750
     name,
685 751
     builder: (data) {
686 752
       final args = data.argsAs<WebviewRouteArgs>();
687
-      return _i17.WebviewPage(
753
+      return _i18.WebviewPage(
688 754
         key: args.key,
689 755
         url: args.url,
690 756
         title: args.title,
@@ -702,13 +768,13 @@ class WebviewRouteArgs {
702 768
     this.htmlFuture,
703 769
   });
704 770
 
705
-  final _i19.Key? key;
771
+  final _i20.Key? key;
706 772
 
707 773
   final String url;
708 774
 
709 775
   final String? title;
710 776
 
711
-  final _i24.Future<_i25.HttpResponse<String>>? htmlFuture;
777
+  final _i25.Future<_i26.HttpResponse<String>>? htmlFuture;
712 778
 
713 779
   @override
714 780
   String toString() {

+ 3 - 0
lib/entity/history_item_info.dart

@@ -90,4 +90,7 @@ class HistoryItemInfo {
90 90
     _isSelectMode = value;
91 91
     isSelected = false;
92 92
   }
93
+
94
+  ///文件URI,如果path为空就返回null
95
+  Uri? get fileUri => path.isEmpty ? null : Uri.file(path);
93 96
 }

+ 104 - 8
lib/funcs.dart

@@ -26,6 +26,9 @@ import 'package:network_info_plus/network_info_plus.dart';
26 26
 import 'package:package_info_plus/package_info_plus.dart';
27 27
 import 'package:path_provider/path_provider.dart';
28 28
 import 'package:permission_handler/permission_handler.dart';
29
+import 'package:pointycastle/asymmetric/pkcs1.dart';
30
+import 'package:pointycastle/asymmetric/rsa.dart';
31
+import 'package:pointycastle/pointycastle.dart';
29 32
 
30 33
 import 'global.dart';
31 34
 
@@ -37,15 +40,20 @@ late Logger logger;
37 40
 ///初始化日志
38 41
 Future<dynamic> initLog() async {
39 42
   LogOutput? output;
40
-  Directory? dir = await getDownloadsDirectory();
41
-  if (dir != null) {
42
-    dir = Directory("${dir.path}/logs");
43
-    if (!await dir.exists()) {
44
-      await dir.create(recursive: true);
43
+  //android版有文件日志
44
+  if (Platform.isAndroid) {
45
+    Directory? dir = await getDownloadsDirectory();
46
+    if (dir != null) {
47
+      dir = Directory("${dir.path}/logs");
48
+      if (!await dir.exists()) {
49
+        await dir.create(recursive: true);
50
+      }
51
+      output = kDebugMode
52
+          ? MultiOutput([ConsoleOutput(), AdvancedFileOutput(path: dir.path)])
53
+          : ConsoleOutput();
45 54
     }
46
-    output = kDebugMode
47
-        ? MultiOutput([ConsoleOutput(), AdvancedFileOutput(path: dir.path)])
48
-        : ConsoleOutput();
55
+  } else {
56
+    output = ConsoleOutput();
49 57
   }
50 58
   logger = Logger(
51 59
       printer: PrettyPrinter(
@@ -532,6 +540,94 @@ String aesDecrypt(String str) {
532 540
   return _encrypter.decrypt(encrptyed, iv: _iv);
533 541
 }
534 542
 
543
+///合并字节数组
544
+Uint8List concatenateBytes(List<Uint8List> byteList) {
545
+  int totalLength = byteList.fold(0, (sum, bytes) => sum + bytes.length);
546
+  Uint8List result = Uint8List(totalLength);
547
+  int offset = 0;
548
+
549
+  for (var bytes in byteList) {
550
+    result.setRange(offset, offset + bytes.length, bytes);
551
+    offset += bytes.length;
552
+  }
553
+
554
+  return result;
555
+}
556
+
557
+///RSA加密,返回BASE64字符串,仅支持PKCS1编码
558
+///
559
+/// [keyBitLength] 密钥长度,应为512,1024,2048,4096中的一个,默认512
560
+String rsaEncrypt(String pubKey, String content, {int keyBitLength = 512}) {
561
+  try {
562
+    final cipher = PKCS1Encoding(RSAEngine())
563
+      ..init(
564
+          true,
565
+          PublicKeyParameter<RSAPublicKey>(
566
+              encrpyt.RSAKeyParser().parse(pubKey) as RSAPublicKey));
567
+
568
+    final utf8Bytes = Uint8List.fromList(utf8.encode(content));
569
+    final inputLen = utf8Bytes.length;
570
+    int offLen = 0;
571
+    int i = 0;
572
+    List<Uint8List> bops = [];
573
+
574
+    int size = (keyBitLength / 8 - 11).toInt();
575
+    while (inputLen - offLen > 0) {
576
+      final chunkSize = (inputLen - offLen > size) ? size : inputLen - offLen;
577
+      final cache = cipher.process(
578
+          Uint8List.sublistView(utf8Bytes, offLen, offLen + chunkSize));
579
+      bops.add(cache);
580
+      i++;
581
+      offLen = size * i;
582
+    }
583
+
584
+    final encryptedData = concatenateBytes(bops);
585
+    final base64Encoded = base64Encode(encryptedData);
586
+
587
+    return base64Encoded;
588
+  } catch (e) {
589
+    loge("RSA加密异常", error: e);
590
+    return "";
591
+  }
592
+}
593
+
594
+///RSA解密,输入BASE64,仅支持PKCS1编码
595
+///
596
+/// [keyBitLength] 密钥长度,应为512,1024,2048,4096中的一个,默认512
597
+String rsaDecrypt(String priKey, String content, {int keyBitLength = 512}) {
598
+  try {
599
+    final cipher = PKCS1Encoding(RSAEngine());
600
+    cipher.init(
601
+        false,
602
+        PrivateKeyParameter<RSAPrivateKey>(
603
+            encrpyt.RSAKeyParser().parse(priKey) as RSAPrivateKey));
604
+
605
+    final encryptedBytes = base64Decode(content);
606
+    final inputLen = encryptedBytes.length;
607
+    int offLen = 0;
608
+    int i = 0;
609
+
610
+    List<Uint8List> byteList = [];
611
+
612
+    int size = keyBitLength ~/ 8;
613
+    while (inputLen - offLen > 0) {
614
+      final int chunkSize =
615
+          (inputLen - offLen > size) ? size : inputLen - offLen;
616
+      final cache = cipher.process(
617
+          Uint8List.sublistView(encryptedBytes, offLen, offLen + chunkSize));
618
+      byteList.add(cache);
619
+      i++;
620
+      offLen = size * i;
621
+    }
622
+
623
+    final byteArray = concatenateBytes(byteList);
624
+    return utf8.decode(byteArray);
625
+  } catch (e) {
626
+    loge("RSA解密异常", error: e);
627
+    return '';
628
+  }
629
+}
630
+
535 631
 ///检查新版本
536 632
 ///
537 633
 /// 返回true表示有新版本,false没有新版本

+ 18 - 8
lib/generated/intl/messages_en.dart

@@ -26,15 +26,17 @@ class MessageLookup extends MessageLookupByLibrary {
26 26
 
27 27
   static String m2(selected) => "${selected} has been selected";
28 28
 
29
-  static String m3(appName) =>
29
+  static String m3(count) => "You can choose up to ${count}";
30
+
31
+  static String m4(appName) =>
30 32
       "Welcome to ${appName}!\n\nWe have formulated the User Agreement and Privacy Policy in accordance with relevant laws to help you understand how we collect, store and use your personal information. \n\nBased on your express authorization, we may call your device permissions, and you have the right to refuse or cancel the authorization, please refer to the \"Permission Description\" for specific permission acquisition";
31 33
 
32
-  static String m4(area) =>
34
+  static String m5(area) =>
33 35
       "Please photograph the oral ${area}, and the best distance is 1.5 cm";
34 36
 
35
-  static String m5(age) => "${age} years old";
37
+  static String m6(age) => "${age} years old";
36 38
 
37
-  static String m6(second) => "${second}Second";
39
+  static String m7(second) => "${second}Second";
38 40
 
39 41
   final messages = _notInlinedMessages(_notInlinedMessages);
40 42
   static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
@@ -146,6 +148,7 @@ class MessageLookup extends MessageLookupByLibrary {
146 148
         "male": MessageLookupByLibrary.simpleMessage("Male"),
147 149
         "maxPatientCount": MessageLookupByLibrary.simpleMessage(
148 150
             "You\'ve already added four patients and can\'t add any more."),
151
+        "maxSelectCountXx": m3,
149 152
         "mobileColon": MessageLookupByLibrary.simpleMessage("Mobile:"),
150 153
         "mobileFormatError": MessageLookupByLibrary.simpleMessage(
151 154
             "Please enter a valid mobile phone number"),
@@ -176,7 +179,7 @@ class MessageLookup extends MessageLookupByLibrary {
176 179
             "The network is not connected"),
177 180
         "open": MessageLookupByLibrary.simpleMessage("Open"),
178 181
         "patientList": MessageLookupByLibrary.simpleMessage("Patient list"),
179
-        "permissionDescDialogContent": m3,
182
+        "permissionDescDialogContent": m4,
180 183
         "permissionDescDialogTitle": MessageLookupByLibrary.simpleMessage(
181 184
             "User Agreement and Privacy Policy Reminder"),
182 185
         "permissionDescription":
@@ -196,6 +199,8 @@ class MessageLookup extends MessageLookupByLibrary {
196 199
             MessageLookupByLibrary.simpleMessage("Please enter your real name"),
197 200
         "pleaseInputValidIdCard": MessageLookupByLibrary.simpleMessage(
198 201
             "Please enter a valid ID number"),
202
+        "pleaseSelectAtLastOne":
203
+            MessageLookupByLibrary.simpleMessage("Please select at least one"),
199 204
         "pleaseSelectPatient":
200 205
             MessageLookupByLibrary.simpleMessage("Please select a patient"),
201 206
         "pleaseSelectRelation": MessageLookupByLibrary.simpleMessage(
@@ -245,6 +250,11 @@ class MessageLookup extends MessageLookupByLibrary {
245 250
         "selectAll": MessageLookupByLibrary.simpleMessage("Select all"),
246 251
         "selectPatient":
247 252
             MessageLookupByLibrary.simpleMessage("Select the patient"),
253
+        "selectPhoto": MessageLookupByLibrary.simpleMessage("Select Photos"),
254
+        "selectPhotoAndRecord": MessageLookupByLibrary.simpleMessage(
255
+            "Select Photo & Video Recording"),
256
+        "selectRecord":
257
+            MessageLookupByLibrary.simpleMessage("Select Recording"),
248 258
         "selectToothAreaHint": MessageLookupByLibrary.simpleMessage(
249 259
             "Please select the tooth area"),
250 260
         "send": MessageLookupByLibrary.simpleMessage("Send"),
@@ -281,7 +291,7 @@ class MessageLookup extends MessageLookupByLibrary {
281 291
         "syncDataWaiting": MessageLookupByLibrary.simpleMessage(
282 292
             "Data is syncing, please wait"),
283 293
         "takePhoto": MessageLookupByLibrary.simpleMessage("Take photo"),
284
-        "takePhotoAreaHint": m4,
294
+        "takePhotoAreaHint": m5,
285 295
         "takePhotoFailed":
286 296
             MessageLookupByLibrary.simpleMessage("Failed to take a photo"),
287 297
         "takePhotoSuccess": MessageLookupByLibrary.simpleMessage(
@@ -311,7 +321,7 @@ class MessageLookup extends MessageLookupByLibrary {
311 321
         "video": MessageLookupByLibrary.simpleMessage("Video"),
312 322
         "waitingConnectDevice": MessageLookupByLibrary.simpleMessage(
313 323
             "Waiting for the device to connect"),
314
-        "xxAge": m5,
315
-        "xxSecond": m6
324
+        "xxAge": m6,
325
+        "xxSecond": m7
316 326
       };
317 327
 }

+ 16 - 8
lib/generated/intl/messages_zh.dart

@@ -26,14 +26,16 @@ class MessageLookup extends MessageLookupByLibrary {
26 26
 
27 27
   static String m2(selected) => "已选择${selected}";
28 28
 
29
-  static String m3(appName) =>
29
+  static String m3(count) => "最多可以选择${count}项";
30
+
31
+  static String m4(appName) =>
30 32
       "欢迎使用${appName}!\n\n我们根据相关法律制定了《用户协议》和《隐私政策》,帮助您了解我们如何收集、保存、使用您的个人信息,请您在同意之前仔细阅读并充分理解相关条款。\n\n基于您的明示授权,我们将可能调用您的设备权限,您有权拒绝或取消授权,具体权限获取情况详见《权限说明》";
31 33
 
32
-  static String m4(area) => "请对口腔${area}域进行拍摄,最佳拍摄距离为1.5cm";
34
+  static String m5(area) => "请对口腔${area}域进行拍摄,最佳拍摄距离为1.5cm";
33 35
 
34
-  static String m5(age) => "${age}岁";
36
+  static String m6(age) => "${age}岁";
35 37
 
36
-  static String m6(second) => "${second}秒";
38
+  static String m7(second) => "${second}秒";
37 39
 
38 40
   final messages = _notInlinedMessages(_notInlinedMessages);
39 41
   static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
@@ -117,6 +119,7 @@ class MessageLookup extends MessageLookupByLibrary {
117 119
         "male": MessageLookupByLibrary.simpleMessage("男"),
118 120
         "maxPatientCount":
119 121
             MessageLookupByLibrary.simpleMessage("您已经添加了四位咨询人,无法再添加更多咨询人了。"),
122
+        "maxSelectCountXx": m3,
120 123
         "mobileColon": MessageLookupByLibrary.simpleMessage("手机号:"),
121 124
         "mobileFormatError": MessageLookupByLibrary.simpleMessage("请输入正确的手机号"),
122 125
         "mobileInputHint": MessageLookupByLibrary.simpleMessage("请输入手机号"),
@@ -140,7 +143,7 @@ class MessageLookup extends MessageLookupByLibrary {
140 143
         "notworkNotConnect": MessageLookupByLibrary.simpleMessage("网络未连接"),
141 144
         "open": MessageLookupByLibrary.simpleMessage("开启"),
142 145
         "patientList": MessageLookupByLibrary.simpleMessage("咨询人列表"),
143
-        "permissionDescDialogContent": m3,
146
+        "permissionDescDialogContent": m4,
144 147
         "permissionDescDialogTitle":
145 148
             MessageLookupByLibrary.simpleMessage("用户协议及隐私政策提示"),
146 149
         "permissionDescription": MessageLookupByLibrary.simpleMessage("权限说明"),
@@ -156,6 +159,8 @@ class MessageLookup extends MessageLookupByLibrary {
156 159
         "pleaseInputRealName": MessageLookupByLibrary.simpleMessage("请输入真实姓名"),
157 160
         "pleaseInputValidIdCard":
158 161
             MessageLookupByLibrary.simpleMessage("请输入有效的身份证号"),
162
+        "pleaseSelectAtLastOne":
163
+            MessageLookupByLibrary.simpleMessage("请至少选择一项"),
159 164
         "pleaseSelectPatient": MessageLookupByLibrary.simpleMessage("请选择咨询人"),
160 165
         "pleaseSelectRelation":
161 166
             MessageLookupByLibrary.simpleMessage("请选择与您本人关系"),
@@ -192,6 +197,9 @@ class MessageLookup extends MessageLookupByLibrary {
192 197
         "saveSuccess": MessageLookupByLibrary.simpleMessage("保存成功"),
193 198
         "selectAll": MessageLookupByLibrary.simpleMessage("全选"),
194 199
         "selectPatient": MessageLookupByLibrary.simpleMessage("选择咨询人"),
200
+        "selectPhoto": MessageLookupByLibrary.simpleMessage("选择照片"),
201
+        "selectPhotoAndRecord": MessageLookupByLibrary.simpleMessage("选择照片和录像"),
202
+        "selectRecord": MessageLookupByLibrary.simpleMessage("选择录像"),
195 203
         "selectToothAreaHint": MessageLookupByLibrary.simpleMessage("请选择牙齿区域"),
196 204
         "send": MessageLookupByLibrary.simpleMessage("发送"),
197 205
         "serverError": MessageLookupByLibrary.simpleMessage("服务器异常"),
@@ -218,7 +226,7 @@ class MessageLookup extends MessageLookupByLibrary {
218 226
         "switchPatient": MessageLookupByLibrary.simpleMessage("切换咨询人"),
219 227
         "syncDataWaiting": MessageLookupByLibrary.simpleMessage("正在同步数据,请稍候"),
220 228
         "takePhoto": MessageLookupByLibrary.simpleMessage("拍照"),
221
-        "takePhotoAreaHint": m4,
229
+        "takePhotoAreaHint": m5,
222 230
         "takePhotoFailed": MessageLookupByLibrary.simpleMessage("拍照失败"),
223 231
         "takePhotoSuccess": MessageLookupByLibrary.simpleMessage("拍照成功"),
224 232
         "tapAgainExit": MessageLookupByLibrary.simpleMessage("再次点击退出程序"),
@@ -243,7 +251,7 @@ class MessageLookup extends MessageLookupByLibrary {
243 251
         "video": MessageLookupByLibrary.simpleMessage("视频"),
244 252
         "waitingConnectDevice":
245 253
             MessageLookupByLibrary.simpleMessage("正在等待设备连接"),
246
-        "xxAge": m5,
247
-        "xxSecond": m6
254
+        "xxAge": m6,
255
+        "xxSecond": m7
248 256
       };
249 257
 }

+ 50 - 0
lib/generated/l10n.dart

@@ -1789,6 +1789,56 @@ class S {
1789 1789
       args: [],
1790 1790
     );
1791 1791
   }
1792
+
1793
+  /// `Select Photos`
1794
+  String get selectPhoto {
1795
+    return Intl.message(
1796
+      'Select Photos',
1797
+      name: 'selectPhoto',
1798
+      desc: '',
1799
+      args: [],
1800
+    );
1801
+  }
1802
+
1803
+  /// `Select Recording`
1804
+  String get selectRecord {
1805
+    return Intl.message(
1806
+      'Select Recording',
1807
+      name: 'selectRecord',
1808
+      desc: '',
1809
+      args: [],
1810
+    );
1811
+  }
1812
+
1813
+  /// `Select Photo & Video Recording`
1814
+  String get selectPhotoAndRecord {
1815
+    return Intl.message(
1816
+      'Select Photo & Video Recording',
1817
+      name: 'selectPhotoAndRecord',
1818
+      desc: '',
1819
+      args: [],
1820
+    );
1821
+  }
1822
+
1823
+  /// `You can choose up to {count}`
1824
+  String maxSelectCountXx(Object count) {
1825
+    return Intl.message(
1826
+      'You can choose up to $count',
1827
+      name: 'maxSelectCountXx',
1828
+      desc: '',
1829
+      args: [count],
1830
+    );
1831
+  }
1832
+
1833
+  /// `Please select at least one`
1834
+  String get pleaseSelectAtLastOne {
1835
+    return Intl.message(
1836
+      'Please select at least one',
1837
+      name: 'pleaseSelectAtLastOne',
1838
+      desc: '',
1839
+      args: [],
1840
+    );
1841
+  }
1792 1842
 }
1793 1843
 
1794 1844
 class AppLocalizationDelegate extends LocalizationsDelegate<S> {

+ 11 - 0
lib/global.dart

@@ -66,3 +66,14 @@ final MethodChannel videoChannel = const MethodChannel(_videoChannelName);
66 66
 
67 67
 ///文件channel
68 68
 final MethodChannel fileChannel = const MethodChannel(_fileChannelName);
69
+
70
+///国康RSA加密公钥
71
+final String gkRsaPublicKey = """
72
+-----BEGIN PUBLIC KEY-----
73
+MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALltnyc4QcGMQ7/ZT+xmV6x/OXdJ2k5ftatsES9XlScM
74
+fPgs/mANKCixDwNFOIAFvTnKUvGgxVhBXpFL8Ma/J0cCAwEAAQ==
75
+-----END PUBLIC KEY-----
76
+    """;
77
+
78
+///国康RSA加密密钥长度
79
+final int gkRsaKeyBitLength = 512;

+ 6 - 1
lib/l10n/intl_en.arb

@@ -172,5 +172,10 @@
172 172
   "permissionDescDialogContent": "Welcome to {appName}!\n\nWe have formulated the User Agreement and Privacy Policy in accordance with relevant laws to help you understand how we collect, store and use your personal information. \n\nBased on your express authorization, we may call your device permissions, and you have the right to refuse or cancel the authorization, please refer to the \"Permission Description\" for specific permission acquisition",
173 173
   "read": "Read",
174 174
   "agreeContinue": "Agree",
175
-  "requestLocationHint": "Since the application companion instrument uses WiFi connection, you need to judge whether you have connected to the WiFi of the instrument through the location permission, and request your location permission, please click Allow in the next pop-up window."
175
+  "requestLocationHint": "Since the application companion instrument uses WiFi connection, you need to judge whether you have connected to the WiFi of the instrument through the location permission, and request your location permission, please click Allow in the next pop-up window.",
176
+  "selectPhoto": "Select Photos",
177
+  "selectRecord": "Select Recording",
178
+  "selectPhotoAndRecord": "Select Photo & Video Recording",
179
+  "maxSelectCountXx": "You can choose up to {count}",
180
+  "pleaseSelectAtLastOne": "Please select at least one"
176 181
 }

+ 6 - 1
lib/l10n/intl_zh.arb

@@ -172,5 +172,10 @@
172 172
   "permissionDescDialogContent": "欢迎使用{appName}!\n\n我们根据相关法律制定了《用户协议》和《隐私政策》,帮助您了解我们如何收集、保存、使用您的个人信息,请您在同意之前仔细阅读并充分理解相关条款。\n\n基于您的明示授权,我们将可能调用您的设备权限,您有权拒绝或取消授权,具体权限获取情况详见《权限说明》",
173 173
   "read": "阅读",
174 174
   "agreeContinue": "同意并继续",
175
-  "requestLocationHint": "因应用配套仪器使用WiFi连接,需通过位置权限判断您是否已连接仪器WiFi,请求获取您的位置权限,请在下个弹窗中点击允许。"
175
+  "requestLocationHint": "因应用配套仪器使用WiFi连接,需通过位置权限判断您是否已连接仪器WiFi,请求获取您的位置权限,请在下个弹窗中点击允许。",
176
+  "selectPhoto": "选择照片",
177
+  "selectRecord": "选择录像",
178
+  "selectPhotoAndRecord": "选择照片和录像",
179
+  "maxSelectCountXx": "最多可以选择{count}项",
180
+  "pleaseSelectAtLastOne": "请至少选择一项"
176 181
 }

+ 8 - 44
lib/pages/history/history_page.dart

@@ -6,6 +6,8 @@ import 'package:eitc_erm_dental_flutter/entity/history_item_info.dart';
6 6
 import 'package:eitc_erm_dental_flutter/funcs.dart';
7 7
 import 'package:eitc_erm_dental_flutter/pages/history/vm/history_view_model.dart';
8 8
 import 'package:eitc_erm_dental_flutter/pages/history/widget/history_item_view.dart';
9
+import 'package:eitc_erm_dental_flutter/widget/empty_widget.dart';
10
+import 'package:eitc_erm_dental_flutter/widget/loading_widget.dart';
9 11
 import 'package:eitc_erm_dental_flutter/widget/main_button.dart';
10 12
 import 'package:flutter/material.dart';
11 13
 import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -190,57 +192,19 @@ class _HistoryPageState extends ConsumerState<HistoryPage> {
190 192
     });
191 193
   }
192 194
 
193
-  Widget _getLoading() {
194
-    return Center(
195
-      child: Row(
196
-        mainAxisSize: MainAxisSize.min,
197
-        crossAxisAlignment: CrossAxisAlignment.center,
198
-        children: [
199
-          Icon(
200
-            Icons.downloading,
201
-            size: 35.r,
202
-          ),
203
-          SizedBox(
204
-            width: 10.w,
205
-          ),
206
-          Text(
207
-            getS().loadingHistories,
208
-          )
209
-        ],
210
-      ),
211
-    );
212
-  }
213
-
214
-  Widget _getEmpty() {
215
-    return Center(
216
-      child: Row(
217
-        mainAxisSize: MainAxisSize.min,
218
-        crossAxisAlignment: CrossAxisAlignment.center,
219
-        children: [
220
-          Icon(
221
-            Icons.sentiment_dissatisfied,
222
-            size: 35.r,
223
-          ),
224
-          SizedBox(
225
-            width: 10.w,
226
-          ),
227
-          Text(
228
-            getS().noHistories,
229
-          )
230
-        ],
231
-      ),
232
-    );
233
-  }
234
-
235 195
   Widget _getListWidget(BuildContext context) {
236 196
     return Consumer(builder: (ctx, ref, _) {
237 197
       AsyncValue<HistoryListData> value = ref.watch(historyListProvider);
238 198
       int viewType = ref.watch(historyViewTypeProvider);
239 199
       return switch (value) {
240 200
         AsyncData<HistoryListData>(value: var data) => data.isEmpty
241
-            ? _getEmpty()
201
+            ? EmptyWidget(
202
+                text: getS().noHistories,
203
+              )
242 204
             : (viewType == 0 ? _getTimeList(data) : _getTypeList(ctx, data)),
243
-        _ => _getLoading()
205
+        _ => LoadingWidget(
206
+            text: getS().loadingHistories,
207
+          )
244 208
       };
245 209
     });
246 210
   }

+ 304 - 0
lib/pages/history/select_history_page.dart

@@ -0,0 +1,304 @@
1
+import 'dart:io';
2
+
3
+import 'package:auto_route/annotations.dart';
4
+import 'package:eitc_erm_dental_flutter/db_util.dart';
5
+import 'package:eitc_erm_dental_flutter/entity/db/local_patient_info.dart';
6
+import 'package:eitc_erm_dental_flutter/global.dart';
7
+import 'package:eitc_erm_dental_flutter/pages/history/vm/history_view_model.dart';
8
+import 'package:eitc_erm_dental_flutter/pages/history/widget/history_item_view.dart';
9
+import 'package:eitc_erm_dental_flutter/widget/empty_widget.dart';
10
+import 'package:eitc_erm_dental_flutter/widget/loading_widget.dart';
11
+import 'package:flutter/material.dart';
12
+import 'package:flutter_riverpod/flutter_riverpod.dart';
13
+import 'package:flutter_screenutil/flutter_screenutil.dart';
14
+
15
+import '../../entity/history_item_info.dart';
16
+import '../../funcs.dart';
17
+import '../../widget/main_button.dart';
18
+
19
+///选择历史记录类型
20
+enum SelectHistoryType {
21
+  ///照片
22
+  photo,
23
+
24
+  ///录像
25
+  record,
26
+
27
+  ///所有
28
+  all;
29
+}
30
+
31
+///历史记录选择页面
32
+@RoutePage(name: "SelectHistoryRoute")
33
+class SelectHistoryPage extends ConsumerStatefulWidget {
34
+  ///选择类型
35
+  final SelectHistoryType selectType;
36
+
37
+  ///是否过滤咨询人
38
+  final bool isFillterPatient;
39
+
40
+  ///是否多选
41
+  final bool isMultiSelect;
42
+
43
+  ///多选最大数量,0表示没有限制
44
+  final int maxCount;
45
+
46
+  const SelectHistoryPage(
47
+      {super.key,
48
+      required this.selectType,
49
+      required this.isFillterPatient,
50
+      this.isMultiSelect = false,
51
+      this.maxCount = 0});
52
+
53
+  @override
54
+  ConsumerState createState() => _SelectHistoryPageState();
55
+}
56
+
57
+class _SelectHistoryPageState extends ConsumerState<SelectHistoryPage> {
58
+  ///咨询人信息
59
+  LocalPatientInfo? _patientInfo;
60
+
61
+  ///记录数量
62
+  int _historyCount = 0;
63
+
64
+  @override
65
+  void initState() {
66
+    super.initState();
67
+    _initPatientInfo();
68
+    _initMultiSelect();
69
+  }
70
+
71
+  ///初始化咨询人信息
72
+  void _initPatientInfo() async {
73
+    if (selectedPatientId < 0) {
74
+      _patientInfo = null;
75
+    }
76
+    _patientInfo = await DbUtil.instance.getLocalPatientById(selectedPatientId);
77
+  }
78
+
79
+  ///初始化多选
80
+  void _initMultiSelect() {
81
+    ProviderSubscription<AsyncValue<HistoryListData>>? listenner;
82
+    //需要在读取到数据后,渲染完一帧才设置选择模式,否则读取不到historySelectModeProvider
83
+    listenner = ref.listenManual(historyListProvider, (_, value) {
84
+      if (value is! AsyncData<HistoryListData>) {
85
+        return;
86
+      }
87
+      listenner?.close();
88
+      WidgetsBinding.instance.addPostFrameCallback((_) {
89
+        ref
90
+            .read(historySelectModeProvider.notifier)
91
+            .setSelectMode(widget.isMultiSelect);
92
+      });
93
+    });
94
+  }
95
+
96
+  @override
97
+  Widget build(BuildContext context) {
98
+    return Scaffold(
99
+      appBar: _getAppBar(context),
100
+      body: SafeArea(
101
+          child: Padding(
102
+        padding: EdgeInsets.symmetric(horizontal: 16.w),
103
+        child: Column(
104
+          children: [
105
+            _getSelectedCount(context),
106
+            Expanded(child: _getListWidget(context)),
107
+            _getBottomButtons(context),
108
+            SizedBox(
109
+              height: 5.h,
110
+            )
111
+          ],
112
+        ),
113
+      )),
114
+    );
115
+  }
116
+
117
+  ///获取appbar
118
+  AppBar _getAppBar(BuildContext context) {
119
+    String title = switch (widget.selectType) {
120
+      SelectHistoryType.photo => getS().selectPhoto,
121
+      SelectHistoryType.record => getS().selectRecord,
122
+      SelectHistoryType.all => getS().selectPhotoAndRecord,
123
+    };
124
+
125
+    return AppBar(
126
+      centerTitle: true,
127
+      forceMaterialTransparency: true,
128
+      title: Text(title),
129
+      leading: IconButton(
130
+          onPressed: () {
131
+            Navigator.pop(context);
132
+          },
133
+          icon: Icon(
134
+              Platform.isIOS ? Icons.arrow_back_ios_new : Icons.arrow_back)),
135
+    );
136
+  }
137
+
138
+  ///获取已选择数量widget
139
+  Widget _getSelectedCount(BuildContext context) {
140
+    if (!widget.isMultiSelect) {
141
+      return SizedBox();
142
+    }
143
+    return Row(
144
+      children: [
145
+        Consumer(builder: (_, tref, __) {
146
+          int count = tref.watch(historySelectedCountProvider);
147
+          return Text(getS().hasSelectCountItem(count));
148
+        }),
149
+        SizedBox(
150
+          width: 6.w,
151
+        ),
152
+        const Spacer(),
153
+        SizedBox(
154
+            width: 25.w,
155
+            child: Consumer(builder: (_, cref, __) {
156
+              int count = cref.watch(historySelectedCountProvider);
157
+              int totalCount = 0;
158
+              HistoryListData? data = cref.read(historyListProvider).value;
159
+              if (data != null) {
160
+                totalCount = switch (widget.selectType) {
161
+                  SelectHistoryType.photo => data.photoList.length,
162
+                  SelectHistoryType.record => data.videoList.length,
163
+                  SelectHistoryType.all => data.getMergedList(false).length,
164
+                };
165
+              }
166
+              return Checkbox(
167
+                  value: totalCount > 0 && count == totalCount,
168
+                  shape: const CircleBorder(),
169
+                  onChanged: _onSelectAll);
170
+            })),
171
+        Text(getS().selectAll),
172
+        SizedBox(
173
+          width: 5.w,
174
+        ),
175
+      ],
176
+    );
177
+  }
178
+
179
+  ///获取底部按钮
180
+  Widget _getBottomButtons(BuildContext context) {
181
+    return widget.isMultiSelect
182
+        ? SizedBox(
183
+            width: double.infinity,
184
+            child: MainButton(
185
+                text: getS().confirm, onPressed: () => _onConfirm(context)),
186
+          )
187
+        : SizedBox();
188
+  }
189
+
190
+  Widget _getListWidget(BuildContext context) {
191
+    return Consumer(builder: (ctx, ref, _) {
192
+      AsyncValue<HistoryListData> value = ref.watch(historyListProvider);
193
+      return switch (value) {
194
+        AsyncData<HistoryListData>(value: var data) => data.isEmpty
195
+            ? EmptyWidget(
196
+                text: getS().noHistories,
197
+              )
198
+            : _getGridView(switch (widget.selectType) {
199
+                SelectHistoryType.photo => data.photoList,
200
+                SelectHistoryType.record => data.videoList,
201
+                SelectHistoryType.all => data.getMergedList(true)
202
+              }),
203
+        _ => LoadingWidget(
204
+            text: getS().loadingHistories,
205
+          )
206
+      };
207
+    });
208
+  }
209
+
210
+  ///获取GridView
211
+  Widget _getGridView(List<HistoryItemInfo> list,
212
+      {bool shinkWarp = false, bool scrollable = true}) {
213
+    //是否过滤咨询人
214
+    if (widget.isFillterPatient) {
215
+      if (_patientInfo == null) {
216
+        list = [];
217
+      } else {
218
+        list = list
219
+            .where((info) =>
220
+                info.prefixInfo != null &&
221
+                info.prefixInfo!.name.isNotEmpty &&
222
+                info.prefixInfo!.name == _patientInfo!.name)
223
+            .toList();
224
+      }
225
+    }
226
+
227
+    _historyCount = list.length;
228
+
229
+    return GridView.builder(
230
+      shrinkWrap: shinkWarp,
231
+      physics: scrollable
232
+          ? const ClampingScrollPhysics()
233
+          : const NeverScrollableScrollPhysics(),
234
+      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
235
+          crossAxisCount: 2,
236
+          childAspectRatio: 164.0 / 120.0,
237
+          mainAxisSpacing: 8.r,
238
+          crossAxisSpacing: 15.r),
239
+      itemBuilder: (ctx, index) {
240
+        HistoryItemInfo item = list[index];
241
+        return GestureDetector(
242
+          child: HistoryItemView(
243
+            index: index,
244
+            name: item.name,
245
+            path: item.path,
246
+            type: item.type,
247
+          ),
248
+          onTap: () => _onTap(ctx, item),
249
+        );
250
+      },
251
+      itemCount: list.length,
252
+    );
253
+  }
254
+
255
+  ///全选
256
+  void _onSelectAll(bool? isSelect) {
257
+    if (isSelect == null || !isSelect) {
258
+      ref.read(historyListProvider.notifier).selectAll(false);
259
+    } else {
260
+      if (_historyCount <= 0) {
261
+        return;
262
+      }
263
+      if (_historyCount > widget.maxCount) {
264
+        showToast(text: getS().maxSelectCountXx(widget.maxCount));
265
+        return;
266
+      }
267
+      ref.read(historyListProvider.notifier).selectAll(true);
268
+    }
269
+  }
270
+
271
+  ///点击
272
+  void _onTap(BuildContext context, HistoryItemInfo info) {
273
+    if(info.isSelected)
274
+    {
275
+      ref.read(historyListProvider.notifier).select(info, false);
276
+      return;
277
+    }
278
+    if (widget.isMultiSelect) {
279
+      if (widget.maxCount > 0 &&
280
+          ref.read(historySelectedCountProvider) >= widget.maxCount) {
281
+        showToast(text: getS().maxSelectCountXx(widget.maxCount));
282
+        return;
283
+      }
284
+      ref.read(historyListProvider.notifier).select(info, true);
285
+      return;
286
+    }
287
+    _onSelected(context, [info]);
288
+  }
289
+
290
+  ///确定
291
+  void _onConfirm(BuildContext context) {
292
+    List<HistoryItemInfo> list =
293
+        ref.read(historyListProvider.notifier).getSelectedItems();
294
+    if (list.isEmpty) {
295
+      showToast(text: getS().pleaseSelectAtLastOne);
296
+      return;
297
+    }
298
+    _onSelected(context, list);
299
+  }
300
+
301
+  void _onSelected(BuildContext context, List<HistoryItemInfo> list) {
302
+    Navigator.pop(context, list);
303
+  }
304
+}

+ 1 - 1
lib/pages/history/vm/history_view_model.g.dart

@@ -186,7 +186,7 @@ final historySelectedCountProvider = AutoDisposeProvider<int>.internal(
186 186
 );
187 187
 
188 188
 typedef HistorySelectedCountRef = AutoDisposeProviderRef<int>;
189
-String _$historyListHash() => r'0658bd2360975795200912466323578419bdd50a';
189
+String _$historyListHash() => r'06fc47638ef14fffaebc2992072f4a4460aceb0f';
190 190
 
191 191
 ///历史记录列表
192 192
 ///

+ 43 - 29
lib/pages/web/webview_page.dart

@@ -1,6 +1,7 @@
1 1
 import 'package:auto_route/annotations.dart';
2 2
 import 'package:eitc_erm_dental_flutter/exts.dart';
3 3
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
+import 'package:eitc_erm_dental_flutter/widget/webview_progress_bar.dart';
4 5
 import 'package:flutter/foundation.dart';
5 6
 import 'package:flutter/material.dart';
6 7
 import 'package:flutter_inappwebview/flutter_inappwebview.dart';
@@ -34,6 +35,9 @@ class _WebviewPageState extends State<WebviewPage> {
34 35
       iframeAllowFullscreen: true,
35 36
       javaScriptEnabled: true);
36 37
 
38
+  final WebviewProgressBarController _progressBarController =
39
+      WebviewProgressBarController();
40
+
37 41
   @override
38 42
   void initState() {
39 43
     super.initState();
@@ -42,6 +46,7 @@ class _WebviewPageState extends State<WebviewPage> {
42 46
   @override
43 47
   void dispose() {
44 48
     super.dispose();
49
+    _progressBarController.dispose();
45 50
   }
46 51
 
47 52
   void _load() async {
@@ -67,35 +72,44 @@ class _WebviewPageState extends State<WebviewPage> {
67 72
       ),
68 73
       //body: SafeArea(child: WebViewWidget(controller: _controller)),
69 74
       body: SafeArea(
70
-        child: InAppWebView(
71
-          key: _webViewKey,
72
-          initialSettings: _settings,
73
-          onWebViewCreated: (controller) {
74
-            _webViewController = controller;
75
-            _load();
76
-          },
77
-          onLoadStart: (controller, url) {
78
-            logd("onLoadStart,url=$url");
79
-          },
80
-          onPermissionRequest: (controller, request) async {
81
-            return PermissionResponse(
82
-                resources: request.resources,
83
-                action: PermissionResponseAction.GRANT);
84
-          },
85
-          onLoadStop: (controller, url) async {
86
-            logd("onLoadStop,url=$url");
87
-          },
88
-          onReceivedError: (controller, request, error) {
89
-            loge("onReceivedError", error: error);
90
-          },
91
-          onProgressChanged: (controller, progress) {
92
-            logd("onProgressChanged,progress=$progress");
93
-          },
94
-          onConsoleMessage: (controller, consoleMessage) {
95
-            if (kDebugMode) {
96
-              logd(consoleMessage);
97
-            }
98
-          },
75
+        child: Stack(
76
+          children: [
77
+            InAppWebView(
78
+              key: _webViewKey,
79
+              initialSettings: _settings,
80
+              onWebViewCreated: (controller) {
81
+                _webViewController = controller;
82
+                _load();
83
+              },
84
+              onLoadStart: (controller, url) {
85
+                logd("onLoadStart,url=$url");
86
+              },
87
+              onPermissionRequest: (controller, request) async {
88
+                return PermissionResponse(
89
+                    resources: request.resources,
90
+                    action: PermissionResponseAction.GRANT);
91
+              },
92
+              onLoadStop: (controller, url) async {
93
+                logd("onLoadStop,url=$url");
94
+              },
95
+              onReceivedError: (controller, request, error) {
96
+                loge("onReceivedError", error: error);
97
+              },
98
+              onProgressChanged: (controller, progress) {
99
+                logd("onProgressChanged,progress=$progress");
100
+                _progressBarController.setProgress(progress);
101
+              },
102
+              onConsoleMessage: (controller, consoleMessage) {
103
+                if (kDebugMode) {
104
+                  logd(consoleMessage);
105
+                }
106
+              },
107
+            ),
108
+            Align(
109
+              alignment: Alignment.topLeft,
110
+              child: WebviewProgressBar(controller: _progressBarController),
111
+            )
112
+          ],
99 113
         ),
100 114
       ),
101 115
     );

+ 36 - 0
lib/widget/empty_widget.dart

@@ -0,0 +1,36 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:flutter_screenutil/flutter_screenutil.dart';
3
+
4
+///无数据Widget
5
+class EmptyWidget extends StatelessWidget {
6
+  final Widget? icon;
7
+  final String? text;
8
+
9
+  const EmptyWidget({super.key, this.text, this.icon});
10
+
11
+  @override
12
+  Widget build(BuildContext context) {
13
+    return Center(
14
+      child: Row(
15
+        mainAxisSize: MainAxisSize.min,
16
+        crossAxisAlignment: CrossAxisAlignment.center,
17
+        children: [
18
+          icon == null
19
+              ? Icon(
20
+                  Icons.sentiment_dissatisfied,
21
+                  size: 35.r,
22
+                )
23
+              : icon!,
24
+          SizedBox(
25
+            width: 10.w,
26
+          ),
27
+          text == null
28
+              ? SizedBox()
29
+              : Text(
30
+                  text!,
31
+                )
32
+        ],
33
+      ),
34
+    );
35
+  }
36
+}

+ 36 - 0
lib/widget/loading_widget.dart

@@ -0,0 +1,36 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:flutter_screenutil/flutter_screenutil.dart';
3
+
4
+///加载Widget
5
+class LoadingWidget extends StatelessWidget {
6
+  final Widget? icon;
7
+  final String? text;
8
+
9
+  const LoadingWidget({super.key, this.text, this.icon});
10
+
11
+  @override
12
+  Widget build(BuildContext context) {
13
+    return Center(
14
+      child: Row(
15
+        mainAxisSize: MainAxisSize.min,
16
+        crossAxisAlignment: CrossAxisAlignment.center,
17
+        children: [
18
+          icon == null
19
+              ? Icon(
20
+                  Icons.downloading,
21
+                  size: 35.r,
22
+                )
23
+              : icon!,
24
+          SizedBox(
25
+            width: 10.w,
26
+          ),
27
+          text == null
28
+              ? SizedBox()
29
+              : Text(
30
+                  text!,
31
+                )
32
+        ],
33
+      ),
34
+    );
35
+  }
36
+}

+ 73 - 0
lib/widget/webview_progress_bar.dart

@@ -0,0 +1,73 @@
1
+import 'package:flutter/material.dart';
2
+
3
+///Webview进度条
4
+class WebviewProgressBar extends StatefulWidget {
5
+  final WebviewProgressBarController controller;
6
+  final bool autoHide;
7
+  final Color? backgroundColor;
8
+  final Color? color;
9
+  final Animation<Color?>? valueColor;
10
+  final String? semanticsLabel;
11
+  final String? semanticsValue;
12
+  final BorderRadiusGeometry borderRadius;
13
+
14
+  const WebviewProgressBar(
15
+      {super.key,
16
+      required this.controller,
17
+      this.autoHide = true,
18
+      this.backgroundColor,
19
+      this.color,
20
+      this.valueColor,
21
+      this.semanticsLabel,
22
+      this.semanticsValue,
23
+      this.borderRadius = BorderRadius.zero});
24
+
25
+  @override
26
+  State<WebviewProgressBar> createState() => _WebviewProgressBarState();
27
+}
28
+
29
+class _WebviewProgressBarState extends State<WebviewProgressBar> {
30
+  @override
31
+  void initState() {
32
+    super.initState();
33
+    widget.controller.progress.addListener(() {
34
+      setState(() {});
35
+    });
36
+  }
37
+
38
+  @override
39
+  Widget build(BuildContext context) {
40
+    WebviewProgressBarController controller = widget.controller;
41
+    if (controller.progress.value >= 100 && widget.autoHide) {
42
+      return SizedBox();
43
+    }
44
+    return LinearProgressIndicator(
45
+      value: controller.progress.value / 100,
46
+      backgroundColor: widget.backgroundColor,
47
+      color: widget.color,
48
+      valueColor: widget.valueColor,
49
+      semanticsLabel: widget.semanticsLabel,
50
+      semanticsValue: widget.semanticsValue,
51
+      borderRadius: widget.borderRadius,
52
+    );
53
+  }
54
+}
55
+
56
+///Webview进度条控制器
57
+class WebviewProgressBarController {
58
+  ///进度
59
+  ValueNotifier<int>? _progress;
60
+
61
+  ///进度
62
+  ValueNotifier<int> get progress => _progress ??= ValueNotifier(0);
63
+
64
+  ///设置进度
65
+  void setProgress(int value) {
66
+    progress.value = value;
67
+  }
68
+
69
+  void dispose() {
70
+    _progress?.dispose();
71
+    _progress = null;
72
+  }
73
+}

+ 1 - 1
pubspec.lock

@@ -955,7 +955,7 @@ packages:
955 955
     source: hosted
956 956
     version: "2.1.8"
957 957
   pointycastle:
958
-    dependency: transitive
958
+    dependency: "direct main"
959 959
     description:
960 960
       name: pointycastle
961 961
       sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"

+ 2 - 1
pubspec.yaml

@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
16 16
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
17 17
 # In Windows, build-name is used as the major, minor, and patch parts
18 18
 # of the product and file versions while build-number is used as the build suffix.
19
-version: 1.0.8+9
19
+version: 1.0.9+10
20 20
 
21 21
 environment:
22 22
   sdk: ^3.5.1
@@ -92,6 +92,7 @@ dependencies:
92 92
   image: ^4.2.0
93 93
 
94 94
   encrypt: ^5.0.3
95
+  pointycastle: ^3.9.1
95 96
 
96 97
   retrofit: ^4.4.1
97 98
   json_annotation: ^4.9.0