1@TEMPLATE decoder_tmpl.c 2Decode With Drops Example 3========================= 4~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION 5This is an example utility which drops a series of frames, as specified 6on the command line. This is useful for observing the error recovery 7features of the codec. 8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION 9 10Usage 11----- 12This example adds a single argument to the `simple_decoder` example, 13which specifies the range or pattern of frames to drop. The parameter is 14parsed as follows: 15 16~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE 17if(argc!=4) 18 die("Usage: %s <infile> <outfile> <N-M|N/M>\n", argv[0]); 19{ 20 char *nptr; 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]); 26} 27~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE 28 29 30Dropping A Range Of Frames 31-------------------------- 32To drop a range of frames, specify the starting frame and the ending 33frame to drop, separated by a dash. The following command will drop 34frames 5 through 10 (base 1). 35 36 $ ./decode_with_drops in.ivf out.i420 5-10 37 38 39Dropping A Pattern Of Frames 40---------------------------- 41To drop a pattern of frames, specify the number of frames to drop and 42the number of frames after which to repeat the pattern, separated by 43a forward-slash. The following command will drop 3 of 7 frames. 44Specifically, it will decode 4 frames, then drop 3 frames, and then 45repeat. 46 47 $ ./decode_with_drops in.ivf out.i420 3/7 48 49 50Extra Variables 51--------------- 52This example maintains the pattern passed on the command line in the 53`n`, `m`, and `is_range` variables: 54 55~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_VARS 56int n, m, is_range; 57~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_VARS 58 59 60Making The Drop Decision 61------------------------ 62The example decides whether to drop the frame based on the current 63frame number, immediately before decoding the frame. 64 65~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE 66if((is_range && frame_cnt >= n && frame_cnt <= m) 67 ||(!is_range && m - (frame_cnt-1)%m <= n)) { 68 putc('X', stdout); 69 continue; 70} 71putc('.', stdout); 72fflush(stdout); 73~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE 74