UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
test_bitstream.c
Go to the documentation of this file.
1/*
2 * FILE: test_bitstream.c
3 * AUTHORS: Colin Perkins
4 *
5 * Copyright (c) 2003-2004 University of Southern California
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, is permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the Computer Science
19 * Department at University College London
20 * 4. Neither the name of the University nor of the Department may be used
21 * to endorse or promote products derived from this software without
22 * specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#include "config.h"
37#include "config_unix.h"
38#include "config_win32.h"
39#include "debug.h"
40#include "memory.h"
41#include "bitstream.h"
42#include "test_bitstream.h"
43
44#define BUFSIZE 10
45
47{
49 u_char *buffer;
50 int buflen;
51
52 printf
53 ("Testing bitstreams ....................................................... ");
54 fflush(stdout);
55
56 buffer = malloc(BUFSIZE);
57 if (buffer == NULL) {
58 printf("FAIL\n");
59 return -1;
60 }
61 buflen = BUFSIZE;
62
63 bs_create(&bs);
64 bs_attach(bs, buffer, buflen);
65 bs_put(bs, 0x0f, 4);
66 bs_put(bs, 0x01, 1);
67 bs_put(bs, 0x02, 3);
68 bs_put(bs, 0xa8, 8);
69 bs_put(bs, 0xff, 1);
70 if (buffer[0] != 0xfa) {
71 printf("FAIL\n");
72 printf(" buffer[0] = 0x%02x\n", buffer[0]);
73 return -1;
74 }
75 if (buffer[1] != 0xa8) {
76 printf("FAIL\n");
77 printf(" buffer[1] = 0x%02x\n", buffer[1]);
78 return -1;
79 }
80 if (buffer[2] != 0x80) {
81 printf("FAIL\n");
82 printf(" buffer[2] = 0x%02x\n", buffer[2]);
83 return -1;
84 }
85 bs_put(bs, 0x01, 7);
86 if (buffer[2] != 0x81) {
87 printf("FAIL\n");
88 printf(" buffer[2] = 0x%02x\n", buffer[2]);
89 return -1;
90 }
91
92 bs_destroy(&bs);
93
94 printf("Ok\n");
95 return 0;
96}
int bs_put(bitstream_t *b, u_char bits, uint8_t nbits)
Definition bitstream.c:50
int bs_attach(bitstream_t *b, u_char *buf, int blen)
Definition bitstream.c:41
struct s_bitstream bs
int bs_create(bitstream_t **ppb)
Definition bitstream.c:23
int bs_destroy(bitstream_t **ppb)
Definition bitstream.c:35
int test_bitstream(void)
#define BUFSIZE