summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c67
1 files changed, 37 insertions, 30 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 13c4b01b8a..9528ede0ec 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -3030,42 +3030,49 @@ int mpeg_create_xing_header(char *filename, void (*progressfunc)(int))
3030 progressfunc(0); 3030 progressfunc(0);
3031 3031
3032 num_frames = count_mp3_frames(fd, entry.first_frame_offset, 3032 num_frames = count_mp3_frames(fd, entry.first_frame_offset,
3033 flen, 3033 flen, progressfunc);
3034 progressfunc);
3035 3034
3036 create_xing_header(fd, entry.first_frame_offset, 3035 if(num_frames)
3037 flen, xingbuf, num_frames, progressfunc, true);
3038
3039 /* Try to fit the Xing header first in the stream. Replace the existing
3040 Xing header if there is one, else see if there is room between the
3041 ID3 tag and the first MP3 frame. */
3042 if(entry.vbr_header_pos)
3043 {
3044 /* Reuse existing Xing header */
3045 fpos = entry.vbr_header_pos;
3046
3047 DEBUGF("Reusing Xing header at %d\n", fpos);
3048 }
3049 else
3050 { 3036 {
3051 /* Any room between ID3 tag and first MP3 frame? */ 3037 create_xing_header(fd, entry.first_frame_offset,
3052 if(entry.first_frame_offset - entry.id3v2len > 417) 3038 flen, xingbuf, num_frames, progressfunc, true);
3039
3040 /* Try to fit the Xing header first in the stream. Replace the existing
3041 Xing header if there is one, else see if there is room between the
3042 ID3 tag and the first MP3 frame. */
3043 if(entry.vbr_header_pos)
3053 { 3044 {
3054 fpos = entry.first_frame_offset - 417; 3045 /* Reuse existing Xing header */
3046 fpos = entry.vbr_header_pos;
3047
3048 DEBUGF("Reusing Xing header at %d\n", fpos);
3055 } 3049 }
3056 else 3050 else
3057 { 3051 {
3058 close(fd); 3052 /* Any room between ID3 tag and first MP3 frame? */
3059 return -3; 3053 if(entry.first_frame_offset - entry.id3v2len > 417)
3054 {
3055 fpos = entry.first_frame_offset - 417;
3056 }
3057 else
3058 {
3059 close(fd);
3060 return -3;
3061 }
3060 } 3062 }
3063
3064 lseek(fd, fpos, SEEK_SET);
3065 write(fd, xingbuf, 417);
3066 close(fd);
3067
3068 if(progressfunc)
3069 progressfunc(100);
3070 return 0;
3071 }
3072 else
3073 {
3074 /* Not a VBR file */
3075 DEBUGF("Not a VBR file\n");
3076 return -9;
3061 } 3077 }
3062
3063 lseek(fd, fpos, SEEK_SET);
3064 write(fd, xingbuf, 417);
3065 close(fd);
3066
3067 if(progressfunc)
3068 progressfunc(100);
3069
3070 return 0;
3071} 3078}