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
Conversation
You need to use delete[] instead of delete. |
dimension, dimension, AV_PIX_FMT_RGB32, | ||
SWS_BICUBIC, NULL, NULL, NULL); | ||
if (!ctx) | ||
return NULL; |
There was a problem hiding this comment.
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.
app/src/main/jni/thumbnail.cpp
Outdated
ALOGV("cropped w:%u h:%u\n", new_w, new_h); | ||
|
||
std::vector<uint32_t> new_data; | ||
new_data.reserve(new_w * new_h); |
There was a problem hiding this comment.
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.
app/src/main/jni/thumbnail.cpp
Outdated
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); |
There was a problem hiding this comment.
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.
app/src/main/jni/thumbnail.cpp
Outdated
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++) { |
There was a problem hiding this comment.
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?
6b6e71e
to
dd9374d
Compare
Merged as 6a7cd9e |
please squash when merging
implements #102