Hi
I would line to encode the same captured frame twice, but in different resolution, by using the Resizer.
I'm Using DMAI 1.21.0.10 and seem that for DM365 the Capture module already open the Resizer device,
Can you suggest other way for resizing?
Thanks
Joni
Joni,
They way I see it, we have your classic case of flexible but complex API vs. simple but less flexible API. Normally, driver APIs are designed to be more flexible but a little more complex to use; you could write your user application right on top of these driver APIs if you wish, and we did write our demos this way before DMAI existed. DMAI is simply a layer between the driver API and the application which tries to hide some of the complexity of driver APIs and provide a simpler API for applications to use and hiding some of the complex choices.
We see similar scenerious all over the industry; windows OS is an abstration of the hardware, MS Word abstracts things even further and for a very specific purpose (word processing) when in fact, the hardware is capable of much more (fexibility sacrificed). Choices need to be made to simplify user interface at the sacrifice of fexibility of what the hardware can do because it would be too difficult for all computer users to learn how to program to the hardware directly (e.g. no os, no word processor...).
Fortunately, embedded systems are simpler than desktop PCs and you do have the source code for the Linux kernel (drivers), DMAI and the demo applications. The closer you stay to the upper layers of software, the more you will be able to leverage these layers to make your life easier. If DMAI does not meet your goal but is close, I would probrably try to change it to support your required scenerious. If DMAI is way off in meeting your goals, then I may consider talking to the driver layer directly (what DMAI does for you) and bypassing DMAI altogether. I doubt you will need to modify the drivers, but you do have the source code if you need to do that as well.
I went into the code (Capture.c in of DMAI) and there is a flag "captureChainMode" only for DM365.
Is it recommended to set it to false and to do the resizing and the chroma conversion in my application?
Is there others considerations in this case?
Hey Joni, There are two options available to you - the resizer hardware supports outputting two different resolution images from a single source, and it can be configured in either 'chain' mode (where the source comes directly from the VPFE raw stream) or in single-shot-mode, where the source comes from SDRAM. The current driver doesn't support dual resizer outputs in chain mode i think (i've had to add support for this) but if you do the DDR mode, all of this is entirely possible. You can then setup the resizer to output two different outputs, and then trigger the resizer each and every time with your video input in ddr memory, and two video output locations in memory as well.
Jerry
Hi Joni,
I confirm that you can use the resizer multiple times using DMAI, but you must disable chaining in DMAI's source code, as already suggested. Also you have to configure IPIPE in One-shoot mode (kernel boot parameter). Then you can use DMAI's resize API to do what need. I didn't know that the resize can do multiple jobs while chained...
The DaVinciLSP_02_10_00_14.tar.gz has resizer A&B support already, what you need is a patch to DMAI.
Put the following code into Resize.c, and recompiled DMAI
When initialization, call Resizer_B_config() after Resizer_continous_config() was called
Then call Capture_get(), get Resizer_A output followed by Resizer_B output
/****************************************************************************** * Initialize & configure resizer B in on-the-fly (continous) mode ******************************************************************************/int Resizer_B_config(int rsz_fd, unsigned int width, unsigned int height){ unsigned int user_mode; struct rsz_channel_config rsz_chan_config; struct rsz_continuous_config rsz_cont_config; user_mode = IMP_MODE_CONTINUOUS; if(rsz_fd <= 0) { Dmai_err0("Cannot use resize device \n"); return NULL; } bzero(&rsz_cont_config, sizeof(struct rsz_continuous_config)); rsz_chan_config.oper_mode = user_mode; rsz_chan_config.chain = 1; rsz_chan_config.len = sizeof(struct rsz_continuous_config); rsz_chan_config.config = &rsz_cont_config; if (ioctl(rsz_fd, RSZ_G_CONFIG, &rsz_chan_config) < 0) { Dmai_err1("Error in getting channel configuration from resizer (%s)\n", strerror(errno)); return Dmai_EFAIL; } /* we can ignore the input spec since we are chaining. So only set output specs */ rsz_cont_config.output2.width = width; rsz_cont_config.output2.height= height; rsz_cont_config.output2.pix_fmt = IPIPE_YUV420SP; rsz_cont_config.output2.enable = 1; rsz_chan_config.len = sizeof(struct rsz_continuous_config); rsz_chan_config.config = &rsz_cont_config; if (ioctl(rsz_fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) { Dmai_err1("Error in setting resizer configuration (%s)\n", strerror(errno)); return Dmai_EFAIL; } Dmai_dbg0("Resizer initialized\n"); return Dmai_EOK;}
The ploblem is, when I use Resizer A&B simultaneously, I get jittering images, anybody can help?
It works for me, but I have to increase size of input buffer for second resizer output. The output is normally stored after first resizer output.
bufSize += 640*480*2; // add maximum size for second buffer
I found also the limitation about max size 640x480 for second rescaller output. E.g. in davinci_vpfe.c - there is 640x480 constant and there are also in other sources.
Thank to Thomas Lee for the post about simple enhancement of DMAI for using second resizer.
hi,I just want to resize the D1 to the cif format. But when I do this ,the error displayed as follows:
root@192.168.1.180:/mnt# ./myencoder
davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:108
davinci_previewer davinci_previewer.2: ipipe_set_preview_config
vpfe ccdc capture vpfe ccdc capture.1: IMP chained
vpfe ccdc capture vpfe ccdc capture.1: Resizer present
vpfe ccdc capture vpfe ccdc capture.1: hpitch = 720, vpitch = 576, bpp = 1
Starting ccdc_config_ycbcr...<7>
starting ccdc_reset...<7>
End of ccdc_reset...<7>
Starting ccdc_setwin...<7>ipipe_set_resizer, resizer - A enabled
DavinciDisplay DavinciDisplay.1: Before finishing with S_FMT:
layer.pix_fmt.bytesperline = 736,
layer.pix_fmt.width = 720,
layer.pix_fmt.height = 576,
layer.pix_fmt.sizeimage =635904
DavinciDisplay DavinciDisplay.1: pixfmt->width = 720,
layer->layer_info.config.line_length= 736
davinci_resizer davinci_resizer.2:
mode doesn't allow multiple instances
Failed to create hResize: Device or resource busy
Can you give me some ways for this problem?
weidong shi, You probably trying to open resizer more than once.
"mode doesn't allow multiple instances" shown when more instances are going to be opened (/drivers/char/imp_resizer.c)
Please open it at most once.
weidong shi hi,I just want to resize the D1 to the cif format. But when I do this ,the error displayed as follows: Can you give me some ways for this problem?
Running the encode demo which comes with the DVSDK with the proper options on top of DM365 EVM should do the resizing you need. No need to modify code or rebuild anything. (./encode -y 1 -r 352x288 -v test.mpeg4 ); the -y option is your input resolution, the -r defines your output resolution, if there is a difference resizer will be used to resize accordingly, see accompanying encode.txt for more details.
Hi, Thank you for your reply.
But actually I want to encode the stream to D1 format and meanwhile save it to disk as cif format .
So maybe I need to resize the video stream two times.
What should I do?
Could you give me some help?
How can I get Resizer_A output followed by Resizer_B output?
Could you explain to me clearly?
Thank you sincerely.
Hi Weidong Shi,
DM365 has two resizers RSZA and RSZB. Both of them work simultaneously to give output of different resolutions. LSP drivers for resizer support enabling both RSZA and RSZB.
DVSDK demos already support RSZB output, but if you want to change your code, please use refer to the following example code, where i am enabling RSZB (output2) in CONTINUOUS mode for output resolution of 352x288. The same is applicable for Single Shot mode also.
/* rsz_cont_config.output2.enable = 1; rsz_cont_config.output2.width = 352; rsz_cont_config.output2.height = 288; rsz_cont_config.output2.pix_fmt = IPIPE_YUV420SP;// rsz_cont_config.output2.pix_fmt = IPIPE_UYVY; */
Please note that the output of RSZB follows just after RSZA, so address for RSZB is not configured by application but is configured by kernel driver itself.
Regards,
Anshuman
Dear Anshuman:
Thank you for your support.
I do this configure in Resizer_continous_config(void) in Resizer.c and rebuild Dmai.
I suppose that when I call Capture_get(hCapture, &hCapBuf) in my application.
Do you mean that the RSZA output and RSZB output are both in hCapBuf ?
How can I get the second buffer output.
Weidong.Shi
Dear Weidong,
Yes, both resizer output are in the same buffer. RSZA output is followed by RSZB. You can get RSZB ouput by adding (RSZA_LineOffset*RSZA_Height*2) to get RSZB output when the output format is UYVY.