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

Background playback improvements #104

Closed
wants to merge 10 commits into from
Closed

Conversation

sfan5
Copy link
Member

@sfan5 sfan5 commented Feb 23, 2018

please squash when merging
implements #102

screen

@sfan5 sfan5 added the feature label Feb 23, 2018
@xyzz
Copy link
Contributor

xyzz commented Feb 23, 2018

You need to use delete[] instead of delete.

dimension, dimension, AV_PIX_FMT_RGB32,
SWS_BICUBIC, NULL, NULL, NULL);
if (!ctx)
return NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

You're leaking new_data here. Probably better to replace with std::vector or similar so that RAII can be utilized.

ALOGV("cropped w:%u h:%u\n", new_w, new_h);

std::vector<uint32_t> new_data;
new_data.reserve(new_w * new_h);
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't use "new" vector members after you call reserve, you need to do resize, or just pass the size as argument to the constructor.

std::vector<uint8_t> scaled;
scaled.reserve(dimension * dst_stride);
uint8_t *src_p[] = { (uint8_t*) new_data.data() }, *dst_p[] = { scaled.data() };
sws_scale(ctx, src_p, &src_stride, 0, new_h, dst_p, &dst_stride);
Copy link
Contributor

Choose a reason for hiding this comment

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

All arrays you pass to sws_scale have to be 4 elements, it's a bug/undocumented in ffmpeg, so make sure src/dst/stride have 4 elements.

std::vector<uint32_t> new_data;
new_data.reserve(new_w * new_h);
for (int y = 0; y < new_h; y++) {
for (int x = 0; x < new_w; x++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can the inner loop be replaced with memcpy?

@jeeb
Copy link
Member

jeeb commented Apr 4, 2018

Merged as 6a7cd9e

@jeeb jeeb closed this Apr 4, 2018
@jeeb jeeb deleted the sfan5/bgplay_improvements branch April 4, 2018 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants