diff options
author | Vikash Garodia <vgarodia@codeaurora.org> | 2016-07-25 23:49:52 +0530 |
---|---|---|
committer | Michael Bestas <mikeioannina@cyanogenmod.org> | 2016-11-04 16:02:11 +0200 |
commit | 4adc8e4aaddd492c271b2f79b98677439b705291 (patch) | |
tree | 940ce0e0523bc6d44faac7481621d09fab5934d5 | |
parent | 19bea17bb3f727cffb49406425c5ad5546878028 (diff) | |
download | android_hardware_qcom_media-4adc8e4aaddd492c271b2f79b98677439b705291.tar.gz android_hardware_qcom_media-4adc8e4aaddd492c271b2f79b98677439b705291.tar.bz2 android_hardware_qcom_media-4adc8e4aaddd492c271b2f79b98677439b705291.zip |
omx_venc: Handle output buffer parameter in secure mode
During secure encode usecase, though the output buffer
is allocated for the size equal to buffer metadata,
the alloc length, filled length and offset were updated
as per the bitstream data
Modify the encoder output buffer to be updated with
the metadata having the native handle. Secure encoder
clients has to extract the handle to get the required
information related to the buffer.
CRs-Fixed: 1041024
Change-Id: Ia6bd0010653d75751105892f36c52d5706a7d468
-rw-r--r-- | mm-video-v4l2/vidc/venc/inc/omx_video_base.h | 5 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/src/omx_video_base.cpp | 33 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp | 11 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp | 6 |
4 files changed, 43 insertions, 12 deletions
diff --git a/mm-video-v4l2/vidc/venc/inc/omx_video_base.h b/mm-video-v4l2/vidc/venc/inc/omx_video_base.h index 842e754e..cb257fe8 100644 --- a/mm-video-v4l2/vidc/venc/inc/omx_video_base.h +++ b/mm-video-v4l2/vidc/venc/inc/omx_video_base.h @@ -148,6 +148,11 @@ static const char* MEM_DEVICE = "/dev/pmem_smipool"; void* enc_message_thread(void *); +struct output_metabuffer { + OMX_U32 type; + native_handle_t *nh; +}; + // OMX video class class omx_video: public qc_omx_component { diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp index 39bffada..ef3768a6 100644 --- a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp +++ b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp @@ -78,6 +78,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define SZ_4K 0x1000 #define SZ_1M 0x100000 +#define ALIGN(x, to_align) ((((unsigned long) x) + (to_align - 1)) & ~(to_align - 1)) typedef struct OMXComponentCapabilityFlagsType { ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS @@ -2965,7 +2966,7 @@ OMX_ERRORTYPE omx_video::allocate_output_buffer( if (i < m_sOutPortDef.nBufferCountActual) { #ifdef USE_ION #ifdef _MSM8974_ - align_size = ((m_sOutPortDef.nBufferSize + 4095)/4096) * 4096; + align_size = ALIGN(m_sOutPortDef.nBufferSize, 4096); m_pOutput_ion[i].ion_device_fd = alloc_map_ion_memory(align_size, &m_pOutput_ion[i].ion_alloc_data, &m_pOutput_ion[i].fd_ion_data,0); @@ -2995,6 +2996,8 @@ OMX_ERRORTYPE omx_video::allocate_output_buffer( m_pOutput_pmem[i].offset = 0; m_pOutput_pmem[i].buffer = NULL; + *bufferHdr = (m_out_mem_ptr + i ); + if(!secure_session) { #ifdef _MSM8974_ m_pOutput_pmem[i].buffer = (unsigned char *)mmap(NULL, @@ -3018,21 +3021,22 @@ OMX_ERRORTYPE omx_video::allocate_output_buffer( else { //This should only be used for passing reference to source type and //secure handle fd struct native_handle_t* - m_pOutput_pmem[i].buffer = malloc(sizeof(OMX_U32) + sizeof(native_handle_t*)); - if (m_pOutput_pmem[i].buffer == NULL) { - DEBUG_PRINT_ERROR("%s: Failed to allocate native-handle", __func__); + native_handle_t *handle = native_handle_create(1, 3); //fd, offset, size, alloc length + if (!handle) { + DEBUG_PRINT_ERROR("ERROR: native handle creation failed"); return OMX_ErrorInsufficientResources; } - (*bufferHdr)->nAllocLen = sizeof(OMX_U32) + sizeof(native_handle_t*); - native_handle_t *handle = native_handle_create(1, 0); + m_pOutput_pmem[i].buffer = malloc(sizeof(output_metabuffer)); + (*bufferHdr)->nAllocLen = sizeof(output_metabuffer); handle->data[0] = m_pOutput_pmem[i].fd; - char *data = (char*) m_pOutput_pmem[i].buffer; - OMX_U32 type = 1; - memcpy(data, &type, 4); - memcpy(data + 4, &handle, sizeof(native_handle_t*)); + handle->data[1] = 0; + handle->data[2] = 0; + handle->data[3] = ALIGN(m_sOutPortDef.nBufferSize, 4096); + output_metabuffer *buffer = (output_metabuffer*) m_pOutput_pmem[i].buffer; + buffer->type = 1; + buffer->nh = handle; } - *bufferHdr = (m_out_mem_ptr + i ); (*bufferHdr)->pBuffer = (OMX_U8 *)m_pOutput_pmem[i].buffer; (*bufferHdr)->pAppPrivate = appData; @@ -3999,6 +4003,13 @@ OMX_ERRORTYPE omx_video::fill_buffer_done(OMX_HANDLETYPE hComp, pending_output_buffers--; + if (secure_session && m_pCallbacks.FillBufferDone) { + if (buffer->nFilledLen > 0) { + m_fbd_count++; + } + m_pCallbacks.FillBufferDone (hComp,m_app_data,buffer); + return OMX_ErrorNone; + } if(!secure_session) { extra_data_handle.create_extra_data(buffer); #ifndef _MSM8974_ diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp index 417e61a8..333719f2 100644 --- a/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp +++ b/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp @@ -1959,6 +1959,7 @@ int omx_venc::async_message_process (void *context, void* message) struct venc_msg *m_sVenc_msg = NULL; OMX_BUFFERHEADERTYPE* omxhdr = NULL; struct venc_buffer *temp_buff = NULL; + native_handle_t *nh = NULL; if (context == NULL || message == NULL) { DEBUG_PRINT_ERROR("ERROR: omx_venc::async_message_process invalid i/p params"); @@ -2028,7 +2029,7 @@ int omx_venc::async_message_process (void *context, void* message) if ( (omxhdr != NULL) && ((OMX_U32)(omxhdr - omx->m_out_mem_ptr) < omx->m_sOutPortDef.nBufferCountActual)) { - if (m_sVenc_msg->buf.len <= omxhdr->nAllocLen) { + if (!omx->is_secure_session() && (m_sVenc_msg->buf.len <= omxhdr->nAllocLen)) { omxhdr->nFilledLen = m_sVenc_msg->buf.len; omxhdr->nOffset = m_sVenc_msg->buf.offset; omxhdr->nTimeStamp = m_sVenc_msg->buf.timestamp; @@ -2042,6 +2043,14 @@ int omx_venc::async_message_process (void *context, void* message) (m_sVenc_msg->buf.ptrbuffer), m_sVenc_msg->buf.len); } + } else if (omx->is_secure_session()) { + output_metabuffer *meta_buf = (output_metabuffer *)(omxhdr->pBuffer); + native_handle_t *nh = meta_buf->nh; + nh->data[1] = m_sVenc_msg->buf.offset; + nh->data[2] = m_sVenc_msg->buf.len; + omxhdr->nFilledLen = sizeof(output_metabuffer); + omxhdr->nTimeStamp = m_sVenc_msg->buf.timestamp; + omxhdr->nFlags = m_sVenc_msg->buf.flags; } else { omxhdr->nFilledLen = 0; } diff --git a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp index 6334bfbb..5ae84d99 100644 --- a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp +++ b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp @@ -2591,6 +2591,12 @@ bool venc_dev::venc_fill_buf(void *buffer, void *pmem_data_buf,unsigned index,un buf.m.planes = plane; buf.length = num_planes; + if (venc_handle->is_secure_session()) { + output_metabuffer *meta_buf = (output_metabuffer *)(bufhdr->pBuffer); + native_handle_t *handle = meta_buf->nh; + plane[0].length = handle->data[3]; + } + extra_idx = EXTRADATA_IDX(num_planes); if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) { |