|
|
@ -16,7 +16,6 @@ |
|
|
|
#include <OMX_QCOMExtns.h> |
|
|
|
#include <OMX_QCOMExtns.h> |
|
|
|
|
|
|
|
|
|
|
|
#include <libyuv.h> |
|
|
|
#include <libyuv.h> |
|
|
|
|
|
|
|
|
|
|
|
#include <msm_media_info.h> |
|
|
|
#include <msm_media_info.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "common/mutex.h" |
|
|
|
#include "common/mutex.h" |
|
|
@ -25,10 +24,6 @@ |
|
|
|
#include "encoder.h" |
|
|
|
#include "encoder.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// encoder: lossey codec using hardware hevc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***** OMX callback functions *****
|
|
|
|
// ***** OMX callback functions *****
|
|
|
|
|
|
|
|
|
|
|
|
static void wait_for_state(EncoderState *s, OMX_STATETYPE state) { |
|
|
|
static void wait_for_state(EncoderState *s, OMX_STATETYPE state) { |
|
|
@ -282,26 +277,26 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height, |
|
|
|
assert(err == OMX_ErrorNone); |
|
|
|
assert(err == OMX_ErrorNone); |
|
|
|
|
|
|
|
|
|
|
|
if (h265) { |
|
|
|
if (h265) { |
|
|
|
// setup HEVC
|
|
|
|
// setup HEVC
|
|
|
|
#ifndef QCOM2 |
|
|
|
#ifndef QCOM2 |
|
|
|
OMX_VIDEO_PARAM_HEVCTYPE hecv_type = {0}; |
|
|
|
OMX_VIDEO_PARAM_HEVCTYPE hevc_type = {0}; |
|
|
|
OMX_INDEXTYPE index_type = (OMX_INDEXTYPE) OMX_IndexParamVideoHevc; |
|
|
|
OMX_INDEXTYPE index_type = (OMX_INDEXTYPE) OMX_IndexParamVideoHevc; |
|
|
|
#else |
|
|
|
#else |
|
|
|
OMX_VIDEO_PARAM_PROFILELEVELTYPE hecv_type = {0}; |
|
|
|
OMX_VIDEO_PARAM_PROFILELEVELTYPE hevc_type = {0}; |
|
|
|
OMX_INDEXTYPE index_type = OMX_IndexParamVideoProfileLevelCurrent; |
|
|
|
OMX_INDEXTYPE index_type = OMX_IndexParamVideoProfileLevelCurrent; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
hecv_type.nSize = sizeof(hecv_type); |
|
|
|
hevc_type.nSize = sizeof(hevc_type); |
|
|
|
hecv_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT; |
|
|
|
hevc_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT; |
|
|
|
err = OMX_GetParameter(s->handle, index_type, |
|
|
|
err = OMX_GetParameter(s->handle, index_type, |
|
|
|
(OMX_PTR) &hecv_type); |
|
|
|
(OMX_PTR) &hevc_type); |
|
|
|
assert(err == OMX_ErrorNone); |
|
|
|
assert(err == OMX_ErrorNone); |
|
|
|
|
|
|
|
|
|
|
|
hecv_type.eProfile = OMX_VIDEO_HEVCProfileMain; |
|
|
|
hevc_type.eProfile = OMX_VIDEO_HEVCProfileMain; |
|
|
|
hecv_type.eLevel = OMX_VIDEO_HEVCHighTierLevel5; |
|
|
|
hevc_type.eLevel = OMX_VIDEO_HEVCHighTierLevel5; |
|
|
|
|
|
|
|
|
|
|
|
err = OMX_SetParameter(s->handle, index_type, |
|
|
|
err = OMX_SetParameter(s->handle, index_type, |
|
|
|
(OMX_PTR) &hecv_type); |
|
|
|
(OMX_PTR) &hevc_type); |
|
|
|
assert(err == OMX_ErrorNone); |
|
|
|
assert(err == OMX_ErrorNone); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// setup h264
|
|
|
|
// setup h264
|
|
|
|
OMX_VIDEO_PARAM_AVCTYPE avc = { 0 }; |
|
|
|
OMX_VIDEO_PARAM_AVCTYPE avc = { 0 }; |
|
|
@ -588,11 +583,11 @@ void encoder_open(EncoderState *s, const char* path) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
s->of = fopen(s->vid_path, "wb"); |
|
|
|
s->of = fopen(s->vid_path, "wb"); |
|
|
|
assert(s->of); |
|
|
|
assert(s->of); |
|
|
|
if (s->codec_config_len > 0) { |
|
|
|
|
|
|
|
#ifndef QCOM2 |
|
|
|
#ifndef QCOM2 |
|
|
|
|
|
|
|
if (s->codec_config_len > 0) { |
|
|
|
fwrite(s->codec_config, s->codec_config_len, 1, s->of); |
|
|
|
fwrite(s->codec_config, s->codec_config_len, 1, s->of); |
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// create camera lock file
|
|
|
|
// create camera lock file
|
|
|
@ -699,6 +694,13 @@ void encoder_destroy(EncoderState *s) { |
|
|
|
err = OMX_FreeHandle(s->handle); |
|
|
|
err = OMX_FreeHandle(s->handle); |
|
|
|
assert(err == OMX_ErrorNone); |
|
|
|
assert(err == OMX_ErrorNone); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (queue_try_pop(&s->free_in));
|
|
|
|
|
|
|
|
while (queue_try_pop(&s->done_out));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s->codec_config) { |
|
|
|
|
|
|
|
free(s->codec_config); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (s->downscale) { |
|
|
|
if (s->downscale) { |
|
|
|
free(s->y_ptr2); |
|
|
|
free(s->y_ptr2); |
|
|
|
free(s->u_ptr2); |
|
|
|
free(s->u_ptr2); |
|
|
|