.. | .. |
---|
57 | 57 | } |
---|
58 | 58 | } |
---|
59 | 59 | |
---|
| 60 | +bool saveBuffers(const char *path, |
---|
| 61 | + void *y_addr, |
---|
| 62 | + void *cr_addr, |
---|
| 63 | + unsigned int y_size, |
---|
| 64 | + unsigned int cr_size, |
---|
| 65 | + bool is_oneframe) { |
---|
| 66 | + int fd; |
---|
| 67 | + HAL_LOGD("Debug to save a frame!"); |
---|
| 68 | + if((access(path, 0) != -1) && (is_oneframe)) { |
---|
| 69 | + HAL_LOGD("File %s is exists!!!\n", path); |
---|
| 70 | + } |
---|
| 71 | + if(is_oneframe) |
---|
| 72 | + fd = open(path, O_CREAT|O_RDWR|O_TRUNC, 0777); //save one frame data |
---|
| 73 | + else |
---|
| 74 | + fd = open(path, O_CREAT|O_RDWR|O_APPEND, 0777); //save more frames |
---|
| 75 | + if(!fd) { |
---|
| 76 | + HAL_LOGE("Open file error"); |
---|
| 77 | + return false; |
---|
| 78 | + } |
---|
| 79 | + if(write(fd, y_addr, y_size)){ |
---|
| 80 | + HAL_LOGD("Write Y data successfully"); |
---|
| 81 | + if(write(fd, cr_addr, cr_size)){ |
---|
| 82 | + HAL_LOGD("Write U data successfully"); |
---|
| 83 | + close(fd); |
---|
| 84 | + return true; |
---|
| 85 | + } |
---|
| 86 | + } |
---|
| 87 | + HAL_LOGE("Write file fail"); |
---|
| 88 | + close(fd); |
---|
| 89 | + return false; |
---|
| 90 | +} |
---|
| 91 | + |
---|
| 92 | + |
---|
60 | 93 | bool saveSizes(int width, int height) { |
---|
61 | 94 | int fd; |
---|
62 | 95 | char buf[128]; |
---|