forked from bartvdbraak/blender
== REDCODE ==
* Fixed ntohl dependency (and hopefully 64bit issues) * Video length detection fixed (tests for picture presence)
This commit is contained in:
parent
4f3768af49
commit
0039da6ed8
2
extern/libredcode/codec.c
vendored
2
extern/libredcode/codec.c
vendored
@ -64,7 +64,7 @@ struct redcode_frame_raw * redcode_decode_video_raw(
|
||||
/* setup the decoder decoding parameters using the current image
|
||||
and user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo,
|
||||
frame->data + frame->offset, frame->length);
|
||||
|
28
extern/libredcode/format.c
vendored
28
extern/libredcode/format.c
vendored
@ -1,9 +1,3 @@
|
||||
#ifdef _WIN32
|
||||
#include <Winsock2.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -11,7 +5,7 @@
|
||||
|
||||
struct red_reob {
|
||||
unsigned long len;
|
||||
char head[4];
|
||||
unsigned long head;
|
||||
|
||||
unsigned long rdvo;
|
||||
unsigned long rdvs;
|
||||
@ -38,8 +32,15 @@ struct redcode_handle {
|
||||
unsigned long * rdao;
|
||||
unsigned long * rdas;
|
||||
long cfra;
|
||||
long length;
|
||||
};
|
||||
|
||||
unsigned long read_be32(unsigned long val)
|
||||
{
|
||||
unsigned char * v = (unsigned char*) & val;
|
||||
|
||||
return (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | v[3];
|
||||
}
|
||||
|
||||
static unsigned char* read_packet(FILE * fp, char * expect)
|
||||
{
|
||||
@ -52,7 +53,7 @@ static unsigned char* read_packet(FILE * fp, char * expect)
|
||||
|
||||
head[4] = 0;
|
||||
|
||||
len = ntohl(len);
|
||||
len = read_be32(len);
|
||||
|
||||
if (strcmp(expect, head) != 0) {
|
||||
fprintf(stderr, "Read: %s, expect: %s\n", head, expect);
|
||||
@ -79,7 +80,7 @@ static unsigned long * read_index_packet(FILE * fp, char * expect)
|
||||
}
|
||||
|
||||
for (i = 2; i < rv[0]/4; i++) {
|
||||
rv[i] = ntohl(rv[i]);
|
||||
rv[i] = read_be32(rv[i]);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -109,6 +110,7 @@ struct redcode_handle * redcode_open(const char * fname)
|
||||
{
|
||||
struct redcode_handle * rv = NULL;
|
||||
struct red_reob * reob = NULL;
|
||||
int i;
|
||||
|
||||
FILE * fp = fopen(fname, "rb");
|
||||
|
||||
@ -136,6 +138,12 @@ struct redcode_handle * redcode_open(const char * fname)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < (rv->rdvo[0] - 8)/4; i++) {
|
||||
if (rv->rdvo[i + 2]) {
|
||||
rv->length = i;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -162,7 +170,7 @@ void redcode_close(struct redcode_handle * handle)
|
||||
|
||||
long redcode_get_length(struct redcode_handle * handle)
|
||||
{
|
||||
return handle->rdvo[0]/4;
|
||||
return handle->length;
|
||||
}
|
||||
|
||||
struct redcode_frame * redcode_read_video_frame(
|
||||
|
Loading…
Reference in New Issue
Block a user