Skip to content

Commit 996c57c

Browse files
committed
Merge branch 'beta' of https://github.com/mailmindlin/v4l4j into beta
2 parents 2beb65b + 3f2e693 commit 996c57c

File tree

8 files changed

+55
-23
lines changed

8 files changed

+55
-23
lines changed

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
*.o
21
*.a
2+
*.d
3+
*.o
34
*.pc
45
*.so
6+
*.save
7+
*.so.0
58
.metadata/**/*
6-
*.d
79
/bin/
810
.classpath
9-
.project
11+
.project
12+
classes/*
13+
libvideo/libv4lconvert/ov511-decomp
14+
libvideo/libv4lconvert/ov518-decomp

build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@
331331
<jvmarg value="-Dtest.channel=${test.channel}" />
332332
<test name="au.edu.jcu.v4l4j.test.FrameGrabberTest" />
333333
<test name="au.edu.jcu.v4l4j.test.PushSourceTest" />
334+
<test name="au.edu.jcu.v4l4j.encoder.AbstractVideoFrameEncoderTest" />
334335
<formatter type="plain" usefile="false" />
335336
<classpath refid="test.classpath" />
336337
</junit>

libvideo/libv4lconvert/libv4lconvert-flat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef __LIBVIDEO_LIBV4LCONVERT_LIBV4LCONVERT_FLAT_CPP
88
#define __LIBVIDEO_LIBV4LCONVERT_LIBV4LCONVERT_FLAT_CPP
99

10+
extern "C" {
11+
1012
#ifndef N_A
1113
#define N_A 0
1214
#endif
@@ -91,4 +93,6 @@ void v4lconvert_encoder_init(struct v4lconvert_encoder* encoder, int converterId
9193
v4lconvert_converter_t* v4lconvert_converter_getConverterById(int converterId) {
9294
return &(v4lconvert_converters[converterId]);
9395
}
96+
97+
}
9498
#endif

libvideo/libv4lconvert/libv4lconvert-flat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#ifndef __LIBVIDEO_LIBV4LCONVERT_LIBV4LCONVERT_FLAT_H
77
#define __LIBVIDEO_LIBV4LCONVERT_LIBV4LCONVERT_FLAT_H
88

9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
913
enum v4lconvert_conversion_fingerprint {
1014
/**
1115
* Value if this fingerprint is unset (struct's will defaultly initialize with this value)
@@ -61,4 +65,8 @@ void v4lconvert_encoder_doConvert(struct v4lconvert_encoder* self, const u8* src
6165
void v4lconvert_encoder_init(struct v4lconvert_encoder* encoder, int converterId, int width, int height);
6266
v4lconvert_converter_t* v4lconvert_converter_getConverterById(int converterId);
6367

68+
#ifdef __cplusplus
69+
}
70+
#endif
71+
6472
#endif

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ OBJ := jpeg.o v4l4j_FrameGrabber.o v4l4j_ImageFormatList.o \
4444

4545
INCLUDES := -I$(JDK_HOME)/include -I$(JDK_HOME)/include/linux/ \
4646
-I$(LIBVIDEO_PATH) -I$(LIBVIDEO_PATH)/pixfc-sse -I.
47-
CFLAGS += $(INCLUDES) $(DBG) $(OPTIMISATION) -fPIC -fno-stack-protector
47+
CFLAGS += $(INCLUDES) $(DBG) $(OPTIMISATION) -fPIC -fno-stack-protector -std=gnu11
4848

4949
LDFLAGS += -shared -ljpeg -L$(LIBVIDEO_PATH) -l$(LIBVIDEO_NAME)
5050

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package au.edu.jcu.v4l4j.encoder;
22

3-
import static org.junit.Assert.*;
4-
53
import java.util.Arrays;
64

75
import org.junit.Test;
86

7+
import au.edu.jcu.v4l4j.ImagePalette;
98
import junit.framework.Assert;
109

1110
/**
@@ -15,17 +14,24 @@
1514
public class AbstractVideoFrameEncoderTest {
1615

1716
@Test
18-
public void test() {
19-
AbstractVideoFrameEncoder encoder = new AbstractVideoFrameEncoder(5, 7, null, null);
20-
21-
int numConverters = -encoder.getConverterIds(encoder.object, null);
22-
Assert.assertEquals(numConverters, 1);
23-
24-
int[] converterIds = new int[numConverters];
25-
numConverters = encoder.getConverterIds(encoder.object, converterIds);
26-
System.out.println(Arrays.toString(converterIds));
27-
Assert.assertEquals(numConverters, 1);
28-
// fail("Not yet implemented");
17+
public void test() throws Exception {
18+
try {
19+
20+
AbstractVideoFrameEncoder encoder = new AbstractVideoFrameEncoder(5, 7, ImagePalette.RGB32, ImagePalette.YUV420);
21+
22+
int numConverters = -encoder.getConverterIds(encoder.object, null);
23+
Assert.assertEquals(numConverters, 1);
24+
25+
int[] converterIds = new int[numConverters];
26+
numConverters = encoder.getConverterIds(encoder.object, converterIds);
27+
System.out.println(Arrays.toString(converterIds));
28+
Assert.assertEquals(numConverters, 1);
29+
30+
encoder.close();
31+
// fail("Not yet implemented");
32+
} catch (Exception e) {
33+
e.printStackTrace();
34+
throw e;
35+
}
2936
}
30-
3137
}

src/debug.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
dprint(LOG_MEMALLOC, "[MEMALLOC]: allocated %lu bytes of type %s for var %s (%p).\n", (long unsigned int)size, #type, #var, (var));}\
6363
} while (0)
6464

65-
#define XCALLLOC(var, type, width, size) \
65+
#define XCALLOC(var, type, width, size) \
6666
do { \
6767
var = (type) calloc((width), (size)); \
6868
if (!var) {dprint(LOG_MEMALLOC, "[MEMALLOC]: Can't allocate %lu of width %lu.\n", (long unsigned int) (size), (long unsigned int) (width));} \
@@ -102,6 +102,12 @@
102102
else { CLEAR(*var);}\
103103
} while (0)
104104

105+
#define XCALLOC(var, type, width, size) \
106+
do { \
107+
var = (type) calloc((width), (size)); \
108+
if (!var) {fprintf(stderr,"[%s:%d %s] MEMALLOC: OUT OF MEMORY !!! Cant allocate %lu of width %lu.\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, (long unsigned int) size, (long unsigned int) width); fflush(stderr);} \
109+
} while (0)
110+
105111
#define XMALLOC_ALIGNED(var, type, size) \
106112
do { \
107113
if (posix_memalign((void**)&(var), 16, (size))!=0) {fprintf(stderr,"[%s:%d %s] MEMALLOC: OUT OF MEMORY !!! Cant allocate %lu bytes.\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, (long unsigned int) size); fflush(stderr);} \

src/v4l4j_VideoFrameEncoder.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,21 @@ JNIEXPORT jint JNICALL Java_au_edu_jcu_v4l4j_encoder_AbstractVideoFrameEncoder_g
169169
return -num_converters;
170170

171171
jint* converter_ids;
172-
XCALLOC(converter_ids, jint, out_length * sizeof(jint));
173-
if (converter_ids == NULL)
172+
XCALLOC(converter_ids, jint*, sizeof(jint), out_length);
173+
if (converter_ids == NULL) {
174174
THROW_EXCEPTION(env, JNI_EXCP, "Unable to allocate memory.");
175+
return 0;
176+
}
175177

176178
if (encoder->is_series) {
177179
struct v4lconvert_encoder_series* v4lcvt_series = encoder->v4lenc.encoder_series;
178180
for (int i=0; i < num_converters; i++)
179-
converter_ids[i] = vcvt_series->encoders[i]->id;
181+
converter_ids[i] = v4lcvt_series->encoders[i]->converter->id;
180182
} else {
181183
converter_ids[0] = encoder->v4lenc.encoder->converter->id;
182184
}
183185

184-
(*env)->SetIntArrayRegion(env, out, 0, converter_ids, num_converters);
186+
(*env)->SetIntArrayRegion(env, out, 0, num_converters, converter_ids);
185187

186188
XFREE(converter_ids);
187189
//TODO check that it was freed

0 commit comments

Comments
 (0)