MediaConverter: fix off-by-one frame limit

This would lead to an attempt to read beyond the track end, making
MediaTrack return an error, and finally causing MediaConverter to not
flush the end of the encoded file to disk properly.
This commit is contained in:
Adrien Destugues 2014-12-23 11:28:28 +01:00
parent 62ee6b76e2
commit b65265eb5c

View File

@ -519,7 +519,7 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
} }
framesRead = 0; framesRead = 0;
for (int64 i = start; (i <= end) && !fCancel; i += framesRead) { for (int64 i = start; (i < end) && !fCancel; i += framesRead) {
if ((ret = inVidTrack->ReadFrames(videoBuffer, &framesRead, if ((ret = inVidTrack->ReadFrames(videoBuffer, &framesRead,
&mh)) != B_OK) { &mh)) != B_OK) {
fprintf(stderr, "Error reading video frame %" B_PRId64 ": %s\n", fprintf(stderr, "Error reading video frame %" B_PRId64 ": %s\n",
@ -579,7 +579,7 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
start = 0; start = 0;
} }
for (int64 i = start; (i <= end) && !fCancel; i += framesRead) { for (int64 i = start; (i < end) && !fCancel; i += framesRead) {
if ((ret = inAudTrack->ReadFrames(audioBuffer, &framesRead, if ((ret = inAudTrack->ReadFrames(audioBuffer, &framesRead,
&mh)) != B_OK) { &mh)) != B_OK) {
fprintf(stderr, "Error reading audio frames: %s\n", strerror(ret)); fprintf(stderr, "Error reading audio frames: %s\n", strerror(ret));