Mercurial > libavformat.hg
comparison mp3.c @ 6325:83cd11644ff1 libavformat
Make frames unsigned.
Patch by Alexander Kojevnikov, alexander kojevnikov com
author | cehoyos |
---|---|
date | Tue, 27 Jul 2010 10:11:05 +0000 |
parents | 8f1439cf4dd0 |
children |
comparison
equal
deleted
inserted
replaced
6324:8f1439cf4dd0 | 6325:83cd11644ff1 |
---|---|
81 * Try to find Xing/Info/VBRI tags and compute duration from info therein | 81 * Try to find Xing/Info/VBRI tags and compute duration from info therein |
82 */ | 82 */ |
83 static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) | 83 static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) |
84 { | 84 { |
85 uint32_t v, spf; | 85 uint32_t v, spf; |
86 int frames = -1; /* Total number of frames in file */ | 86 unsigned frames = 0; /* Total number of frames in file */ |
87 unsigned size = 0; /* Total number of bytes in the stream */ | 87 unsigned size = 0; /* Total number of bytes in the stream */ |
88 const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}}; | 88 const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}}; |
89 MPADecodeHeader c; | 89 MPADecodeHeader c; |
90 int vbrtag_size = 0; | 90 int vbrtag_size = 0; |
91 | 91 |
120 frames = get_be32(s->pb); | 120 frames = get_be32(s->pb); |
121 size = get_be32(s->pb); | 121 size = get_be32(s->pb); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 if(frames < 0 && !size) | 125 if(!frames && !size) |
126 return -1; | 126 return -1; |
127 | 127 |
128 /* Skip the vbr tag frame */ | 128 /* Skip the vbr tag frame */ |
129 url_fseek(s->pb, base + vbrtag_size, SEEK_SET); | 129 url_fseek(s->pb, base + vbrtag_size, SEEK_SET); |
130 | 130 |
131 spf = c.lsf ? 576 : 1152; /* Samples per frame, layer 3 */ | 131 spf = c.lsf ? 576 : 1152; /* Samples per frame, layer 3 */ |
132 if(frames >= 0) | 132 if(frames) |
133 st->duration = av_rescale_q(frames, (AVRational){spf, c.sample_rate}, | 133 st->duration = av_rescale_q(frames, (AVRational){spf, c.sample_rate}, |
134 st->time_base); | 134 st->time_base); |
135 if(size) | 135 if(size) |
136 st->codec->bit_rate = av_rescale(size, 8 * c.sample_rate, frames * (int64_t)spf); | 136 st->codec->bit_rate = av_rescale(size, 8 * c.sample_rate, frames * (int64_t)spf); |
137 | 137 |