[jpege]: add jpeg encoder basic flow

Change-Id: I9227008e5c46ddca27df1e807e96813e57e1bb34
Signed-off-by: herman.chen <herman.chen@rock-chips.com>
This commit is contained in:
herman.chen
2016-09-02 08:33:35 +08:00
committed by Herman Chen
parent 6b744430b4
commit f54382264e
14 changed files with 384 additions and 9 deletions

View File

@@ -26,8 +26,7 @@ target_link_libraries(mpp_codec
codec_vp9d
codec_jpegd
codec_h264e
codec_jpege
codec_dummy_enc
codec_dummy_dec
mpp_base)

View File

@@ -3,3 +3,5 @@
add_subdirectory(dummy)
add_subdirectory(h264)
add_subdirectory(jpeg)

View File

@@ -0,0 +1,9 @@
# vim: syntax=cmake
include_directories(.)
add_library(codec_jpege STATIC
jpege_api.c
)
target_link_libraries(codec_jpege mpp_base)
set_target_properties(codec_jpege PROPERTIES FOLDER "mpp/codec")

View File

@@ -0,0 +1,98 @@
/*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define MODULE_TAG "jpege_api"
#include "mpp_err.h"
#include "mpp_log.h"
#include "mpp_env.h"
#include "mpp_common.h"
#include "jpege_api.h"
typedef struct {
void *ctx;
} JpegeCtx;
RK_U32 jpege_debug = 0;
MPP_RET jpege_init(void *ctx, ControllerCfg *ctrlCfg)
{
(void)ctx;
(void)ctrlCfg;
return MPP_OK;
}
MPP_RET jpege_deinit(void *ctx)
{
(void)ctx;
return MPP_OK;
}
MPP_RET jpege_encode(void *ctx, HalEncTask *task)
{
(void)ctx;
(void)task;
return MPP_OK;
}
MPP_RET jpege_reset(void *ctx)
{
(void)ctx;
return MPP_OK;
}
MPP_RET jpege_flush(void *ctx)
{
(void)ctx;
return MPP_OK;
}
MPP_RET jpege_config(void *ctx, RK_S32 cmd, void *param)
{
(void)ctx;
(void)cmd;
(void)param;
return MPP_OK;
}
MPP_RET jpege_callback(void *ctx, void *feedback)
{
(void)ctx;
(void)feedback;
return MPP_OK;
}
const ControlApi api_jpege_controller = {
"jpege_control",
MPP_VIDEO_CodingMJPEG,
sizeof(JpegeCtx),
0,
jpege_init,
jpege_deinit,
jpege_encode,
jpege_reset,
jpege_flush,
jpege_config,
jpege_callback,
};

32
mpp/codec/inc/jpege_api.h Normal file
View File

@@ -0,0 +1,32 @@
/*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __JPEGE_API_H__
#define __JPEGE_API_H__
#include "encoder_codec_api.h"
#ifdef __cplusplus
extern "C" {
#endif
extern const ControlApi api_jpege_controller;
#ifdef __cplusplus
}
#endif
#endif /*__JPEGE_API_H__*/

View File

