On Thu, 2001-11-15 at 15:54, Michael Zayats wrote: > Hello all, > > I am now customizing bttv v4l1 driver for my custom needs and have a problem > distinguishing odd and even fields. I can not trust bt8x8 flags because of > switching cameras that I do after each frame with a custom multiplexer. As I > learned from Justin, the halfline of "almost" black pixels is being placed > by camera (not bt) to mark odd or even field (don't remember which exactly). > Because I do camera switch, I cannot allow both odd and even fields to > appear for the same camera (it's 288 in height, thus only one field > required), otherwise it will jump one pixel lower or higher (odd and even > fields). > AFAIK, odd and even fields look like: (b = black) ODD: bbbbxxxx xxxxxxxx ... xxxxxxxx xxxxxxxx EVEN: xxxxxxxx xxxxxxxx ... xxxxxxxx xxxxbbbb Both half "b" lines are due to the time the cathodic beam (is that right english?) takes to go back to the top of the screen so that it can start drawing the next (odd) field. Strictly speaking, you get a "1/2 pixel" flickering, not 1 pixel. As you say, cams generate PAL signals this way, it has nothing to do with the decoder. BT8x8 chips can detect the field parity, but several time (= consecutive fields) is required in advance so that it stabilises (see chip specs). This is not possible when switching cameras, since there is never time enought to stabilise (provided you switch fast). Well, it is possible if you use phase syncronised cams., which I believe is not your case. > back to the problem I should distinguish odd and even fields without using > bt flags. > The black line placed by camera is a problematic solution becuase the camera > might work in darkness that will cause all fields to seem of the same > parity. > > Nevertheless bt distinguishes them someway even in darkness, what else > symptom I might get about parity of the field? > We used to do SW field detection (ie "looking for" half black lines), but it did not work very fine (not at all at night time!). Since we cannot trust BT878`s "odd" field in status register, we added a LM1881 (a sync detector) chip in our board design and wired its ODD/#EVEN output directly to one of the GPIO pins. This HW info IS reliable. Take into account that if you intend to switch inputs and just consider, say, even fields, your worst-case switching speed gets worse (you get fields each 40 ms. instead 20 ms. -PAL, of course-). What we do is take any parity and if frames are odd, mark them at interrupt time and interpolate (linear algorithm, just the mean of both upper and lower pixels) them so that they "ressemble" even ones. Hope this all helps, Miguel