Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better fix for not allowed bitrate #77

Merged
merged 1 commit into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions libtwolame/twolame.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,16 @@ static int init_header_info(twolame_options * glopts)
return -1;
}
}
// Convert the max VBR bitrate to the an index
glopts->vbr_upper_index = twolame_get_bitrate_index(glopts->vbr_max_bitrate, header->version);
if (glopts->vbr_upper_index < 0) {
fprintf(stderr, "Not a valid max VBR bitrate for this version: %i\n",
glopts->vbr_max_bitrate);
return -1;
if (glopts->vbr && glopts->vbr_max_bitrate > 0)
{
/* user required vbr and a specified max bitrate */
/* convert max VBR bitrate to an index */
glopts->vbr_upper_index = twolame_get_bitrate_index(glopts->vbr_max_bitrate, header->version);
if (glopts->vbr_upper_index < 0) {
fprintf(stderr, "Not a valid max VBR bitrate for this version: %i\n",
glopts->vbr_max_bitrate);
return -1;
}
}
// Copy accross the other settings
header->padding = 0; /* when requested, padding will be evaluated later for this frame */
Expand Down
5 changes: 1 addition & 4 deletions libtwolame/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,9 @@ int twolame_get_bitrate_index(int bitrate, TWOLAME_MPEG_version version)
return -1;
}

while (index < 15) {
while (++index < 15)
if (bitrate_table[version][index] == bitrate)
break;
else
++index;
}

if (index == 15) {
fprintf(stderr,
Expand Down