Skip to content

Commit

Permalink
Merge pull request #5 from tantanGH/v0.2.5
Browse files Browse the repository at this point in the history
v0.2.5
  • Loading branch information
tantanGH authored Mar 3, 2024
2 parents 8228ccd + 0f3782b commit d62c7cb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
Binary file removed HMP3P024.ZIP
Binary file not shown.
Binary file added HMP3P025.ZIP
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TARGET_FILE = HMP3P.X
DOCUMENT_FILE = HMP3P.DOC

# Distribution package
PACKAGE_FILE = ../HMP3P024.ZIP
PACKAGE_FILE = ../HMP3P025.ZIP

# ヘッダ検索パス
INCLUDE_FLAGS = -I${XDEV68K_DIR}/include/xc -I${XDEV68K_DIR}/include/xdev68k -I${LIBMAD_DIR}
Expand Down
5 changes: 4 additions & 1 deletion src/hmp3p.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __H_HMP3P__
#define __H_HMP3P__

#define VERSION "0.2.4 (2024/03/02)"
#define VERSION "0.2.5 (2024/03/03)"

#define MAX_PATH_LEN (256)

Expand All @@ -16,6 +16,9 @@
#define DRIVER_PCM8A (0)
#define DRIVER_PCM8PP (1)

#define DEFAULT_VOLUME (6)
#define DEFAULT_BUFFERS (4)

//
// link array chain table
//
Expand Down
24 changes: 14 additions & 10 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ static void show_help_message() {
printf("usage: hmp3p [options] <input-file.mp3>\n");
printf("options:\n");
printf(" -l[n] ... loop count (none:endless, default:1)\n");
printf(" -v<n> ... volume (1-15, default:6)\n");
printf(" -v<n> ... volume (1-15, default:%d)\n", DEFAULT_VOLUME);
printf(" -q<n> ... mp3 quality (0:high, 1:normal, default:0)\n");
printf(" -t<n> ... album art display brightness (1-100, default:off)\n");
printf(" -b<n> ... buffer size [x 64KB] (3-32,default:6)\n");
printf(" -b<n> ... buffer size [x 64KB] (3-32,default:%d)\n", DEFAULT_BUFFERS);
printf(" -n ... no progress bar\n");
printf(" -s ... use main memory for file reading (SCSI disk)\n");
printf(" -h ... show help message\n");
}
Expand All @@ -161,14 +162,15 @@ int32_t main(int32_t argc, uint8_t* argv[]) {

// parse command line options
uint8_t* mp3_file_name = NULL;
int16_t playback_volume = 6;
int16_t playback_volume = DEFAULT_VOLUME;
int16_t loop_count = 1;
int16_t mp3_quality = 0;
int16_t num_buffers = 6;
int16_t num_buffers = DEFAULT_BUFFERS;
int16_t use_high_memory = 0;
int16_t playback_driver = DRIVER_NONE;
int16_t staging_file_read = 0;
int16_t pic_brightness = 0;
int16_t quiet_mode = 0;

// total number of chains
int32_t num_chains = 0;
Expand Down Expand Up @@ -208,6 +210,8 @@ int32_t main(int32_t argc, uint8_t* argv[]) {
}
} else if (argv[i][1] == 's') {
staging_file_read = 1;
} else if (argv[i][1] == 'n') {
quiet_mode = 1;
} else if (argv[i][1] == 't') {
pic_brightness = atoi(argv[i]+2);
if (pic_brightness < 0 || pic_brightness > 100 || strlen(argv[i]) < 3) {
Expand Down Expand Up @@ -687,7 +691,7 @@ int32_t main(int32_t argc, uint8_t* argv[]) {
// end of mp3?
if (decoded_bytes == 0) {
end_flag = 1;
B_PRINT("|");
if (!quiet_mode) B_PRINT("|");
continue;
}

Expand Down Expand Up @@ -717,9 +721,9 @@ int32_t main(int32_t argc, uint8_t* argv[]) {

int16_t dt = num_chains - block_counter;
if (dt >= buffer_delta) {
B_PRINT(">");
if (!quiet_mode) B_PRINT(">");
} else {
B_PRINT("*");
if (!quiet_mode) B_PRINT("*");
buffer_delta = dt;
}

Expand Down Expand Up @@ -763,7 +767,7 @@ int32_t main(int32_t argc, uint8_t* argv[]) {
// end of mp3?
if (decoded_bytes == 0) {
end_flag = 1;
B_PRINT("|");
if (!quiet_mode) B_PRINT("|");
continue;
}

Expand All @@ -780,9 +784,9 @@ int32_t main(int32_t argc, uint8_t* argv[]) {
// in case any buffered chain is consumed, display '*'. Otherwise display '.'.
int16_t dt = num_chains - (block_counter_ofs + pcm8pp_get_block_counter(0));
if (dt >= buffer_delta) {
B_PRINT(">");
if (!quiet_mode) B_PRINT(">");
} else {
B_PRINT("*");
if (!quiet_mode) B_PRINT("*");
buffer_delta = dt;
}

Expand Down
16 changes: 11 additions & 5 deletions src/mp3_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int32_t mp3_decode_parse_tags(MP3_DECODE_HANDLE* decode, int16_t pic_brightness,

//printf("total tag size = %d\n",total_tag_size);

while (ofs < total_tag_size) {
while ((ofs + 10) < total_tag_size) {

fread(frame_header, 1, 10, fp);

Expand All @@ -185,12 +185,14 @@ int32_t mp3_decode_parse_tags(MP3_DECODE_HANDLE* decode, int16_t pic_brightness,
uint8_t* frame_data = himem_malloc(frame_size, 0);
fread(frame_data, 1, frame_size, fp);
if (frame_data[0] == 0x00) { // ISO-8859-1
decode->mp3_title = frame_data + 1;
decode->mp3_title = himem_malloc(frame_size - 1 + 1, 0);
memcpy(decode->mp3_title, frame_data + 1, frame_size - 1);
decode->mp3_title[frame_size - 1] = '\0';
} else if (frame_data[0] == 0x01) { // UTF-16 with BOM
decode->mp3_title = himem_malloc(frame_size - 3 + 1, 0);
decode->mp3_title[0] = '\0';
convert_utf16_to_cp932(decode->mp3_title, frame_data + 1, frame_size - 1);
}
}
himem_free(frame_data, 0);

} else if (memcmp(frame_header, "TPE1", 4) == 0 && frame_size >= 4) {
Expand All @@ -200,7 +202,9 @@ int32_t mp3_decode_parse_tags(MP3_DECODE_HANDLE* decode, int16_t pic_brightness,
fread(frame_data, 1, frame_size, fp);

if (frame_data[0] == 0x00) { // ISO-8859-1
decode->mp3_artist = frame_data + 1;
decode->mp3_artist = himem_malloc(frame_size - 1 + 1, 0);
memcpy(decode->mp3_artist, frame_data + 1, frame_size - 1);
decode->mp3_artist[frame_size - 1] = '\0';
} else if (frame_data[0] == 0x01) { // UTF-16 with BOM
decode->mp3_artist = himem_malloc(frame_size - 3 + 1, 0);
decode->mp3_artist[0] = '\0';
Expand All @@ -215,7 +219,9 @@ int32_t mp3_decode_parse_tags(MP3_DECODE_HANDLE* decode, int16_t pic_brightness,
fread(frame_data, 1, frame_size, fp);

if (frame_data[0] == 0x00) { // ISO-8859-1
decode->mp3_album = frame_data + 1;
decode->mp3_album = himem_malloc(frame_size - 1 + 1, 0);
memcpy(decode->mp3_album, frame_data + 1, frame_size - 1);
decode->mp3_album[frame_size - 1] = '\0';
} else if (frame_data[0] == 0x01) { // UTF-16 with BOM
decode->mp3_album = himem_malloc(frame_size - 3 + 1, 0);
decode->mp3_album[0] = '\0';
Expand Down

0 comments on commit d62c7cb

Please sign in to comment.