1 @TEMPLATE decoder_tmpl.c
2 Decode With Drops Example
3 =========================
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
5 This is an example utility which drops a series of frames, as specified
6 on the command line. This is useful for observing the error recovery
8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
12 This example adds a single argument to the `simple_decoder` example,
13 which specifies the range or pattern of frames to drop. The parameter is
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
18 die("Usage: %s <infile> <outfile> <N-M|N/M>\n", argv[0]);
21 n = strtol(argv[3], &nptr, 0);
22 m = strtol(nptr+1, NULL, 0);
23 is_range = *nptr == '-';
24 if(!n || !m || (*nptr != '-' && *nptr != '/'))
25 die("Couldn't parse pattern %s\n", argv[3]);
27 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
30 Dropping A Range Of Frames
31 --------------------------
32 To drop a range of frames, specify the starting frame and the ending
33 frame to drop, separated by a dash. The following command will drop
34 frames 5 through 10 (base 1).
36 $ ./decode_with_drops in.ivf out.i420 5-10
39 Dropping A Pattern Of Frames
40 ----------------------------
41 To drop a pattern of frames, specify the number of frames to drop and
42 the number of frames after which to repeat the pattern, separated by
43 a forward-slash. The following command will drop 3 of 7 frames.
44 Specifically, it will decode 4 frames, then drop 3 frames, and then
47 $ ./decode_with_drops in.ivf out.i420 3/7
52 This example maintains the pattern passed on the command line in the
53 `n`, `m`, and `is_range` variables:
55 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_VARS
57 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_VARS
60 Making The Drop Decision
61 ------------------------
62 The example decides whether to drop the frame based on the current
63 frame number, immediately before decoding the frame.
65 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE
66 if((is_range && frame_cnt >= n && frame_cnt <= m)
67 ||(!is_range && m - (frame_cnt-1)%m <= n)) {
73 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE