Comments (7)
Looks like a bug in Android 4.0: https://code.google.com/p/android/issues/detail?id=24327
So if you cannot update to 4.1 at least, it looks like the workaround is to recreate the buffers you are using, in Java.
from javacpp.
@aydinkn I get the same problem. Do you use FFmpegFrameFilter?
On Android4.0.4, I removed FFmpegFrameFilter process code, and it worked, but certainly no more crop process.
from javacpp.
@szitguy my application need FFmpegFrameFilter (for transpose). I changed application min android version to >= 4.1 for now.
from javacpp.
@aydinkn OK, but my app still want to support from Android4.0.
I am trying to find some way to fix it.
from javacpp.
@aydinkn I fixed the problem just now, i modified the "pull" method of class FFmpegFrameFilter, here is my "pull" code(look at the line writing "if (SystemVersionUtil.hasJellyBean())"):
public Frame pull() throws Exception {
av_frame_unref(filt_frame);
/* pull a filtered frame from the filtergraph */
int ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
if (ret == -11 /*AVERROR(EAGAIN)*/ || ret == AVERROR_EOF) {
return null;
} else if (ret < 0) {
throw new Exception("av_buffersink_get_frame(): Error occurred: "
+ av_make_error_string(new BytePointer(256), 256, ret).getString());
}
frame.imageWidth = filt_frame.width();
frame.imageHeight = filt_frame.height();
frame.imageDepth = Frame.DEPTH_UBYTE;
if (filt_frame.data(1) == null) {
frame.imageStride = filt_frame.linesize(0);
BytePointer ptr = filt_frame.data(0);
if (ptr != null && !ptr.equals(image_ptr[0])) {
image_ptr[0] = ptr.capacity(frame.imageHeight * frame.imageStride);
image_buf[0] = ptr.asBuffer();
}
frame.image = image_buf;
frame.image[0].position(0).limit(frame.imageHeight * frame.imageStride);
frame.imageChannels = frame.imageStride / frame.imageWidth;
} else {
frame.imageStride = frame.imageWidth;
int size = avpicture_get_size(filt_frame.format(), frame.imageWidth, frame.imageHeight);
// Fix bug on Android4.0,check out https://github.com/bytedeco/javacpp/issues/39
if (SystemVersionUtil.hasJellyBean()) {
if (image_ptr[0] == null || image_ptr[0].capacity() < size) {
image_ptr[0] = new BytePointer(size);
image_buf[0] = image_ptr[0].asBuffer();
}
frame.image = image_buf;
frame.image[0].position(0).limit(size);
frame.imageChannels = 2;
ret = avpicture_layout(new AVPicture(filt_frame), filt_frame.format(),
frame.imageWidth, frame.imageHeight, image_ptr[0].position(0), image_ptr[0].capacity());
} else {
if (image_buf[0] == null || image_buf[0].capacity() < size) {
image_buf[0] = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
}
frame.image = image_buf;
frame.image[0].position(0).limit(size);
frame.imageChannels = 2;
ret = avpicture_layout(new AVPicture(filt_frame), filt_frame.format(),
frame.imageWidth, frame.imageHeight, (ByteBuffer) frame.image[0].position(0), frame.image[0].capacity());
}
}
return frame;
}
from javacpp.
@szitguy Your fix looks to me, no need to keep the old code around. So, remove the SystemVersionUtil.hasJellyBean()
check that doesn't work on Java SE anyway, and send me a pull request. I'll merge that in, thanks!
from javacpp.
@saudet OK!
from javacpp.
Related Issues (20)
- Optional pair HOT 2
- ParserException for valid c++ code HOT 1
- Function pointer returning shared_ptr HOT 10
- LNK2001: Unresolved external, issue with namespace? HOT 7
- infinite recursion when calling virtualized inherited function HOT 4
- Mapping Template Constraints, Parser Error HOT 5
- Parser cannot compile because of QT HOT 4
- Template class with template functions HOT 15
- Inadequate Error Handling HOT 1
- `@StdVector` default annotation causing `Parser` to ignore templated constructors and operator overloads with `std::vector` arguments HOT 10
- Crash when passing a unique_ptr by value HOT 12
- Potential class loading deadlock when call static methods of Loader or Pointer HOT 13
- Multiple pointer types and automatic generation of function overloads HOT 1
- Parser doesn't add @Virtual annotations HOT 2
- A question about garbage collection on native objects HOT 3
- Pointer types don't work on the native side if allocated in java HOT 16
- Missing dependencies reported by gradle HOT 1
- Not found libs based on x86 in 1.5.10 HOT 4
- Marking an interface with virtualize() causes compilation failure when returning byte array
- Panama HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javacpp.