java - MediaCodec AAC -> PCM Decoder Configuration on Android -
I'm trying to implement AAC ->; PCM Decoder
by MediaCode
.
First of all, I have successfully updated the PCM - & gt; AAC encoder is intended as
MediaCodec
as below
Private Boolean set encoder (enc rate) {encoder = MediaCodec.createEncoderByType (" Audio / mp4a-latm "); Media format format = new media format (); Format.setString (MediaFormat.KEY_MIME, "audio / mp4a-latm"); Format.setInteger (MediaFormat.KEY_CHANNEL_COUNT, 1); Format.setInteger (MediaFormat.KEY_SAMPLE_RATE, 44100); Format.setInteger (MediaFormat.KEY_BIT_RATE, 64 * 1024); // AAC-HE 64kbps format.setInteger (MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectHE); Encoder Configure (format, empty, empty, mediacode. CONFIGURE_FLAG_ENCODE); Back true; }
INPUT: PCM bitrate = 44100 (hj) x 16 (beat) x 1 (monial) = 705600 bit / s
Output: AAC-O bitrate = 64 x 1024 (bit) = 65536 bit / s
So, the size of the data is almost compressed The size of the data is approximately Now, I have an UDP server to get encoded data, then decode it. The decoder profile is set as follows: x11
x11 < / Code> is compressed, so far is good.
Private boolean set decoder (int rate) {decoder = MediaCodec.createDecoderByType ("audio / mp4a-latm"); Media format format = new media format (); Format.setString (MediaFormat.KEY_MIME, "audio / mp4a-latm"); Format.setInteger (MediaFormat.KEY_CHANNEL_COUNT, 1); Format.setInteger (MediaFormat.KEY_SAMPLE_RATE, 44100); Format.setInteger (MediaFormat.KEY_BIT_RATE, 64 * 1024); // AAC-HE 64kbps format.setInteger (MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectHE); Decoder.configure (format, empty, zero, 0); Back true; UDPserver packet buffer size
1024
- UDPserver: 1024 bytes received
P> and since It is compressed AAC data, I expect the decoding size
would be approximately 1024 x11
, though the actual result
- AudioDecoder: 8192 bytes decode
It's almost x8
, and I find something wrong.
Can anyone give me an idea on this issue? Thank you.
PS
The decoder code is as follows:
byte [] buffer 2 = new byte [1024]; Datagram packet packet = new datagram packet (buffer 2, buffer 2. lamp); // .............. // Get the UDP packet here .............. ds.receive (packet); SockAddress = packet.getSocketAddress (); Address = sockAddress.toString (); // now inputbuffer encoding = decoder.get inputbuffers (); Output buffers = decoder.get overput buffers (); Inputbufferindexx = decoder.dequinput buffer (-1); If (inputbufferedx> = 0) {inputbuffer = inputbufers [inputfounderx]; InputBuffer.clear (); InputBuffer.put (buffer2); Decoder.queueInputBuffer (inputfoundX, 0, buffer 2. line, 0, 0); } Buffer Info = New MediaCodec.BufferInfo (); OutputBufferIndex = Decoder DequeueOutputBuffer (BufferInfo, 0); While (OutputBufferX> = 0) {outputbuffer = OutputBuffers [OutputBuffer Index]; Outdata = new byte [buffer infosys]; OutputBuffer.get (outData); Log D. ("Audiodicoder", outdata lamps + "bytes decode"); Decoder.releaseOutputBuffer (outputBufferIndex, Incorrect); OutputBufferIndex = Decoder DequeueOutputBuffer (BufferInfo, 0); }
Comments
Post a Comment