UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
test_bitstream.c File Reference
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#include "debug.h"
#include "memory.h"
#include "bitstream.h"
#include "test_bitstream.h"
Include dependency graph for test_bitstream.c:

Go to the source code of this file.

Macros

#define BUFSIZE   10
 

Functions

int test_bitstream (void)
 

Macro Definition Documentation

◆ BUFSIZE

#define BUFSIZE   10

Definition at line 44 of file test_bitstream.c.

Referenced by test_bitstream().

Function Documentation

◆ test_bitstream()

int test_bitstream ( void )

Definition at line 46 of file test_bitstream.c.

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
#define BUFSIZE

References bs_attach(), bs_create(), bs_destroy(), bs_put(), and BUFSIZE.

Here is the call graph for this function: