Skip to content

Commit

Permalink
fix seeking next ID3/MP4Box frame when current frame size over
Browse files Browse the repository at this point in the history
  • Loading branch information
elehobica committed Nov 2, 2024
1 parent 987a202 commit f4fb6b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
* Revise active battery check voltage divider to torelate up to 5.5V
* Fix ID3v2 tag (RIFF ID3v2) read failure for large file over 32bit signed size range
* Fix seeking next ID3/MP4Box frame when current frame size ove

## [v0.9.5] - 2024-06-06
### Added
Expand Down
11 changes: 6 additions & 5 deletions src/TagRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ id32* TagRead::ID32Detect(FIL* infile, const size_t pos)
*/
frame->data = (char*) calloc(1, frame_start_bytes); // for frame parsing
f_read_unsync(infile, frame->data, frame_start_bytes, &br, unsync);
if (f_lseek(infile, frame->size - frame_start_bytes) == FR_OK) {
if (f_lseek(infile, frame->pos + frame->size) == FR_OK) {
result = frame->size;
} else {
result = 0;
Expand Down Expand Up @@ -388,13 +388,13 @@ id32* TagRead::ID32Detect(FIL* infile, const size_t pos)
result = br;
frame->isUnsynced = unsync;
frame->hasFullData = true;
} else { // give up to get full contents due to size over
} else { // give up to get full contents due to size over to skip frame such as cover art (APIC)
/*
printf("frameID: %c%c%c%c size over %d\n", frame->ID[0], frame->ID[1], frame->ID[2], frame->ID[3], frame->size);
printf("frameID: %c%c%c%c size over at pos %d size %d\n", frame->ID[0], frame->ID[1], frame->ID[2], frame->ID[3], frame->pos, frame->size);
*/
frame->data = (char*) calloc(1, frame_start_bytes); // for frame parsing
f_read_unsync(infile, frame->data, frame_start_bytes, &br, unsync);
if (f_lseek(infile, frame->size - frame_start_bytes) == FR_OK) {
if (f_lseek(infile, frame->pos + frame->size) == FR_OK) {
result = frame->size;
} else {
result = 0;
Expand Down Expand Up @@ -482,7 +482,7 @@ id32* TagRead::ID32Detect(FIL* infile, const size_t pos)
frame->data = (char*) calloc(1, frame_start_bytes); // for frame parsing
fr = f_read_unsync(infile, frame->data, frame_start_bytes, &br, unsync);
result = br;
if (f_lseek(infile, frame->size - result) == FR_OK) {
if (f_lseek(infile, frame->pos + frame->size) == FR_OK) {
result = frame->size;
} else {
result = 0;
Expand Down Expand Up @@ -1134,6 +1134,7 @@ int TagRead::findNextMP4Box(FIL* file, size_t end_pos, char type[4], size_t* pos
mp4_ilst.last->hasFullData = false;
mp4_ilst.last->data_buf = (char*) calloc(1, frame_start_bytes);
f_read(file, mp4_ilst.last->data_buf, frame_start_bytes, &br);
f_lseek(file, mp4_ilst.last->pos + data_size);
}
mp4_ilst.last->next = NULL;
}
Expand Down

0 comments on commit f4fb6b8

Please sign in to comment.