Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

enc: resize output buffer size #72

Merged
merged 1 commit into from
Feb 7, 2017
Merged

enc: resize output buffer size #72

merged 1 commit into from
Feb 7, 2017

Conversation

wudping
Copy link
Contributor

@wudping wudping commented Jan 17, 2017

re-alloc a new bigger output buffer for the encoded picture size is
larger than the default.

to fix issue #657

Signed-off-by: wudping dongpingx.wu@intel.com

@wudping
Copy link
Contributor Author

wudping commented Jan 17, 2017

please help to review.

@@ -159,6 +159,15 @@ int main(int argc, char** argv)
fwrite(MVBuffer.data, MVBuffer.bufferSize, 1, MVFp);
}
#endif
if (status == ENCODE_BUFFER_TOO_SMALL) {
maxOutSize = (maxOutSize * 3) / 2;
free(outputBuffer.data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to move this to createOutputBuffer

Copy link
Contributor Author

@wudping wudping Jan 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, accordingly, how about:
bool createOutputBuffer(VideoEncOutputBuffer* outputBuffer, int maxOutSize)
{
if(outputBuffer.data){
free(outputBuffer.data);
outputBuffer.data = NULL;
}
outputBuffer->data = static_cast<uint8_t*>(malloc(maxOutSize));
if (!outputBuffer->data)
return false;
outputBuffer->bufferSize = maxOutSize;
outputBuffer->format = OUTPUT_EVERYTHING;
return true;
}
?

Thanks @xuguangxin .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, and you do not need set "outputBuffer.data = NULL" since you will allocate the data later. Please check the outputBuffer, please make sure you memset the outputBuffer in main(), else free(outputBuffer.data) will crash your programe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, thanks @xuguangxin .

re-alloc a new bigger output buffer for the encoded picture size is
larger than the default.

Signed-off-by: wudping <dongpingx.wu@intel.com>
@wudping
Copy link
Contributor Author

wudping commented Jan 22, 2017

updated according to the suggestions, please help to review.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants