[FFmpeg-devel] [PATCH] Add android_capture indev
felix at matouschek.org
Tue Jan 2 11:23:31 EET 2018
> Am 28.12.2017 um 19:20 schrieb Michael Niedermayer <michael at niedermayer.cc>:
>> + av_image_copy_to_buffer(pkt.data, pkt_buffer_size,
>> + (const uint8_t * const *) image_plane_data,
>> + image_linestrides, ctx->image_format,
>> + ctx->width, ctx->height, 32);
> Is the copy needed ?
> can the data not be put in a AVPacket without copy but by pointing to the image?
> the AVPackets deallocation can be overridden to free the image
I’m not sure but I guess it could lead to problems as the AImageReader has its own queue, which is currently limited to two images. In general the image_available callback is processed fast enough so this is not a problem and all AVPackets are buffered in the thread message queue (ctx->input_queue) while the original AImage is deleted. Every AImage is also permanently associated with the AImageReader and needs to be deleted for the AImageReader to accept new images. I think if doing so the input_queue and the AImageReader queue probably need the same size.
How could I put the different pointers I get from the Android system for each plane into the AVPacket? I’m not even sure if all planes live in the same contiguous space of memory? How does one overwrite the AVPacket deallocation?
Currently I’m using AImageReader_acquireLatestImage(), this should be changed to AImageReader_acquireNextImage(), other than that it could work.
More information about the ffmpeg-devel