103 lines
3.3 KiB
C
Executable File
103 lines
3.3 KiB
C
Executable File
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
|
|
#include "fh_common.h"
|
|
#include "fh_system_mpi.h"
|
|
#include "fh_vb_mpi.h"
|
|
#include "fh_defines.h"
|
|
#include "vmm_api.h"
|
|
#include "fh_jpege_mpi.h"
|
|
#include "types/bufCtrl.h"
|
|
|
|
#include "common.h"
|
|
#include "xconfig.h"
|
|
#include "libhttp_mjpeg.h"
|
|
|
|
extern bool g_bRunning ;
|
|
|
|
int jpege_test(int tcase)
|
|
{
|
|
int s32Ret = 0;
|
|
JPEGE_STREAM_S stStream;
|
|
JPEGE_CHN_ATTR_S stJpegAttr;
|
|
JPEGE_CROP_CFG_S veCorp;
|
|
FH_UINT32 u32Width = 0;
|
|
FH_UINT32 u32Height = 0;
|
|
char cases[64];
|
|
FH_UINT32 picnt = 0;
|
|
JPEGE_CHN chn = 0;
|
|
|
|
sprintf(cases, "test_cases[%d]", tcase);
|
|
|
|
s32Ret = config_has_key(cases, NULL, "jpege");
|
|
IPO_LOG_CHECK_GOTO(!s32Ret, exit, "parameters for jpege does not exist!");
|
|
|
|
|
|
memset(&stJpegAttr, 0, sizeof(stJpegAttr));
|
|
|
|
u32Width = config_get_int(cases, "jpege.width", 0);
|
|
IPO_LOG_CHECK_GOTO(0 == u32Width, exit, "invalid width = %d!", u32Width);
|
|
u32Height = config_get_int(cases, "jpege.height", 0);
|
|
IPO_LOG_CHECK_GOTO(0 == u32Width, exit, "invalid height = %d!", u32Height);
|
|
|
|
stJpegAttr.u32MaxPicWidth = u32Width;
|
|
stJpegAttr.u32MaxPicHeight = u32Height;
|
|
stJpegAttr.u32PicWidth = u32Width;
|
|
stJpegAttr.u32PicHeight = u32Height;
|
|
stJpegAttr.u32BufSize = u32Width * u32Height * 4;
|
|
|
|
s32Ret = FH_JPEGE_CreateChn(chn, &stJpegAttr);
|
|
IPO_LOG_CHECK_GOTO(s32Ret, exit, "FH_JPEGE_CreateChn failed! ret = 0x%x", s32Ret);
|
|
s32Ret = FH_JPEGE_StartRecvPic(chn);
|
|
IPO_LOG_CHECK_GOTO(s32Ret, exit, "FH_JPEGE_StartRecvPic failed! ret = 0x%x", s32Ret);
|
|
|
|
int crop_en = config_get_int(cases, "jpege.crop.en", 0);
|
|
if (crop_en) {
|
|
veCorp.bEnable = FH_TRUE;
|
|
veCorp.stRect.s32X = config_get_int(cases, "jpege.crop.s32X", 0);
|
|
veCorp.stRect.s32Y = config_get_int(cases, "jpege.crop.s32Y", 0);
|
|
veCorp.stRect.u32Width = config_get_int(cases, "jpege.crop.u32Width", 0);
|
|
veCorp.stRect.u32Height = config_get_int(cases, "jpege.crop.u32Height", 0);
|
|
s32Ret = FH_JPEGE_SetCrop(chn, &veCorp);
|
|
IPO_LOG_CHECK_GOTO(s32Ret, exit, "FH_JPEGE_SetCrop failed! ret = 0x%x", s32Ret);
|
|
}
|
|
picnt = 0;
|
|
int count = 0;
|
|
int max_count = config_get_int(cases, "jpege.count", 10);
|
|
int update_osd = config_get_int(cases, "jpege.update_osd", 1);
|
|
while (g_bRunning) {
|
|
memset(&stStream, 0, sizeof(stStream));
|
|
stStream.s32MilliSec = 1000;
|
|
s32Ret = FH_JPEGE_GetStream((0), &stStream);
|
|
|
|
if (s32Ret == 0) {
|
|
if (++count < max_count) {
|
|
char fname[128];
|
|
sprintf(fname, "dump/jpeg_%dx%d_%05d.jpeg", u32Width, u32Height, picnt++);
|
|
FILE *fp = fopen(fname, "wb");
|
|
if (fp) {
|
|
fwrite(stStream.pu8Addr, stStream.u32Len, 1, fp);
|
|
fclose(fp);
|
|
}
|
|
}
|
|
libmjpeg_send_stream(stStream.pu8Addr, stStream.u32Len);
|
|
|
|
FH_JPEGE_ReleaseStream((0), &stStream);
|
|
if(update_osd) {
|
|
vpu_update_gosd(0, 0, 1);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
exit:
|
|
printf("jpege test done! encode jpeg pictrues:%d\n", picnt);
|
|
FH_JPEGE_StopRecvPic(chn);
|
|
FH_JPEGE_DestroyChn(chn);
|
|
return s32Ret;
|
|
|
|
} |