Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

De-interlacing issue using IPP

bo1ka
Beginner
1,288 Views
Hello
I need to deinterlace a PAL captured video content that is in the following form:
1 (odd) line field 1
2 (even) line filed 2
3 (odd) line field 1
4 (even) line field 2
....
565 (odd) line field 1
566 (even) line field 2
---------- this is one video frame (820 width and 566 height)
and so on
Which deinterlacing function do you recommend me to use for best video results?
I tried to use "ippiDeinterlaceFilterCAVT_8u_C1R" but the syntax and documentation does not say exactly how the input image is represented in memory. Do I need to provide a pointer to a frame that is in the form describer above (odd and even lines are weaved) or shoud the input image be represented in memory in the form of first the odd lines and then the even lines. Also I do not understand what is the effect of the threshold parameter in the generation of the output image.
Tank you in advance.
0 Kudos
5 Replies
Naveen_G_Intel
Employee
1,288 Views

Hi,

Thereis an example to show usage of ippiDeinterlaceFilterCAVT_8u_C1R.

Download IPP sample code and refer to folder : -\ipp-samples\audio-video-codecs\codec\color_space_converter

Regards,

Naveen Gv

0 Kudos
bo1ka
Beginner
1,288 Views
Hi,
I have already seen those examples, the thing is that they are not intuitive. I was hoping for o more simple and direct answer on this forum. I have used a lot of IPP functions in my code, which are welldocumentedand explained with examples directly in the documentation files (ippiman.pdf or ippsman.pdf) but for some unknown reason this is not valid for the deinterlacing functions.
ForippiDeinterlaceFilterCAVT_8u_C1R the documentation states that it performs deinterlacing on a two-filed image. But how are the two fileds maped in the memory, as this function takes a pSrc pointer to the sorce image without explaining the memory sequence for the two fields.
0 Kudos
Chao_Y_Intel
Moderator
1,288 Views

Hello,

This is the comment from the owner on the function: In ippiDeinterlaceFilterCAVT function, for the even line, it copys data from source to the destination, For odd line, it use the filter defined as bellow:

line 0: copy src to dst

line 1: filter...

line 2: copy src to dst

line 3: the line 3 value is computed by:

int edge2 = EDGE(s1, s3, s5);

int value = INTERP(s0, s2, s4, s6);

if (ABS(edge2) < thresh) {

value = IPP_MIN(value, IPP_MAX(s2, s4));

value = IPP_MAX(value, IPP_MIN(s2, s4));

}

dst= value;

,where:

s0 is a pointer to the line 0 of src, S1 is line 1 of src, s2 line 2 of src, etc.

#define ABS(x) ((x) < 0 ? -(x) : (x))

#define EDGE(a, b, c) (int)(- 4*a + 8*b - 4*c);

#define INTERP(a, b, c, d) (int)((a + 7*b + 7*c + d + edge2 + 8) >> 4)

line 4: copy src to dst

line 5: filter like line 3.


Thanks,
Chao

0 Kudos
j_miles
Beginner
1,288 Views
So the answer to the question of how the fields are mapped in memory seems to be that the fields are interleaved with the first line/row being from the first field (even) and the second line/row from the second field (odd) and so on. The fields are stored as top-down although it probably makes no real difference for this algorithm if they were flipped as in bottom-up.

Your sampled resolution of 820x566 seems uncommon to me - where does it stem from?


Chao:

I can only echo the sentiment that the deinterlacing functionality needs update of the documentation. This thread only highlights the issue.

What is the "filter" applied for line 1? I assume that the same will apply to the last (odd) line being filtered?


- Jay
0 Kudos
bo1ka
Beginner
1,288 Views
Thank you all for the clarifications. As a response to the previous post, the resulting resolution is related mainly to the sampling that I make and also on other preprocessing (filtering) that I do. In the mean time I have managed to have a working IPP deinterlacer,using the only function that has no knowledge on the field type (ippiDeinterlaceFilterTriangle_8u_C1R()) for which I concluded that the fields were interleaved (after serveral hours of trial end error tests). My written deinterlacer (which performs intra-field directional interpolation) was much worse than the one I used from IPP.Do you think that the other deinterlacing functions would give much better results? And related to them, if the fields are interleaved as it is said in the previous post, then how come some of the IPP deinterlacing fuctions have a parameter calledfieldNum? I would redescribe my problem again.
1. I have 820 samples / line.
2. I have 566 lines.
3. I identify the field type and pile up the lines in the following form:
line 0: o o o o o o o . . . o o o (820 o's)
line 2: e e e e e e e . . . e e e (820 e's)
line 3: o o o o o o o . . . o o o (820 o's)
.
.
.
line 565: o o o o o o . . . o o o (820 o's)
line 566: e e e e e e . . . e e e (820 e's)
where: "o" means "odd" and "e" means "even"
Applying "ippiDeinterlaceFilterTriangle_8u_C1R"was simple:
roiSize.width = 820;
roiSize.height = 566;
ippsZero_8u(pDst,roiSize.width *roiSize.height);
ippiDeinterlaceFilterTriangle_8u_C1R(pSrc,roiSize.width, pDst,roiSize.width, roiSize, 128,IPP_LOWER | IPP_UPPER | IPP_CENTER);
where pSrc was a pointer to the start od the interleaved imaged buffer andpDst was a pointer to a buffer of the same size as the input image buffer.
Now how can Iadapt to this scenario and apply "ippiDeinterlaceMedianThreshold_8u_C1R"or "ippiDeinterlaceMotionAdaptive_8u_C1"? (if these to give better results)
And as a last remark, to optimize my code, do i need to reset the destination image buffer to zero all the time before I call the deinterlacing function.
Thank you all for your time. I appreciate it a lot.
0 Kudos
Reply