@@ -19,7 +19,9 @@
#include "mpp_mem.h"
#include "mpp_log.h"
#include "mpp_common.h"
#include "h264e_api.h"
#include "jpege_api.h"
#include "mpp_controller.h"
/*
@@ -27,6 +29,7 @@
*/
static const ControlApi *controllers[] = {
&api_h264e_controller,
&api_jpege_controller,
};
typedef struct ControllerImpl_t {

64
mpp/common/jpege_syntax.h Normal file
View File

@@ -0,0 +1,64 @@
#ifndef __JPEGE_SYNTAX_H__
#define __JPEGE_SYNTAX_H__
#include "rk_type.h"
typedef struct jpege_syntax_t {
RK_U32 qp;
RK_U32 qpMin;
RK_U32 qpMax;
RK_U32 xFill;
RK_U32 yFill;
RK_U32 frameNum;
RK_U32 idrPicId;
RK_U32 mbsInRow;
RK_U32 mbsInCol;
RK_U32 jpegMode;
RK_U32 cabacInitIdc;
RK_U32 enableCabac;
RK_U32 sliceSizeMbRows;
RK_U32 outputStrmBase;
RK_U32 outputStrmSize;
RK_U32 inputLumBase; // inputLumBase
RK_U32 inputCrBase; // inputCbBase
RK_U32 inputCbBase; // inputCrBase
RK_U32 pixelsOnRow; // inputImageFormat
RK_U32 jpegSliceEnable;
RK_U32 jpegRestartInterval;
RK_U32 inputLumaBaseOffset;
RK_U32 filterDisable;
RK_U32 inputChromaBaseOffset;
RK_S32 chromaQpIndexOffset;
RK_U32 strmStartMSB;
RK_U32 strmStartLSB;
RK_S32 madQpDelta;
RK_U32 firstFreeBit;
RK_U32 madThreshold;
RK_S32 sliceAlphaOffset;
RK_S32 sliceBetaOffset;
RK_U32 transform8x8Mode;
RK_U32 jpegcolor_conversion_coeff_a; //colorConversionCoeffA
RK_U32 jpegcolor_conversion_coeff_b; //colorConversionCoeffB
RK_U32 jpegcolor_conversion_coeff_c; //colorConversionCoeffC
RK_U32 jpegcolor_conversion_coeff_e; //colorConversionCoeffE
RK_U32 jpegcolor_conversion_coeff_f; //colorConversionCoeffF
RK_U32 jpegcolor_conversion_r_mask_msb; //rMaskMsb
RK_U32 jpegcolor_conversion_g_mask_msb; //gMaskMsb
RK_U32 jpegcolor_conversion_b_mask_msb; //bMaskMsb
/* RKVENC extra syntax below */
RK_S32 profile_idc; //TODO: may be removed later, get from sps/pps instead
RK_S32 level_idc; //TODO: may be removed later, get from sps/pps instead
RK_S32 link_table_en;
RK_S32 keyframe_max_interval;
} jpege_syntax; //EncJpegInstance.h
#endif

View File

@@ -34,6 +34,8 @@ add_subdirectory(vpu/jpegd)
add_subdirectory(rkenc/h264e)
add_subdirectory(vpu/jpege)
# ----------------------------------------------------------------------------
# add hardware worker implement
# ----------------------------------------------------------------------------
@@ -56,6 +58,7 @@ target_link_libraries(mpp_hal
hal_vp9d
hal_jpegd
hal_h264e
hal_jpege
hal_dummy
${RKPLAT_VPU}
)

View File

@@ -0,0 +1,33 @@
/*
*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __HAL_JPEGE_API_H__
#define __HAL_JPEGE_API_H__
#include "mpp_hal.h"
#ifdef __cplusplus
extern "C" {
#endif
extern const MppHalApi hal_api_jpege;
#ifdef __cplusplus
}
#endif
#endif /*__HAL_JPEGE_API_H__*/

View File

@@ -27,14 +27,15 @@
#include "hal_h263d_api.h"
#include "hal_h264d_api.h"
#include "hal_h264e_api.h"
#include "hal_h265d_api.h"
#include "hal_vp8d_api.h"
#include "hal_vp9d_api.h"
#include "hal_avsd_api.h"
#include "hal_m2vd_api.h"
#include "hal_mpg4d_api.h"
#include "hal_vp8d_api.h"
#include "hal_h264e_api.h"
#include "hal_jpegd_api.h"
#include "hal_jpege_api.h"
// for test and demo
#include "hal_dummy_dec_api.h"
@@ -54,6 +55,7 @@ static const MppHalApi *hw_apis[] = {
&hal_api_vp9d,
&hal_api_jpegd,
&hal_api_h264e,
&hal_api_jpege,
&hal_api_dummy_dec,
&hal_api_dummy_enc,
};

View File

@@ -0,0 +1,16 @@
# vim: syntax=cmake
# hal jpeg reg
set(HAL_JPEGE_HDR
)
set(HAL_JPEGE_SRC
hal_jpege_api.c
)
add_library(hal_jpege STATIC
${HAL_JPEGE_SRC} ${HAL_JPEGE_HDR}
)
set_target_properties(hal_jpege PROPERTIES FOLDER "mpp/hal")
target_link_libraries(hal_jpege mpp_base)

View File

@@ -0,0 +1,108 @@
/*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define MODULE_TAG "hal_jpege_api"
#include "mpp_hal.h"
#include "hal_jpege_api.h"
typedef struct hal_jpege_ctx_s {
MppBufSlots frm_slots;
MppBufSlots pkt_slots;
IOInterruptCB int_cb;
} hal_jpege_ctx;
RK_U32 hal_jpege_debug = 0;
MPP_RET hal_jpege_init(void *hal, MppHalCfg *cfg)
{
(void)hal;
(void)cfg;
return MPP_OK;
}
MPP_RET hal_jpege_deinit(void *hal)
{
(void)hal;
return MPP_OK;
}
MPP_RET hal_jpege_gen_regs(void *hal, HalTaskInfo *task)
{
(void)hal;
(void)task;
return MPP_OK;
}
MPP_RET hal_jpege_start(void *hal, HalTaskInfo *task)
{
(void)task;
(void)hal;
return MPP_OK;
}
MPP_RET hal_jpege_wait(void *hal, HalTaskInfo *task)
{
(void)task;
(void)hal;
return MPP_OK;
}
MPP_RET hal_jpege_reset(void *hal)
{
(void)hal;
return MPP_OK;
}
MPP_RET hal_jpege_flush(void *hal)
{
(void)hal;
return MPP_OK;
}
MPP_RET hal_jpege_control(void *hal, RK_S32 cmd_type, void *param)
{
(void)hal;
(void)param;
(void)cmd_type;
return MPP_OK;
}
const MppHalApi hal_api_jpege = {
"jpege_vpu",
MPP_CTX_ENC,
MPP_VIDEO_CodingMJPEG,
sizeof(hal_jpege_ctx),
0,
hal_jpege_init,
hal_jpege_deinit,
hal_jpege_gen_regs,
hal_jpege_start,
hal_jpege_wait,
hal_jpege_reset,
hal_jpege_flush,
hal_jpege_control,
};

View File

@@ -731,6 +731,7 @@ RK_S32 VpuApiLegacy::encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm,
// copy encoded stream into output buffer, and set outpub stream size
if (packet != NULL) {
RK_U32 eos = mpp_packet_get_eos(packet);
RK_S64 pts = mpp_packet_get_pts(packet);
RK_U32 flag = mpp_packet_get_flag(packet);
size_t length = mpp_packet_get_length(packet);
@@ -746,6 +747,10 @@ RK_S32 VpuApiLegacy::encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm,
}
memcpy(aEncOut->data, (RK_U8*) mpp_buffer_get_ptr(str_buf), aEncOut->size);
}
vpu_api_dbg_output("get packet %p size %d pts %lld keyframe %d eos %d\n",
packet, length, pts, aEncOut->keyFrame, eos);
mpp_packet_deinit(&packet);
} else {
mpp_log("outputPacket is NULL!");

View File

@@ -45,6 +45,7 @@ static MppCodingTypeInfo support_list[] = {
{ MPP_CTX_DEC, MPP_VIDEO_CodingAVS, "dec", "avs+", },
{ MPP_CTX_DEC, MPP_VIDEO_CodingMJPEG, "dec", "jpeg", },
{ MPP_CTX_ENC, MPP_VIDEO_CodingAVC, "enc", "h.264/AVC", },
{ MPP_CTX_ENC, MPP_VIDEO_CodingMJPEG, "enc", "jpeg", },
};
#define check_mpp_ctx(ctx) _check_mpp_ctx(ctx, __FUNCTION__)