Preface - Teasers - Enhanced Terminology - Reference - Encoding of DVD & Bluray Content - About Audio - Recovering The Camera Shots
Basic Primitives - Pulldown Primitives - Advanced Interpolations - Seen In The Wild, Repairing Video


tokens: Letters or numbers that represent instances of pictures, halfpics, scans, and frames in notations and in diagrams.
Example: AB denotes a stream having tokens A B etc. which represent, for pps streams: pictures, or for hps streams: successive top halfpics, or for sps streams: successive 1st scans.
Example: ab denotes a stream having tokens a b etc. which represent, for hps streams: successive bottom halfpics, or for sps streams: successive 2nd scans.
Example: AaBb denotes a stream of 4 halfpics that alternate top halfpic - bottom halfpic etc.
Example: AbCd denotes a stream of 4 scans that alternate 1st scan - 2nd scan etc.
Example: (A+a)(B+b) depicts a stream of 2 pictures: (A+a) (B+b), woven from halfpics: A a B b, and having A-to-a and B-to-b intervals of zero, and (A+a)-to-(B+b) intervals of 1/pps seconds.
Example: (A+b)(C+d) depicts a stream of 2 quasi pictures: (A+b) (C+d), interlaced from scans: A b C d, and having A-to-b and C-to-d intervals of 1/sps seconds, and (A+b)-to-(C+d) intervals of 2/sps seconds.
Example: [A+a][B+b] depicts a stream of 2 frames: [A+a] [B+b], containing encoded versions of (A+a) (B+b), and having [A+a]-to-[B+b] intervals of 1/fps seconds.
Example: [A+b][C+d] depicts a stream of 2 frames: [A+b] [C+d], containing encoded versions of (A+b) (C+d), and having [A+b]-to-[C+d] intervals of 2/fps seconds.

Tokens that are not in stride ranges can be of any type, letters and/or numbers, and in any order. In contrast, tokens that appear within ranges within compact stride notations must be in a predictable letter and/or number order (for example, A-Z a-z Aa-Zz Ab-Yz 0-9 etc.).
Example: If in an hps stream, (Aa-Dd)(AaBbBcCdDd) is the conventional way to represent 2-3-2-3 pulldown.
Example: If in an hps stream, (1-8)(1234365878) also represents 2-3-2-3 pulldown.
Example: If in an hps stream, (QuC2jx6N)(QuC2CxjN6N), though very strange looking, also represents 2-3-2-3 pulldown but can't be represented in compact notation.

? token: An anonymous token used in comparisons, that exists, but otherwise does not participate in the comparison, a placeholder. For example, to unconditionally drop the 1st 2 elements of a stream,
(AA..)(..)
doesn't work because it only matches the 1st 2 elements if they have the same content but not if they have differing content, and
(AB..)(..)
doesn't work because it only matches the 1st 2 elements if they have differing content but not if they have the same content. But
(?A..)(..) or (A?..)(..) or (??..)(..)
works as expected.

simple drops: Any import tokens not appearing in the export stride are dropped from the exported stream.

simple repeats: Any tokens repeated in the export stride are added to the exported stream at the points where they are repeated.

__ operator: Underline-underline: __ , is an operator that passes a stream from left to right.

( ) delimiters: Pairs of parentheses: ( )( ) , differentiate an import stride (left) from an export stride (right).
Example: For 11x2-3-11x2-3 pulldown (aka Euro pulldown),
   ____________________________________________________ import stride
  /                                                /______________________________________________________ export stride
 /                                                //                                                  /
(AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXx)(AaBbCcDdEeFfGgHhIiJjKkLlLmMnNoOpPqQrRsStTuUvVwWxXx)   ...full stride notation
(Aa............................................Xx)(Aa....................LlLm....................WxXx)   ...sparse stride notation
                                           (Aa-Xx)(Aa-LlLm-WxXx)                                         ...compact stride notation
                                           (Aa-Xx)(Aa-Ll Lm-Wx Xx)                                       ...added 'readablity' spaces are ignored
Aa-Xx Aa-Ll and Lm-Wx are stride ranges.

Recommended range formats: Though both of the following denote the same stride, the one on the left is easier to comprehend and is preferred due to its consistency.
(Aa-Xx)(Aa-Ll Lm-Wx Xx)   ...preferred              (Aa-Xx)(Aa-Ll L mM-xX x)
       (Aa-Ll             ...a range of pictures           (Aa-Ll              ...a range of pictures
              Lm-Wx       ...a range of pictures                  L            ...a lone top halfpic
                    Xx)   ...ending picture                         mM-xX      ...a range of reverse-order halfpics
                                                                          x)   ...a lone bottom halfpic

'look' notation & 'look' scanner. The 'look' notation expands on and generalizes the simple (import)(export) notation above.
The entire imported stream passes, from beginning to end, through a 'look' scanner controlled by a 'look' notation interpreted from left to right. The 'look' scanner 'watches' the stream (as though watching a passing parade).

The 'look' notation
1, 'tells' the 'look' scanner what to 'look' for, and
2, 'tells' the 'look' scanner what to do when the scanner 'sees' what it's told to 'look' for, and
3, optionally 'tells' the 'look' scanner what to do when the scanner doesn't 'see' what it's told to 'look' for.

The terms of 'look' notations are delimited by parentheses. Allowed 'look' notations [note 1] are
(look)(seen)                                 ...note: 2 terms
(look)(seen)(unseen)                         ...      3 terms
(look)(firstseen)(seen)(finalseen)           ...      4 terms
(look)(firstseen)(seen)()                    ...      4 terms
(look)()(seen)(finalseen)                    ...      4 terms
(look)(firstseen)(seen)(finalseen)(unseen)   ...      5 terms
(look)(firstseen)(seen)()(unseen)            ...      5 terms
(look)()(seen)(finalseen)(unseen)            ...      5 terms
[note 1] The words "look" "firstseen" "seen" "finalseen" & "unseen" are surrogates (not the actual words) for the actual scanner notations that you supply.

Tip: Note how the number of terms is an important part of the scanner format and how the scanner works.

(look) is the import stream pattern (i.e. the template) to look for.
(seen) specifies operations to run when (look) succeeds [note 2]. (seen) can be any chain of primatives (including nested 'look' notations) without restriction or limit.
(unseen) specifies operations to run when (look) fails. (unseen) can be any chain of primatives (including nested 'look' notations) without restriction or limit.
Scene change is built into the architecture, and (firstseen) and (finalseen) specify operations to run on scene changes [note 2]. (firstseen) can be any chain of primatives (including nested 'look' notations) without restriction or limit. (finalseen) can be any chain of primatives (including nested 'look' notations) without restriction or limit. For 4-factor and 5-factor 'look's, both (firstseen) and (finalseen) must be present but either of them can be empty, i.e. () .

[note 2] IMPORTANT: Upon each (look) success, the scanner will run one of these: (seen) or (firstseen) or (finalseen), but not more than one.
Upon first (look) success, the scanner runs (firstseen) unless (firstseen) is either missing or empty. If (firstseen) is either missing or empty, the scanner falls back and runs (seen), instead.
Upon last (look) success, the scanner runs (finalseen) unless (finalseen) is either missing or empty. If (finalseen) is either missing or empty, the scanner falls back and runs (seen), instead.

When a 'look' pass doesn't 'see' the entire (look) pattern at all,
1: The 1st (look) element (a single picture or single halfpic, only) is exported, unchanged, and
2: The import stream pointer is incremented by 1, and
3: The entire 'look' notation is repeated (until the import stream ends).

When a 'look' pass 'sees' the (look) pattern,
1: The entire (seen) stride or (firstseen) stride or (finalseen) stride is exported, and
2: The import stream pointer is incremented by the (look) stride length, and
3: The entire 'look' notation is repeated (until the import stream ends).
In addition, any added notation inside the (seen)-term or (firstseen)-term or (finalseen)-term is also run [note 3].

[note 3] Accummulation of successful (look) patterns allows nested 'look' notations to add to (or subtract from) the outer (seen) stride or (firstseen) stride or (finalseen) stride. Nesting 'look' notations plus (optionally) other primative notations can extremely complex processess that are nonetheless fairly easy to read -- and all without FFmpeg-style 'select' filters. For a practical example, see "Seen In The Wild, Repairing Video", '"ALL ABOUT EVE" Bluray, UPC 024543706878, "The Secret of SARAH SIDDONS", 00390.m2ts'.

