« clib/dvb_ts_lib/descriptors/parse_desc_short_event.c
↑ Summary
clib/dvb_ts_lib/descriptors/parse_desc_stream_identifier.c »
| 1 | /* | ||||||||||||||
| 2 | * parse_desc_short_smoothing_buffer.c | ||||||||||||||
| 3 | * | ||||||||||||||
| 4 | * Created by: si_desc.pl | ||||||||||||||
| 5 | * Created on: 20-May-2011 | ||||||||||||||
| 6 | * Author: sdprice1 | ||||||||||||||
| 7 | */ | ||||||||||||||
| 8 | |||||||||||||||
| 9 | |||||||||||||||
| 10 | // VERSION = 1.00 | ||||||||||||||
| 11 | |||||||||||||||
| 12 | /*=============================================================================================*/ | ||||||||||||||
| 13 | // USES | ||||||||||||||
| 14 | /*=============================================================================================*/ | ||||||||||||||
| 15 | |||||||||||||||
| 16 | #include <stdio.h> | ||||||||||||||
| 17 | #include <stdlib.h> | ||||||||||||||
| 18 | #include <unistd.h> | ||||||||||||||
| 19 | #include <string.h> | ||||||||||||||
| 20 | #include <errno.h> | ||||||||||||||
| 21 | #include <ctype.h> | ||||||||||||||
| 22 | #include <fcntl.h> | ||||||||||||||
| 23 | #include <inttypes.h> | ||||||||||||||
| 24 | |||||||||||||||
| 25 | #include "parse_desc_short_smoothing_buffer.h" | ||||||||||||||
| 26 | #include "descriptors/parse_desc.h" | ||||||||||||||
| 27 | |||||||||||||||
| 28 | /*=============================================================================================*/ | ||||||||||||||
| 29 | // CONSTANTS | ||||||||||||||
| 30 | /*=============================================================================================*/ | ||||||||||||||
| 31 | |||||||||||||||
| 32 | /*=============================================================================================*/ | ||||||||||||||
| 33 | // MACROS | ||||||||||||||
| 34 | /*=============================================================================================*/ | ||||||||||||||
| 35 | |||||||||||||||
| 36 | /*=============================================================================================*/ | ||||||||||||||
| 37 | // FUNCTIONS | ||||||||||||||
| 38 | /*=============================================================================================*/ | ||||||||||||||
| 39 | |||||||||||||||
| 40 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 41 | // | ||||||||||||||
| 42 | // short_smoothing_buffer_descriptor(){ | ||||||||||||||
| 43 | // descriptor_tag 8 uimsbf | ||||||||||||||
| 44 | // descriptor_length 8 uimsbf | ||||||||||||||
| 45 | // sb_size 2 uimsbf | ||||||||||||||
| 46 | // sb_leak_rate 6 uimsbf | ||||||||||||||
| 47 | // for (i=0;i<N;i++){ | ||||||||||||||
| 48 | // DVB_reserved 8 bslbf | ||||||||||||||
| 49 | // } | ||||||||||||||
| 50 | // } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | |||||||||||||||
| 53 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 54 | 0 | void print_short_smoothing_buffer(struct Descriptor_short_smoothing_buffer *ssbd, int level) | |||||||||||||
| 55 | { | ||||||||||||||
| 56 | struct list_head *item, *safe; | ||||||||||||||
| 57 | |||||||||||||||
| 58 | 0 | printf(" Descriptor: short_smoothing_buffer [0x%02x]\n", ssbd->descriptor_tag) ; | |||||||||||||
| 59 | 0 | printf(" Length: %d\n", ssbd->descriptor_length) ; | |||||||||||||
| 60 | |||||||||||||||
| 61 | 0 | printf(" sb_size = %d\n", ssbd->sb_size) ; | |||||||||||||
| 62 | 0 | printf(" sb_leak_rate = %d\n", ssbd->sb_leak_rate) ; | |||||||||||||
| 63 | 0 | bits_dump("DVB_reserved", ssbd->DVB_reserved, ssbd->descriptor_length, 2) ; | |||||||||||||
| 64 | 0 | } | |||||||||||||
| 65 | |||||||||||||||
| 66 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 67 | 0 | struct Descriptor *parse_short_smoothing_buffer(struct TS_bits *bits, unsigned tag, unsigned len) | |||||||||||||
| 68 | { | ||||||||||||||
| 69 | struct Descriptor_short_smoothing_buffer *ssbd ; | ||||||||||||||
| 70 | unsigned byte ; | ||||||||||||||
| 71 | int end_buff_len ; | ||||||||||||||
| 72 | |||||||||||||||
| 73 | 0 | ssbd = (struct Descriptor_short_smoothing_buffer *)malloc( sizeof(*ssbd) ) ; | |||||||||||||
| 74 | 0 | memset(ssbd,0,sizeof(*ssbd)); | |||||||||||||
| 75 | |||||||||||||||
| 76 | //== Parse data == | ||||||||||||||
| 77 | 0 | INIT_LIST_HEAD(&ssbd->next); | |||||||||||||
| 78 | 0 | ssbd->descriptor_tag = tag ; // already extracted by parse_desc() | |||||||||||||
| 79 | 0 | ssbd->descriptor_length = len ; // already extracted by parse_desc() | |||||||||||||
| 80 | 0 | ssbd->sb_size = bits_get(bits, 2) ; | |||||||||||||
| 81 | 0 | ssbd->sb_leak_rate = bits_get(bits, 6) ; | |||||||||||||
| 82 | |||||||||||||||
| 83 | 0 | end_buff_len = bits_len_calc(bits, -(ssbd->descriptor_length - 1)) ; | |||||||||||||
| 84 | 0 | ssbd->DVB_reserved[0] = 0 ; | |||||||||||||
| 85 | 0 | ▶ | for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_DVB_RESERVED_LEN); ++byte) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 86 | { | ||||||||||||||
| 87 | 0 | ssbd->DVB_reserved[byte] = bits_get(bits, 8) ; | |||||||||||||
| 88 | 0 | ssbd->DVB_reserved[byte+1] = 0 ; | |||||||||||||
| 89 | } | ||||||||||||||
| 90 | |||||||||||||||
| 91 | |||||||||||||||
| 92 | 0 | return (struct Descriptor *)ssbd ; | |||||||||||||
| 93 | } | ||||||||||||||
| 94 | |||||||||||||||
| 95 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 96 | 0 | void free_short_smoothing_buffer(struct Descriptor_short_smoothing_buffer *ssbd) | |||||||||||||
| 97 | { | ||||||||||||||
| 98 | struct list_head *item, *safe; | ||||||||||||||
| 99 | |||||||||||||||
| 100 | 0 | free(ssbd) ; | |||||||||||||
| 101 | 0 | } | |||||||||||||