• «
  • 1
  • 2
  • 3
  • »
  • Pages: 1/3     Go
主题 : 关于Tiny210v2 JPG硬件解码的问题 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 76848
精华: 0
发帖: 13
金钱: 65 两
威望: 13 点
贡献值: 0 点
综合积分: 26 分
注册时间: 2012-08-30
最后登录: 2014-10-25
楼主  发表于: 2013-07-02 15:26

 关于Tiny210v2 JPG硬件解码的问题

使用的系统  linux-3.0.8-20130327.tgz
用的是三星的测试程序
------------------------Decoder Test Start ---------------------
inFilename : test2.jpg
outFilename : test.bin
[JPEG_API: TRACE] SsbSipJPEGDecodeInit: init decode handle : 4
filesize :-1093469356
inBuf : 0xbed2fb54
[JPEG_API: TRACE] SsbSipJPEGDecodeExe: jCtx->decParam->fileSize : 288667
[JPEG_API: TRACE] SsbSipJPEGDecodeExe: decParam->width : 0 decParam->height : 0
[JPEG_API: TRACE] SsbSipJPEGDecodeExe: streamSize : 0
[JPEG_API: TRACE] SsbSipJPEGGetDecodeOutBuf: DecodeOutBuf : 0x1  size : 0
OutBuf : 0xbed2fb54 streamsize : 0
width : -1093469356 height : 4096 samplemode : 1952737655
convertyuvformat
indexY(-1093469388), indexCB(0), indexCR(1701080681)
------------------------Decoder Test Done ---------------------

ioctl(dev_fd, IOCTL_JPG_DECODE, jCtx->decParam);把第三个参数改为 jCtx

解码错误有那个朋友测试过没有
级别: 新手上路
UID: 76848
精华: 0
发帖: 13
金钱: 65 两
威望: 13 点
贡献值: 0 点
综合积分: 26 分
注册时间: 2012-08-30
最后登录: 2014-10-25
1楼  发表于: 2013-07-02 15:27
是linux 下不是安卓的
级别: 新手上路
UID: 76848
精华: 0
发帖: 13
金钱: 65 两
威望: 13 点
贡献值: 0 点
综合积分: 26 分
注册时间: 2012-08-30
最后登录: 2014-10-25
2楼  发表于: 2013-07-03 10:34
自己顶一下 有测试过的吗
级别: 新手上路
UID: 93240
精华: 0
发帖: 48
金钱: 240 两
威望: 48 点
贡献值: 0 点
综合积分: 96 分
注册时间: 2013-06-18
最后登录: 2017-09-13
3楼  发表于: 2013-07-03 17:00
这是我这两天刚做完成了,你参照下吧,应该对你会有帮助的!!使用的数据时yuv422的

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/select.h>
#include <sys/time.h>
#include <errno.h>
#include <sys/mman.h>
#include "test_jpeg.h"
#include "s3c-jpeg.h"

#define CTRL_FILE_NAME   "./640_480.yuv422"
#define JESULT_NG  0
#define JESULT_OK  1


