Lines 163-176
Link Here
|
163 |
= (*env)->GetByteArrayElements (env, samples, NULL); |
163 |
= (*env)->GetByteArrayElements (env, samples, NULL); |
164 |
|
164 |
|
165 |
if (samples_ptr) { |
165 |
if (samples_ptr) { |
166 |
ret = (jint) avcodec_encode_audio( |
166 |
AVCodecContext *avctx = (AVCodecContext*)(intptr_t)ctx; |
167 |
(AVCodecContext *) (intptr_t) ctx, |
167 |
AVPacket pkt; |
168 |
(uint8_t *) (buf_ptr + buf_offset), (int) buf_size, |
168 |
AVFrame *frame = av_frame_alloc(); |
169 |
(const short *) (samples_ptr + samples_offset)); |
169 |
int got_output; |
|
|
170 |
|
171 |
if (!frame) |
172 |
return AVERROR(ENOMEM); |
173 |
frame->data[0] = (uint8_t*)(samples_ptr + samples_offset); |
174 |
frame->linesize[0] = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt) * |
175 |
avctx->channels; |
176 |
|
177 |
pkt.data = (uint8_t*)(buf_ptr + buf_offset); |
178 |
pkt.size = buf_size; |
179 |
ret = (jint) avcodec_encode_audio2( |
180 |
avctx, &pkt, frame, &got_output); |
170 |
(*env)->ReleaseByteArrayElements( |
181 |
(*env)->ReleaseByteArrayElements( |
171 |
env, |
182 |
env, |
172 |
samples, samples_ptr, |
183 |
samples, samples_ptr, |
173 |
JNI_ABORT); |
184 |
JNI_ABORT); |
|
|
185 |
av_frame_free(&frame); |
186 |
if (ret >= 0) |
187 |
ret = got_output ? pkt.size : 0; |
174 |
} else |
188 |
} else |
175 |
ret = -1; |
189 |
ret = -1; |
176 |
(*env)->ReleaseByteArrayElements (env, buf, buf_ptr, 0); |
190 |
(*env)->ReleaseByteArrayElements (env, buf, buf_ptr, 0); |
Lines 192-203
Link Here
|
192 |
jbyte *buf_ptr = (*env)->GetByteArrayElements (env, buf, NULL); |
206 |
jbyte *buf_ptr = (*env)->GetByteArrayElements (env, buf, NULL); |
193 |
|
207 |
|
194 |
if (buf_ptr) { |
208 |
if (buf_ptr) { |
|
|
209 |
int got_output; |
210 |
AVPacket pkt; |
211 |
pkt.data = (uint8_t*)buf_ptr; |
212 |
pkt.size = (int)buf_size; |
195 |
ret |
213 |
ret |
196 |
= (jint) |
214 |
= (jint) |
197 |
avcodec_encode_video( |
215 |
avcodec_encode_video2( |
198 |
(AVCodecContext *) (intptr_t) ctx, |
216 |
(AVCodecContext *) (intptr_t) ctx, |
199 |
(uint8_t *) buf_ptr, (int) buf_size, |
217 |
&pkt, (const AVFrame *) (intptr_t) frame, |
200 |
(const AVFrame *) (intptr_t) frame); |
218 |
&got_output); |
|
|
219 |
if (ret >= 0) |
220 |
ret = got_output ? pkt.size : 0; |
201 |
(*env)->ReleaseByteArrayElements (env, buf, buf_ptr, 0); |
221 |
(*env)->ReleaseByteArrayElements (env, buf, buf_ptr, 0); |
202 |
} else |
222 |
} else |
203 |
ret = -1; |
223 |
ret = -1; |
Lines 210-223
Link Here
|
210 |
Java_org_jitsi_impl_neomedia_codec_FFmpeg_avcodec_1find_1decoder |
230 |
Java_org_jitsi_impl_neomedia_codec_FFmpeg_avcodec_1find_1decoder |
211 |
(JNIEnv *env, jclass clazz, jint id) |
231 |
(JNIEnv *env, jclass clazz, jint id) |
212 |
{ |
232 |
{ |
213 |
return (jlong) (intptr_t) avcodec_find_decoder((enum CodecID) id); |
233 |
return (jlong) (intptr_t) avcodec_find_decoder((enum AVCodecID) id); |
214 |
} |
234 |
} |
215 |
|
235 |
|
216 |
JNIEXPORT jlong JNICALL |
236 |
JNIEXPORT jlong JNICALL |
217 |
Java_org_jitsi_impl_neomedia_codec_FFmpeg_avcodec_1find_1encoder |
237 |
Java_org_jitsi_impl_neomedia_codec_FFmpeg_avcodec_1find_1encoder |
218 |
(JNIEnv *env, jclass clazz, jint id) |
238 |
(JNIEnv *env, jclass clazz, jint id) |
219 |
{ |
239 |
{ |
220 |
return (jlong) (intptr_t) avcodec_find_encoder((enum CodecID) id); |
240 |
return (jlong) (intptr_t) avcodec_find_encoder((enum AVCodecID) id); |
221 |
} |
241 |
} |
222 |
|
242 |
|
223 |
JNIEXPORT jint JNICALL |
243 |
JNIEXPORT jint JNICALL |