完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
你好 专家 我出现以下问题不知道怎么了?
我是做了解码后的resize 解码后是420的 所以是420_to_420的resize 我是把1920x1080 缩小的 不知道为什么会出现这样条纹 我的代码是这样的 Void *displayThrFxn(Void *arg) [ Resize_Attrs rszAttrs = Resize_Attrs_DEFAULT; DisplayEnv *envp = (DisplayEnv *) arg; Display_Attrs dAttrs = Display_Attrs_DM365_VID_DEFAULT; Display_Handle hDisplay = NULL; Framecopy_Handle hFc = NULL; Void *status = THREAD_SUCCESS; Uns frameCnt = 0; BufferGfx_Dimensions srcDim,dim; Buffer_Handle hSrcBuf, hDstBuf; Resize_Handle hRsz = NULL; Int fifoRet; ColorSpace_Type colorSpace = ColorSpace_YUV420PSEMI; BufferGfx_Attrs gfxAttrs = BufferGfx_Attrs_DEFAULT; BufTab_Handle hBufTab = NULL; Int32 bufSize; time_Attrs tAttrs = Time_Attrs_DEFAULT; Time_Handle hTime = NULL; Int32 time, waitTime; Int bufCnt = 1; BufTab_Handle hDisplayBufTab; hTime = Time_create(&tAttrs); Int bufIdx; if (hTime == NULL) [ ERR("Failed to create Time objectn"); cleanup(THREAD_FAILURE); ] /* Create the resize job */ hRsz = Resize_create(&rszAttrs); if (hRsz == NULL) [ /// ret = Dmai_EFAIL; ERR("Failed to create resize jobn"); cleanup(THREAD_FAILURE); ] if(Time_reset(hTime) != Dmai_EOK) [ ERR("Failed to reset timern"); cleanup(THREAD_FAILURE); ] if (bufCnt == 1) [ // Create the Display at the first frame gfxAttrs.dim.width =960; gfxAttrs.dim.height =540+17; gfxAttrs.dim.lineLength =Dmai_roundUp(BufferGfx_calcLineLength(gfxAttrs.dim.width, colorSpace), 32)+64; printf("jjjj=%dn",gfxAttrs.dim.lineLength); gfxAttrs.dim.x =4;// srcDim.x; gfxAttrs.dim.y =-2;// srcDim.y; if (colorSpace == ColorSpace_YUV420PSEMI) [ bufSize = gfxAttrs.dim.lineLength * gfxAttrs.dim.height * 3 / 2; ] else [ bufSize = gfxAttrs.dim.lineLength * gfxAttrs.dim.height * 2; ] /* Create a table of buffers to use with the device drivers */ gfxAttrs.colorSpace = colorSpace; hBufTab = BufTab_create(NUM_DISPLAY_BUFS, bufSize, BufferGfx_getBufferAttrs(&gfxAttrs)); if (hBufTab == NULL) [ ERR("Failed to create buftabn"); cleanup(THREAD_FAILURE); ] /* Create the display device instance */ dAttrs.delayStreamon = TRUE; dAttrs.numBufs = NUM_DISPLAY_BUFS; dAttrs.videoStd = envp->videoStd; /* * Round down the width to a multiple of 32 as required by * display driver. Otherwise, the driver would internally round * up the width, resulting in the codec padding showing up * on the display when the image width is not a multiple of 32. */ dAttrs.width = ((gfxAttrs.dim.width & 0x1f) ? (gfxAttrs.dim.width & ~(0x1f)) : gfxAttrs.dim.width); dAttrs.height = gfxAttrs.dim.height; dAttrs.videoOutput = envp->displayOutput; dAttrs.colorSpace = colorSpace; hDisplay = Display_create(hBufTab, &dAttrs); if (hDisplay == NULL) [ ERR("Failed to create display devicen"); cleanup(THREAD_FAILURE); ] hDisplayBufTab = Display_getBufTab(hDisplay); for (bufIdx = 0; bufIdx < BufTab_getNumBufs(hDisplayBufTab); bufIdx++) [ hDstBuf = BufTab_getBuf(hDisplayBufTab, bufIdx); BufferGfx_getDimensions(hDstBuf, &dim); dim.width =gfxAttrs.dim.width; dim.height =gfxAttrs.dim.height; dim.x = gfxAttrs.dim.x; dim.y = gfxAttrs.dim.y; // dim.lineLength=gfxAttrs.dim.lineLength; if (BufferGfx_setDimensions(hDstBuf, &dim) < 0) [ //ret = Dmai_EFAIL; fprintf(stderr,"Output resolution does not fit in display framen"); // goto cleanup; ] if (Display_put(hDisplay, hDstBuf) < 0) [ ERR("Failed to put display buffern"); cleanup(THREAD_FAILURE); ] ] ] bufCnt++; /* Signal that initialization is done and wait for other threads */ Rendezvous_meet(envp->hRendezvousInit); while (!gblGetQuit()) [ /* Pause processing? */ Pause_test(envp->hPauseProcess); /* Pause for priming? */ Pause_test(envp->hPausePrime); /* Get decoded video frame */ fifoRet = Fifo_get(envp->hInFifo, &hSrcBuf); if (fifoRet < 0) [ ERR("Failed to get buffer from video threadn"); cleanup(THREAD_FAILURE); ] /* Did the video thread flush the fifo? */ if (fifoRet == Dmai_EFLUSH) [ cleanup(THREAD_SUCCESS); ] // BufferGfx_getDimensions(hSrcBuf, &srcDim); // printf("+%d +%d +%d +%d+%dn",srcDim.width,srcDim.height,srcDim.x,srcDim.y,srcDim.lineLength); /* Get a buffer from the display device driver */ if (Display_get(hDisplay, &hDstBuf) < 0) [ ERR("Failed to get display buffern"); cleanup(THREAD_FAILURE); ] if (Resize_420_to_420_execute(hRsz, hSrcBuf, hDstBuf) < 0) [////Resize_doYUV420SP/////Resize_420_to_420_execute ERR("Failed to execute resize jobn"); cleanup(THREAD_FAILURE); ] /* Send buffer back to the video thread */ if (Fifo_put(envp->hOutFifo, hSrcBuf) < 0) [ ERR("Failed to send buffer to video threadn"); cleanup(THREAD_FAILURE); ] if (envp->videoStd == VideoStd_720P_60) [ if (Time_delta(hTime, (UInt32*)&time) < 0) [ ERR("Failed to get timer deltan"); cleanup(THREAD_FAILURE); ] waitTime = DISPLAYLOOPLATENCY - time; if(waitTime > 0) [ usleep(waitTime); ] if(Time_reset(hTime) != Dmai_EOK) [ ERR("Failed to reset timern"); cleanup(THREAD_FAILURE); ] ] /* Incremement statistics for the user interface */ gblIncFrames(); /* Give a filled buffer back to the display device driver */ if (Display_put(hDisplay, hDstBuf) < 0) [ ERR("Failed to put display buffern"); cleanup(THREAD_FAILURE); ] frameCnt++; ] cleanup: /* Make sure the other threads aren't waiting for us */ Rendezvous_force(envp->hRendezvousInit); Pause_off(envp->hPauseProcess); Pause_off(envp->hPausePrime); Fifo_flush(envp->hOutFifo); /* Meet up with other threads before cleaning up */ Rendezvous_meet(envp->hRendezvousCleanup); /* Clean up the thread before exiting */ if (hFc) [ Framecopy_delete(hFc); ] if (hDisplay) [ Display_delete(hDisplay); ] /* Clean up the thread before exiting */ if (hBufTab) [ BufTab_delete(hBufTab); ] if(hTime) [ Time_delete(hTime); ] return status; ] 执行resize代码是这样的 Int Resize_doYUV420SP(Resize_Handle hResize, Buffer_Handle hSrcBuf, Buffer_Handle hDstBuf) [ BufferGfx_Dimensions srcDim, dstDim; UInt hDif; UInt vDif; struct rsz_channel_config rsz_chan_config; struct rsz_single_shot_config rsz_ss_config; struct imp_convert rsz; UInt32 ysrcOffset, csrcOffset; UInt32 ydstOffset, cdstOffset; UInt32 numBytesUsed; /* Make sure our input parameters are valid */ if (!hResize) [ Dmai_err0("Resize_Handle parameter must not be NULLn"); return Dmai_EINVAL; ] if (!hSrcBuf) [ Dmai_err0("Source buffer parameter must not be NULLn"); return Dmai_EINVAL; ] if (!hDstBuf) [ Dmai_err0("Destination buffer parameter must not be NULLn"); return Dmai_EINVAL; ] /* Buffer needs to be graphics buffers */ if (Buffer_getType(hSrcBuf) != Buffer_Type_GRAPHICS || Buffer_getType(hDstBuf) != Buffer_Type_GRAPHICS) [ Dmai_err0("Src and dst buffers need to be graphics buffersn"); return Dmai_EINVAL; ] BufferGfx_getDimensions(hSrcBuf, &srcDim); BufferGfx_getDimensions(hDstBuf, &dstDim); if (dstDim.width <= 0) [ Dmai_err0("Destination buffer width must be greater than zeron"); return Dmai_EINVAL; ] if (dstDim.height <= 0) [ Dmai_err0("Destination buffer height must be greater than zeron"); return Dmai_EINVAL; ] if ((srcDim.lineLength & 0x1F) != 0) [ Dmai_err0("Source buffer pitch must be a multiple of 32 bytesn"); return Dmai_EINVAL; ] if ((dstDim.lineLength & 0x1F) != 0) [ Dmai_err0("Destination buffer pitch must be a multiple of 32 bytesn"); return Dmai_EINVAL; ] /* Check for valid buffer scaling */ hDif = srcDim.width * 256 / dstDim.width; vDif = srcDim.height * 256 / dstDim.height; if (hDif < 32) [ Dmai_err0("Horizontal up-scaling must not exceed 8xn"); return Dmai_EINVAL; ] if (hDif > 4096) [ Dmai_err0("Horizontal down-scaling must not exceed 1/16xn"); return Dmai_EINVAL; ] if (vDif < 32) [ Dmai_err0("Vertical up-scaling must not exceed 8xn"); return Dmai_EINVAL; ] if (vDif > 4096) [ Dmai_err0("Vertical down-scaling must not exceed 1/16xn"); return Dmai_EINVAL; ] /* Set the driver default parameters and retrieve what was set */ Dmai_clear(rsz_ss_config); rsz_chan_config.oper_mode = IMP_MODE_SINGLE_SHOT; rsz_chan_config.chain = 0; rsz_chan_config.len = 0; rsz_chan_config.config = NULL; /* to set defaults in driver */ if (ioctl(hResize->fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) [ Dmai_err0("Error in setting default configuration for single shot moden"); goto cleanup; ] /* default configuration setting in Resizer successfull */ Dmai_clear(rsz_ss_config); rsz_chan_config.oper_mode = IMP_MODE_SINGLE_SHOT; rsz_chan_config.chain = 0; rsz_chan_config.len = sizeof(struct rsz_single_shot_config); rsz_chan_config.config = &rsz_ss_config; if (ioctl(hResize->fd, RSZ_G_CONFIG, &rsz_chan_config) < 0) [ Dmai_err0("Error in getting resizer channel configuration from drivern"); goto cleanup; ] /* input params are set at the resizer */ rsz_ss_config.input.image_width = srcDim.width; rsz_ss_config.input.image_height = srcDim.height; rsz_ss_config.input.ppln = rsz_ss_config.input.image_width + 8; rsz_ss_config.input.lpfr = rsz_ss_config.input.image_height + 10; rsz_ss_config.input.clk_div.m = 60;//10; rsz_ss_config.input.clk_div.n = 70;//3;//70;// rsz_ss_config.input.pix_fmt = IPIPE_420SP_Y; rsz_ss_config.output1.pix_fmt = IPIPE_YUV420SP; rsz_ss_config.output1.enable = 1; rsz_ss_config.output1.width = dstDim.width; rsz_ss_config.output1.height = dstDim.height; rsz_ss_config.output2.enable = 0; rsz_chan_config.oper_mode = IMP_MODE_SINGLE_SHOT; rsz_chan_config.chain = 0; rsz_chan_config.len = sizeof(struct rsz_single_shot_config); if (ioctl(hResize->fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) [ Dmai_err0("Error in setting default configuration for single shot moden"); goto cleanup; ] rsz_chan_config.oper_mode = IMP_MODE_SINGLE_SHOT; rsz_chan_config.chain = 0; rsz_chan_config.len = sizeof(struct rsz_single_shot_config); /* read again and verify */ if (ioctl(hResize->fd, RSZ_G_CONFIG, &rsz_chan_config) < 0) [ Dmai_err0("Error in getting configuration from drivern"); goto cleanup; ] ///////////////////////////////////////////////////////////////// Dmai_clear(rsz); /* printf("srcbuf ptr: %lx, bytesused: %ld, dstbuf ptr: %lx, bytesused: %ldn", (UInt32) Buffer_getUserPtr(hSrcBuf), (UInt32)Buffer_getNumBytesUsed(hSrcBuf), (UInt32) Buffer_getUserPtr(hDstBuf), (UInt32)Buffer_getNumBytesUsed(hDstBuf)); printf("srcdim linelength: %ld, x: %ld, y: %ld, w:%ld, h:%ld n", srcDim.lineLength, srcDim.x, srcDim.y, srcDim.width, srcDim.height); printf("dstdim linelength: %ld, x: %ld, y: %ld, w:%ld, h:%ld n", dstDim.lineLength, dstDim.x, dstDim.y, dstDim.width, dstDim.height);*/ //resize Y first ysrcOffset = srcDim.y * srcDim.lineLength + (srcDim.x << 0); //by xiaoguang 1 -> 0 ydstOffset = dstDim.y * dstDim.lineLength + (dstDim.x << 0); //by xiaoguang 1 -> 0 rsz.in_buff.index = -1; rsz.in_buff.buf_type = IMP_BUF_IN; rsz.in_buff.offset = (UInt32) Buffer_getUserPtr(hSrcBuf) + ysrcOffset; rsz.in_buff.size = srcDim.width * srcDim.height; rsz.out_buff1.index = -1; rsz.out_buff1.buf_type = IMP_BUF_OUT1; rsz.out_buff1.offset = (UInt32) Buffer_getUserPtr(hDstBuf) + ydstOffset; rsz.out_buff1.size = dstDim.width * dstDim.height; /* * The IPIPE requires that the memory offsets of the input and output * buffers start on 32-byte boundaries. */ rsz.in_buff.offset = ((rsz.in_buff.offset + 31)/32)*32; rsz.out_buff1.offset = ((rsz.out_buff1.offset + 31)/32)*32; assert((rsz.in_buff.offset & 0x1F) == 0); assert((rsz.out_buff1.offset & 0x1F) == 0); /* Start IPIPE operation */ if (ioctl(hResize->fd, RSZ_RESIZE, &rsz) == -1) [ Dmai_err0("Failed RSZ_RESIZEn"); return Dmai_EFAIL; ] //resize CbCr /* input params are set at the resizer */ rsz_ss_config.input.image_width = srcDim.width; rsz_ss_config.input.image_height = srcDim.height/2; rsz_ss_config.input.ppln = rsz_ss_config.input.image_width + 8; rsz_ss_config.input.lpfr = rsz_ss_config.input.image_height + 10; rsz_ss_config.input.clk_div.m = 60;//10; rsz_ss_config.input.clk_div.n = 70;//3;//70;// rsz_ss_config.input.pix_fmt = IPIPE_420SP_C; rsz_ss_config.output1.pix_fmt = IPIPE_YUV420SP; rsz_ss_config.output1.enable = 1; rsz_ss_config.output1.width = dstDim.width; rsz_ss_config.output1.height = dstDim.height+1; rsz_ss_config.output2.enable = 0; rsz_chan_config.oper_mode = IMP_MODE_SINGLE_SHOT; rsz_chan_config.chain = 0; rsz_chan_config.len = sizeof(struct rsz_single_shot_config); rsz_chan_config.config = &rsz_ss_config; if (ioctl(hResize->fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) [ Dmai_err0("Error in setting default configuration for single shot moden"); goto cleanup; ] rsz_chan_config.oper_mode = IMP_MODE_SINGLE_SHOT; rsz_chan_config.chain = 0; rsz_chan_config.len = sizeof(struct rsz_single_shot_config); /* read again and verify */ if (ioctl(hResize->fd, RSZ_G_CONFIG, &rsz_chan_config) < 0) [ Dmai_err0("Error in getting configuration from drivern"); goto cleanup; ] csrcOffset = ysrcOffset /2; cdstOffset = ydstOffset /2; rsz.in_buff.offset = (UInt32) Buffer_getUserPtr(hSrcBuf) + ysrcOffset*2 + srcDim.width * srcDim.height + csrcOffset; rsz.in_buff.size = srcDim.width * srcDim.height / 2; #if 0 rsz.out_buff1.offset = (UInt32) Buffer_getUserPtr(hDstBuf) + ydstOffset*2 + dstDim.width * dstDim.height + cdstOffset; rsz.out_buff1.size = dstDim.width * dstDim.height / 2; #else rsz.out_buff1.offset = (UInt32) Buffer_getUserPtr(hDstBuf) + ydstOffset*2 +((dstDim.height-1)*dstDim.width); rsz.out_buff1.size = dstDim.width * (dstDim.height+1) / 2; #endif rsz.in_buff.offset = ((rsz.in_buff.offset + 31)/32)*32; rsz.out_buff1.offset = ((rsz.out_buff1.offset + 31)/32)*32; assert((rsz.in_buff.offset & 0x1F) == 0); assert((rsz.out_buff1.offset & 0x1F) == 0); /* Start IPIPE operation */ if (ioctl(hResize->fd, RSZ_RESIZE, &rsz) == -1) [ Dmai_err0("Failed RSZ_RESIZEn"); return Dmai_EFAIL; ] numBytesUsed = (UInt32)( ((dstDim.x << 1) + dstDim.width ) * ((dstDim.y << 1) + dstDim.height) * 3 / 2 ); Buffer_setNumBytesUsed(hDstBuf, numBytesUsed); return Dmai_EOK; /////////////////////////////////////////////////////////////////// cleanup: close(hResize->fd); hResize->fd = 0; return Dmai_EFAIL; ] |
|
相关推荐
4 个讨论
|
|
只有小组成员才能发言,加入小组>>
545 浏览 0 评论
1609 浏览 0 评论
2045 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1507 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1331 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1756浏览 29评论
2781浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1723浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1634浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1645浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 17:02 , Processed in 1.817406 second(s), Total 42, Slave 35 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1748