Log in

View Full Version : Feature Req.: Conditional bool functions for Frame props like AR, FO, lacing, IPB etc


scharfis_brain
16th December 2005, 13:03
In order to create fully automatic AVS script functions working properly with DVB MPEG streams I need functions for the AVS conditional environment to judge framewise whether a frame
- is an I, B, or B frame
- is encoded Interlaced or Progressive
- has an aspect ratio of 4x3 or 16x9 (maybe 1:1 & 2.21 too, but not necessary)
- is TFF or BFF

would this be possible to implement into DGDecode.dll?

I am asking this because of this question:
http://forum.doom9.org/showthread.php?p=752043#post752043

Because it would be an easy thing to reecode a Stream with dynamic AR (switching between 4x3 and 16x9) if I would have such a function like is16x9(d2v="xxx.d2v",clip x) available.
Where String d2v presents the inputted MPEG Stream and Clip x is used to get the actual frame number.

tritical
17th December 2005, 11:37
The biggest problem with implementing conditional filtering based off things like frame type (I, P, B), Interlaced vs Progressive, etc... is that those properties apply to frames in the encoded stream. However, if there are rff flags, then the stream passed to avisynth from dgdecode would not have the original frames, but could have frames that are combinations of frames with different properties. What would you do in such a case? Also, some of the properties are not per frame, but are per GOP or per sequence header. Thus, the only safe way to do it would be to require field operation=Ignore pulldown flags, and then, after the conditional processing, do the necessary pulldown. Something like:

mpeg2source() # with field operation = ignore pulldown flags
isAspectRatio(d2v="")
isFrameType(d2v="")
isInterlaced(d2v="")
doPulldown(d2v="")

It would also be required that the input clip to the functions is not altered in any way that would effect field/frame positioning, though there could be an option to support triming frames. The above type operations would be easy to implement (assuming the mentioned restrictions) since most of that info is now included per gop or per frame in the d2v file (frametype/interlaced/progressive sequence/tff/open or closed gop). The exception is aspect ratio which is currently stored only at the top of the d2v file. IIRC, aspect ratio information is included in the sequence header, so ideally it should be stored on a per line basis in the d2v file, in the same way as the the color_coefficients value currently is, if an isAspectRatio(d2v="") type function is to work. The fact that the d2v now includes most of the information that is needed for conditional filtering eliminates one of the previous major obstacles to this which was how to effectively get the information to avisynth filters.

Didée
17th December 2005, 20:10
I'm fully with scharfis_brain here. Availability of the diverse stream/frame properties could be of big value.

I.e., one thing that can be seen very often in DVB broadcasts (and it's driving me nuts!) is that all frames show artefacts typical for their frametype, like:
- I-frames are full of hi-frequency noise (dot patterns)
- P-frames are sharp /w detail, Bframes are soft w/o detail, and so the stream flickers along: "detail-nodetail-nodetail-detail-nodetail-nodetail-noise-nodetail-nodetail-detail..."

If frametype was accessable in Avisynth, it would open some interesting possibilities.
It's obviously not straightforward how to do it - deinterlacing, IVTC, decimating and whatnotelse would/could throw it off. But then, this is something the user would have to be aware of.

Perhaps this really aims at Avisynth 3.0, and the proposed "frame metadata"?