Optimizes the H.264 decoder (i.e. JNIDecoder) and the image scaler and colorspace converter (i.e. SwScaler) by: (1) passing the decoded frames from JNIDecoder to SwScaler in the native format of FFmpeg thus sparing the conversions from the native to the Java and back to the native format, (2) removes the conversion to RGB from JNIDecoder because the decoded frame will be either converted or scaled by SwScaler afterwards anyway, (3) uses sws_getCachedContext in SwScaler in order to remove the penalty of the expensive initialization that sws_getContext performs and (4) notes that FFmpeg is to be built without --disable-mmx. WARNING: The FFmpeg JNI binaries must be rebuilt.

cusax-fix
Lyubomir Marinov 16 years ago
parent 9aca0d5432
commit 6fc9119de8

@ -4,7 +4,7 @@ JAVA_HOME?=/usr/lib/jvm/java-6-sun
#JAVA_HOME=C:\Progra~1\jdk1.6.0_18
X264_HOME?=/home/seb/svn_work/x264-snapshot-20091208-2245
CC=gcc
CC=gcc -g
CPPFLAGS=-DJNI_IMPLEMENTATION \
-I$(JAVA_HOME)/include \
-I$(FFMPEG_HOME)
@ -41,5 +41,5 @@ LIBS=-L$(FFMPEG_HOME)/libavformat -L$(FFMPEG_HOME)/libavcodec -L$(FFMPEG_HOME)/l
-L$(FFMPEG_HOME)/libswscale -L$(X264_HOME) \
-lavformat -lavcodec -lavutil -lswscale -lx264
$(TARGET): net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG.c net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG.h
$(TARGET): net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg.c net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg.h
$(CC) $(CPPFLAGS) $< $(LDFLAGS) -o $@ $(LIBS)

@ -29,7 +29,7 @@ make
32-bit
./configure \
--target-os=mingw32 \
--disable-mmx --enable-memalign-hack \
--enable-memalign-hack \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
@ -49,7 +49,7 @@ check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_
Then run:
./configure \
--arch=amd64 --target-os=mingw32 \
--disable-mmx --enable-memalign-hack \
--enable-memalign-hack \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
@ -67,7 +67,7 @@ Note: mingw64-make failed to work (segmentation fault) that's why we fallback to
- Linux, FreeBSD
./configure \
--disable-mmx --enable-pic \
--enable-pic \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
@ -81,7 +81,6 @@ Note: mingw64-make failed to work (segmentation fault) that's why we fallback to
- Mac OS X(removed from configure script the option to add -mdynamic-no-pic)
./configure \
--disable-mmx \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \

@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
#include "net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG.h"
#include "net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg.h"
#include <string.h>
@ -15,43 +15,43 @@
#include <libswscale/swscale.h>
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_av_1free (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_av_1free (
JNIEnv *jniEnv, jclass clazz, jlong ptr) {
av_free ((void *) ptr);
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_av_1malloc (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_av_1malloc (
JNIEnv *jniEnv, jclass clazz, jint size) {
return (jlong) av_malloc ((unsigned int) size);
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_av_1register_1all (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_av_1register_1all (
JNIEnv *jniEnv, jclass clazz) {
av_register_all ();
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1alloc_1context (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1alloc_1context (
JNIEnv *jniEnv, jclass clazz) {
return (jlong) avcodec_alloc_context ();
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1alloc_1frame (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1alloc_1frame (
JNIEnv *jniEnv, jclass clazz) {
return (jlong) avcodec_alloc_frame ();
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1close (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1close (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
return (jint) avcodec_close ((AVCodecContext *) avctx);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1decode_1video (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1decode_1video (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jlong frame,
jbooleanArray got_picture, jbyteArray buf, jint buf_size) {
jint ret;
@ -90,7 +90,7 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1decode_
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1encode_1video (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1encode_1video (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jbyteArray buf,
jint buf_size, jlong frame) {
jint ret;
@ -112,13 +112,13 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1encode_
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1find_1decoder (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1find_1decoder (
JNIEnv *jniEnv, jclass clazz, jint id) {
return (jlong) avcodec_find_decoder ((enum CodecID) id);
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1find_1encoder (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1find_1encoder (
JNIEnv *jniEnv, jclass clazz, jint id) {
return (jlong) avcodec_find_encoder ((enum CodecID) id);
}
@ -129,146 +129,146 @@ static void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1init (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1init (
JNIEnv *jniEnv, jclass clazz) {
avcodec_init ();
av_log_set_callback(log_callback_help);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1open (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1open (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jlong codec) {
return (jint) avcodec_open ((AVCodecContext *) avctx, (AVCodec *) codec);
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1add_1flags (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1add_1flags (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint flags) {
((AVCodecContext *) avctx)->flags |= (int) flags;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1add_1partitions (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1add_1partitions (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint partitions) {
((AVCodecContext *) avctx)->partitions |= (int) partitions;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1get_1height (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1get_1height (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
return (jint) (((AVCodecContext *) avctx)->height);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1get_1pix_1fmt (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1get_1pix_1fmt (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
return (jint) (((AVCodecContext *) avctx)->pix_fmt);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1get_1width (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1get_1width (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
return (jint) (((AVCodecContext *) avctx)->width);
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1b_1frame_1strategy (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1b_1frame_1strategy (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint b_frame_strategy) {
((AVCodecContext *) avctx)->b_frame_strategy = (int) b_frame_strategy;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1bit_1rate (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1bit_1rate (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint bit_rate) {
((AVCodecContext *) avctx)->bit_rate = (int) bit_rate;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1bit_1rate_1tolerance (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1bit_1rate_1tolerance (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint bit_rate_tolerance) {
((AVCodecContext *) avctx)->bit_rate_tolerance = (int) bit_rate_tolerance;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1chromaoffset (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1chromaoffset (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint chromaoffset) {
((AVCodecContext *) avctx)->chromaoffset = (int) chromaoffset;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1crf (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1crf (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jfloat crf) {
((AVCodecContext *) avctx)->crf = (float) crf;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1deblockbeta (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1deblockbeta (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint deblockbeta) {
((AVCodecContext *) avctx)->deblockbeta = (int) deblockbeta;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1gop_1size (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1gop_1size (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint gop_size) {
((AVCodecContext *) avctx)->gop_size = (int) gop_size;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1i_1quant_1factor (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1i_1quant_1factor (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jfloat i_quant_factor) {
((AVCodecContext *) avctx)->i_quant_factor = (float) i_quant_factor;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1max_1b_1frames (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1max_1b_1frames (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint max_b_frames) {
((AVCodecContext *) avctx)->max_b_frames = (int) max_b_frames;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1mb_1decision (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1mb_1decision (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint mb_decision) {
((AVCodecContext *) avctx)->mb_decision = (int) mb_decision;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1me_1cmp (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1me_1cmp (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint me_cmp) {
((AVCodecContext *) avctx)->me_cmp = (int) me_cmp;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1me_1method (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1me_1method (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint me_method) {
((AVCodecContext *) avctx)->me_method = (int) me_method;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1me_1range (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1me_1range (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint me_range) {
((AVCodecContext *) avctx)->me_range = (int) me_range;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1me_1subpel_1quality (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1me_1subpel_1quality (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint me_subpel_quality) {
((AVCodecContext *) avctx)->me_subpel_quality = (int) me_subpel_quality;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1pix_1fmt (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1pix_1fmt (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint pix_fmt) {
((AVCodecContext *) avctx)->pix_fmt = (int) pix_fmt;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1qcompress (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1qcompress (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jfloat qcompress) {
((AVCodecContext *) avctx)->qcompress = (float) qcompress;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1quantizer (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1quantizer (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint qmin, jint qmax,
jint max_qdiff) {
AVCodecContext *n_avctx = (AVCodecContext *) avctx;
@ -279,13 +279,13 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1rc_1buffer_1size (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1rc_1buffer_1size (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint rc_buffer_size) {
((AVCodecContext *) avctx)->rc_buffer_size = (int) rc_buffer_size;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1rc_1eq (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1rc_1eq (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jstring rc_eq) {
char *n_rc_eq;
@ -304,19 +304,19 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1rc_1max_1rate (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1rc_1max_1rate (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint rc_max_rate) {
((AVCodecContext *) avctx)->rc_max_rate = (int) rc_max_rate;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1refs (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1refs (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint refs) {
((AVCodecContext *) avctx)->refs = (int) refs;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1sample_1aspect_1ratio (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1sample_1aspect_1ratio (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint num, jint den) {
AVRational *sample_aspect_ratio =
&(((AVCodecContext *) avctx)->sample_aspect_ratio);
@ -326,14 +326,14 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1scenechange_1threshold (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1scenechange_1threshold (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint scenechange_threshold) {
((AVCodecContext *) avctx)->scenechange_threshold =
(int) scenechange_threshold;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1size (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1size (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint width, jint height) {
AVCodecContext *n_avctx = (AVCodecContext *) avctx;
@ -342,19 +342,19 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1thread_1count (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1thread_1count (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint thread_count) {
((AVCodecContext *) avctx)->thread_count = (int) thread_count;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1ticks_1per_1frame (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1ticks_1per_1frame (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint ticks_per_frame) {
((AVCodecContext *) avctx)->ticks_per_frame = (int) ticks_per_frame;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1time_1base (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1time_1base (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint num, jint den) {
AVRational *time_base = &(((AVCodecContext *) avctx)->time_base);
@ -363,19 +363,19 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1trellis (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1trellis (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint trellis) {
((AVCodecContext *) avctx)->trellis = (int) trellis;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1workaround_1bugs (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1workaround_1bugs (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint workaround_bugs) {
((AVCodecContext *) avctx)->workaround_bugs = (int) workaround_bugs;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avframe_1set_1data (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avframe_1set_1data (
JNIEnv *jniEnv, jclass clazz, jlong frame, jlong data0, jlong offset1,
jlong offset2) {
AVFrame *n_frame = (AVFrame *) frame;
@ -386,13 +386,13 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avframe_1set_1da
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avframe_1set_1key_1frame (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avframe_1set_1key_1frame (
JNIEnv *jniEnv, jclass clazz, jlong frame, jboolean key_frame) {
((AVFrame *) frame)->key_frame = (JNI_TRUE == key_frame) ? 1 : 0;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avframe_1set_1linesize (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avframe_1set_1linesize (
JNIEnv *jniEnv, jclass clazz, jlong frame, jint linesize0,
jint linesize1, jint linesize2) {
AVFrame *n_frame = (AVFrame *) frame;
@ -403,7 +403,7 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avframe_1set_1li
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avpicture_1fill (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avpicture_1fill (
JNIEnv *jniEnv, jclass clazz, jlong picture, jlong ptr, jint pix_fmt,
jint width, jint height) {
return (jint)
@ -412,31 +412,47 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avpicture_1fill
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avpicture_1get_1data0 (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avpicture_1get_1data0 (
JNIEnv *jniEnv, jclass clazz, jlong picture) {
return (jlong) (((AVPicture *) picture)->data[0]);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avpicture_1get_1size (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avpicture_1get_1size (
JNIEnv *jniEnv, jclass clazz, jint pix_fmt, jint width, jint height) {
return (jint) avpicture_get_size ((int) pix_fmt, (int) width, (int) height);
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_memcpy___3IIIJ (
JNIEnv *jniEnv, jclass clazz, jintArray dst, jint dst_offset,
jint dst_length, jlong src) {
(*jniEnv)
->SetIntArrayRegion (jniEnv, dst, dst_offset, dst_length, (jint *) src);
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_memcpy__J_3BII (
JNIEnv *jniEnv, jclass clazz, jlong dst, jbyteArray src,
jint src_offset, jint src_length) {
(*jniEnv)->GetByteArrayRegion (jniEnv, src, src_offset, src_length,
(jbyte *) dst);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getBGR32Format (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1BGR32 (
JNIEnv *env, jclass clazz) {
return PIX_FMT_BGR32;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getBGR32_11Format (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1BGR32_11 (
JNIEnv *env, jclass clazz) {
return PIX_FMT_BGR32_1;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getRGB24Format (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1RGB24 (
JNIEnv *jniEnv, jclass clazz) {
uint32_t test = 1;
int little_endian = *((uint8_t*)&test);
@ -445,124 +461,95 @@ Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getRGB24Format (
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getRGB32Format (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1RGB32 (
JNIEnv *env, jclass clazz) {
return PIX_FMT_RGB32;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getRGB32_11Format (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1RGB32_11 (
JNIEnv *env, jclass clazz) {
return PIX_FMT_RGB32_1;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getYUV420PFormat (
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1YUV420P (
JNIEnv *env, jclass clazz) {
return PIX_FMT_YUV420P;
}
static int image_convert (AVPicture* dst, int dst_pix_fmt, const AVPicture* src,
int pix_fmt, int width, int height, int newWidth, int newHeight) {
struct SwsContext *img_convert_ctx
= sws_getContext(
width, height, pix_fmt,
newWidth, newHeight, dst_pix_fmt,
SWS_BICUBIC, NULL, NULL, NULL);
int result
= sws_scale(
img_convert_ctx,
(uint8_t**)src->data, (int*)src->linesize, 0, height,
dst->data, dst->linesize);
sws_freeContext(img_convert_ctx);
return result;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_img_1convert__JIJIII (
JNIEnv *jniEnv, jclass clazz, jlong dst, jint dst_pix_fmt, jlong src,
jint pix_fmt, jint width, jint height) {
return (jint)
image_convert (
(AVPicture *) dst, (int) dst_pix_fmt,
(const AVPicture *) src, (int) pix_fmt,
(int) width, (int) height,
(int) width, (int) height);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_img_1convert__Ljava_lang_Object_2IJIIIII (
JNIEnv *jniEnv, jclass clazz, jobject dst, jint dst_pix_fmt,
jlong src, jint pix_fmt, jint width, jint height, jint newWidth, jint newHeight) {
uint8_t* dst_buf = (*jniEnv)->GetPrimitiveArrayCritical(jniEnv, (jarray)dst, 0);
jint ret;
if (dst_buf)
{
AVPicture dst_dummy;
/* Turn the bytes into an AVPicture. */
avpicture_fill(
&dst_dummy,
dst_buf,
(int)dst_pix_fmt,
newWidth, newHeight);
ret
= image_convert(
&dst_dummy, (int) dst_pix_fmt,
(AVPicture *) src, (int) pix_fmt, (int) width, (int) height,
(int) newWidth, (int) newHeight);
(*jniEnv)->ReleasePrimitiveArrayCritical(jniEnv, dst, dst_buf, 0);
}
else
ret = -1;
return ret;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_img_1convert__Ljava_lang_Object_2ILjava_lang_Object_2IIIII (
JNIEnv *jniEnv, jclass clazz, jobject dst, jint dst_pix_fmt,
jobject src, jint pix_fmt, jint width, jint height, jint newWidth, jint newHeight) {
uint8_t* src_buf = (*jniEnv)->GetPrimitiveArrayCritical(jniEnv, (jarray) src, 0);
jint ret;
if (src_buf)
{
AVPicture src_dummy;
/* Turn the bytes into an AVPicture. */
avpicture_fill(&src_dummy, src_buf, (int) pix_fmt, width, height);
ret
= Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_img_1convert__Ljava_lang_Object_2IJIIIII(
jniEnv, clazz,
dst, dst_pix_fmt,
(jlong) &src_dummy, pix_fmt, width, height,
newWidth, newHeight);
/* Clean up. */
(*jniEnv)->ReleasePrimitiveArrayCritical(jniEnv, src, src_buf, 0);
}
else
ret = -1;
return ret;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_memcpy___3IIIJ (
JNIEnv *jniEnv, jclass clazz, jintArray dst, jint dst_offset,
jint dst_length, jlong src) {
(*jniEnv)
->SetIntArrayRegion (jniEnv, dst, dst_offset, dst_length, (jint *) src);
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_memcpy__J_3BII (
JNIEnv *jniEnv, jclass clazz, jlong dst, jbyteArray src,
jint src_offset, jint src_length) {
(*jniEnv)->GetByteArrayRegion (jniEnv, src, src_offset, src_length,
(jbyte *) dst);
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1freeContext (
JNIEnv *jniEnv, jclass clazz, jlong context) {
sws_freeContext ((struct SwsContext *) context);
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1getCachedContext (
JNIEnv *jniEnv, jclass clazz, jlong context, jint srcW, jint srcH,
jint srcFormat, jint dstW, jint dstH, jint dstFormat, jint flags) {
return
(jlong)
sws_getCachedContext (
(struct SwsContext *) context,
(int) srcW, (int) srcH, (enum PixelFormat) srcFormat,
(int) dstW, (int) dstH, (enum PixelFormat) dstFormat,
(int) flags,
NULL, NULL, NULL);
}
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1scale__JJIILjava_lang_Object_2III (
JNIEnv *jniEnv, jclass clazz, jlong context, jlong src, jint srcSliceY,
jint srcSliceH, jobject dst, jint dstFormat, jint dstW, jint dstH) {
AVPicture *srcPicture;
uint8_t *dstPtr;
int ret;
srcPicture = (AVPicture *) src;
dstPtr = (*jniEnv)->GetPrimitiveArrayCritical (jniEnv, dst, NULL);
if (dstPtr) {
AVPicture dstPicture;
/* Turn the bytes into an AVPicture. */
avpicture_fill (
&dstPicture, dstPtr, (int) dstFormat, (int) dstW, (int) dstH);
ret
= sws_scale (
(struct SwsContext *) context,
(uint8_t **) srcPicture->data, (int *) srcPicture->linesize,
(int) srcSliceY, (int) srcSliceH,
(uint8_t **) dstPicture.data,
(int *) dstPicture.linesize);
(*jniEnv)->ReleasePrimitiveArrayCritical (jniEnv, dst, dstPtr, 0);
}
else
ret = -1;
return (jint) ret;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1scale__JLjava_lang_Object_2IIIIILjava_lang_Object_2III (
JNIEnv *jniEnv, jclass class, jlong context, jobject src,
jint srcFormat, jint srcW, jint srcH, jint srcSliceY, jint srcSliceH,
jobject dst, jint dstFormat, jint dstW, jint dstH) {
uint8_t *srcPtr;
jint ret;
srcPtr = (*jniEnv)->GetPrimitiveArrayCritical (jniEnv, src, NULL);
if (srcPtr) {
AVPicture srcPicture;
avpicture_fill (
&srcPicture, srcPtr, (int) srcFormat, (int) srcW, (int) srcH);
ret
= Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1scale__JJIILjava_lang_Object_2III (
jniEnv, class,
context,
(jlong) &srcPicture, srcSliceY, srcSliceH,
dst, dstFormat, dstW, dstH);
(*jniEnv)->ReleasePrimitiveArrayCritical (jniEnv, src, srcPtr, 0);
}
else
ret = -1;
return ret;
}

@ -1,529 +1,523 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG */
/* Header for class net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg */
#ifndef _Included_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
#define _Included_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
#ifndef _Included_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
#define _Included_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
#ifdef __cplusplus
extern "C" {
#endif
#undef net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_CODEC_FLAG_LOOP_FILTER
#define net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_CODEC_FLAG_LOOP_FILTER 2048L
#undef net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_CODEC_ID_H264
#define net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_CODEC_ID_H264 28L
#undef net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_FF_BUG_AUTODETECT
#define net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_FF_BUG_AUTODETECT 1L
#undef net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_FF_CMP_CHROMA
#define net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_FF_CMP_CHROMA 256L
#undef net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_FF_INPUT_BUFFER_PADDING_SIZE
#define net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_FF_INPUT_BUFFER_PADDING_SIZE 8L
#undef net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_FF_MB_DECISION_SIMPLE
#define net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_FF_MB_DECISION_SIMPLE 0L
#undef net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_X264_RC_ABR
#define net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_X264_RC_ABR 2L
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: av_free
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_av_1free
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_av_1free
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: av_malloc
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_av_1malloc
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_av_1malloc
(JNIEnv *, jclass, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: av_register_all
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_av_1register_1all
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_av_1register_1all
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_alloc_context
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1alloc_1context
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1alloc_1context
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_alloc_frame
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1alloc_1frame
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1alloc_1frame
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_close
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1close
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1close
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_decode_video
* Signature: (JJ[Z[BI)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1decode_1video
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1decode_1video
(JNIEnv *, jclass, jlong, jlong, jbooleanArray, jbyteArray, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_encode_video
* Signature: (J[BIJ)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1encode_1video
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1encode_1video
(JNIEnv *, jclass, jlong, jbyteArray, jint, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_find_decoder
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1find_1decoder
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1find_1decoder
(JNIEnv *, jclass, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_find_encoder
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1find_1encoder
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1find_1encoder
(JNIEnv *, jclass, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_init
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1init
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1init
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodec_open
* Signature: (JJ)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodec_1open
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodec_1open
(JNIEnv *, jclass, jlong, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_add_flags
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1add_1flags
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1add_1flags
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_add_partitions
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1add_1partitions
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1add_1partitions
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_get_height
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1get_1height
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1get_1height
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_get_pix_fmt
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1get_1pix_1fmt
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1get_1pix_1fmt
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_get_width
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1get_1width
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1get_1width
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_b_frame_strategy
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1b_1frame_1strategy
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1b_1frame_1strategy
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_bit_rate
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1bit_1rate
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1bit_1rate
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_bit_rate_tolerance
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1bit_1rate_1tolerance
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1bit_1rate_1tolerance
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_chromaoffset
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1chromaoffset
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1chromaoffset
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_crf
* Signature: (JF)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1crf
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1crf
(JNIEnv *, jclass, jlong, jfloat);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_deblockbeta
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1deblockbeta
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1deblockbeta
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_gop_size
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1gop_1size
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1gop_1size
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_i_quant_factor
* Signature: (JF)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1i_1quant_1factor
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1i_1quant_1factor
(JNIEnv *, jclass, jlong, jfloat);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_max_b_frames
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1max_1b_1frames
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1max_1b_1frames
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_mb_decision
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1mb_1decision
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1mb_1decision
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_me_cmp
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1me_1cmp
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1me_1cmp
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_me_method
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1me_1method
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1me_1method
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_me_range
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1me_1range
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1me_1range
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_me_subpel_quality
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1me_1subpel_1quality
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1me_1subpel_1quality
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_pix_fmt
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1pix_1fmt
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1pix_1fmt
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_qcompress
* Signature: (JF)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1qcompress
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1qcompress
(JNIEnv *, jclass, jlong, jfloat);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_quantizer
* Signature: (JIII)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1quantizer
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1quantizer
(JNIEnv *, jclass, jlong, jint, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_rc_buffer_size
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1rc_1buffer_1size
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1rc_1buffer_1size
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_rc_eq
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1rc_1eq
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1rc_1eq
(JNIEnv *, jclass, jlong, jstring);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_rc_max_rate
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1rc_1max_1rate
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1rc_1max_1rate
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_refs
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1refs
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1refs
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_sample_aspect_ratio
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1sample_1aspect_1ratio
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1sample_1aspect_1ratio
(JNIEnv *, jclass, jlong, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_scenechange_threshold
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1scenechange_1threshold
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1scenechange_1threshold
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_size
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1size
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1size
(JNIEnv *, jclass, jlong, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_thread_count
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1thread_1count
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1thread_1count
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_ticks_per_frame
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1ticks_1per_1frame
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1ticks_1per_1frame
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_time_base
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1time_1base
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1time_1base
(JNIEnv *, jclass, jlong, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_trellis
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1trellis
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1trellis
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avcodeccontext_set_workaround_bugs
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avcodeccontext_1set_1workaround_1bugs
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avcodeccontext_1set_1workaround_1bugs
(JNIEnv *, jclass, jlong, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avframe_set_data
* Signature: (JJJJ)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avframe_1set_1data
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avframe_1set_1data
(JNIEnv *, jclass, jlong, jlong, jlong, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avframe_set_key_frame
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avframe_1set_1key_1frame
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avframe_1set_1key_1frame
(JNIEnv *, jclass, jlong, jboolean);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avframe_set_linesize
* Signature: (JIII)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avframe_1set_1linesize
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avframe_1set_1linesize
(JNIEnv *, jclass, jlong, jint, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avpicture_fill
* Signature: (JJIII)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avpicture_1fill
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avpicture_1fill
(JNIEnv *, jclass, jlong, jlong, jint, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avpicture_get_data0
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avpicture_1get_1data0
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avpicture_1get_1data0
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: avpicture_get_size
* Signature: (III)I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_avpicture_1get_1size
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_avpicture_1get_1size
(JNIEnv *, jclass, jint, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: getRGB32Format
* Signature: ()I
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: memcpy
* Signature: ([IIIJ)V
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getRGB32Format
(JNIEnv *, jclass);
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_memcpy___3IIIJ
(JNIEnv *, jclass, jintArray, jint, jint, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: memcpy
* Signature: (J[BII)V
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_memcpy__J_3BII
(JNIEnv *, jclass, jlong, jbyteArray, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: getRGB32_1Format
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: PIX_FMT_BGR32
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getRGB32_11Format
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1BGR32
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: getBGR32Format
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: PIX_FMT_BGR32_1
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getBGR32Format
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1BGR32_11
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: getBGR32_1Format
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: PIX_FMT_RGB24
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getBGR32_11Format
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1RGB24
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: getRGB24Format
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: PIX_FMT_RGB32
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getRGB24Format
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1RGB32
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: getYUV420PFormat
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: PIX_FMT_RGB32_1
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_getYUV420PFormat
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1RGB32_11
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: img_convert
* Signature: (JIJIII)I
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: PIX_FMT_YUV420P
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_img_1convert__JIJIII
(JNIEnv *, jclass, jlong, jint, jlong, jint, jint, jint);
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_PIX_1FMT_1YUV420P
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: img_convert
* Signature: (Ljava/lang/Object;IJIIIII)I
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: sws_freeContext
* Signature: (J)V
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_img_1convert__Ljava_lang_Object_2IJIIIII
(JNIEnv *, jclass, jobject, jint, jlong, jint, jint, jint, jint, jint);
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1freeContext
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: img_convert
* Signature: (Ljava/lang/Object;ILjava/lang/Object;IIIII)I
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: sws_getCachedContext
* Signature: (JIIIIIII)J
*/
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_img_1convert__Ljava_lang_Object_2ILjava_lang_Object_2IIIII
(JNIEnv *, jclass, jobject, jint, jobject, jint, jint, jint, jint, jint);
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1getCachedContext
(JNIEnv *, jclass, jlong, jint, jint, jint, jint, jint, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: memcpy
* Signature: ([IIIJ)V
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: sws_scale
* Signature: (JJIILjava/lang/Object;III)I
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_memcpy___3IIIJ
(JNIEnv *, jclass, jintArray, jint, jint, jlong);
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1scale__JJIILjava_lang_Object_2III
(JNIEnv *, jclass, jlong, jlong, jint, jint, jobject, jint, jint, jint);
/*
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG
* Method: memcpy
* Signature: (J[BII)V
* Class: net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg
* Method: sws_scale
* Signature: (JLjava/lang/Object;IIIIILjava/lang/Object;III)I
*/
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFMPEG_memcpy__J_3BII
(JNIEnv *, jclass, jlong, jbyteArray, jint, jint);
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_codec_video_FFmpeg_sws_1scale__JLjava_lang_Object_2IIIIILjava_lang_Object_2III
(JNIEnv *, jclass, jlong, jobject, jint, jint, jint, jint, jint, jobject, jint, jint, jint);
#ifdef __cplusplus
}

@ -4,13 +4,16 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.neomedia.codec.audio.g729;
package net.java.sip.communicator.impl.neomedia.codec;
import javax.media.*;
import net.sf.fmj.media.*;
/**
* Extends FMJ's <tt>AbstractCodec</tt> to make it even easier to implement a
* <tt>Codec</tt>.
*
* @author Lubomir Marinov
*/
public abstract class AbstractCodecExt

@ -59,9 +59,10 @@ public class EncodingConfiguration
FMJConditionals.FMJ_CODECS
? "net.sf.fmj.media.codec.audio.ulaw.Packetizer"
: "net.java.sip.communicator.impl.neomedia.codec.audio.ulaw.Packetizer",
"net.java.sip.communicator.impl.neomedia.codec.video.h264.DePacketizer",
"net.java.sip.communicator.impl.neomedia.codec.video.h264.JNIDecoder",
"net.java.sip.communicator.impl.neomedia.codec.video.h264.JNIEncoder",
"net.java.sip.communicator.impl.neomedia.codec.video.h264.Packetizer",
"net.java.sip.communicator.impl.neomedia.codec.video.h264.JNIDecoder",
//"net.java.sip.communicator.impl.neomedia.codec.video.ImageScaler",
"net.java.sip.communicator.impl.neomedia.codec.video.SwScaler",
"net.java.sip.communicator.impl.neomedia.codec.audio.speex.JavaEncoder",
@ -329,9 +330,13 @@ public void registerCustomCodecs()
.getPlugInList(null, null, PlugInManager.CODEC));
boolean commit = false;
/* remove JavaRGBToYUV */
PlugInManager.removePlugIn("com.sun.media.codec.video.colorspace.JavaRGBToYUV", PlugInManager.CODEC);
PlugInManager.removePlugIn("com.sun.media.codec.video.colorspace.JavaRGBConverter", PlugInManager.CODEC);
// Remove JavaRGBToYUV.
PlugInManager.removePlugIn(
"com.sun.media.codec.video.colorspace.JavaRGBToYUV",
PlugInManager.CODEC);
PlugInManager.removePlugIn(
"com.sun.media.codec.video.colorspace.JavaRGBConverter",
PlugInManager.CODEC);
for (String className : CUSTOM_CODECS)
{

@ -10,6 +10,7 @@
import javax.media.format.*;
import net.java.sip.communicator.impl.neomedia.*;
import net.java.sip.communicator.impl.neomedia.codec.*;
/**
* @author Lubomir Marinov

@ -12,6 +12,7 @@
import javax.media.format.*;
import net.java.sip.communicator.impl.neomedia.*;
import net.java.sip.communicator.impl.neomedia.codec.*;
/**
* @author Lubomir Marinov

@ -0,0 +1,48 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.neomedia.codec.video;
/**
* Represents a pointer to a native FFmpeg <tt>AVFrame</tt> object.
*
* @author Lubomir Marinov
*/
public class AVFrame
{
/**
* The pointer to the native FFmpeg <tt>AVFrame</tt> object represented by
* this instance.
*/
private final long ptr;
/**
* Initializes a new <tt>AVFrame</tt> instance which is to represent a
* specific pointer to a native FFmpeg <tt>AVFrame</tt> object.
*
* @param ptr the pointer to the native FFmpeg <tt>AVFrame</tt> object to be
* represented by the new instance
*/
public AVFrame(long ptr)
{
if (ptr == 0)
throw new IllegalArgumentException("ptr");
this.ptr = ptr;
}
/**
* Gets the pointer to the native FFmpeg <tt>AVFrame</tt> object represented
* by this instance.
*
* @return the pointer to the native FFmpeg <tt>AVFrame</tt> object
* represented by this instance
*/
public long getPtr()
{
return ptr;
}
}

@ -0,0 +1,104 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.neomedia.codec.video;
import java.awt.*;
import javax.media.*;
import javax.media.format.*;
/**
* Implements a <tt>VideoFormat</tt> for a <tt>Buffer</tt> carrying
* <tt>AVFrame</tt> as its <tt>data</tt>. While the <tt>AVFrameFormat</tt> class
* is not strictly necessary and <tt>VideoFormat</tt> could have be directly
* used, it is conceived as an appripriate way to avoid possible matching with
* other <tt>VideoFormat</tt>s and a very obvious one.
*
* @author Lubomir Marinov
*/
public class AVFrameFormat
extends VideoFormat
{
private int pixFmt;
/**
* Initializes a new <tt>AVFrameFormat</tt> instance with unspecified size
* and frame rate.
*/
public AVFrameFormat()
{
this(null, NOT_SPECIFIED);
}
/**
* Initializes a new <tt>AVFrameFormat</tt> instance with specific size and
* frame rate.
*/
public AVFrameFormat(Dimension size, float frameRate)
{
super("AVFrame", size, NOT_SPECIFIED, AVFrame.class, frameRate);
this.pixFmt = FFmpeg.PIX_FMT_YUV420P;
}
/**
* Initializes a new <tt>AVFrameFormat</tt> instance which has the same
* properties as this instance.
*
* @return a new <tt>AVFrameFormat</tt> instance which has the same
* properties as this instance
*/
@Override
public Object clone()
{
AVFrameFormat f = new AVFrameFormat(size, frameRate);
f.copy(this);
return f;
}
@Override
protected void copy(Format f)
{
super.copy(f);
if (f instanceof AVFrameFormat)
{
AVFrameFormat avFrameFormat = (AVFrameFormat) f;
pixFmt = avFrameFormat.pixFmt;
}
}
/**
* Determines whether a specific <tt>Object</tt> represents a value that is
* equal to the value represented by this instance.
*
* @param obj the <tt>Object</tt> to be determined whether it represents a
* value that is equal to the value represented by this instance
* @return <tt>true</tt> if the specified <tt>obj</tt> represents a value
* that is equal to the value represented by this instance; otherwise,
* <tt>false</tt>
*/
@Override
public boolean equals(Object obj)
{
if ((obj instanceof AVFrameFormat) && super.equals(obj))
{
AVFrameFormat avFrameFormat = (AVFrameFormat) obj;
return (pixFmt == avFrameFormat.pixFmt);
}
else
return false;
}
public int getPixFmt()
{
return pixFmt;
}
}

@ -8,8 +8,9 @@
/**
* @author Lubomir Marinov
* @author Sebastien Vincent
*/
public class FFMPEG
public class FFmpeg
{
public static final int CODEC_FLAG_LOOP_FILTER = 0x00000800;
@ -22,25 +23,13 @@ public class FFMPEG
public static final int FF_INPUT_BUFFER_PADDING_SIZE = 8;
public static final int FF_MB_DECISION_SIMPLE = 0;
/**
* RGB32 format handled in endian specific manner.
* It is stored as ARGB on big-endian and BGRA on little-endian.
*/
public static final int PIX_FMT_RGB32;
/**
* RGB32_1 format handled in endian specific manner.
* It is stored as RGBA on big-endian and ABGR on little-endian.
*/
public static final int PIX_FMT_RGB32_1;
/**
* BGR32 format handled in endian specific manner.
* It is stored as ABGR on big-endian and RGBA on little-endian.
*/
public static final int PIX_FMT_BGR32;
/**
* BGR32_1 format handled in endian specific manner.
* It is stored as BGRA on big-endian and ARGB on little-endian.
@ -53,21 +42,23 @@ public class FFMPEG
*/
public static final int PIX_FMT_RGB24;
public static final int PIX_FMT_YUV420P;
public static final int X264_RC_ABR = 2;
/**
* RGB32 format handled in endian specific manner.
* It is stored as ARGB on big-endian and BGRA on little-endian.
*/
public static final int PIX_FMT_RGB32;
public static native int getRGB32Format();
public static native int getRGB32_1Format();
public static native int getBGR32Format();
/**
* RGB32_1 format handled in endian specific manner.
* It is stored as RGBA on big-endian and ABGR on little-endian.
*/
public static final int PIX_FMT_RGB32_1;
public static native int getBGR32_1Format();
public static final int PIX_FMT_YUV420P;
public static native int getRGB24Format();
public static final int SWS_BICUBIC = 4;
public static native int getYUV420PFormat();
public static final int X264_RC_ABR = 2;
public static native void av_free(long ptr);
@ -105,14 +96,23 @@ public static native void avcodeccontext_add_partitions(long avctx,
public static native int avcodeccontext_get_pix_fmt(long avctx);
public static native int avcodeccontext_get_width(long avctx);
public static native void avcodeccontext_set_b_frame_strategy(long avctx,
int b_frame_strategy);
public static native void avcodeccontext_set_bit_rate(long avctx,
int bit_rate);
public static native void avcodeccontext_set_bit_rate_tolerance(long avctx,
int bit_rate_tolerance);
public static native void avcodeccontext_set_chromaoffset(long avctx,
int chromaoffset);
public static native void avcodeccontext_set_crf(long avctx, float crf);
public static native void avcodeccontext_set_deblockbeta(long avctx,
int deblockbeta);
public static native void avcodeccontext_set_gop_size(long avctx,
int gop_size);
@ -120,6 +120,9 @@ public static native void avcodeccontext_set_gop_size(long avctx,
public static native void avcodeccontext_set_i_quant_factor(long avctx,
float i_quant_factor);
public static native void avcodeccontext_set_max_b_frames(long avctx,
int max_b_frames);
public static native void avcodeccontext_set_mb_decision(long avctx,
int mb_decision);
@ -149,6 +152,9 @@ public static native void avcodeccontext_set_rc_buffer_size(long avctx,
public static native void avcodeccontext_set_rc_max_rate(long avctx,
int rc_max_rate);
public static native void avcodeccontext_set_refs(long avctx,
int refs);
public static native void avcodeccontext_set_sample_aspect_ratio(
long avctx, int num, int den);
@ -161,34 +167,19 @@ public static native void avcodeccontext_set_size(long avctx, int width,
public static native void avcodeccontext_set_thread_count(long avctx,
int thread_count);
public static native void avcodeccontext_set_ticks_per_frame(long avctx,
int ticks_per_frame);
public static native void avcodeccontext_set_time_base(long avctx, int num,
int den);
public static native void avcodeccontext_set_trellis(long avctx,
int trellis);
public static native void avcodeccontext_set_workaround_bugs(long avctx,
int workaround_bugs);
public static native void avcodeccontext_set_max_b_frames(long avctx,
int max_b_frames);
public static native void avcodeccontext_set_b_frame_strategy(long avctx,
int b_frame_strategy);
public static native void avcodeccontext_set_trellis(long avctx,
int trellis);
public static native void avcodeccontext_set_refs(long avctx,
int refs);
public static native void avcodeccontext_set_chromaoffset(long avctx,
int chromaoffset);
public static native void avcodeccontext_set_deblockbeta(long avctx,
int deblockbeta);
public static native void avcodeccontext_set_ticks_per_frame(long avctx,
int ticks_per_frame);
public static native void avframe_set_data(long frame, long data0,
long offset1, long offset2);
@ -206,43 +197,55 @@ public static native int avpicture_fill(long picture, long ptr,
public static native int avpicture_get_size(int pix_fmt, int width,
int height);
public static native int img_convert(long dst, int dst_pix_fmt, long src,
int pix_fmt, int width, int height);
/**
* Convert image bytes (scale/format).
*
* @param dst destination image. Its type must be an array (int[], byte[]
* or short[])
* @param dst_pix_fmt destination format
* @param src source image. Its type must be an array (int[], byte[] or short[])
* @param pix_fmt the format of <tt>src</tt>
* @param width original width
* @param height original height
* @param newWidth new width
* @param newHeight new height
*/
public static native int img_convert(Object dst, int dst_pix_fmt,
Object src, int pix_fmt, int width, int height, int newWidth,
int newHeight);
public static native void memcpy(int[] dst, int dst_offset, int dst_length,
long src);
public static native void memcpy(long dst, byte[] src, int src_offset,
int src_length);
private static native int PIX_FMT_BGR32();
private static native int PIX_FMT_BGR32_1();
private static native int PIX_FMT_RGB24();
private static native int PIX_FMT_RGB32();
private static native int PIX_FMT_RGB32_1();
private static native int PIX_FMT_YUV420P();
public static native void sws_freeContext(long context);
public static native long sws_getCachedContext(
long context,
int srcW, int srcH, int srcFormat,
int dstW, int dstH, int dstFormat,
int flags);
public static native int sws_scale(
long context,
long src, int srcSliceY, int srcSliceH,
Object dst, int dstFormat, int dstW, int dstH);
public static native int sws_scale(
long context,
Object src, int srcFormat, int srcW, int srcH,
int srcSliceY, int srcSliceH,
Object dst, int dstFormat, int dstW, int dstH);
static
{
System.loadLibrary("ffmpeg");
av_register_all();
avcodec_init();
PIX_FMT_RGB24 = getRGB24Format();
PIX_FMT_RGB32 = getRGB32Format();
PIX_FMT_RGB32_1 = getRGB32_1Format();
PIX_FMT_BGR32 = getBGR32Format();
PIX_FMT_BGR32_1 = getBGR32_1Format();
PIX_FMT_YUV420P = getYUV420PFormat();
PIX_FMT_BGR32 = PIX_FMT_BGR32();
PIX_FMT_BGR32_1 = PIX_FMT_BGR32_1();
PIX_FMT_RGB24 = PIX_FMT_RGB24();
PIX_FMT_RGB32 = PIX_FMT_RGB32();
PIX_FMT_RGB32_1 = PIX_FMT_RGB32_1();
PIX_FMT_YUV420P = PIX_FMT_YUV420P();
}
}

@ -39,25 +39,6 @@ public class SwScaler
private final FrameProcessingControlImpl frameProcessingControl
= new FrameProcessingControlImpl();
/**
* Supported input formats.
*/
private final Format[] supportedInputFormats = new Format[]
{
new RGBFormat(null, -1, Format.byteArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(null, -1, Format.intArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(null, -1, Format.shortArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(null, -1, Format.byteArray, -1.0f, 24, -1, -1, -1),
new RGBFormat(null, -1, Format.intArray, -1.0f, 24, -1, -1, -1),
new RGBFormat(null, -1, Format.shortArray, -1.0f, 24, -1, -1, -1),
new YUVFormat(null, -1, Format.byteArray, -1.0f, YUVFormat.YUV_420,
-1, -1, 0, -1, -1),
new YUVFormat(null, -1, Format.intArray, -1.0f, YUVFormat.YUV_420,
-1, -1, 0, -1, -1),
new YUVFormat(null, -1, Format.shortArray, -1.0f, YUVFormat.YUV_420,
-1, -1, 0, -1, -1),
};
/**
* Supported output formats.
*/
@ -77,6 +58,8 @@ public class SwScaler
new RGBFormat(null, -1, Format.shortArray, -1.0f, 24, -1, -1, -1),
};
private long swsContext = 0;
/**
* Initializes a new <tt>SwScaler</tt> instance which doesn't have an output
* size and will use a default one when it becomes necessary unless an
@ -84,123 +67,41 @@ public class SwScaler
*/
public SwScaler()
{
inputFormats = new Format[]
{
new AVFrameFormat(),
new RGBFormat(null, -1, Format.byteArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(null, -1, Format.intArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(null, -1, Format.shortArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(null, -1, Format.byteArray, -1.0f, 24, -1, -1, -1),
new RGBFormat(null, -1, Format.intArray, -1.0f, 24, -1, -1, -1),
new RGBFormat(null, -1, Format.shortArray, -1.0f, 24, -1, -1, -1),
new YUVFormat(null, -1, Format.byteArray, -1.0f, YUVFormat.YUV_420,
-1, -1, 0, -1, -1),
new YUVFormat(null, -1, Format.intArray, -1.0f, YUVFormat.YUV_420,
-1, -1, 0, -1, -1),
new YUVFormat(null, -1, Format.shortArray, -1.0f, YUVFormat.YUV_420,
-1, -1, 0, -1, -1),
};
addControl(frameProcessingControl);
}
/**
* Sets the <tt>Format</tt> in which this <tt>Codec</tt> is to output media
* data.
*
* @param format the <tt>Format</tt> in which this <tt>Codec</tt> is to
* output media data
* @return the <tt>Format</tt> in which this <tt>Codec</tt> is currently
* configured to output media data or <tt>null</tt> if <tt>format</tt> was
* found to be incompatible with this <tt>Codec</tt>
*/
@Override
public Format setOutputFormat(Format format)
public void close()
{
Format outputFormat = super.setOutputFormat(format);
if (logger.isDebugEnabled() && (outputFormat != null))
logger.debug("SwScaler set to output in " + outputFormat);
return outputFormat;
}
/**
* Sets the output size.
*
* @param size the size to set as the output size
*/
public void setOutputSize(Dimension size)
{
if(size == null)
size = new Dimension(640, 480);
supportedOutputFormats[0]
= new YUVFormat(size, -1, Format.byteArray, -1.0f,
YUVFormat.YUV_420, -1, -1, 0, -1, -1);
supportedOutputFormats[1]
= new YUVFormat(size, -1, Format.intArray, -1.0f, YUVFormat.YUV_420,
-1, -1, 0, -1, -1);
supportedOutputFormats[2]
= new YUVFormat(size, -1, Format.shortArray, -1.0f,
YUVFormat.YUV_420, -1, -1, 0, -1, -1);
supportedOutputFormats[3]
= new RGBFormat(size, -1, Format.byteArray, -1.0f, 32, -1, -1, -1);
supportedOutputFormats[4]
= new RGBFormat(size, -1, Format.intArray, -1.0f, 32, -1, -1, -1);
supportedOutputFormats[5]
= new RGBFormat(size, -1, Format.shortArray, -1.0f, 32, -1, -1, -1);
supportedOutputFormats[6]
= new RGBFormat(size, -1, Format.byteArray, -1.0f, 24, -1, -1, -1);
supportedOutputFormats[7]
= new RGBFormat(size, -1, Format.intArray, -1.0f, 24, -1, -1, -1);
supportedOutputFormats[8]
= new RGBFormat(size, -1, Format.shortArray, -1.0f, 24, -1, -1, -1);
// Set the size to the outputFormat as well.
VideoFormat outputFormat = (VideoFormat) getOutputFormat();
/*
* Since the size of the Format has changed, its size-related properties
* should change as well. Format#intersects doesn't seem to be cool
* because it preserves them and thus the resulting Format is
* inconsistent.
*/
if (outputFormat instanceof RGBFormat)
try
{
RGBFormat rgbOutputFormat = (RGBFormat) outputFormat;
Class<?> dataType = outputFormat.getDataType();
int bitsPerPixel = rgbOutputFormat.getBitsPerPixel();
int pixelStride = rgbOutputFormat.getPixelStride();
if ((pixelStride == Format.NOT_SPECIFIED)
&& (dataType != null)
&& (bitsPerPixel != Format.NOT_SPECIFIED))
pixelStride
= dataType.equals(Format.byteArray)
? (bitsPerPixel / 8)
: 1;
setOutputFormat(
new RGBFormat(
size,
Format.NOT_SPECIFIED,
dataType,
outputFormat.getFrameRate(),
bitsPerPixel,
rgbOutputFormat.getRedMask(),
rgbOutputFormat.getGreenMask(),
rgbOutputFormat.getBlueMask(),
pixelStride,
(pixelStride == Format.NOT_SPECIFIED)
? Format.NOT_SPECIFIED
: (pixelStride * size.width), // lineStride
rgbOutputFormat.getFlipped(),
rgbOutputFormat.getEndian()));
if (swsContext != 0)
{
FFmpeg.sws_freeContext(swsContext);
swsContext = 0;
}
}
else if (outputFormat instanceof YUVFormat)
finally
{
YUVFormat yuvOutputFormat = (YUVFormat) outputFormat;
setOutputFormat(
new YUVFormat(
size,
Format.NOT_SPECIFIED,
outputFormat.getDataType(),
outputFormat.getFrameRate(),
yuvOutputFormat.getYuvType(),
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
0,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED));
super.close();
}
else if (outputFormat != null)
logger.warn(
"SwScaler outputFormat of type "
+ outputFormat.getClass().getSimpleName()
+ " is not supported for optimized scaling.");
}
/**
@ -220,6 +121,46 @@ public Format getInputFormat()
return super.getInputFormat();
}
/**
* Gets native (FFmpeg) RGB format.
*
* @param rgb JMF <tt>RGBFormat</tt>
* @return native RGB format
*/
public static int getNativeRGBFormat(RGBFormat rgb)
{
int fmt;
if(rgb.getBitsPerPixel() == 32)
switch(rgb.getRedMask())
{
case 1:
case 0xff:
fmt = FFmpeg.PIX_FMT_BGR32;
break;
case 2:
case (0xff << 8):
fmt = FFmpeg.PIX_FMT_BGR32_1;
break;
case 3:
case (0xff << 16):
fmt = FFmpeg.PIX_FMT_RGB32;
break;
case 4:
case (0xff << 24):
fmt = FFmpeg.PIX_FMT_RGB32_1;
break;
default:
/* assume ARGB ? */
fmt = FFmpeg.PIX_FMT_RGB32;
break;
}
else
fmt = FFmpeg.PIX_FMT_RGB24;
return fmt;
}
/**
* Gets the output size.
*
@ -237,17 +178,6 @@ public Dimension getOutputSize()
return ((VideoFormat) outputFormat).getSize();
}
/**
* Gets the supported input formats.
*
* @return array of supported input format
*/
@Override
public Format[] getSupportedInputFormats()
{
return supportedInputFormats;
}
/**
* Gets the supported output formats for an input one.
*
@ -299,69 +229,6 @@ public Format[] getSupportedOutputFormats(Format input)
};
}
/**
* Sets the input format.
*
* @param format format to set
* @return format
*/
@Override
public Format setInputFormat(Format format)
{
Format inputFormat
= ((format instanceof VideoFormat)
&& (((VideoFormat) format).getSize() == null))
? null // size is required
: super.setInputFormat(format);
if (inputFormat != null)
{
if (logger.isDebugEnabled())
logger.debug("SwScaler set to input in " + inputFormat);
}
return inputFormat;
}
/**
* Gets native (FFMPEG) RGB format.
*
* @param rgb JMF <tt>RGBFormat</tt>
* @return native RGB format
*/
public static int getNativeRGBFormat(RGBFormat rgb)
{
int fmt;
if(rgb.getBitsPerPixel() == 32)
switch(rgb.getRedMask())
{
case 1:
case 0xff:
fmt = FFMPEG.PIX_FMT_BGR32;
break;
case 2:
case (0xff << 8):
fmt = FFMPEG.PIX_FMT_BGR32_1;
break;
case 3:
case (0xff << 16):
fmt = FFMPEG.PIX_FMT_RGB32;
break;
case 4:
case (0xff << 24):
fmt = FFMPEG.PIX_FMT_RGB32_1;
break;
default:
/* assume ARGB ? */
fmt = FFMPEG.PIX_FMT_RGB32;
break;
}
else
fmt = FFMPEG.PIX_FMT_RGB24;
return fmt;
}
/**
* Processes (converts color space and/or scales) a buffer.
*
@ -375,10 +242,9 @@ public int process(Buffer input, Buffer output)
{
if (!checkInputBuffer(input))
return BUFFER_PROCESSED_FAILED;
if (isEOM(input))
{
propagateEOM(output); // TODO Can there be any data?
propagateEOM(output);
return BUFFER_PROCESSED_OK;
}
if (input.isDiscard() || frameProcessingControl.isMinimalProcessing())
@ -387,24 +253,18 @@ public int process(Buffer input, Buffer output)
return BUFFER_PROCESSED_OK;
}
/* determine input format */
VideoFormat inputFormat = (VideoFormat)input.getFormat();
// Determine the input Format.
VideoFormat inputFormat = (VideoFormat) input.getFormat();
Format thisInputFormat = getInputFormat();
if ((inputFormat != thisInputFormat)
&& !inputFormat.equals(thisInputFormat))
setInputFormat(inputFormat);
int srcFmt;
if(inputFormat instanceof YUVFormat)
srcFmt = FFMPEG.PIX_FMT_YUV420P;
else // RGBFormat
srcFmt = getNativeRGBFormat((RGBFormat)inputFormat);
// Determine the output Format and size.
VideoFormat outputFormat = (VideoFormat) getOutputFormat();
if(outputFormat == null)
if (outputFormat == null)
{
/*
* The format of the output Buffer is not documented to be used as
@ -413,7 +273,7 @@ public int process(Buffer input, Buffer output)
* unlikely to ever happen.
*/
outputFormat = (VideoFormat) output.getFormat();
if (outputFormat == null) // first buffer has no output format set
if (outputFormat == null)
return BUFFER_PROCESSED_FAILED;
}
@ -423,35 +283,34 @@ public int process(Buffer input, Buffer output)
int outputWidth = outputSize.width;
int outputHeight = outputSize.height;
/* determine output format and output size needed */
if(outputFormat instanceof YUVFormat)
if (outputFormat instanceof YUVFormat)
{
dstFmt = FFMPEG.PIX_FMT_YUV420P;
dstFmt = FFmpeg.PIX_FMT_YUV420P;
/* YUV420P is 12 bpp (bit per pixel) => 1,5 bytes */
dstLength = (int)(outputWidth * outputHeight * 1.5);
}
else /* RGB format */
{
dstFmt = FFMPEG.PIX_FMT_RGB32;
dstFmt = FFmpeg.PIX_FMT_RGB32;
dstLength = (outputWidth * outputHeight * 4);
}
Class<?> outputDataType = outputFormat.getDataType();
Object dst = output.getData();
if(Format.byteArray.equals(outputDataType))
if (Format.byteArray.equals(outputDataType))
{
if(dst == null || ((byte[])dst).length < dstLength)
dst = new byte[dstLength];
}
else if(Format.intArray.equals(outputDataType))
else if (Format.intArray.equals(outputDataType))
{
/* Java int is always 4 bytes */
dstLength = (dstLength % 4) + dstLength / 4;
if(dst == null || ((int[])dst).length < dstLength)
dst = new int[dstLength];
}
else if(Format.shortArray.equals(outputDataType))
else if (Format.shortArray.equals(outputDataType))
{
/* Java short is always 2 bytes */
dstLength = (dstLength % 2) + dstLength / 2;
@ -464,19 +323,43 @@ else if(Format.shortArray.equals(outputDataType))
return BUFFER_PROCESSED_FAILED;
}
Dimension inputSize = inputFormat.getSize();
int inputWidth = inputSize.width;
int inputHeight = inputSize.height;
Object src = input.getData();
int srcFmt;
long srcPicture;
synchronized(src)
if (src instanceof AVFrame)
{
/* conversion! */
Dimension inputSize = inputFormat.getSize();
FFMPEG.img_convert(
dst, dstFmt,
src, srcFmt,
inputSize.width, inputSize.height,
outputWidth, outputHeight);
srcFmt = ((AVFrameFormat) inputFormat).getPixFmt();
srcPicture = ((AVFrame) src).getPtr();
}
else
{
srcFmt
= (inputFormat instanceof YUVFormat)
? FFmpeg.PIX_FMT_YUV420P
: getNativeRGBFormat((RGBFormat) inputFormat);
srcPicture = 0;
}
swsContext
= FFmpeg.sws_getCachedContext(
swsContext,
inputWidth, inputHeight, srcFmt,
outputWidth, outputHeight, dstFmt,
FFmpeg.SWS_BICUBIC);
if (srcPicture == 0)
FFmpeg.sws_scale(
swsContext,
src, srcFmt, inputWidth, inputHeight, 0, inputHeight,
dst, dstFmt, outputWidth, outputHeight);
else
FFmpeg.sws_scale(
swsContext,
srcPicture, 0, inputHeight,
dst, dstFmt, outputWidth, outputHeight);
output.setData(dst);
output.setDuration(input.getDuration());
@ -489,4 +372,143 @@ else if(Format.shortArray.equals(outputDataType))
return BUFFER_PROCESSED_OK;
}
/**
* Sets the input format.
*
* @param format format to set
* @return format
*/
@Override
public Format setInputFormat(Format format)
{
Format inputFormat
= ((format instanceof VideoFormat)
&& (((VideoFormat) format).getSize() == null))
? null // size is required
: super.setInputFormat(format);
if (inputFormat != null)
{
if (logger.isDebugEnabled())
logger.debug("SwScaler set to input in " + inputFormat);
}
return inputFormat;
}
/**
* Sets the <tt>Format</tt> in which this <tt>Codec</tt> is to output media
* data.
*
* @param format the <tt>Format</tt> in which this <tt>Codec</tt> is to
* output media data
* @return the <tt>Format</tt> in which this <tt>Codec</tt> is currently
* configured to output media data or <tt>null</tt> if <tt>format</tt> was
* found to be incompatible with this <tt>Codec</tt>
*/
@Override
public Format setOutputFormat(Format format)
{
Format outputFormat = super.setOutputFormat(format);
if (logger.isDebugEnabled() && (outputFormat != null))
logger.debug("SwScaler set to output in " + outputFormat);
return outputFormat;
}
/**
* Sets the output size.
*
* @param size the size to set as the output size
*/
public void setOutputSize(Dimension size)
{
if(size == null)
size = new Dimension(640, 480);
supportedOutputFormats[0]
= new YUVFormat(size, -1, Format.byteArray, -1.0f,
YUVFormat.YUV_420, -1, -1, 0, -1, -1);
supportedOutputFormats[1]
= new YUVFormat(size, -1, Format.intArray, -1.0f, YUVFormat.YUV_420,
-1, -1, 0, -1, -1);
supportedOutputFormats[2]
= new YUVFormat(size, -1, Format.shortArray, -1.0f,
YUVFormat.YUV_420, -1, -1, 0, -1, -1);
supportedOutputFormats[3]
= new RGBFormat(size, -1, Format.byteArray, -1.0f, 32, -1, -1, -1);
supportedOutputFormats[4]
= new RGBFormat(size, -1, Format.intArray, -1.0f, 32, -1, -1, -1);
supportedOutputFormats[5]
= new RGBFormat(size, -1, Format.shortArray, -1.0f, 32, -1, -1, -1);
supportedOutputFormats[6]
= new RGBFormat(size, -1, Format.byteArray, -1.0f, 24, -1, -1, -1);
supportedOutputFormats[7]
= new RGBFormat(size, -1, Format.intArray, -1.0f, 24, -1, -1, -1);
supportedOutputFormats[8]
= new RGBFormat(size, -1, Format.shortArray, -1.0f, 24, -1, -1, -1);
// Set the size to the outputFormat as well.
VideoFormat outputFormat = (VideoFormat) getOutputFormat();
/*
* Since the size of the Format has changed, its size-related properties
* should change as well. Format#intersects doesn't seem to be cool
* because it preserves them and thus the resulting Format is
* inconsistent.
*/
if (outputFormat instanceof RGBFormat)
{
RGBFormat rgbOutputFormat = (RGBFormat) outputFormat;
Class<?> dataType = outputFormat.getDataType();
int bitsPerPixel = rgbOutputFormat.getBitsPerPixel();
int pixelStride = rgbOutputFormat.getPixelStride();
if ((pixelStride == Format.NOT_SPECIFIED)
&& (dataType != null)
&& (bitsPerPixel != Format.NOT_SPECIFIED))
pixelStride
= dataType.equals(Format.byteArray)
? (bitsPerPixel / 8)
: 1;
setOutputFormat(
new RGBFormat(
size,
Format.NOT_SPECIFIED,
dataType,
outputFormat.getFrameRate(),
bitsPerPixel,
rgbOutputFormat.getRedMask(),
rgbOutputFormat.getGreenMask(),
rgbOutputFormat.getBlueMask(),
pixelStride,
(pixelStride == Format.NOT_SPECIFIED)
? Format.NOT_SPECIFIED
: (pixelStride * size.width), // lineStride
rgbOutputFormat.getFlipped(),
rgbOutputFormat.getEndian()));
}
else if (outputFormat instanceof YUVFormat)
{
YUVFormat yuvOutputFormat = (YUVFormat) outputFormat;
setOutputFormat(
new YUVFormat(
size,
Format.NOT_SPECIFIED,
outputFormat.getDataType(),
outputFormat.getFrameRate(),
yuvOutputFormat.getYuvType(),
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
0,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED));
}
else if (outputFormat != null)
logger.warn(
"SwScaler outputFormat of type "
+ outputFormat.getClass().getSimpleName()
+ " is not supported for optimized scaling.");
}
}

@ -0,0 +1,302 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.neomedia.codec.video.h264;
import java.util.*;
import javax.media.*;
import javax.media.format.*;
import net.java.sip.communicator.impl.neomedia.codec.*;
import net.java.sip.communicator.impl.neomedia.codec.video.*;
import net.java.sip.communicator.util.*;
/**
* Implements <tt>Codec</tt> to represent a depacketizer of H.264 RTP packets
* into NAL units.
*
* @author Lubomir Marinov
* @author Damian Minkov
*/
public class DePacketizer
extends AbstractCodecExt
{
/**
* The <tt>Logger</tt> used by the <tt>DePacketizer</tt> class and its
* instances for logging output.
*/
private static final Logger logger = Logger.getLogger(DePacketizer.class);
/**
* The start sequence of every NAL.
*/
private static final byte[] NAL_START_SEQUENCE = { 0, 0, 1 };
/**
* If last processed packet has a marker (indicate end of frame).
*/
private boolean lastHasMarker = false;
/**
* Keeps track of last (input) sequence number in order to avoid
* inconsistent data.
*/
private long lastSequenceNumber = -1;
/**
* The timestamp of the last received RTP packet.
*/
private long lastTimeStamp = -1;
/**
* The size of the padding at the end of the output data of this
* <tt>DePpacketizer</tt> expected by the H.264 decoder.
*/
private final int outputPaddingSize
= FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE;
/**
* In case of inconsistent input drop all data until a marker is received.
*/
private boolean waitingForMarker = false;
/**
* Initializes a new <tt>DePacketizer</tt> instance which is to depacketize
* H.264 RTP packets into NAL units.
*/
public DePacketizer()
{
super(
"H264 DePacketizer",
VideoFormat.class,
new VideoFormat[] { new VideoFormat(Constants.H264) });
inputFormats
= new VideoFormat[] { new VideoFormat(Constants.H264_RTP) };
}
/**
* Extracts a fragment of a NAL unit from a specific FU-A RTP packet
* payload.
*
* @param input the payload of the RTP packet from which a FU-A fragment of
* a NAL unit is to be extracted
* @param inputOffset the offset in <tt>input</tt> at which the payload
* starts
* @param inputLength the length of the payload in <tt>input</tt> starting
* at <tt>inputOffset</tt>
* @param outputBuffer the <tt>Buffer</tt> which is to receive the extracted
* FU-A fragment of a NAL unit
*/
private void deencapsulateFU(
byte[] input, int inputOffset, int inputLength,
Buffer outputBuffer)
{
byte fu_indicator = input[inputOffset];
// Skip fu_indicator.
inputOffset++;
inputLength--;
byte fu_header = input[inputOffset];
boolean start_bit = (fu_header >> 7) != 0;
//boolean end_bit = ((fu_header & 0x40) >> 6) != 0;
int nal_type = (fu_header & 0x1f);
byte reconstructed_nal;
//reconstruct this packet's true nal; only the data follows..
//the original nal forbidden bit and NRI are stored in this packet's nal;
reconstructed_nal = (byte)(fu_indicator & (byte)0xe0);
reconstructed_nal |= nal_type;
// Skip fu_header.
inputOffset++;
inputLength--;
int outputOffset = outputBuffer.getOffset();
int outputLength = outputBuffer.getLength();
int newOutputLength = outputLength + inputLength;
if (start_bit)
newOutputLength += NAL_START_SEQUENCE.length + 1;
byte[] output
= validateByteArraySize(
outputBuffer,
outputOffset + newOutputLength + outputPaddingSize);
outputOffset += outputLength;
if (start_bit)
{
// Copy in the start sequence and the reconstructed NAL.
System.arraycopy(
NAL_START_SEQUENCE, 0,
output, outputOffset,
NAL_START_SEQUENCE.length);
outputOffset += NAL_START_SEQUENCE.length;
output[outputOffset] = reconstructed_nal;
outputOffset++;
}
System.arraycopy(
input, inputOffset,
output, outputOffset,
inputLength);
outputOffset += inputLength;
padOutput(output, outputOffset);
outputBuffer.setLength(newOutputLength);
}
protected void doClose()
{
}
protected void doOpen()
throws ResourceUnavailableException
{
lastHasMarker = false;
lastSequenceNumber = -1;
lastTimeStamp = -1;
waitingForMarker = false;
}
protected int doProcess(Buffer inputBuffer, Buffer outputBuffer)
{
if (waitingForMarker)
{
lastSequenceNumber = inputBuffer.getSequenceNumber();
if ((inputBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0)
{
waitingForMarker = false;
discardOutputBuffer(outputBuffer);
return BUFFER_PROCESSED_OK;
}
else
return OUTPUT_BUFFER_NOT_FILLED;
}
long inputSequenceNumber = inputBuffer.getSequenceNumber();
// Detect inconsistent input drop.
if ((lastSequenceNumber != -1)
&& (inputSequenceNumber - lastSequenceNumber > 1))
{
if (logger.isTraceEnabled())
logger.trace(
"Dropping RTP data! "
+ lastSequenceNumber + "/" + inputSequenceNumber);
lastSequenceNumber = inputSequenceNumber;
waitingForMarker = true;
outputBuffer.setLength(0);
return OUTPUT_BUFFER_NOT_FILLED;
}
else
lastSequenceNumber = inputSequenceNumber;
// if the timestamp changes we are starting receiving a new frame
// this is also the case when last processed packet has marker
long timeStamp = inputBuffer.getTimeStamp();
if((timeStamp != lastTimeStamp) || lastHasMarker)
outputBuffer.setLength(0); // reset
// the new frame timestamp
lastTimeStamp = timeStamp;
byte[] input = (byte[]) inputBuffer.getData();
int inputOffset = inputBuffer.getOffset();
byte fByte = input[inputOffset];
/*
* A value of 00 indicates that the content of the NAL unit is not used
* to reconstruct reference pictures for inter picture prediction. Such
* NAL units can be discarded without risking the integrity of the
* reference pictures.
*/
int nri = (fByte & 0x60) >> 5;
if(nri == 0)
return OUTPUT_BUFFER_NOT_FILLED;
int type = fByte & 0x1f;
try
{
if ((type >= 1) && (type <= 23)) // Single NAL unit packet per H.264
{
int outputOffset = outputBuffer.getOffset();
int outputLength = outputBuffer.getLength();
int inputLength = inputBuffer.getLength();
int newOutputLength
= outputLength + NAL_START_SEQUENCE.length + inputLength;
byte[] output
= validateByteArraySize(
outputBuffer,
outputOffset + newOutputLength + outputPaddingSize);
outputOffset += outputLength;
System.arraycopy(
NAL_START_SEQUENCE, 0,
output, outputOffset,
NAL_START_SEQUENCE.length);
outputOffset += NAL_START_SEQUENCE.length;
System.arraycopy(
input, inputOffset,
output, outputOffset,
inputLength);
outputOffset += inputLength;
padOutput(output, outputOffset);
outputBuffer.setLength(newOutputLength);
}
else if (type == 28) // FU-A Fragmentation unit
{
deencapsulateFU(
input, inputOffset, inputBuffer.getLength(),
outputBuffer);
}
else
{
logger.warn("Skipping unsupported NAL unit type");
return OUTPUT_BUFFER_NOT_FILLED;
}
}
catch (Exception ex)
{
logger.warn("Cannot parse incoming packet", ex);
outputBuffer.setLength(0); // reset
return OUTPUT_BUFFER_NOT_FILLED;
}
outputBuffer.setTimeStamp(timeStamp);
// the rtp marker field points that this is the last packet of
// the received frame
boolean hasMarker
= (inputBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0;
lastHasMarker = hasMarker;
return hasMarker ? BUFFER_PROCESSED_OK : OUTPUT_BUFFER_NOT_FILLED;
}
private void padOutput(byte[] output, int outputOffset)
{
Arrays.fill(
output,
outputOffset,
outputOffset + outputPaddingSize,
(byte) 0);
}
}

@ -1,204 +0,0 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.neomedia.codec.video.h264;
import java.util.*;
import javax.media.*;
import net.java.sip.communicator.util.*;
/**
* Parses H264 rtp headers and extracts the data in the format
* the decoder expects it. RFC3984.
*
* @author Damian Minkov
* @author Lubomir Marinov
*/
public class H264Parser
{
private final Logger logger = Logger.getLogger(H264Parser.class);
// allocate enough space for the incoming data
private static final int MAX_FRAME_SIZE = 1280 * 1024;
// every NAL starts with this start sequence
private static final byte[] startSequence = { 0, 0, 1};
// the timestamp of the last received rtp packet
private long lastTimestamp = -1;
// the result data is collected in this buffer
private final byte[] encodedFrame;
// the size of the result data
private int encodedFrameLen;
private final int encodedFramePaddingSize;
/**
* If last processed packet has a marker (indicate end of frame).
*/
private boolean lastHasMarker = false;
public H264Parser()
{
this(0);
}
public H264Parser(int encodedFramePaddingSize)
{
this.encodedFramePaddingSize = encodedFramePaddingSize;
this.encodedFrame =
new byte[MAX_FRAME_SIZE + this.encodedFramePaddingSize];
}
/**
* New rtp packet is received. We push it to the parser to extract the data.
* @param inputBuffer the data from the rtp packet
* @return true if the result data must be passed to the decoder.
*/
public boolean pushRTPInput(Buffer inputBuffer)
{
long currentStamp = inputBuffer.getTimeStamp();
// the rtp marker field points that this is the last packet of
// the received frame
boolean hasMarker =
(inputBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0;
// if the timestamp changes we are starting receiving a new frame
// this is also the case when last processed packet has marker
if(!(currentStamp == lastTimestamp) || lastHasMarker)
{
reset();
}
// the new frame timestamp
lastTimestamp = currentStamp;
byte[] inData = (byte[]) inputBuffer.getData();
int inputOffset = inputBuffer.getOffset();
byte fByte = inData[inputOffset];
int type = fByte & 0x1f;
int nri = (fByte & 0x60) >> 5;
if(nri == 0)
return false;
try
{
// types from 1 to 23 are treated the same way
if (type >= 1 && type <= 23)
{
System.arraycopy(startSequence, 0, encodedFrame, encodedFrameLen, startSequence.length);
encodedFrameLen += startSequence.length;
int len = inputBuffer.getLength();
System.arraycopy(inData, inputOffset, encodedFrame, encodedFrameLen, len);
encodedFrameLen += len;
ensureEncodedFramePaddingSize();
}
//else if (type == 24)
//{
//return deencapsulateSTAP(inputBuffer);
//}
else if (type == 28)
{
deencapsulateFU(fByte, inputBuffer);
}
else
{
logger.warn("Skipping unsupported NAL unit type");
return false;
}
}
catch(Exception ex)
{
logger.warn("Cannot parse incoming " + ex.getMessage());
reset();
return false;
}
lastHasMarker = hasMarker;
return hasMarker;
}
/**
* Extract data from FU packet. This are packets across several rtp packets,
* the first has a start bit set, we store all data and don't care about end
* bit.
*
* @param nal
* @param inputBuffer
*/
private void deencapsulateFU (byte nal, Buffer inputBuffer)
{
byte[] buf = (byte[])inputBuffer.getData();
int len = inputBuffer.getLength();
int offset = inputBuffer.getOffset();
offset++;
len--;
byte fu_indicator = nal;
byte fu_header = buf[offset];
boolean start_bit = (fu_header >> 7) != 0;
//boolean end_bit = ((fu_header & 0x40) >> 6) != 0;
int nal_type = (fu_header & 0x1f);
byte reconstructed_nal;
//reconstruct this packet's true nal; only the data follows..
//the original nal forbidden bit and NRI are stored in this packet's nal;
reconstructed_nal = (byte)(fu_indicator & (byte)0xe0);
reconstructed_nal |= nal_type;
// skip the fu_header...
offset++;
len--;
if (start_bit)
{
// copy in the start sequence, and the reconstructed nal....
System.arraycopy(startSequence, 0, encodedFrame, encodedFrameLen,
startSequence.length);
encodedFrameLen += startSequence.length;
encodedFrame[encodedFrameLen] = reconstructed_nal;
encodedFrameLen++;
}
System.arraycopy(buf, offset, encodedFrame, encodedFrameLen, len);
encodedFrameLen += len;
ensureEncodedFramePaddingSize();
}
/**
* Returns the result data extracted from one ore more rtp packest.
* @return the result data.
*/
public byte[] getEncodedFrame()
{
return encodedFrame;
}
/**
* Returns the result data length.
* @return the result length.
*/
public int getEncodedFrameLen()
{
return encodedFrameLen;
}
void reset()
{
encodedFrameLen = 0;
ensureEncodedFramePaddingSize();
}
private void ensureEncodedFramePaddingSize()
{
Arrays.fill(encodedFrame, encodedFrameLen, encodedFrameLen
+ encodedFramePaddingSize, (byte) 0);
}
}

@ -13,33 +13,27 @@
import net.java.sip.communicator.impl.neomedia.codec.*;
import net.java.sip.communicator.impl.neomedia.codec.video.*;
import net.java.sip.communicator.util.*;
import net.sf.fmj.media.*;
/**
* Decodes incoming rtp data of type h264 and returns the result frames in RGB
* format.
*
* Decodes H.264 NAL units and returns the resulting frames as FFmpeg
* <tt>AVFrame</tt>s (i.e. in YUV format).
*
* @author Damian Minkov
* @author Lubomir Marinov
* @author Sebastien Vincent
*/
public class JNIDecoder
extends AbstractCodec
implements Codec
{
private final Logger logger = Logger.getLogger(JNIDecoder.class);
private static final String PLUGIN_NAME = "H.264 Decoder";
private static final int RED_MASK = 0xff0000;
private static final int GREEN_MASK = 0x00ff00;
private static final int BLUE_MASK = 0x0000ff;
private final VideoFormat[] outputFormats;
private final VideoFormat[] defaultOutputFormats
= new VideoFormat[] { new RGBFormat() };
private static final VideoFormat[] DEFAULT_OUTPUT_FORMATS
= new VideoFormat[] { new AVFrameFormat() };
// The codec we will use
private long avcontext;
@ -47,42 +41,59 @@ public class JNIDecoder
// The decoded data is stored in avpicture in native ffmpeg format (YUV)
private long avframe;
// Used to convert decoded data to RGB
private long frameRGB;
// The parser used to parse rtp content
private final H264Parser parser
= new H264Parser(FFMPEG.FF_INPUT_BUFFER_PADDING_SIZE);
// current width of video, so we can detect changes in video size
private double currentVideoWidth;
// keep track of last received sequence in order to avoid inconsistent data
private long lastReceivedSeq = -1;
private final boolean[] got_picture = new boolean[1];
// in case of inconsistent data drop all data till a marker is received
private boolean waitingForMarker = false;
private final VideoFormat[] outputFormats;
private final boolean[] got_picture = new boolean[1];
// current width of video, so we can detect changes in video size
private int width;
/**
* Constructs new h264 decoder
* Initializes a new <tt>JNIDecoder</tt> instance which is to decode H.264
* NAL units into frames in YUV format.
*/
public JNIDecoder()
{
inputFormats
= new VideoFormat[] { new VideoFormat(Constants.H264_RTP) };
outputFormats = new VideoFormat[1];
// default output format
outputFormats[0] = new RGBFormat(
new Dimension(Constants.VIDEO_WIDTH, Constants.VIDEO_HEIGHT),
-1, Format.intArray,
ensureFrameRate(Format.NOT_SPECIFIED), 32, RED_MASK,
GREEN_MASK, BLUE_MASK, 1, -1, Format.FALSE,
Format.NOT_SPECIFIED);
currentVideoWidth = outputFormats[0].getSize().getWidth();
= new VideoFormat[] { new VideoFormat(Constants.H264) };
outputFormats
= new VideoFormat[]
{
new AVFrameFormat(
new Dimension(
Constants.VIDEO_WIDTH,
Constants.VIDEO_HEIGHT),
ensureFrameRate(Format.NOT_SPECIFIED))
};
width = outputFormats[0].getSize().width;
}
public boolean checkFormat(Format format)
{
return format.getEncoding().equals(Constants.H264_RTP);
}
@Override
public synchronized void close()
{
if (opened)
{
opened = false;
super.close();
FFmpeg.avcodec_close(avcontext);
FFmpeg.av_free(avcontext);
avcontext = 0;
FFmpeg.av_free(avframe);
avframe = 0;
}
}
private float ensureFrameRate(float frameRate)
{
return frameRate;
}
protected Format[] getMatchingOutputFormats(Format in)
@ -108,33 +119,29 @@ protected Format[] getMatchingOutputFormats(Format in)
return
new Format[]
{
new RGBFormat(
outSize,
-1,
Format.intArray,
ensureFrameRate(ivf.getFrameRate()),
32,
RED_MASK, GREEN_MASK, BLUE_MASK,
1,
outSize.width,
Format.FALSE,
Format.NOT_SPECIFIED)
new AVFrameFormat(outSize, ensureFrameRate(ivf.getFrameRate()))
};
}
/**
* Set the data input format.
*
* @return false if the format is not supported.
*/
@Override
public Format setInputFormat(Format format)
public String getName()
{
Format setFormat = super.setInputFormat(format);
return PLUGIN_NAME;
}
if (setFormat != null)
reset();
return setFormat;
public Format[] getSupportedOutputFormats(Format in)
{
// null input format
if (in == null)
return DEFAULT_OUTPUT_FORMATS;
// mismatch input format
if (!(in instanceof VideoFormat)
|| (AbstractCodecExt.matches(in, inputFormats) == null))
return new Format[0];
// match input format
return getMatchingOutputFormats(in);
}
/**
@ -147,52 +154,30 @@ public synchronized void open()
if (opened)
return;
long avcodec = FFMPEG.avcodec_find_decoder(FFMPEG.CODEC_ID_H264);
long avcodec = FFmpeg.avcodec_find_decoder(FFmpeg.CODEC_ID_H264);
avcontext = FFMPEG.avcodec_alloc_context();
FFMPEG.avcodeccontext_set_workaround_bugs(avcontext,
FFMPEG.FF_BUG_AUTODETECT);
avcontext = FFmpeg.avcodec_alloc_context();
FFmpeg.avcodeccontext_set_workaround_bugs(avcontext,
FFmpeg.FF_BUG_AUTODETECT);
if (FFMPEG.avcodec_open(avcontext, avcodec) < 0)
throw new RuntimeException("Could not open codec");
if (FFmpeg.avcodec_open(avcontext, avcodec) < 0)
throw new RuntimeException("Could not open codec CODEC_ID_H264");
avframe = FFMPEG.avcodec_alloc_frame();
frameRGB = FFMPEG.avcodec_alloc_frame();
avframe = FFmpeg.avcodec_alloc_frame();
opened = true;
super.open();
}
@Override
public synchronized void close()
{
if (opened)
{
opened = false;
super.close();
FFMPEG.avcodec_close(avcontext);
FFMPEG.av_free(avcontext);
avcontext = 0;
FFMPEG.av_free(avframe);
avframe = 0;
}
}
public synchronized int process(Buffer inputBuffer, Buffer outputBuffer)
{
if (!checkInputBuffer(inputBuffer))
{
return BUFFER_PROCESSED_FAILED;
}
if (isEOM(inputBuffer) || !opened)
{
propagateEOM(outputBuffer);
return BUFFER_PROCESSED_OK;
}
if (inputBuffer.isDiscard())
{
inputBuffer.setDiscard(true);
@ -200,68 +185,14 @@ public synchronized int process(Buffer inputBuffer, Buffer outputBuffer)
return BUFFER_PROCESSED_OK;
}
if(waitingForMarker)
{
lastReceivedSeq = inputBuffer.getSequenceNumber();
if((inputBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0)
{
waitingForMarker = false;
outputBuffer.setDiscard(true);
return BUFFER_PROCESSED_OK;
}
else
return OUTPUT_BUFFER_NOT_FILLED;
}
if (lastReceivedSeq != -1
&& inputBuffer.getSequenceNumber() - lastReceivedSeq > 1)
{
long oldRecv = lastReceivedSeq;
lastReceivedSeq = inputBuffer.getSequenceNumber();
waitingForMarker = true;
logger.trace("DROP rtp data! " + oldRecv + "/" + lastReceivedSeq);
parser.reset();
reset();
return OUTPUT_BUFFER_NOT_FILLED;
}
else if (!parser.pushRTPInput(inputBuffer))
{
lastReceivedSeq = inputBuffer.getSequenceNumber();
return OUTPUT_BUFFER_NOT_FILLED;
}
lastReceivedSeq = inputBuffer.getSequenceNumber();
// decodes the data
got_picture[0] = false;
FFMPEG.avcodec_decode_video(avcontext, avframe, got_picture, parser
.getEncodedFrame(), parser.getEncodedFrameLen());
int avctxWidth = FFMPEG.avcodeccontext_get_width(avcontext);
int avctxHeight = FFMPEG.avcodeccontext_get_height(avcontext);
if (avctxWidth != 0 && currentVideoWidth != avctxWidth)
{
currentVideoWidth = avctxWidth;
VideoFormat ivf = (VideoFormat) inputBuffer.getFormat();
/* output format with same size as input */
VideoFormat ovf
= new RGBFormat(
new Dimension(avctxWidth, avctxHeight),
-1,
Format.intArray,
ensureFrameRate(ivf.getFrameRate()),
32,
RED_MASK, GREEN_MASK, BLUE_MASK,
1,
avctxWidth, Format.FALSE,
Format.NOT_SPECIFIED);
if (ovf != null)
outputFormat = ovf;
}
outputBuffer.setFormat(outputFormat);
// TODO Take into account the offset of inputBuffer.
FFmpeg.avcodec_decode_video(
avcontext,
avframe,
got_picture,
(byte[]) inputBuffer.getData(), inputBuffer.getLength());
if (!got_picture[0])
{
@ -269,79 +200,44 @@ else if (!parser.pushRTPInput(inputBuffer))
return BUFFER_PROCESSED_OK;
}
// convert the picture in RGB Format
int numBytes =
FFMPEG.avpicture_get_size(FFMPEG.PIX_FMT_RGB32, avctxWidth,
avctxHeight);
long buffer = FFMPEG.av_malloc(numBytes);
FFMPEG.avpicture_fill(frameRGB, buffer, FFMPEG.PIX_FMT_RGB32,
avctxWidth, avctxHeight);
// Convert the image from its native format to RGB
FFMPEG.img_convert(frameRGB, FFMPEG.PIX_FMT_RGB32, avframe, FFMPEG
.avcodeccontext_get_pix_fmt(avcontext), avctxWidth, avctxHeight);
Object outData = outputBuffer.getData();
int dataLength = numBytes / 4;
int[] data;
if ((outData instanceof int[])
&& ((int[]) outData).length >= dataLength)
data = (int[]) outData;
else
data = new int[dataLength];
FFMPEG
.memcpy(data, 0, dataLength, FFMPEG.avpicture_get_data0(frameRGB));
outputBuffer.setData(data);
outputBuffer.setLength(dataLength);
outputBuffer.setOffset(0);
//outputBuffer.setTimeStamp(inputBuffer.getTimeStamp());
int avctxWidth = FFmpeg.avcodeccontext_get_width(avcontext);
int avctxHeight = FFmpeg.avcodeccontext_get_height(avcontext);
FFMPEG.av_free(buffer);
return BUFFER_PROCESSED_OK;
}
public boolean checkFormat(Format format)
{
return format.getEncoding().equals(Constants.H264_RTP);
}
if ((avctxWidth != 0) && (avctxWidth != width))
{
width = avctxWidth;
private float ensureFrameRate(float frameRate)
{
return frameRate;
}
// Output in same size and frame rate as input.
Dimension outSize = new Dimension(avctxWidth, avctxHeight);
VideoFormat ivf = (VideoFormat) inputBuffer.getFormat();
float outFrameRate = ensureFrameRate(ivf.getFrameRate());
@Override
public String getName()
{
return PLUGIN_NAME;
}
outputFormat = new AVFrameFormat(outSize, outFrameRate);
}
outputBuffer.setFormat(outputFormat);
public Format[] getSupportedOutputFormats(Format in)
{
// null input format
if (in == null)
return defaultOutputFormats;
Object outputData = outputBuffer.getData();
// mismatch input format
if (!(in instanceof VideoFormat) || (matches(in, inputFormats) == null))
return new Format[0];
if (!(outputData instanceof AVFrame)
|| (((AVFrame) outputData).getPtr() != avframe))
outputBuffer.setData(new AVFrame(avframe));
// match input format
return getMatchingOutputFormats(in);
//outputBuffer.setTimeStamp(inputBuffer.getTimeStamp());
return BUFFER_PROCESSED_OK;
}
/**
* Utility to perform format matching.
* Set the data input format.
*
* @return false if the format is not supported.
*/
public static Format matches(Format in, Format outs[])
@Override
public Format setInputFormat(Format format)
{
for (Format out : outs)
if (in.matches(out))
return out;
return null;
Format setFormat = super.setInputFormat(format);
if (setFormat != null)
reset();
return setFormat;
}
}

@ -24,7 +24,6 @@
*/
public class JNIEncoder
extends AbstractCodec
implements Codec
{
private static final String PLUGIN_NAME = "H.264 Encoder";
@ -93,7 +92,7 @@ public Format[] getSupportedOutputFormats(Format in)
// mismatch input format
if (!(in instanceof VideoFormat)
|| (null == JNIDecoder.matches(in, inputFormats)))
|| (null == AbstractCodecExt.matches(in, inputFormats)))
return new Format[0];
return getMatchingOutputFormats(in);
@ -104,7 +103,7 @@ public Format setInputFormat(Format in)
{
// mismatch input format
if (!(in instanceof VideoFormat)
|| null == JNIDecoder.matches(in, inputFormats))
|| null == AbstractCodecExt.matches(in, inputFormats))
return null;
VideoFormat videoIn = (VideoFormat) in;
@ -143,8 +142,10 @@ public Format setOutputFormat(Format out)
{
// mismatch output format
if (!(out instanceof VideoFormat)
|| null == JNIDecoder.matches(out,
getMatchingOutputFormats(inputFormat)))
|| (null
== AbstractCodecExt.matches(
out,
getMatchingOutputFormats(inputFormat))))
return null;
VideoFormat videoOut = (VideoFormat) out;
@ -198,23 +199,23 @@ public synchronized int process(Buffer inBuffer, Buffer outBuffer)
}
// copy data to avframe
FFMPEG.memcpy(rawFrameBuffer, (byte[]) inBuffer.getData(), inBuffer
FFmpeg.memcpy(rawFrameBuffer, (byte[]) inBuffer.getData(), inBuffer
.getOffset(), encFrameLen);
if (framesSinceLastIFrame >= IFRAME_INTERVAL)
{
FFMPEG.avframe_set_key_frame(avframe, true);
FFmpeg.avframe_set_key_frame(avframe, true);
framesSinceLastIFrame = 0;
}
else
{
framesSinceLastIFrame++;
FFMPEG.avframe_set_key_frame(avframe, false);
FFmpeg.avframe_set_key_frame(avframe, false);
}
// encode data
int encLen =
FFMPEG.avcodec_encode_video(avcontext, encFrameBuffer, encFrameLen,
FFmpeg.avcodec_encode_video(avcontext, encFrameBuffer, encFrameLen,
avframe);
byte[] r = new byte[encLen];
@ -246,67 +247,67 @@ public synchronized void open()
width = (int)((VideoFormat)outputFormat).getSize().getWidth();
height = (int)((VideoFormat)outputFormat).getSize().getHeight();
long avcodec = FFMPEG.avcodec_find_encoder(FFMPEG.CODEC_ID_H264);
long avcodec = FFmpeg.avcodec_find_encoder(FFmpeg.CODEC_ID_H264);
avcontext = FFMPEG.avcodec_alloc_context();
avcontext = FFmpeg.avcodec_alloc_context();
FFMPEG.avcodeccontext_set_pix_fmt(avcontext, FFMPEG.PIX_FMT_YUV420P);
FFMPEG.avcodeccontext_set_size(avcontext, width, height);
FFmpeg.avcodeccontext_set_pix_fmt(avcontext, FFmpeg.PIX_FMT_YUV420P);
FFmpeg.avcodeccontext_set_size(avcontext, width, height);
FFMPEG.avcodeccontext_set_qcompress(avcontext, 0.6f);
FFmpeg.avcodeccontext_set_qcompress(avcontext, 0.6f);
//int _bitRate = 768000;
int _bitRate = 128000;
// average bit rate
FFMPEG.avcodeccontext_set_bit_rate(avcontext, _bitRate);
FFmpeg.avcodeccontext_set_bit_rate(avcontext, _bitRate);
// so to be 1 in x264
FFMPEG.avcodeccontext_set_bit_rate_tolerance(avcontext, _bitRate);
FFMPEG.avcodeccontext_set_rc_max_rate(avcontext, _bitRate);
FFMPEG.avcodeccontext_set_sample_aspect_ratio(avcontext, 0, 0);
FFMPEG.avcodeccontext_set_thread_count(avcontext, 1);
FFmpeg.avcodeccontext_set_bit_rate_tolerance(avcontext, _bitRate);
FFmpeg.avcodeccontext_set_rc_max_rate(avcontext, _bitRate);
FFmpeg.avcodeccontext_set_sample_aspect_ratio(avcontext, 0, 0);
FFmpeg.avcodeccontext_set_thread_count(avcontext, 1);
/* time base should be 1 / frame rate */
FFMPEG.avcodeccontext_set_time_base(avcontext, 1, TARGET_FRAME_RATE);
FFMPEG.avcodeccontext_set_quantizer(avcontext, 22, 30, 4);
FFmpeg.avcodeccontext_set_time_base(avcontext, 1, TARGET_FRAME_RATE);
FFmpeg.avcodeccontext_set_quantizer(avcontext, 22, 30, 4);
// avcontext.chromaoffset = -2;
FFMPEG.avcodeccontext_add_partitions(avcontext, 0x111);
FFmpeg.avcodeccontext_add_partitions(avcontext, 0x111);
// X264_PART_I4X4 0x001
// X264_PART_P8X8 0x010
// X264_PART_B8X8 0x100
FFMPEG.avcodeccontext_set_mb_decision(avcontext,
FFMPEG.FF_MB_DECISION_SIMPLE);
FFmpeg.avcodeccontext_set_mb_decision(avcontext,
FFmpeg.FF_MB_DECISION_SIMPLE);
FFMPEG.avcodeccontext_set_rc_eq(avcontext, "blurCplx^(1-qComp)");
FFmpeg.avcodeccontext_set_rc_eq(avcontext, "blurCplx^(1-qComp)");
FFMPEG.avcodeccontext_add_flags(avcontext,
FFMPEG.CODEC_FLAG_LOOP_FILTER);
FFMPEG.avcodeccontext_set_me_method(avcontext, 7);
FFMPEG.avcodeccontext_set_me_subpel_quality(avcontext, 6);
FFMPEG.avcodeccontext_set_me_range(avcontext, 16);
FFMPEG.avcodeccontext_set_me_cmp(avcontext, FFMPEG.FF_CMP_CHROMA);
FFMPEG.avcodeccontext_set_scenechange_threshold(avcontext, 40);
FFmpeg.avcodeccontext_add_flags(avcontext,
FFmpeg.CODEC_FLAG_LOOP_FILTER);
FFmpeg.avcodeccontext_set_me_method(avcontext, 7);
FFmpeg.avcodeccontext_set_me_subpel_quality(avcontext, 6);
FFmpeg.avcodeccontext_set_me_range(avcontext, 16);
FFmpeg.avcodeccontext_set_me_cmp(avcontext, FFmpeg.FF_CMP_CHROMA);
FFmpeg.avcodeccontext_set_scenechange_threshold(avcontext, 40);
// Constant quality mode (also known as constant ratefactor)
/* FFMPEG.avcodeccontext_set_crf(avcontext, 0); */
FFMPEG.avcodeccontext_set_rc_buffer_size(avcontext, 0);
FFMPEG.avcodeccontext_set_gop_size(avcontext, IFRAME_INTERVAL);
FFMPEG.avcodeccontext_set_i_quant_factor(avcontext, 1f / 1.4f);
/* FFmpeg.avcodeccontext_set_crf(avcontext, 0); */
FFmpeg.avcodeccontext_set_rc_buffer_size(avcontext, 0);
FFmpeg.avcodeccontext_set_gop_size(avcontext, IFRAME_INTERVAL);
FFmpeg.avcodeccontext_set_i_quant_factor(avcontext, 1f / 1.4f);
FFMPEG.avcodeccontext_set_refs(avcontext, 4);
FFMPEG.avcodeccontext_set_trellis(avcontext, 2);
FFmpeg.avcodeccontext_set_refs(avcontext, 4);
FFmpeg.avcodeccontext_set_trellis(avcontext, 2);
if (FFMPEG.avcodec_open(avcontext, avcodec) < 0)
if (FFmpeg.avcodec_open(avcontext, avcodec) < 0)
throw new RuntimeException("Could not open codec");
encFrameLen = (width * height * 3) / 2;
rawFrameBuffer = FFMPEG.av_malloc(encFrameLen);
rawFrameBuffer = FFmpeg.av_malloc(encFrameLen);
avframe = FFMPEG.avcodec_alloc_frame();
avframe = FFmpeg.avcodec_alloc_frame();
int size = width * height;
FFMPEG.avframe_set_data(avframe, rawFrameBuffer, size, size / 4);
FFMPEG.avframe_set_linesize(avframe, width, width / 2, width / 2);
FFmpeg.avframe_set_data(avframe, rawFrameBuffer, size, size / 4);
FFmpeg.avframe_set_linesize(avframe, width, width / 2, width / 2);
encFrameBuffer = new byte[encFrameLen];
@ -322,13 +323,13 @@ public synchronized void close()
opened = false;
super.close();
FFMPEG.avcodec_close(avcontext);
FFMPEG.av_free(avcontext);
FFmpeg.avcodec_close(avcontext);
FFmpeg.av_free(avcontext);
avcontext = 0;
FFMPEG.av_free(avframe);
FFmpeg.av_free(avframe);
avframe = 0;
FFMPEG.av_free(rawFrameBuffer);
FFmpeg.av_free(rawFrameBuffer);
rawFrameBuffer = 0;
encFrameBuffer = null;

@ -78,7 +78,7 @@ public Format[] getSupportedOutputFormats(Format in)
// mismatch input format
if (!(in instanceof VideoFormat)
|| (null == JNIDecoder.matches(in, inputFormats)))
|| (null == AbstractCodecExt.matches(in, inputFormats)))
return new Format[0];
return getMatchingOutputFormats(in);
@ -89,7 +89,7 @@ public Format setInputFormat(Format in)
{
// mismatch input format
if (!(in instanceof VideoFormat)
|| null == JNIDecoder.matches(in, inputFormats))
|| null == AbstractCodecExt.matches(in, inputFormats))
return null;
inputFormat = in;
@ -102,7 +102,10 @@ public Format setOutputFormat(Format out)
{
// mismatch output format
if (!(out instanceof VideoFormat)
|| null == JNIDecoder.matches(out, getMatchingOutputFormats(inputFormat)))
|| (null
== AbstractCodecExt.matches(
out,
getMatchingOutputFormats(inputFormat))))
return null;
VideoFormat videoOut = (VideoFormat) out;

Loading…
Cancel
Save