ImageVerifierCode 换一换
格式:DOCX , 页数:27 ,大小:23.53KB ,
资源ID:12095933      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/12095933.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(videocopy例程修改.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

videocopy例程修改.docx

1、videocopy例程修改Video_copy例程修改本实验只要目的:实现在codec engine video_copy例程上的修改,加入简单的图像处理。通过对例程的修改,掌握整个工程所需要的文件,以及文件中的相互关系和开发流程。但是请注意,这里只是开发方式中的一种,也是最简便的一种,所以实现相对而言比较简便,如果想要自己创建工程,还需对其中的文件进一步的理解以及熟悉。1、codecs修改在/home/dvsdk_1_40_02_33/codec_engine_2_10_02/examples/ti/sdo/ce/examples/codecs中,有两个文件夹,分别为viddec_copy和

2、videnc_copy文件夹,这两个文件名分别表示视频的解码和编码。表面上是这样的意思,其实打开里面的源文件,发现只是实现了拷贝的一个动作,并没有涉及到编解码的相关知识。这两个文件夹就是两个codec,我们只需要对其中一个进行修改就可以了。其实在第二步中我们所讲的Server构建的时候,其中有配置文件提到了,这边是调用了两个codec,我们完全可以只调用其中一个。这里为了不带来不必要的麻烦,就没有删除。我们主要在videnc_copy中进行修改,主要修改process函数,其他的都没有改动。主要把其中DMA部分去掉,然后添加我们自己写的算法,如下所示:* = VIDENCCOPY_TI_pro

3、cess = */ /zxj 二值化void image_binarization(char *inBufs,char *outBufs,int size) int i; for (i=0;isize;i+)/这里执行二值化,注意这里是有符号8位整型,图片中是无符号的 if (inBufsi 0) outBufsi=0xFF; else outBufsi=0x0; /zxj 灰度化void image_gray(unsigned char *inBufs,unsigned char *outBufs,int size) int i; unsigned char tmp; for (i=0;is

4、ize != sizeof(*inArgs) | (outArgs-size != sizeof(*outArgs) GT_2trace(curTrace, GT_ENTER, VIDENCCOPY_TI_process, unsupported size (0x%x, 0x%x)n, inArgs-size, outArgs-size); return (IVIDENC_EFAIL); #ifdef USE_ACPY3 /* * Activate Channel scratch DMA channels. */ ACPY3_activate(videncObj-dmaHandle1D1D8B

5、);#endif /* outArgs-bytesGenerated reports the total number of bytes generated */ outArgs-bytesGenerated = 0; /* * A couple constraints for this simple copy codec: * - Video encoding presumes a single input buffer, so only one input * buffer will be encoded, regardless of inBufs-numBufs. * - Given a

6、 different size of an input and output buffers, only * encode (i.e., copy) the lesser of the sizes. */ for (curBuf = 0; (curBuf numBufs) & (curBuf numBufs); curBuf+) /* theres an available in and out buffer, how many samples? */ minSamples = inBufs-bufSizescurBuf bufSizescurBuf ? inBufs-bufSizescurB

7、uf : outBufs-bufSizescurBuf;#if 0 thisTransferSrcAddr = (Uint32)inBufs-bufscurBuf; thisTransferDstAddr = (Uint32)outBufs-bufscurBuf; remainingTransferChunkSize = minSamples; while (remainingTransferChunkSize 0) if (remainingTransferChunkSize maxTransferChunkSize) thisTransferChunkSize = maxTransferC

8、hunkSize; else thisTransferChunkSize = remainingTransferChunkSize; /* Configure the logical channel */ params.transferType = ACPY3_1D1D; params.srcAddr = (void *)thisTransferSrcAddr; params.dstAddr = (void *)thisTransferDstAddr; params.elementSize = thisTransferChunkSize; params.numElements = 1; par

9、ams.waitId = 0; params.numFrames = 1; remainingTransferChunkSize -= thisTransferChunkSize; thisTransferSrcAddr += thisTransferChunkSize; thisTransferDstAddr += thisTransferChunkSize; /* Configure logical dma channel */ ACPY3_configure(videncObj-dmaHandle1D1D8B, ¶ms, 0); /* Use DMA to copy data *

10、/ ACPY3_start(videncObj-dmaHandle1D1D8B); /* wait for transfer to finish */ ACPY3_wait(videncObj-dmaHandle1D1D8B); GT_1trace(curTrace, GT_2CLASS, VIDENCCOPY_TI_process ACPY3 Processed %d bytes.n, minSamples);#endif GT_3trace(curTrace, GT_2CLASS, VIDENCCOPY_TI_process memcpy (0x%x, 0x%x, %d)n, outBuf

11、s-bufscurBuf, inBufs-bufscurBuf, minSamples); /* process the data: read input, produce output */ /memcpy(outBufs-bufscurBuf, inBufs-bufscurBuf, minSamples); /image_binarization(inBufs-bufscurBuf,outBufs-bufscurBuf,minSamples); image_gray(inBufs-bufscurBuf,outBufs-bufscurBuf,minSamples); outArgs-byte

12、sGenerated += minSamples; /* Fill out the rest of the outArgs struct */ outArgs-extendedError = 0; outArgs-encodedFrameType = 0; /* TODO */ outArgs-inputFrameSkip = IVIDEO_FRAME_ENCODED; outArgs-reconBufs.numBufs = 0; /* important: indicate no reconBufs */ return (IVIDENC_EOK);其实上面标红的部分就是我们加上的主要部分,实

13、现了图像的二值化和灰度化。主要的难点其实是在数据的传送部分。bufs是一个二维指针,这个需要非常注意。还有需要注意的是其中数据的类型,注意char*和unsigned char*的区别。上面程序修改之后,编译codec,没有错误的话,会生成.a64P文件,这个文件供后面Server生成调用。2、Server集成由于我们是在例程上修改的,所以那些配置文件基本上不用动的,如果你想修改包含的Codec也可以进行修改。但是这里我们需要尽快跑通程序,而没有做过多的尝试。在/home/dvsdk_1_40_02_33/codec_engine_2_10_02/examples/ti/sdo/ce/exam

14、ples/servers/video_copy/evmDM6467目录下编译,生成.X64P文件。3、应用端程序应用端的源文件主要是app.c和ceapp.c文件。其中app.c是主函数,以及打开文件保存文件的操作。具体的codec engine相关调用全部放在ceapp.c中。在/home/dvsdk_1_40_02_33/codec_engine_2_10_02/examples/ti/sdo/ce/examples/apps/video_copy/dualcpu/evmDM6467目录下,主要修改地方如下:之前是dat文件格式的读写操作,在这里修改成的bmp文件的读写。主要修改后文件如下

15、所示:/* * Copyright 2008 * Texas Instruments Incorporated * * All rights reserved. Property of Texas Instruments Incorporated * Restricted rights to use, duplicate or disclose this code are * granted through contract. * */* * = app.c = * * Non-Codec-Engine-using part of the Arm-side Linux application,

16、 that at * certain points talks to the Codec-Engine-using part of the Arm-side * Linux application. The latter module is in file ceapp.c. * * The call flow is: app.c functions - ceapp.c functions - CodecEngine libs */#include #include /* Definition of buffer sizes for input data, encoded data, outpu

17、t data. * * Our application reads a raw video file one block at the time at the * input buffer. It calls ceapp to encodes that from the input buffer into the * encoded data buffer. Then it calls ceapp to decode the video data from * encoded data buffer into the output buffer. Finally it writes the *

18、 output block to another file. This flow is illustrated here: * * =(app)= inBuf = * =(ceapp/encoder)= encodedBuf = * =(ceapp/decoder)= outBuf = * =(app)= * * For simplicity, below we define all blocks to be 1K, but those sizes * could be arbitrary (though they must match). * * Note: It is EXTREMELY

19、important that the buffers that hold the data are not * simply malloc()ed, but are actually physically contiguous. This is so * because the buffers are passed on to the codecs running on the DSP * verbatim (there is no buffer copying involved). CodecEngine * (and the ceapp module) provides and API f

20、or allocating such buffers. */#define INFRAMESIZE (1024 * sizeof(char) /* raw frame (input) */#define ENCODEDFRAMESIZE (1024 * sizeof(char) /* encoded frame */#define OUTFRAMESIZE (1024 * sizeof(char) /* decoded frame (output) */zxj#pragma pack(2) /两字节对齐,否则bmp_fileheader会占16Bytetypedef struct BMP /1

21、4字节 unsigned short bfType; /文件标识 2字节 必须为BM unsigned int bfSize; /文件大小 4字节 unsigned short bfReserved1; /保留,每字节以00填写 2字节 unsigned short bfReserved2; /同上 2字节 unsigned int bfOffBits; /记录图像数据区的起始位置(图象数据相对于文件头字节的偏移量)。 4字节 /40字节 unsigned int biSize; /表示本结构的大小 4字节 int biWidth; /位图的宽度 4字节 int biHeight; /位图的高

22、度 4字节 unsigned short biPlanes; /永远为1 , 2字节 unsigned short biBitCount; /位图的位数 分为1 4 8 16 24 32 2字节 unsigned int biCompression; /压缩说明 4字节 unsigned int biSizeImage; /表示位图数据区域的大小以字节为单位 4字节 int biXPelsPerMeter; /用象素/米表示的水平分辨率 4字节 int biYPelsPerMeter; /用象素/米表示的垂直分辨率 4字节 unsigned int biClrUsed; /位图使用的颜色索引数

23、 4字节 unsigned int biClrImportant; /对图象显示有重要影响的颜色索引的数目 4字节 BMP; BMP bmp;/* prototypes of functions defined in ceapp.c: */extern int ceapp_init(); /* initialize the ceapp module */extern char *ceapp_allocContigBuf( /* allocate physically contiguous */ int bufSize, /* buffer of given size; description

24、*/ char *bufDescription /* is used only for print */ );extern int ceapp_validateBufSizes( /* confirm that the enc/dec codecs */ int inBufSize, /* support these buffer sizes */ int encodedBufSize, /* for the raw input video, encoded */ int outBufSize /* video data, and decoded output */ );extern int

25、ceapp_encodeBuf( /* encode raw video data in inBuf */ char *inBuf, /* and store result in encodedBuf */ int inBufSize, char *encodedBuf, int encodedBufSize );extern int ceapp_decodeBuf( /* decode data from encodedBuf and */ char *encodedBuf, /* store resulting raw data in outBuf */ int encodedBufSiz

26、e, char *outBuf, int outBufSize );extern void ceapp_freeContigBuf( /* free the contiguous buffer */ char *buf, int bufSize );extern void ceapp_exit(); /* exit the ceapp module */* * = encodeDecodeFile = * This function reads blocks of the input file one at the time, encodes * each block, decodes it,

27、 and writes the result to the output file. */static int encodeDecodeFile(char *inFileName, char *outFileName) /* pointers to contiguous shared data buffers (shared b/w Arm and DSP) */ static char *inBuf = NULL; /* to contig-alloc for INFRAMESIZE */ static char *encodedBuf = NULL; /* to contig-alloc for ENCODEDFRAMESIZE */ static char *outBuf = NULL; /* to contig-alloc for OUTFRAMESIZE */ FILE *inFile = NULL, *outFile = NULL; int status, n; /* open file streams for input and output */ if (inFile = fopen(inFileName, rb)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1