Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libjitsi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZRTP
libjitsi
Commits
4adc909f
Commit
4adc909f
authored
10 years ago
by
Lyubomir Marinov
Browse files
Options
Downloads
Patches
Plain Diff
Applies formatting, simplifies source code.
parent
ef67ae72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/org/jitsi/impl/neomedia/codec/audio/g729/JavaDecoder.java
+4
-7
4 additions, 7 deletions
...org/jitsi/impl/neomedia/codec/audio/g729/JavaDecoder.java
src/org/jitsi/impl/neomedia/codec/audio/g729/JavaEncoder.java
+81
-92
81 additions, 92 deletions
...org/jitsi/impl/neomedia/codec/audio/g729/JavaEncoder.java
with
85 additions
and
99 deletions
src/org/jitsi/impl/neomedia/codec/audio/g729/JavaDecoder.java
+
4
−
7
View file @
4adc909f
...
@@ -73,19 +73,16 @@ public JavaDecoder()
...
@@ -73,19 +73,16 @@ public JavaDecoder()
};
};
}
}
private
void
depacketize
(
private
void
depacketize
(
byte
[]
inFrame
,
int
inFrameOffset
,
short
[]
serial
)
byte
[]
inputFrame
,
int
inputFrameOffset
,
short
[]
serial
)
{
{
serial
[
0
]
=
SYNC_WORD
;
serial
[
0
]
=
SYNC_WORD
;
serial
[
1
]
=
SIZE_WORD
;
serial
[
1
]
=
SIZE_WORD
;
for
(
int
s
=
0
;
s
<
L_FRAME
;
s
++)
for
(
int
s
=
0
;
s
<
L_FRAME
;
s
++)
{
{
int
in
put
=
in
put
Frame
[
in
put
FrameOffset
+
s
/
8
];
int
in
=
inFrame
[
inFrameOffset
+
s
/
8
];
in
put
&=
1
<<
(
7
-
(
s
%
8
));
in
&=
1
<<
(
7
-
(
s
%
8
));
serial
[
2
+
s
]
=
(
0
!=
in
put
)
?
BIT_1
:
BIT_0
;
serial
[
2
+
s
]
=
(
0
!=
in
)
?
BIT_1
:
BIT_0
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/org/jitsi/impl/neomedia/codec/audio/g729/JavaEncoder.java
+
81
−
92
View file @
4adc909f
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
import
org.jitsi.impl.neomedia.codec.*
;
import
org.jitsi.impl.neomedia.codec.*
;
/**
/**
*
* @author Lubomir Marinov
* @author Lubomir Marinov
*/
*/
public
class
JavaEncoder
public
class
JavaEncoder
...
@@ -34,21 +35,21 @@ public class JavaEncoder
...
@@ -34,21 +35,21 @@ public class JavaEncoder
private
Coder
coder
;
private
Coder
coder
;
private
int
out
put
FrameCount
;
private
int
outFrameCount
;
/**
/**
* The previous input if it was less than the input frame size and which is
* The previous input if it was less than the input frame size and which is
* to be prepended to the next input in order to form a complete input
* to be prepended to the next input in order to form a complete input
* frame.
* frame.
*/
*/
private
byte
[]
prevIn
put
;
private
byte
[]
prevIn
;
/**
/**
* The length of the previous input if it was less than the input frame size
* The length of the previous input if it was less than the input frame size
* and which is to be prepended to the next input in order to form a
* and which is to be prepended to the next input in order to form a
* complete input frame.
* complete input frame.
*/
*/
private
int
prevIn
put
Length
;
private
int
prevInLength
;
private
short
[]
serial
;
private
short
[]
serial
;
...
@@ -99,24 +100,24 @@ public JavaEncoder()
...
@@ -99,24 +100,24 @@ public JavaEncoder()
@Override
@Override
public
Format
getOutputFormat
()
public
Format
getOutputFormat
()
{
{
Format
outputFormat
=
super
.
getOutputFormat
();
Format
f
=
super
.
getOutputFormat
();
if
((
outputFormat
!=
null
)
if
((
f
!=
null
)
&&
(
f
.
getClass
()
==
AudioFormat
.
class
))
&&
(
outputFormat
.
getClass
()
==
AudioFormat
.
class
))
{
{
AudioFormat
outputAudioFormat
=
(
AudioFormat
)
outputFormat
;
AudioFormat
af
=
(
AudioFormat
)
f
;
outputFormat
=
setOutputFormat
(
f
new
AudioFormat
(
=
setOutputFormat
(
outputAudioFormat
.
getEncoding
(),
new
AudioFormat
(
outputAudioFormat
.
getSampleRate
(),
af
.
getEncoding
(),
outputAudioFormat
.
getSampleSizeInBits
(),
af
.
getSampleRate
(),
outputAudioFormat
.
getChannels
(),
af
.
getSampleSizeInBits
(),
outputAudioFormat
.
getEndian
(),
af
.
getChannels
(),
outputAudioFormat
.
getSigned
(),
af
.
getEndian
(),
outputAudioFormat
.
getFrameSizeInBits
(),
af
.
getSigned
(),
outputAudioFormat
.
getFrameRate
(),
af
.
getFrameSizeInBits
(),
outputAudioFormat
.
getDataType
())
af
.
getFrameRate
(),
af
.
getDataType
())
{
{
private
static
final
long
serialVersionUID
=
0L
;
private
static
final
long
serialVersionUID
=
0L
;
...
@@ -127,7 +128,7 @@ public long computeDuration(long length)
...
@@ -127,7 +128,7 @@ public long computeDuration(long length)
}
}
});
});
}
}
return
outputFormat
;
return
f
;
}
}
@Override
@Override
...
@@ -135,7 +136,7 @@ protected void discardOutputBuffer(Buffer outputBuffer)
...
@@ -135,7 +136,7 @@ protected void discardOutputBuffer(Buffer outputBuffer)
{
{
super
.
discardOutputBuffer
(
outputBuffer
);
super
.
discardOutputBuffer
(
outputBuffer
);
out
put
FrameCount
=
0
;
outFrameCount
=
0
;
}
}
/*
/*
...
@@ -144,8 +145,8 @@ protected void discardOutputBuffer(Buffer outputBuffer)
...
@@ -144,8 +145,8 @@ protected void discardOutputBuffer(Buffer outputBuffer)
@Override
@Override
protected
void
doClose
()
protected
void
doClose
()
{
{
prevIn
put
=
null
;
prevIn
=
null
;
prevIn
put
Length
=
0
;
prevInLength
=
0
;
sp16
=
null
;
sp16
=
null
;
serial
=
null
;
serial
=
null
;
...
@@ -167,134 +168,122 @@ protected void doClose()
...
@@ -167,134 +168,122 @@ protected void doClose()
protected
void
doOpen
()
protected
void
doOpen
()
throws
ResourceUnavailableException
throws
ResourceUnavailableException
{
{
prevIn
put
=
new
byte
[
INPUT_FRAME_SIZE_IN_BYTES
];
prevIn
=
new
byte
[
INPUT_FRAME_SIZE_IN_BYTES
];
prevIn
put
Length
=
0
;
prevInLength
=
0
;
sp16
=
new
short
[
L_FRAME
];
sp16
=
new
short
[
L_FRAME
];
serial
=
new
short
[
SERIAL_SIZE
];
serial
=
new
short
[
SERIAL_SIZE
];
coder
=
new
Coder
();
coder
=
new
Coder
();
out
put
FrameCount
=
0
;
outFrameCount
=
0
;
}
}
/*
/*
* Implements AbstractCodecExt#doProcess(Buffer, Buffer).
* Implements AbstractCodecExt#doProcess(Buffer, Buffer).
*/
*/
@Override
@Override
protected
int
doProcess
(
Buffer
in
put
Buffer
,
Buffer
out
put
Buffer
)
protected
int
doProcess
(
Buffer
inBuffer
,
Buffer
outBuffer
)
{
{
byte
[]
in
put
=
(
byte
[])
in
put
Buffer
.
getData
();
byte
[]
in
=
(
byte
[])
inBuffer
.
getData
();
int
in
put
Length
=
in
put
Buffer
.
getLength
();
int
inLength
=
inBuffer
.
getLength
();
int
in
put
Offset
=
in
put
Buffer
.
getOffset
();
int
inOffset
=
inBuffer
.
getOffset
();
if
((
prevIn
put
Length
+
in
put
Length
)
<
INPUT_FRAME_SIZE_IN_BYTES
)
if
((
prevInLength
+
inLength
)
<
INPUT_FRAME_SIZE_IN_BYTES
)
{
{
System
.
arraycopy
(
System
.
arraycopy
(
input
,
in
,
inOffset
,
inputOffset
,
prevIn
,
prevInLength
,
prevInput
,
inLength
);
prevInputLength
,
prevInLength
+=
inLength
;
inputLength
);
prevInputLength
+=
inputLength
;
return
BUFFER_PROCESSED_OK
|
OUTPUT_BUFFER_NOT_FILLED
;
return
BUFFER_PROCESSED_OK
|
OUTPUT_BUFFER_NOT_FILLED
;
}
}
int
readShorts
=
0
;
int
readShorts
=
0
;
if
(
prevIn
put
Length
>
0
)
if
(
prevInLength
>
0
)
{
{
readShorts
readShorts
+=
readShorts
(
prevIn
,
0
,
sp16
,
0
,
prevInLength
/
2
);
+=
readShorts
(
prevInput
,
0
,
sp16
,
0
,
prevInputLength
/
2
);
prevInLength
=
0
;
prevInputLength
=
0
;
}
}
readShorts
readShorts
=
readShorts
(
=
readShorts
(
input
,
in
,
inOffset
,
inputOffset
,
sp16
,
readShorts
,
sp16
.
length
-
readShorts
);
sp16
,
readShorts
,
sp16
.
length
-
readShorts
);
int
readBytes
=
2
*
readShorts
;
int
readBytes
=
2
*
readShorts
;
in
put
Length
-=
readBytes
;
inLength
-=
readBytes
;
in
put
Buffer
.
setLength
(
in
put
Length
);
inBuffer
.
setLength
(
inLength
);
in
put
Offset
+=
readBytes
;
inOffset
+=
readBytes
;
in
put
Buffer
.
setOffset
(
in
put
Offset
);
inBuffer
.
setOffset
(
inOffset
);
coder
.
process
(
sp16
,
serial
);
coder
.
process
(
sp16
,
serial
);
byte
[]
output
byte
[]
output
=
validateByteArraySize
(
=
validateByteArraySize
(
out
put
Buffer
,
outBuffer
,
out
put
Buffer
.
getOffset
()
+
2
*
OUTPUT_FRAME_SIZE_IN_BYTES
,
outBuffer
.
getOffset
()
+
2
*
OUTPUT_FRAME_SIZE_IN_BYTES
,
true
);
true
);
packetize
(
packetize
(
serial
,
serial
,
output
,
output
,
outputBuffer
.
getOffset
()
outBuffer
.
getOffset
()
+
OUTPUT_FRAME_SIZE_IN_BYTES
*
outputFrameCount
);
+
OUTPUT_FRAME_SIZE_IN_BYTES
*
outFrameCount
);
outputBuffer
.
setLength
(
outBuffer
.
setLength
(
outBuffer
.
getLength
()
+
OUTPUT_FRAME_SIZE_IN_BYTES
);
outputBuffer
.
getLength
()
+
OUTPUT_FRAME_SIZE_IN_BYTES
);
out
put
Buffer
.
setFormat
(
outputFormat
);
outBuffer
.
setFormat
(
outputFormat
);
int
processResul
t
=
BUFFER_PROCESSED_OK
;
int
re
t
=
BUFFER_PROCESSED_OK
;
if
(
out
put
FrameCount
==
1
)
if
(
outFrameCount
==
1
)
out
put
FrameCount
=
0
;
outFrameCount
=
0
;
else
else
{
{
out
put
FrameCount
=
1
;
outFrameCount
=
1
;
processResul
t
|=
OUTPUT_BUFFER_NOT_FILLED
;
re
t
|=
OUTPUT_BUFFER_NOT_FILLED
;
}
}
if
(
in
put
Length
>
0
)
if
(
inLength
>
0
)
processResul
t
|=
INPUT_BUFFER_NOT_CONSUMED
;
re
t
|=
INPUT_BUFFER_NOT_CONSUMED
;
if
(
processResul
t
==
BUFFER_PROCESSED_OK
)
if
(
re
t
==
BUFFER_PROCESSED_OK
)
{
{
updateOutput
(
updateOutput
(
outputBuffer
,
outBuffer
,
getOutputFormat
(),
outputBuffer
.
getLength
(),
getOutputFormat
(),
outputBuffer
.
getOffset
());
outBuffer
.
getLength
(),
outputBuffer
.
setDuration
(
duration
);
outBuffer
.
getOffset
());
outBuffer
.
setDuration
(
duration
);
}
}
return
processResul
t
;
return
re
t
;
}
}
private
void
packetize
(
private
void
packetize
(
short
[]
serial
,
byte
[]
outFrame
,
int
outFrameOffset
)
short
[]
serial
,
byte
[]
outputFrame
,
int
outputFrameOffset
)
{
{
Arrays
.
fill
(
Arrays
.
fill
(
outputFrame
,
outFrame
,
outFrameOffset
,
outFrameOffset
+
L_FRAME
/
8
,
outputFrameOffset
,
(
byte
)
0
);
outputFrameOffset
+
L_FRAME
/
8
,
(
byte
)
0
);
for
(
int
s
=
0
;
s
<
L_FRAME
;
s
++)
for
(
int
s
=
0
;
s
<
L_FRAME
;
s
++)
{
if
(
BIT_1
==
serial
[
2
+
s
])
if
(
BIT_1
==
serial
[
2
+
s
])
{
{
int
o
=
out
put
FrameOffset
+
s
/
8
;
int
o
=
outFrameOffset
+
s
/
8
;
int
out
put
=
out
put
Frame
[
o
];
int
out
=
outFrame
[
o
];
out
put
|=
1
<<
(
7
-
(
s
%
8
));
out
|=
1
<<
(
7
-
(
s
%
8
));
out
put
Frame
[
o
]
=
(
byte
)
(
out
put
&
0xFF
);
outFrame
[
o
]
=
(
byte
)
(
out
&
0xFF
);
}
}
}
}
}
private
static
int
readShorts
(
private
static
int
readShorts
(
byte
[]
input
,
byte
[]
in
,
int
inOffset
,
int
inputOffset
,
short
[]
out
,
int
outOffset
,
int
outLength
)
short
[]
output
,
int
outputOffset
,
int
outputLength
)
{
{
for
(
int
o
=
out
put
Offset
,
i
=
in
put
Offset
;
o
<
out
put
Length
;
o
++,
i
+=
2
)
for
(
int
o
=
outOffset
,
i
=
inOffset
;
o
<
outLength
;
o
++,
i
+=
2
)
out
put
[
o
]
=
ArrayIOUtils
.
readShort
(
in
put
,
i
);
out
[
o
]
=
ArrayIOUtils
.
readShort
(
in
,
i
);
return
out
put
Length
;
return
outLength
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment