Browse Source

stm32_radio: Updated the VBR average bitrate calculation.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@425 bbd45198-f89e-11dd-88c7-29a3b14d5316
kyle.hu.gz 15 years ago
parent
commit
579a566b44
1 changed files with 2 additions and 1 deletions
  1. 2 1
      bsp/stm32_radio/mp3.c

+ 2 - 1
bsp/stm32_radio/mp3.c

@@ -410,6 +410,7 @@ void mp3_get_info(const char* filename, struct tag_info* info)
 			{
 				rt_uint32_t frames = ((rt_uint32_t) mp3_fd_buffer[p + 8] << 24) | ((rt_uint32_t) mp3_fd_buffer[p + 9] << 16) | ((rt_uint32_t) mp3_fd_buffer[p + 10] << 8) | (rt_uint32_t) mp3_fd_buffer[p + 11];
 				info->duration = frames * samples_per_frame / frame_info.samprate;
+				info->bit_rate = lseek(fd, 0, SEEK_END) * 8 / info->duration;
 			}
 		}
 		/*
@@ -420,8 +421,8 @@ void mp3_get_info(const char* filename, struct tag_info* info)
 		{
 			// CBR
 			info->duration = lseek(fd, 0, SEEK_END) / (frame_info.bitrate / 8); /* second */
+			info->bit_rate = frame_info.bitrate;
 		}
-		info->bit_rate = frame_info.bitrate;
 		info->sampling = frame_info.samprate;
 	}