TIP: (look) patterns and the export strides produced by (seen) terms can be (and often will be) of differring lengths so that the length and rate of import streams and export streams differ.

.. operator: Two dots: .. , is an operator that, if preceeding a pattern of tokens: denotes an entire stream from its beginning to the point at which the token pattern is encountered, or if following a token: denotes an entire stream following the token to the end of the stream, or if there is no token: denotes an entire stream from beginning to end.
Example: ..AaBbBcCdDd denotes a stream up to and including the 1st encountered 2-3-2-3 pulldown pattern.
Example: A.. denotes the 1st picture (or 1st halfpic or 1st scan) of a stream plus the remaining stream to the stream's end -- note that (A..)(AA..) denotes an export stream that repeats solely the 1st token of the import stream (regardless of stride, if any).
Example: .. denotes an entire stream.

§ operator: The section symbol: § , is an operator that interpolates, either temporally or spatially, 2 pictures or halfpics.

^ alias: The carat symbol: ^ , is an alias that 'reaches' beyond the current import stride to access the previous import stride. The details below show how '^' can be used when synthesizing new pictures and halfpics.
If the streams are pps streams, '^' is replaced by the value of the ending picture of the previous import stride. For example,
NOTATION: (A)(^§A A)
                     +-------1st stride------->+-------2nd stride------->+-------3rd stride------->
       NOTATION:     (^§A________)(A__________)(^§A________)(A__________)(^§A________)(A__________)..

import halfpics:     (A_______________________)(B_______________________)(C_______________________)..   ...#pps
                      :`.¸¸¸¸¸¸¸¸               :`.¸¸¸¸¸¸¸¸               :`.¸¸¸¸¸¸¸¸                   ...step 1: copy 'A' 'B' 'C' ..
                      `.         `.             `.         `.             `.         `.
                     (^§A________)(A__________)(^§B________)(B__________)(^§C________)(C__________)..   ...#x2pps

import halfpics: ?   (A_______________________)(B_______________________)(C_______________________)..   ...#pps
                  `.   `.¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸   `.¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸   `.¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸      ...step 2: replace '^'s
                    `.                        `.                        `.                        `.
export pictures:     (?§A________)(A__________)(A§B________)(B__________)(B§C________)(C__________)..   ...#x2pps
If the streams are hps streams and '^' is in the 1st halfpic, '^' is replaced by the 1st halfpic of the ending picture of the previous import stride.
Author comment: I've not found a use for '^' in the 1st halfpic, but perhaps someone else will.
If the streams are hps streams and '^' is in the 2nd halfpic, '^' is replaced by the 2nd halfpic of the ending picture of the previous import stride. For example,
NOTATION: (Ab)(A ^§b)
                     +-------1st stride------->+-------2nd stride------->+-------3rd stride------->
       NOTATION:     (A__________)(^§b________)(A__________)(^§b________)(A__________)(^§b________)..

import halfpics:     (A__________)(b__________)(C__________)(d__________)(E__________)(f__________)..   ...#hps
                      :            :            :            :            :            :                ...step 1: copy 'A' 'b' 'C' 'd' 'E' 'f' ..
                      :            `.           :            `.           :            `.
                     (A__________)(^§b________)(C__________)(^§d________)(E__________)(^§f________)..   ...#hps

import halfpics: ?   (A__________)(b__________)(C__________)(d__________)(E__________)(f__________)..   ...#hps
                  `.¸¸¸¸¸¸¸¸¸¸¸¸¸   `.¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸   `.¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸   `.¸¸¸¸¸¸¸¸¸¸    ...step 2: replace '^'s
                                 `.                        `.                        `.
export halfpics:     (A__________)(?§b________)(C__________)(b§d________)(E__________)(d§f________)..   ...#hps
As indicated by the '?'s above, there's a problem: the 1st stride has no previous stride! The problem can be overcome via a resolved (firstseen) term. In the example that follows, the (firstseen) term is resolved to an interpolated bobbing of the 'A' & 'b' halfpics: (A A§b), followed by an active (seen) term: (A ^§b), followed by an empty (finalseen) term: ().
NOTATION: (Ab)(A A§b)(A ^§b)()
                     +-------1st stride------->+-------2nd stride------->+-------3rd stride------->
       NOTATION:     (A__________)(A§b________)(A__________)(^§b________)(A__________)(^§b________)..

import halfpics:     (A__________)(b__________)(C__________)(d__________)(E__________)(f__________)..   ...#hps
                      :`.¸¸¸¸¸¸¸¸  :            :            :            :            :                ...step 1: copy 'A' 'b' 'C' 'd' 'E' 'f' ..
                      :          `.`.           :            `.           :            `.
                     (A__________)(A§b________)(C__________)(^§d________)(E__________)(^§f________)..   ...#hps

