From 4fb59978984faaba980e7c687008902d0e19b4aa Mon Sep 17 00:00:00 2001 From: lxowalle Date: Tue, 12 Nov 2024 18:55:21 +0800 Subject: [PATCH] * optimize photos & camera --- projects/app_camera/main/app/app.cpp | 2 +- projects/app_photos/main/app/app.cpp | 33 +++++++++++++++------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/projects/app_camera/main/app/app.cpp b/projects/app_camera/main/app/app.cpp index 7239c9ec..a8e83708 100644 --- a/projects/app_camera/main/app/app.cpp +++ b/projects/app_camera/main/app/app.cpp @@ -249,7 +249,7 @@ static int _get_encode_bitrate_by_camera_resolution(int w, int h) { } else if (w == 1920 && h == 1080) { return 4 * 1000 * 1000; } else if (w == 2560 && h == 1440) { - return 8 * 1000 * 1000; + return 6 * 1000 * 1000; } else { return 3 * 1000 * 1000; } diff --git a/projects/app_photos/main/app/app.cpp b/projects/app_photos/main/app/app.cpp index d054b6e4..148c3e73 100644 --- a/projects/app_photos/main/app/app.cpp +++ b/projects/app_photos/main/app/app.cpp @@ -363,13 +363,13 @@ class PhotoVideo { PhotoVideoInfo *find_next_photo_video(std::string date, std::string path) { bool return_next_item = false; - auto iter = _video_photo_list->rbegin(); - for (; iter != _video_photo_list->rend(); iter++) { + auto iter = _video_photo_list->begin(); + for (; iter != _video_photo_list->end(); iter++) { auto item = *iter; auto list = item.second; if (date == item.first || return_next_item) { - auto list_iter = list.begin(); - for (; list_iter != list.end(); list_iter ++) { + auto list_iter = list.rbegin(); + for (; list_iter != list.rend(); list_iter ++) { auto &list_item = *list_iter; if (return_next_item) { return list_item.clone(); @@ -387,13 +387,13 @@ class PhotoVideo { PhotoVideoInfo *find_prev_photo_video(std::string date, std::string path) { bool return_next_item = false; - auto iter = _video_photo_list->begin(); - for (; iter != _video_photo_list->end(); iter++) { + auto iter = _video_photo_list->rbegin(); + for (; iter != _video_photo_list->rend(); iter++) { auto item = *iter; auto list = item.second; if (date == item.first || return_next_item) { - auto list_iter = list.rbegin(); - for (; list_iter != list.rend(); list_iter ++) { + auto list_iter = list.begin(); + for (; list_iter != list.end(); list_iter ++) { auto &list_item = *list_iter; if (return_next_item) { return list_item.clone(); @@ -707,19 +707,22 @@ int app_init(display::Display *disp) auto list = priv.photo_video->get_video_photo_list(); auto iter = list->begin(); for (; iter != list->end(); iter++) { - auto item = *iter; + auto &item = *iter; auto date = item.first; - auto info_list = item.second; - // log::info("\t[%s] number:%d", date.c_str(), info_list.size()); + auto &info_list = item.second; + log::info("\t[%s] number:%d", date.c_str(), info_list.size()); ui_photo_add_dir((char *)date.c_str()); auto list_iter = info_list.rbegin(); - for (; list_iter != info_list.rend(); list_iter ++) { + for (; list_iter != info_list.rend();) { auto list_item = *list_iter; - // log::info("\tpath:%s", list_item.path.c_str()); + log::info("\tpath:%s", list_item.path.c_str()); lv_image_dsc_t *dsc = load_thumbnail_image((char *)list_item.path.c_str(), (char *)list_item.thumbnail_path.c_str()); if (dsc) { ui_photo_add_photo((char *)date.c_str(), (char *)list_item.path.c_str(), dsc, list_item.is_video()); free_thumbnail_image(dsc); + list_iter ++; + } else { + list_iter = std::make_reverse_iterator(info_list.erase(std::next(list_iter).base())); } } } @@ -1111,7 +1114,7 @@ int app_loop(void) delete info; } else { - printf("The last photo is not found!\r\n"); + printf("The prev photo is not found!\r\n"); } } @@ -1141,7 +1144,7 @@ int app_loop(void) delete info; } else { - printf("The last photo is not found!\r\n"); + printf("The next photo is not found!\r\n"); } } return 0;