Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use 64bit (long long) for position offset

  • Loading branch information...
commit 970c9e4d34d9345c0f2fe61dbcacf9912ed5c809 1 parent 3390fef
@x42 authored
View
19 src/decoder.c
@@ -48,12 +48,6 @@
/** for upto 16-bit binary constants, MSB first */
#define B16(dmsb,dlsb) (((unsigned short)B8(dmsb)<<8) + B8(dlsb))
-/** for upto 32-bit binary constants, MSB first */
-#define B32(dmsb,db2,db3,dlsb) (((unsigned long)B8(dmsb)<<24) \
- + ((unsigned long)B8(db2)<<16) \
- + ((unsigned long)B8(db3)<<8) \
- + B8(dlsb))
-
/** turn a numeric literal into a hex constant
*(avoids problems with leading zeroes)
* 8-bit constants max value 0x11111111, always fits in unsigned long
@@ -77,16 +71,9 @@
/** for upto 16-bit binary constants, MSB first */
#define B16(dmsb,dlsb) (((unsigned short)B8(dmsb)<<8) + B8(dlsb))
-/** for upto 32-bit binary constants, MSB first */
-#define B32(dmsb,db2,db3,dlsb) (((unsigned long)B8(dmsb)<<24) \
- + ((unsigned long)B8(db2)<<16) \
- + ((unsigned long)B8(db3)<<8) \
- + B8(dlsb))
-
/* Example usage:
* B8(01010101) = 85
* B16(10101010,01010101) = 43605
- * B32(10000000,11111111,10101010,01010101) = 2164238933
*/
#include <stdio.h>
@@ -115,7 +102,7 @@
printf("\n"); \
}
-static void parse_ltc(LTCDecoder *d, unsigned char bit, int offset, long int posinfo) {
+static void parse_ltc(LTCDecoder *d, unsigned char bit, int offset, ltc_off_t posinfo) {
int bit_num, bit_set, byte_num;
if (d->bit_cnt == 0) {
@@ -238,7 +225,7 @@ static void parse_ltc(LTCDecoder *d, unsigned char bit, int offset, long int pos
}
}
-static inline void biphase_decode2(LTCDecoder *d, int offset, long int pos) {
+static inline void biphase_decode2(LTCDecoder *d, int offset, ltc_off_t pos) {
if (d->snd_to_biphase_state == d->biphase_prev) {
d->biphase_state = 1;
parse_ltc(d, 0, offset, pos);
@@ -251,7 +238,7 @@ static inline void biphase_decode2(LTCDecoder *d, int offset, long int pos) {
d->biphase_prev = d->snd_to_biphase_state;
}
-void decode_ltc(LTCDecoder *d, ltcsnd_sample_t *sound, int size, long int posinfo) {
+void decode_ltc(LTCDecoder *d, ltcsnd_sample_t *sound, int size, ltc_off_t posinfo) {
int i;
for (i = 0 ; i < size ; i++) {
View
4 src/decoder.h
@@ -43,9 +43,9 @@ struct LTCDecoder {
LTCFrame ltc_frame;
int bit_cnt;
- long int frame_start_off;
+ ltc_off_t frame_start_off;
int frame_start_prev;
};
-void decode_ltc(LTCDecoder *d, ltcsnd_sample_t *sound, int size, long int posinfo);
+void decode_ltc(LTCDecoder *d, ltcsnd_sample_t *sound, int size, ltc_off_t posinfo);
View
6 src/ltc.c
@@ -61,7 +61,7 @@ int ltc_decoder_free(LTCDecoder *d) {
return 0;
}
-void ltc_decoder_write_float(LTCDecoder *d, float *buf, size_t size, long int posinfo) {
+void ltc_decoder_write_float(LTCDecoder *d, float *buf, size_t size, ltc_off_t posinfo) {
int i;
for (i=0; i<size; i++) {
ltcsnd_sample_t s = 128 + (buf[i] * 127.0);
@@ -69,7 +69,7 @@ void ltc_decoder_write_float(LTCDecoder *d, float *buf, size_t size, long int po
}
}
-void ltc_decoder_write_s16(LTCDecoder *d, short *buf, size_t size, long int posinfo) {
+void ltc_decoder_write_s16(LTCDecoder *d, short *buf, size_t size, ltc_off_t posinfo) {
int i;
for (i=0; i<size; i++) {
ltcsnd_sample_t s = 128 + (buf[i] >> 8);
@@ -77,7 +77,7 @@ void ltc_decoder_write_s16(LTCDecoder *d, short *buf, size_t size, long int posi
}
}
-void ltc_decoder_write(LTCDecoder *d, ltcsnd_sample_t *buf, size_t size, long int posinfo) {
+void ltc_decoder_write(LTCDecoder *d, ltcsnd_sample_t *buf, size_t size, ltc_off_t posinfo) {
decode_ltc(d, buf, size, posinfo);
}
View
11 src/ltc.h
@@ -51,6 +51,11 @@ extern "C" {
typedef unsigned char ltcsnd_sample_t;
/**
+ * sample-count offset - 64bit wide
+ */
+typedef long long int ltc_off_t;
+
+/**
* Raw 80 bit SMPTE frame
*
* The datastream for each video frame of Longitudinal TimeCode consists of eighty bit-periods.
@@ -180,8 +185,8 @@ typedef struct LTCFrame LTCFrame;
*/
struct LTCFrameExt {
LTCFrame ltc; ///< the actual LTC frame. see \ref LTCFrame
- long int off_start; ///< the approximate sample in the stream corresponding to the start of the LTC frame.
- long int off_end; ///< the sample in the stream corresponding to the end of the LTC frame.
+ ltc_off_t off_start; ///< the approximate sample in the stream corresponding to the start of the LTC frame.
+ ltc_off_t off_end; ///< the sample in the stream corresponding to the end of the LTC frame.
int reverse; ///< if non-zero, a reverse played LTC frame was detected. Since the frame was reversed, it started at off_end and finishes as off_start (off_end > off_start). (Note: in reverse playback the (reversed) sync-word of the next/previous frame is detected, this offset is corrected).
};
@@ -288,7 +293,7 @@ int ltc_decoder_free(LTCDecoder *d);
*/
void ltc_decoder_write(LTCDecoder *d,
ltcsnd_sample_t *buf, size_t size,
- long int posinfo);
+ ltc_off_t posinfo);
/**
* Decoded LTC frames are placed in a queue. This function retrieves
View
19 tests/ltcdecode.c
@@ -81,15 +81,16 @@ int main(int argc, char **argv) {
stime.timezone
);
- printf("%02d:%02d:%02d%c%02d | %8ld %8ld%s\n",
- stime.hours, stime.mins,
- stime.secs,
- (frame.ltc.dfbit) ? '.' : ':',
- stime.frame,
- frame.off_start,
- frame.off_end,
- frame.reverse?" R":""
- );
+ printf("%02d:%02d:%02d%c%02d | %8lld %8lld%s\n",
+ stime.hours,
+ stime.mins,
+ stime.secs,
+ (frame.ltc.dfbit) ? '.' : ':',
+ stime.frame,
+ frame.off_start,
+ frame.off_end,
+ frame.reverse ? " R" : ""
+ );
}
total += n;
Please sign in to comment.
Something went wrong with that request. Please try again.