int main_dnc(void)
{
    int jpeg_fd,fileSize=0;
    int ret = 0,result;
    char *InBuf,*OutBuf;
    FILE * inbuf_fp,*outdnc_fp;
    int addr_base;
    int addr_offer;
    int i;
    int tmp_addr;
    struct jpg_args  param_dnc;
    struct jpg_dec_proc_param    *my_dnc_param;
    
    // 打开jpeg 设备
    printf("@@@@@APP@@@@@open start \n");
    jpeg_fd = open("/dev/s3c-jpg", O_RDWR);
    if (jpeg_fd < 0) {
        perror("open device jpeg");
    }

    addr_base = mmap(NULL,1024*1024*8,PROT_READ|PROT_WRITE,MAP_PRIVATE,jpeg_fd,0);
    if(addr_base == MAP_FAILED){
        printf(" mmap InBuf failed\n");
        goto ERR1;
    }

    
    addr_offer =  ioctl(jpeg_fd, IOCTL_JPG_GET_FRMBUF, 0);
    if(!addr_offer){
        printf("s3c_jpeg_ioctl OutBuf NG \n");
        goto ERR2;
    }
    #if 0
    tmp_addr =  ioctl(jpeg_fd, IOCTL_JPG_GET_STRBUF,addr_base);
    printf("####tmp_addr = 0x%08x\n",tmp_addr);
    #endif
    
    #if 0
    addr_phy_offer =  ioctl(jpeg_fd, IOCTL_JPG_GET_PHY_FRMBUF);
    if(!addr_phy_offer){
        printf("s3c_jpeg_ioctl addr_phy_offer NG \n");
        goto ERR2;
    }
    #endif
    
    printf("@@@@@APP@@@@@  addr_base = 0x%x ,addr_offer +addr_base= 0x%x \n",addr_base ,addr_offer +addr_base);

    my_dnc_param = (struct jpg_dec_proc_param *)malloc(sizeof(struct jpg_dec_proc_param));
    
    if(NULL == my_dnc_param){
        printf("malloc my_dnc_param failed\n");
        goto ERR2;
    }
    memset(my_dnc_param, 0, sizeof(struct jpg_dec_proc_param));
    
    InBuf   = (char *)addr_base;
    OutBuf = (char *)(addr_base+addr_offer);
    
    if (addr_offer % 16  !=0)
    {
        printf("addr_offer is not 16 bit addr\n");
        goto ERR2;
    }
    printf("is good\n");

    // 打开图像文件
    inbuf_fp = fopen("./640_480.jpg","rb");
    if(inbuf_fp == NULL)
    {
        perror("./JPEG_data.jpg\n");
        goto ERR3;
    }

    // 在这里用于计算打开的JTAG图像文件的大小(byte)
    fseek(inbuf_fp, 0, SEEK_END);
    fileSize = ftell(inbuf_fp);
    fseek(inbuf_fp, 0, SEEK_SET);
    printf("@@@filesize =%d\n",fileSize);
    ret = fread(OutBuf, 1, fileSize, inbuf_fp);
    for(i=0;i<5;i++){
        printf("@@@@@OutBuf = 0x%08x\n",OutBuf);
    }
    fclose (inbuf_fp);

    printf("@@@@@APP@@@@@file  Inbuf file open ok ret =%d\n\n",ret);
    
    param_dnc.in_buf = InBuf;
      param_dnc.out_buf = OutBuf;
      param_dnc.dec_param = my_dnc_param;
    my_dnc_param->out_format=YCBCR_422;
    #if 0
    my_dnc_param->width =640;
    my_dnc_param->height = 480;
    my_dnc_param->sample_mode = JPG_422;
    #endif


    // ioctl 开始进行编解码处理
    printf("@@@@@APP@@@@@ioctl start \n");

    result = ioctl(jpeg_fd, IOCTL_JPG_DECODE, &param_dnc);
    if(!result){
        printf("s3c_jpeg_ioctl:decode NG \n");
        goto ERR4;
    }
    printf("end decode my_dnc_param->data_size = %d\n",my_dnc_param->data_size);

    outdnc_fp= fopen("./JPEG_data_dnc","wb");
    
    if(outdnc_fp < 0)
    {
        printf("file open  ./JPEG_data error \n");
        goto ERR4;
    }
    ret = fwrite(OutBuf, 1,20  , outdnc_fp);
        
    ret = fwrite(InBuf, 1,my_dnc_param->data_size  , outdnc_fp);
    if(ret < 0){
        printf("fwrite failed ret = %d",ret);
        goto ERR5;
    }
    printf("@@@@@APP@@@@@JPG_DECODE END ret = %d!\n ",ret);
    
    fclose(outdnc_fp);
    free(my_dnc_param);    
    munmap(addr_base,1024*1024*8);
    close(jpeg_fd);
    
    return JESULT_OK;
ERR5:
    fclose(outdnc_fp);
ERR4:
    fclose(inbuf_fp);
ERR3:    
    free(my_dnc_param);
ERR2:
    munmap(addr_base,1024*1024*8);
ERR1:
    close(jpeg_fd);
    return JESULT_NG;    
    
}
/*********************************** 编码测试 yuv422 *********************/
int main(void)
{
    int fileSize = 0,jpeg_fd;
    int ret = 0,result,timecount=0;
    FILE * inbuf_fp,*outbuf_fp,*outdnc_fp;
    char *InBuf,*OutBuf;
    int cnt;
    struct jpg_args param , param_dnc;
    struct jpg_enc_proc_param    *my_enc_param;
    struct jpg_dec_proc_param    *my_dnc_param;
    struct timeval cur_time,pre_time;

    
      int addr_base;
      int addr_offer;
    

    
    // 打开jpeg 设备
    printf("@@@@@APP@@@@@open start \n");
    jpeg_fd = open("/dev/s3c-jpg", O_RDWR);
    if (jpeg_fd < 0) {
        perror("open device jpeg");
        //goto ERR1;
    }
    addr_base = mmap(NULL,1024*1024*8,PROT_READ|PROT_WRITE,MAP_PRIVATE,jpeg_fd,0);
    if(addr_base == MAP_FAILED){
        printf(" mmap InBuf failed\n");
        goto ERR1;
    }
    
    addr_offer =  ioctl(jpeg_fd, IOCTL_JPG_GET_FRMBUF, 0);
    if(!addr_offer){
        printf("s3c_jpeg_ioctl OutBuf NG \n");
        goto ERR2;
    }
    printf("@@@@@APP@@@@@  addr_base = 0x%x ,addr_offer +addr_base = 0x%x \n",addr_base ,addr_offer+addr_base);
    
    my_enc_param = (struct jpg_enc_proc_param *)malloc(sizeof(struct jpg_enc_proc_param));
    
    if(NULL == my_enc_param){
        printf("malloc my_enc_param failed\n");
        goto ERR2;
    }
    memset(my_enc_param, 0, sizeof(struct jpg_enc_proc_param));

    InBuf   = (char *)addr_base;
    OutBuf = (char *)(addr_base+addr_offer);
    
    // 开始对一桢数据进行编码
    param.in_buf = InBuf;
      param.in_buf_size = 1024*1024*2;
      param.out_buf = OutBuf;
      param.out_buf_size =800*600*2;
      param.enc_param = my_enc_param;
      my_enc_param->sample_mode = JPG_422;
    my_enc_param->enc_type = JPG_MAIN;
    my_enc_param->in_format = JPG_MODESEL_YCBCR;
    my_enc_param->width = 640;
    my_enc_param->height =480;
    my_enc_param->quality = JPG_QUALITY_LEVEL_1;
    //my_enc_param->data_size = 640*480*2;
    //my_enc_param->file_size = 640*480*2;

     // 打开图像文件
    inbuf_fp = fopen("./640_480.yuv422","rb");
    if(inbuf_fp == NULL)
    {
        perror("./640_480.yuv422");
        goto ERR3;
    }
        // 在这里用于计算打开的JTAG图像文件的大小(byte)
    fseek(inbuf_fp, 0, SEEK_END);
    fileSize = ftell(inbuf_fp);
    fseek(inbuf_fp, 0, SEEK_SET);

    ret = fread(InBuf, 1, fileSize, inbuf_fp);
    fclose (inbuf_fp);
    
    printf("@@@@@APP@@@@@file  Inbuf file open ok ret =%d\n\n",ret);

    // ioctl 开始进行编解码处理
    printf("@@@@@APP@@@@@ioctl start \n");

      param.in_buf_size = fileSize;
    gettimeofday(&pre_time,NULL);
    result = ioctl(jpeg_fd, IOCTL_JPG_ENCODE, &param);
    if(!result){
        printf("s3c_jpeg_ioctl NG \n");
        goto ERR4;
    }
    gettimeofday(&cur_time,NULL);
    if(pre_time.tv_sec == cur_time.tv_sec)
        timecount = cur_time.tv_usec - pre_time.tv_usec;
    else
        timecount = (cur_time.tv_usec  - pre_time.tv_usec)/1000+1;

    printf("~@@@@~~~~~~~timecount=%d\n",timecount);
    //printf("my_enc_param->data_size = %d\n",my_enc_param->data_size);
    printf("@@@@@APP@@@@@my_enc_param->file_size = %d\n",my_enc_param->file_size);

    //编解码完成后,图像进行写处理

    //write(jpeg_fd,(char*)OutBuf,file_size);
    outbuf_fp= fopen("./JPEG_data","wb");
    
    if(outbuf_fp < 0)
    {
        printf("file open  ./JPEG_data error \n");
        goto ERR5;
    }

    ret = fwrite(OutBuf, 1,my_enc_param->file_size  , outbuf_fp);
    if(ret < 0){
        printf("fwrite failed ret = %d",ret);
        goto ERR5;
    }
    fclose (outbuf_fp);


    #if 0
    
       // 开始解码
       printf("**********************DECODE START*************************************\n\n");
    memset(InBuf,0,fileSize);
    outdnc_fp = fopen("./JPEG_dnc","wb");
    if(outdnc_fp < 0)
    {
        printf("file open  ./JPEG_dnc error \n");
        goto ERR5;
    }    
    
    my_dnc_param = (struct jpg_dec_proc_param *)malloc(sizeof(struct jpg_dec_proc_param));
    
    if(NULL == my_dnc_param){
        printf("malloc my_enc_param failed\n");
        goto ERR6;
    }

    memset(my_dnc_param, 0, sizeof(struct jpg_dec_proc_param));

    #if 0
    addr_offer =  ioctl(jpeg_fd, IOCTL_JPG_GET_FRMBUF, 0);
    if(!addr_offer){
        printf("s3c_jpeg_ioctl OutBuf NG \n");
        goto ERR7;
    }
    printf("@@@@@APP@@@@@IOCTL_JPG_GET_FRMBUF OK!\n ");
    #endif
    param_dnc.in_buf = InBuf;
      param_dnc.out_buf = OutBuf;
      param_dnc.dec_param = my_dnc_param;
    my_dnc_param->out_format=YCBCR_422;

    printf("start decode my_dnc_param->data_size = %d\n",my_dnc_param->data_size);
    result = ioctl(jpeg_fd, IOCTL_JPG_DECODE, &param_dnc);
    if(!result){
        printf("s3c_jpeg_ioctl:decode NG \n");
        goto ERR7;
    }
    printf("end decode my_dnc_param->data_size = %d\n",my_dnc_param->data_size);

    printf("InBuf[0]= 0x%08x, InBuf[1]=0x%08x,InBuf[2]=0x%08x\n ",InBuf[0],InBuf[1],InBuf[2]);
    ret = fwrite(InBuf, 1,my_dnc_param->data_size  , outdnc_fp);
    if(ret < 0){
        printf("fwrite failed ret = %d",ret);
        goto ERR7;
    }
    printf("@@@@@APP@@@@@JPG_DECODE END!\n ");
    
    /***************************************************************************************************/
    free(my_dnc_param);    

    fclose(outdnc_fp);
#endif
    free(my_enc_param);
    munmap(InBuf,1024*1024*8);
    close(jpeg_fd);
    
    return JESULT_OK;
#if 0
ERR7:
    free(my_dnc_param);

ERR6:
    fclose(outdnc_fp);    
#endif
ERR5:
    fclose(outbuf_fp);
ERR4:
    fclose (inbuf_fp);    
ERR3:    
    free(my_enc_param);
ERR2:
    munmap(InBuf,1024*1024*8);

ERR1:
    close(jpeg_fd);
    return JESULT_NG;    
    
}
级别: 新手上路
UID: 76848
精华: 0
发帖: 13
金钱: 65 两
威望: 13 点
贡献值: 0 点
综合积分: 26 分
注册时间: 2012-08-30
最后登录: 2014-10-25
4楼  发表于: 2013-07-04 14:15
谢谢 你的可以成功解码是吧
级别: 新手上路
UID: 76848
精华: 0
发帖: 13
金钱: 65 两
威望: 13 点
贡献值: 0 点
综合积分: 26 分
注册时间: 2012-08-30
最后登录: 2014-10-25
5楼  发表于: 2013-07-04 14:21
你使用的开发板Tiny210V2 和操作系统和我的是一样的吧 3.08 的内核 linux 下的
级别: 新手上路
UID: 93240
精华: 0
发帖: 48
金钱: 240 两
威望: 48 点
贡献值: 0 点
综合积分: 96 分
注册时间: 2013-06-18
最后登录: 2017-09-13
6楼  发表于: 2013-07-05 10:43

 回 5楼(x260573569) 的帖子

一样的 ,不过我用的是2.6.35的内核。可以通过测试~!
级别: 新手上路
UID: 38447
精华: 0
发帖: 19
金钱: 95 两
威望: 19 点
贡献值: 0 点
综合积分: 38 分
注册时间: 2011-02-25
最后登录: 2017-09-17
7楼  发表于: 2013-07-13 16:12
請問  測試檔 怎麼取得 是用 YUV 422 RAW 的檔案嗎

感謝
级别: 侠客
UID: 82171
精华: 0
发帖: 54
金钱: 275 两
威望: 55 点
贡献值: 0 点
综合积分: 108 分
注册时间: 2012-11-19
最后登录: 2016-02-27
8楼  发表于: 2013-10-28 18:53
你好,你说的这个三星的测试程序在哪下载啊?
级别: 新手上路
UID: 86000
精华: 0
发帖: 1
金钱: 5 两
威望: 1 点
贡献值: 0 点
综合积分: 2 分
注册时间: 2013-01-12
最后登录: 2014-01-05
9楼  发表于: 2014-01-05 14:31

 red envelopes

本部分内容设定了隐藏,需要回复后才能看到
  • «
  • 1
  • 2
  • 3
  • »
  • Pages: 1/3     Go