import halfpics:     (A__________)(b__________)(C__________)(d__________)(E__________)(f__________)..   ...#hps
                                    `.¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸   `.¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸   `.¸¸¸¸¸¸¸¸¸¸    ...step 2: replace '^'s
                                                           `.                        `.
export halfpics:     (A__________)(A§b________)(C__________)(b§d________)(E__________)(d§f________)..   ...#hps

$ alias: The dollar symbol: $ , is an alias that 'reaches' beyond the current import stride to access the next import stride.
If the streams are pps streams, '$' is replaced by the value of the beginning picture of the next import stride. For example,
NOTATION: (A)(A A§$)
                       +--next to final stride-->+------final stride------>
       NOTATION:     ..(A__________)(A§$________)(A__________)(A§$________)

import pictures:     ..(Y_______________________)(Z_______________________)     ...#hps
                        :`.¸¸¸¸¸¸¸¸               :`.¸¸¸¸¸¸¸¸                   ...step 1: copy ..'Y' 'Z'
                        :          `.             :          `.
                     ..(Y__________)(Y§$________)(Z__________)(Z§$________)     ...#hps

import pictures:     ..(Y_______________________)(Z_______________________) ?   ...#hps
                                          ¸¸¸¸¸¸.´                  ¸¸¸¸¸¸.´    ...step 2: replace '$'s
                                        .´                        .´
export halfpics:     ..(Y__________)(Y§Z________)(Z__________)(Z§?________)     ...#hps
If the streams are hps streams and '$' is in the 1st halfpic, '$' is replaced by the 1st halfpic of the next import stride. For example,
NOTATION: (Ab)(A§$ b)
                       +--next to final stride-->+------final stride------>
       NOTATION:     ..(A§$________)(b__________)(A§b________)(b__________)

import halfpics:     ..(W__________)(x__________)(Y__________)(z__________)     ...#hps
                        :            :            :            :                ...step 1: copy ..'W' 'x' 'Y' 'z'
                        :            :            :            :
                     ..(W§$________)(x__________)(Y§$________)(z__________)     ...#hps

import halfpics:     ..(W__________)(x__________)(Y__________)(z__________) ?   ...#hps
                             ¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸.´     ¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸.´    ...step 2: replace '$'s
                           .´                        .´
export halfpics:     ..(W§Y________)(x__________)(Y§$________)(z__________)     ...#hps
If the streams are hps streams and '$' is in the 2nd halfpic, '$' is replaced by the 2nd halfpic of the final picture of the next import stride.
Author comment: I've not found a use for '$' in the 2nd halfpic, but perhaps someone else will.

As in the case of a '^' in the 1st picture of an export stride, '$' in the final picture has a problem: the final stride has no next stride! The problem can be overcome via a resolved (lastseen) term. In the example that follows, the (lastseen) term is resolved to an interpolated bobbing of the 'A' & 'b' halfpics: (A§b b), preceeded by an active (seen) term: (A§$ b), preceeded by an empty (firstseen) term: ().
NOTATION: (Ab)()(A§$ b)(A§b b)
                       +--next to final stride-->+------final stride------>
       NOTATION:     ..(A§$________)(b__________)(A§b________)(b__________)

import halfpics:     ..(W__________)(x__________)(Y__________)(z__________)   ...#hps
                        :            :            :    ¸¸¸¸¸¸.´:              ...step 1: copy ..'W' 'x' 'Y' 'z'
                        :            :            :  .´        :
                     ..(W§$________)(x__________)(Y§z________)(z__________)   ...#hps

import halfpics:     ..(W__________)(x__________)(Y__________)(z__________)   ...#hps
                             ¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸.´                            ...step 2: replace '$'s
                           .´
export halfpics:     ..(W§Y________)(x__________)(Y§z________)(z__________)   ...#hps