Prepares the source of the FFmpeg JNI library for an update to a more recent version of FFmpeg.

cusax-fix
Lyubomir Marinov 15 years ago
parent c8638d40b0
commit ee9edb3641

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by Emil Ivov on Jul 6, 2005 8:30:22 PM-->
<project default="ant-usage" name="sip-communicator">
<project default="ant-usage" name="jitsi">
<dirname property="sc.basedir" file="${ant.file.sip-communicator}"/>
<dirname property="sc.basedir" file="${ant.file.jitsi}"/>
<property environment="system"/>
<property name="jdk.home" value="/usr/java/java"/>
<property name="dest" value="classes"/>
@ -412,7 +412,7 @@
<bottom>
<![CDATA[
<font size="-1">
<a href="http://sip-communicator.org"> SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. </a>
<a href="http://jitsi.org"> Jitsi, the OpenSource Java VoIP and Instant Messaging client. </a>
<br>
<a href="http://gnu.org"> Distributable under LGPL license. </a>
<br>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>sip-communicator-1-0-draft</name>
<name>jitsi</name>
<comment></comment>
<projects>
</projects>

@ -28,7 +28,7 @@
- there is app-version variable in the izpack installer xml
- you must change the installer jar name in the launcher.ini file
-->
<project name="sip-communicator-installer" basedir="." default="ant-usage">
<project name="jitsi-installer" basedir="." default="ant-usage">
<import file="../../build.xml"/>

@ -1,4 +1,4 @@
<project name="sip-communicator-native" default="help-native">
<project name="jitsi-native" default="help-native">
<import file="../../build.xml"/>
<!-- additionnal property -->
@ -303,19 +303,23 @@
<linkerarg value="-L${ffmpeg}/libavformat" />
<linkerarg value="-L${ffmpeg}/libavcodec" />
<linkerarg value="-L${ffmpeg}/libavutil" />
<linkerarg value="-L${ffmpeg}/libavcore" />
<linkerarg value="-L${ffmpeg}/libavfilter" />
<linkerarg value="-L${ffmpeg}/libswscale" />
<linkerarg value="-L${x264}" />
<!--
Depending on the way that lame is built, libmp3lame.a may be in
libmp3lame/ or libmp3lame/.libs/.
-->
<linkerarg value="-L${lame}/libmp3lame" />
<linkerarg value="-L${lame}/libmp3lame/.libs" />
<!-- static libraries MUST be at the end otherwise
they will not be added to shared library
<!--
Static libraries MUST be at the end otherwise they will not be added to
the shared library.
-->
<linkerarg value="-lavformat" location="end" />
<linkerarg value="-lavcodec" location="end" />
<linkerarg value="-lavfilter" location="end" />
<linkerarg value="-lavutil" location="end" />
<linkerarg value="-lavcore" location="end" />
<linkerarg value="-lswscale" location="end" />
<linkerarg value="-lx264" location="end" />
<linkerarg value="-lmp3lame" location="end" />
@ -369,6 +373,8 @@
<fileset dir="${src}/native/ffmpeg" includes="*.c"/>
</cc>
<delete dir="${obj}" failonerror="false" />
<delete file="${native_install_dir}/history.xml" failonerror="false" />
</target>
<!-- compile jnportaudio library -->

@ -1,137 +1,140 @@
1. lame-3.98.4
./configure --disable-shared --enable-static --enable-nasm \
--disable-analyzer-hooks --disable-decoder \
--disable-frontend --with-pic
FFmpeg looks for lame.h as lame/lame.h but the uninstalled lame-3.98.4 does not
have the lame directory so go into lame-3.98.4/include and "ln -s . lame".
MS Windows notes
- before make, open Makefile, libmp3lame/Makefile and libmp3lame/i386/Makefile
and replace "NASM = C:\Program Files\nasm\nasm" by "NASM = nasm" (be sure nasm is in your PATH anyway);
- For Windows x64, add --build=x86_64-w64-mingw32 to the configure line.
2. x264-snapshot-20101103-2245
- Windows
Download yasm for Windows (32-bit or 64-bit) at http://www.tortall.net/projects/yasm/wiki/Download
and copy it to C:\MinGW\bin (or in a directory registered in the PATH environment variable).
./configure --disable-pthread
make
- FreeBSD
Apply x264_bsd.diff patch first and compile:
patch -p1 < /path/to/x264_bsd.diff
./configure --enable-pic
gmake
- Linux, Mac OS X
./configure --enable-pic
make
3. ffmpeg-r25669
First patch ffmpeg with ffmpeg-25669.diff
patch -p0 < ffmpeg-25669.diff
- Windows
32-bit:
./configure \
--target-os=mingw32 \
--enable-memalign-hack \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
--disable-network \
--enable-libx264 --enable-gpl --enable-parser=h264 --enable-encoder=libx264 \
--enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 \
--enable-parser=h263 --enable-encoder=h263p \
--enable-decoder=h263 --enable-muxer=h263 --enable-demuxer=h263 \
--enable-libmp3lame --enable-encoder=libmp3lame \
--extra-ldflags="-L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" --extra-cflags="-I$MP3LAME_HOME/include -I$X264_HOME" \
--disable-debug \
--disable-ffserver --disable-ffplay --disable-ffmpeg \
--disable-pthreads --enable-w32threads
64-bit:
Then run:
./configure \
--arch=amd64 --target-os=mingw32 \
--enable-memalign-hack \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
--disable-network \
--disable-dxva2 \
--enable-libx264 --enable-gpl --enable-parser=h264 --enable-encoder=libx264 \
--enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 \
--enable-parser=h263 --enable-encoder=h263p \
--enable-decoder=h263 --enable-muxer=h263 --enable-demuxer=h263 \
--enable-libmp3lame --enable-encoder=libmp3lame \
--extra-ldflags="-L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" --extra-cflags="-I$MP3LAME_HOME/include -I$X264_HOME" \
--disable-debug \
--disable-ffserver --disable-ffplay --disable-ffmpeg \
--disable-pthreads --enable-w32threads \
--enable-cross-compile
mingw32-make
Note: mingw64-make failed to work (segmentation fault) that's why we fallback to mingw32-make.
- Linux, FreeBSD
Note: remove --enable-pic for x86 architecture.
./configure \
--enable-pic \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
--disable-network \
--enable-libx264 --enable-gpl --enable-parser=h264 --enable-encoder=libx264 \
--enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 \
--enable-parser=h263 --enable-encoder=h263p \
--enable-decoder=h263 --enable-muxer=h263 --enable-demuxer=h263 \
--enable-decoder=mjpeg --enable-muxer=mjpeg --enable-demuxer=mjpeg --enable-parser=mjpeg \
--enable-libmp3lame --enable-encoder=libmp3lame \
--extra-ldflags="-L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" --extra-cflags="-I$MP3LAME_HOME/include -I$X264_HOME" \
--disable-debug \
--disable-ffserver --disable-ffprobe --disable-ffplay --disable-ffmpeg \
--enable-pthreads
- Mac OS X
Note: removed from configure script the option to add -mdynamic-no-pic unless you compile
for i386 architecture (intel 32-bit). For i386, remove "--enable-pic" from the following
command.
./configure \
--enable-pic \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
--disable-network \
--enable-libx264 --enable-gpl --enable-parser=h264 --enable-encoder=libx264 \
--enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 \
--enable-parser=h263 --enable-encoder=h263p \
--enable-decoder=h263 --enable-muxer=h263 --enable-demuxer=h263 \
--enable-libmp3lame --enable-encoder=libmp3lame \
--extra-ldflags="-fPIC -L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" --extra-cflags="-fPIC -I$MP3LAME_HOME/include -I$X264_HOME" \
--disable-debug \
--disable-ffserver --disable-ffprobe --disable-ffplay --disable-ffmpeg \
--enable-pthreads
4. libffmpeg
Open Makefile, uncomment the section for your OS and comment out the others.
Be careful to correctly set FFMPEG_HOME, JAVA_HOME, MP3LAME_HOME and X264_HOME variables.
Then run:
make (gmake on FreeBSD)
1. lame
./configure \
--disable-shared --enable-static \
--enable-nasm \
--disable-analyzer-hooks --disable-decoder --disable-frontend \
--with-pic
FFmpeg looks for lame.h as lame/lame.h but the uninstalled lame-3.98.4 does not
have the lame directory so go into lame-3.98.4/include and "ln -s . lame" on
Linux and Mac OS X or "mklink /d lame ." on Windows.
MS Windows notes:
- As an alternative to configure and a subsequent make, just use:
make -f Makefile.unix HAVE_NASM=YES NOUNIXCMD=NO UNAME=MSDOS
- Before make, open Makefile, libmp3lame/Makefile and
libmp3lame/i386/Makefile and make sure that the path to nasm.exe is
correct (e.g. have NASM=nasm and nasm.exe on the PATH);
- For Windows x64, add --build=x86_64-w64-mingw32 to the configure line.
2. x264
- Windows
Download yasm for Windows (32-bit or 64-bit) at
http://www.tortall.net/projects/yasm/wiki/Download and copy it to a directory on
the PATH.
./configure --disable-pthread
make
- FreeBSD
patch -p1 < x264-01-freebsd.patch
./configure --enable-pic
gmake
- Linux, Mac OS X
./configure --enable-pic
make
3. ffmpeg
patch -p0 < ffmpeg-01-libavcodec_libx264.c-zero_latency.patch
- Windows
32-bit:
./configure \
--target-os=mingw32 \
--enable-memalign-hack \
--enable-static --disable-shared --shlibdir=. \
--disable-debug \
--disable-everything --disable-network \
--disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver \
--enable-libmp3lame --enable-encoder=libmp3lame \
--enable-decoder=h263 --enable-encoder=h263p --enable-parser=h263 \
--enable-libx264 --enable-gpl \
--enable-decoder=h264 --enable-encoder=libx264 --enable-parser=h264 \
--enable-filter=buffer --enable-filter=hflip --enable-filter=scale --enable-filter=nullsink \
--extra-cflags="-I$MP3LAME_HOME/include -I$X264_HOME" \
--extra-ldflags="-L$MP3LAME_HOME/libmp3lame -L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" \
--disable-pthreads --enable-w32threads
64-bit:
Then run:
./configure \
--arch=amd64 --target-os=mingw32 \
--enable-memalign-hack \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
--disable-network \
--disable-dxva2 \
--enable-libx264 --enable-gpl --enable-parser=h264 --enable-encoder=libx264 \
--enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 \
--enable-parser=h263 --enable-encoder=h263p \
--enable-decoder=h263 --enable-muxer=h263 --enable-demuxer=h263 \
--enable-libmp3lame --enable-encoder=libmp3lame \
--extra-ldflags="-L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" --extra-cflags="-I$MP3LAME_HOME/include -I$X264_HOME" \
--disable-debug \
--disable-ffserver --disable-ffplay --disable-ffmpeg \
--disable-pthreads --enable-w32threads \
--enable-cross-compile
mingw32-make
Note: mingw64-make failed to work (segmentation fault) that's why we fallback to
mingw32-make.
- Linux, FreeBSD
Note: remove --enable-pic for x86 architecture.
./configure \
--enable-pic \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
--disable-network \
--enable-libx264 --enable-gpl --enable-parser=h264 --enable-encoder=libx264 \
--enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 \
--enable-parser=h263 --enable-encoder=h263p \
--enable-decoder=h263 --enable-muxer=h263 --enable-demuxer=h263 \
--enable-decoder=mjpeg --enable-muxer=mjpeg --enable-demuxer=mjpeg --enable-parser=mjpeg \
--enable-libmp3lame --enable-encoder=libmp3lame \
--extra-ldflags="-L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" --extra-cflags="-I$MP3LAME_HOME/include -I$X264_HOME" \
--disable-debug \
--disable-ffserver --disable-ffprobe --disable-ffplay --disable-ffmpeg \
--enable-pthreads
- Mac OS X
Note: removed from configure script the option to add -mdynamic-no-pic unless
you compile for the i386 architecture (Intel 32-bit). For i386, remove
"--enable-pic" from the following command.
./configure \
--enable-pic \
--enable-static --disable-shared --shlibdir=. \
--disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
--disable-parsers --disable-bsfs --disable-protocols --disable-devices \
--disable-network \
--enable-libx264 --enable-gpl --enable-parser=h264 --enable-encoder=libx264 \
--enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 \
--enable-parser=h263 --enable-encoder=h263p \
--enable-decoder=h263 --enable-muxer=h263 --enable-demuxer=h263 \
--enable-libmp3lame --enable-encoder=libmp3lame \
--extra-ldflags="-fPIC -L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" --extra-cflags="-fPIC -I$MP3LAME_HOME/include -I$X264_HOME" \
--disable-debug \
--disable-ffserver --disable-ffprobe --disable-ffplay --disable-ffmpeg \
--enable-pthreads
4. libffmpeg
Define the environment variable JAVA_HOME so that the JNI headers can be found.
Change the current directory to src\native and run "ant ffmpeg" passing it
values for the ffmpeg, lame and x264 properties which specify the paths to the
homes of the development trees of the respective libraries.

@ -0,0 +1,18 @@
Index: libavcodec/libx264.c
===================================================================
--- libavcodec/libx264.c (révision 25669)
+++ libavcodec/libx264.c (copie de travail)
@@ -303,6 +303,13 @@
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
x4->params.b_repeat_headers = 0;
+ /* zero latency */
+ x4->params.rc.i_lookahead = 0;
+ x4->params.i_sync_lookahead = 0;
+ x4->params.i_bframe = 0;
+ x4->params.b_sliced_threads = 1;
+ x4->params.b_vfr_input = 0;
+
x4->enc = x264_encoder_open(&x4->params);
if (!x4->enc)
return -1;

@ -1,36 +0,0 @@
Index: libavcodec/libx264.c
===================================================================
--- libavcodec/libx264.c (révision 25669)
+++ libavcodec/libx264.c (copie de travail)
@@ -163,7 +163,7 @@
x4->params.p_log_private = avctx;
x4->params.i_keyint_max = avctx->gop_size;
- x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH;
+ x4->params.b_intra_refresh = 1; //avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH;
x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
@@ -193,7 +193,7 @@
x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE;
avctx->has_b_frames = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
- x4->params.i_keyint_min = avctx->keyint_min;
+ x4->params.i_keyint_min = 0; //avctx->keyint_min;
if (x4->params.i_keyint_min > x4->params.i_keyint_max)
x4->params.i_keyint_min = x4->params.i_keyint_max;
@@ -303,6 +303,13 @@
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
x4->params.b_repeat_headers = 0;
+ /* zero latency */
+ x4->params.rc.i_lookahead = 0;
+ x4->params.i_sync_lookahead = 0;
+ x4->params.i_bframe = 0;
+ x4->params.b_sliced_threads = 1;
+ x4->params.b_vfr_input = 0;
+
x4->enc = x264_encoder_open(&x4->params);
if (!x4->enc)
return -1;

@ -1,212 +0,0 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
/*
* Various utilities for command line tools
* Copyright (c) 2000-2003 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <math.h>
/* Include only the enabled headers since some compilers (namely, Sun
Studio) will not omit unused inline functions and create undefined
references to libraries that are not being built. */
#include "libavcodec/opt.h"
#include "libavformat/avformat.h"
#include "libavutil/pixdesc.h"
#include "libavfilter/avfilter.h"
#include "libavfilter/graphparser.h"
#include "libavfilter/vsrc_buffer.h"
#include "libswscale/swscale.h"
#include "ffmpeg_utils.h"
static int ffsink_init(AVFilterContext *ctx, const char *args, void *opaque)
{
FFSinkContext *priv = ctx->priv;
if (!opaque)
return AVERROR(EINVAL);
*priv = *(FFSinkContext *)opaque;
return 0;
}
static void null_end_frame(AVFilterLink *inlink) { }
static int ffsink_query_formats(AVFilterContext *ctx)
{
FFSinkContext *priv = ctx->priv;
enum PixelFormat pix_fmts[] = { priv->pix_fmt, PIX_FMT_NONE };
avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
return 0;
}
AVFilter ffsink = {
.name = "ffsink",
.priv_size = sizeof(FFSinkContext),
.init = ffsink_init,
.query_formats = ffsink_query_formats,
.inputs = (AVFilterPad[]) {{ .name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.end_frame = null_end_frame,
.min_perms = AV_PERM_READ, },
{ .name = NULL }},
.outputs = (AVFilterPad[]) {{ .name = NULL }},
};
int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
struct AVFilterBufferRef **picref_ptr, AVRational *tb)
{
int ret;
AVFilterBufferRef *picref;
if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
{
return ret;
}
if (!(picref = ctx->inputs[0]->cur_buf))
{
return AVERROR(ENOENT);
}
*picref_ptr = picref;
ctx->inputs[0]->cur_buf = NULL;
*tb = ctx->inputs[0]->time_base;
memcpy(frame->data, picref->data, sizeof(frame->data));
memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
frame->interlaced_frame = picref->video->interlaced;
frame->top_field_first = picref->video->top_field_first;
return 1;
}
int configure_filters(AVInputStream *ist, int pix_fmt, int w, int h,
AVFilterGraph *graph, const char* vfilters)
{
AVFilterContext *last_filter;
/** filter graph containing all filters including input & output */
//AVCodecContext *codec = ost->st->codec;
//AVCodecContext *icodec = ist->st->codec;
FFSinkContext ffsink_ctx = { .pix_fmt = pix_fmt };
char args[255];
int ret;
int width = w;
int height = h;
//graph = av_mallocz(sizeof(AVFilterGraph));
if ((ret = avfilter_open(&ist->input_video_filter, avfilter_get_by_name("buffer"), "src")) < 0)
{
return ret;
}
if ((ret = avfilter_open(&ist->output_video_filter, &ffsink, "out")) < 0)
{
return ret;
}
snprintf(args, 255, "%d:%d:%d:%d:%d", width,
height, pix_fmt, 1, AV_TIME_BASE);
if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0)
{
return ret;
}
if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &ffsink_ctx)) < 0)
{
return ret;
}
/* add input and output filters to the overall graph */
avfilter_graph_add_filter(graph, ist->input_video_filter);
avfilter_graph_add_filter(graph, ist->output_video_filter);
last_filter = ist->input_video_filter;
/*
if (codec->width != icodec->width || codec->height != icodec->height) {
AVFilterContext *filter;
snprintf(args, 255, "%d:%d:flags=0x%X",
codec->width,
codec->height,
(int)av_get_int(sws_opts, "sws_flags", NULL));
if ((ret = avfilter_open(&filter, avfilter_get_by_name("scale"), NULL)) < 0)
return ret;
if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
return ret;
last_filter = filter;
avfilter_graph_add_filter(graph, last_filter);
}
*/
//snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL));
snprintf(args, sizeof(args), "flags=0x%X", SWS_BICUBIC);
graph->scale_sws_opts = av_strdup(args);
if (vfilters) {
AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut));
outputs->name = av_strdup("in");
outputs->filter = last_filter;
outputs->pad_idx = 0;
outputs->next = NULL;
inputs->name = av_strdup("out");
inputs->filter = ist->output_video_filter;
inputs->pad_idx = 0;
inputs->next = NULL;
if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
{
return ret;
}
//av_freep(&vfilters);
} else {
if ((ret = avfilter_link(last_filter, 0, ist->output_video_filter, 0)) < 0)
{
return ret;
}
}
if ((ret = avfilter_graph_config(graph, NULL)) < 0)
{
return ret;
}
/*
codec->width = ist->output_video_filter->inputs[0]->w;
codec->height = ist->output_video_filter->inputs[0]->h;
*/
return 0;
}

@ -1,113 +0,0 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
/*
* Various utilities for command line tools
* copyright (c) 2003 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FFMPEG_CMDUTILS_H
#define FFMPEG_CMDUTILS_H
#include <inttypes.h>
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavfilter/avfilter.h"
#include "libavfilter/avfiltergraph.h"
typedef struct {
enum PixelFormat pix_fmt;
} FFSinkContext;
extern AVFilter ffsink;
struct AVInputStream;
typedef struct AVOutputStream {
int file_index; /* file index */
int index; /* stream index in the output file */
int source_index; /* AVInputStream index */
AVStream *st; /* stream in the output file */
int encoding_needed; /* true if encoding needed for this stream */
int frame_number;
/* input pts and corresponding output pts
for A/V sync */
//double sync_ipts; /* dts from the AVPacket of the demuxer in second units */
struct AVInputStream *sync_ist; /* input stream to sync against */
int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ //FIXME look at frame_number
AVBitStreamFilterContext *bitstream_filters;
/* video only */
int video_resample;
AVFrame pict_tmp; /* temporary image for resampling */
// struct SwsContext *img_resample_ctx; /* for image resampling */
// int resample_height;
// int resample_width;
// int resample_pix_fmt;
/* full frame size of first frame */
int original_height;
int original_width;
/* forced key frames */
int64_t *forced_kf_pts;
int forced_kf_count;
int forced_kf_index;
} AVOutputStream;
typedef struct AVInputStream {
int file_index;
int index;
AVStream *st;
int discard; /* true if stream data should be discarded */
int decoding_needed; /* true if the packets must be decoded in 'raw_fifo' */
int64_t sample_index; /* current sample */
int64_t start; /* time when read started */
int64_t next_pts; /* synthetic pts for cases where pkt.pts
is not defined */
int64_t pts; /* current pts */
//PtsCorrectionContext pts_ctx;
int is_start; /* is 1 at the start and after a discontinuity */
int showed_multi_packet_warning;
int is_past_recording_time;
AVFilterContext *output_video_filter;
AVFilterContext *input_video_filter;
AVFrame *filter_frame;
int has_filter_frame;
AVFilterBufferRef *picref;
} AVInputStream;
/**
* Extract a frame from sink.
*
* @return a negative error in case of failure, 1 if one frame has
* been extracted successfully.
*/
int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame,
AVFilterBufferRef **picref, AVRational *pts_tb);
int configure_filters(AVInputStream *ist, int pix_fmt, int width, int height,
AVFilterGraph *graph, const char* vfilters);
#endif /* FFMPEG_CMDUTILS_H */

@ -12,51 +12,74 @@
#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
#include <libavfilter/avfiltergraph.h>
#include <libavfilter/vsrc_buffer.h>
#include <libswscale/swscale.h>
#include "ffmpeg_utils.h"
#include "libavfilter/vsrc_buffer.h"
#define DEFINE_AVCODECCONTEXT_F_PROPERTY_SETTER(name, property) \
JNIEXPORT void JNICALL \
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1##name \
(JNIEnv *jniEnv, jclass clazz, jlong avctx, jfloat property) \
{ \
((AVCodecContext *) avctx)->property = (float) property; \
}
#define DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(name, property) \
JNIEXPORT void JNICALL \
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1##name \
(JNIEnv *jniEnv, jclass clazz, jlong avctx, jint property) \
{ \
((AVCodecContext *) avctx)->property = (int) property; \
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_av_1free (
JNIEnv *jniEnv, jclass clazz, jlong ptr) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_av_1free
(JNIEnv *jniEnv, jclass clazz, jlong ptr)
{
av_free ((void *) ptr);
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_av_1malloc (
JNIEnv *jniEnv, jclass clazz, jint size) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_av_1register_1all (
JNIEnv *jniEnv, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_av_1register_1all
(JNIEnv *jniEnv, jclass clazz)
{
av_register_all ();
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1alloc_1context (
JNIEnv *jniEnv, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1alloc_1context
(JNIEnv *jniEnv, jclass clazz)
{
return (jlong) avcodec_alloc_context ();
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1alloc_1frame (
JNIEnv *jniEnv, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1alloc_1frame
(JNIEnv *jniEnv, jclass clazz)
{
return (jlong) avcodec_alloc_frame ();
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1close (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodec_1decode_1video__JJ_3Z_3BI (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jlong frame,
jbooleanArray got_picture, jbyteArray buf, jint buf_size) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1decode_1video__JJ_3Z_3BI
(JNIEnv *jniEnv, jclass clazz,
jlong avctx,
jlong frame, jbooleanArray got_picture, jbyteArray buf, jint buf_size)
{
jint ret;
int n_got_picture;
@ -94,8 +117,8 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1decode_1video
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1decode_1video__JJJI
(JNIEnv *jniEnv, jclass clazz, jlong avcontext, jlong avframe, jlong src,
jint src_length)
(JNIEnv *jniEnv, jclass clazz,
jlong avctx, jlong avframe, jlong src, jint src_length)
{
AVPacket avpkt;
int got_picture = 0;
@ -105,18 +128,21 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1decode_1video
avpkt.data = (uint8_t*)src;
avpkt.size = (int)src_length;
ret = avcodec_decode_video2((AVCodecContext *) avcontext,
(AVFrame *)avframe, &got_picture,
&avpkt);
ret
= avcodec_decode_video2(
(AVCodecContext *) avctx,
(AVFrame *)avframe, &got_picture, &avpkt);
return got_picture ? ret : -1;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1encode_1audio (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jbyteArray buf,
jint buf_offset, jint buf_size, jbyteArray samples,
jint samples_offset) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1encode_1audio
(JNIEnv *jniEnv, jclass clazz,
jlong avctx,
jbyteArray buf, jint buf_offset, jint buf_size,
jbyteArray samples, jint samples_offset)
{
jint ret;
if (buf) {
@ -127,11 +153,11 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1encode_1audio
= (*jniEnv)->GetByteArrayElements (jniEnv, samples, NULL);
if (samples_ptr) {
ret = (jint) avcodec_encode_audio (
ret = (jint) avcodec_encode_audio(
(AVCodecContext *) avctx,
(uint8_t *) (buf_ptr + buf_offset), (int) buf_size,
(const short *) (samples_ptr + samples_offset));
(*jniEnv)->ReleaseByteArrayElements (
(*jniEnv)->ReleaseByteArrayElements(
jniEnv,
samples, samples_ptr,
JNI_ABORT);
@ -146,9 +172,10 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1encode_1audio
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1encode_1video (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jbyteArray buf,
jint buf_size, jlong frame) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1encode_1video
(JNIEnv *jniEnv, jclass clazz,
jlong avctx, jbyteArray buf, jint buf_size, jlong frame)
{
jint ret;
if (buf) {
@ -168,184 +195,121 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1encode_1video
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1find_1decoder (
JNIEnv *jniEnv, jclass clazz, jint id) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodec_1find_1encoder (
JNIEnv *jniEnv, jclass clazz, jint id) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1find_1encoder
(JNIEnv *jniEnv, jclass clazz, jint id)
{
return (jlong) avcodec_find_encoder ((enum CodecID) id);
}
/* Empty log function to skip all logs coming out onto the terminal. */
static void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
/**
* Implements a log callback that does not log anything in order to prevent logs
* from appearing on stdout and/or stderr.
*/
static void
null_log_callback(void* ptr, int level, const char* fmt, va_list vl)
{
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1init (
JNIEnv *jniEnv, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1init
(JNIEnv *jniEnv, jclass clazz)
{
avcodec_init ();
av_log_set_callback(log_callback_help);
av_log_set_callback(null_log_callback);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodec_1open (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jlong codec) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodeccontext_1add_1flags (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint flags) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodeccontext_1add_1flags2
(JNIEnv *jniEnv, jclass clazz, jlong avctx, jint flags)
(JNIEnv *jniEnv, jclass clazz, jlong avctx, jint flags2)
{
((AVCodecContext *) avctx)->flags2 |= (int) flags;
((AVCodecContext *) avctx)->flags2 |= (int) flags2;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1add_1partitions (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint partitions) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodeccontext_1get_1frame_1size (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1get_1frame_1size
(JNIEnv *jniEnv, jclass clazz, jlong avctx)
{
return (jint) (((AVCodecContext *) avctx)->frame_size);
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1get_1height (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodeccontext_1get_1pix_1fmt (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodeccontext_1get_1width (
JNIEnv *jniEnv, jclass clazz, jlong avctx) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_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;
}
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(b_1frame_1strategy, b_frame_strategy)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(bit_1rate, bit_rate)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(bit_1rate_1tolerance, bit_rate_tolerance)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(channels, channels)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(chromaoffset, chromaoffset)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1bit_1rate (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint bit_rate) {
((AVCodecContext *) avctx)->bit_rate = (int) bit_rate;
}
DEFINE_AVCODECCONTEXT_F_PROPERTY_SETTER(crf, crf)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_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;
}
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(deblockbeta, deblockbeta)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(gop_1size, gop_size)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1channels (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint channels) {
((AVCodecContext *) avctx)->channels = (int) channels;
}
DEFINE_AVCODECCONTEXT_F_PROPERTY_SETTER(i_1quant_1factor, i_quant_factor)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1chromaoffset (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint chromaoffset) {
((AVCodecContext *) avctx)->chromaoffset = (int) chromaoffset;
}
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(keyint_1min, keyint_min)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(max_1b_1frames, max_b_frames)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(mb_1decision, mb_decision)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(me_1cmp, me_cmp)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(me_1method, me_method)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(me_1range, me_range)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(me_1subpel_1quality, me_subpel_quality)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(pix_1fmt, pix_fmt)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1crf (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jfloat crf) {
((AVCodecContext *) avctx)->crf = (float) crf;
}
DEFINE_AVCODECCONTEXT_F_PROPERTY_SETTER(qcompress, qcompress)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_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_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_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_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_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_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_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_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_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_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_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_FFmpeg_avcodeccontext_1set_1quantizer (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint qmin, jint qmax,
jint max_qdiff) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1quantizer
(JNIEnv *jniEnv, jclass clazz, jlong avctx, jint qmin, jint qmax,
jint max_qdiff)
{
AVCodecContext *n_avctx = (AVCodecContext *) avctx;
n_avctx->qmin = (int) qmin;
@ -353,15 +317,12 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1q
n_avctx->max_qdiff = (int) max_qdiff;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_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;
}
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(rc_1buffer_1size, rc_buffer_size)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1rc_1eq (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jstring rc_eq) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1rc_1eq
(JNIEnv *jniEnv, jclass clazz, jlong avctx, jstring rc_eq)
{
char *n_rc_eq;
if (rc_eq) {
@ -378,26 +339,14 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1r
((AVCodecContext *) avctx)->rc_eq = n_rc_eq;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_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;
}
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(rc_1max_1rate, rc_max_rate)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(refs, refs)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(rtp_1payload_1size, rtp_payload_size)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodeccontext_1set_1rtp_1payload_1size (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint rtp_payload_size) {
((AVCodecContext *) avctx)->rtp_payload_size = (int) rtp_payload_size;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1sample_1aspect_1ratio (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint num, jint den) {
Java_net_java_sip_communicator_impl_neomedia_codec_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);
@ -405,71 +354,47 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1s
sample_aspect_ratio->den = (int) den;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1sample_1rate (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint sample_rate) {
((AVCodecContext *) avctx)->sample_rate = (int) sample_rate;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1scenechange_1threshold (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint scenechange_threshold) {
((AVCodecContext *) avctx)->scenechange_threshold =
(int) scenechange_threshold;
}
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(sample_1rate, sample_rate)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(scenechange_1threshold, scenechange_threshold)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1size (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint width, jint height) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1size
(JNIEnv *jniEnv, jclass clazz, jlong avctx, jint width, jint height)
{
AVCodecContext *n_avctx = (AVCodecContext *) avctx;
n_avctx->width = (int) width;
n_avctx->height = (int) height;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_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_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;
}
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(thread_1count, thread_count)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(ticks_1per_1frame, ticks_per_frame)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1time_1base (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint num, jint den) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avcodeccontext_1set_1time_1base
(JNIEnv *jniEnv, jclass clazz, jlong avctx, jint num, jint den)
{
AVRational *time_base = &(((AVCodecContext *) avctx)->time_base);
time_base->num = (int) num;
time_base->den = (int) den;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avcodeccontext_1set_1workaround_1bugs (
JNIEnv *jniEnv, jclass clazz, jlong avctx, jint workaround_bugs) {
((AVCodecContext *) avctx)->workaround_bugs = (int) workaround_bugs;
}
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(trellis, trellis)
DEFINE_AVCODECCONTEXT_I_PROPERTY_SETTER(workaround_1bugs, workaround_bugs)
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1get_1pts (
JNIEnv *jniEnv, jclass clazz, jlong frame) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1get_1pts
(JNIEnv *jniEnv, jclass clazz, jlong frame)
{
return (jlong) (((AVFrame *) frame)->pts);
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1set_1data (
JNIEnv *jniEnv, jclass clazz, jlong frame, jlong data0, jlong offset1,
jlong offset2) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1set_1data
(JNIEnv *jniEnv, jclass clazz, jlong frame, jlong data0, jlong offset1,
jlong offset2)
{
AVFrame *n_frame = (AVFrame *) frame;
n_frame->data[0] = (uint8_t *) data0;
@ -478,16 +403,18 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1set_1data (
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1set_1key_1frame (
JNIEnv *jniEnv, jclass clazz, jlong frame, jboolean key_frame) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1set_1key_1frame
(JNIEnv *jniEnv, jclass clazz, jlong frame, jboolean key_frame)
{
((AVFrame *) frame)->key_frame = (JNI_TRUE == key_frame) ? 1 : 0;
((AVFrame *) frame)->pict_type = (JNI_TRUE == key_frame) ? FF_I_TYPE : 0;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1set_1linesize (
JNIEnv *jniEnv, jclass clazz, jlong frame, jint linesize0,
jint linesize1, jint linesize2) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1set_1linesize
(JNIEnv *jniEnv, jclass clazz, jlong frame, jint linesize0,
jint linesize1, jint linesize2)
{
AVFrame *n_frame = (AVFrame *) frame;
n_frame->linesize[0] = (int) linesize0;
@ -496,57 +423,65 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avframe_1set_1linesize
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avpicture_1fill (
JNIEnv *jniEnv, jclass clazz, jlong picture, jlong ptr, jint pix_fmt,
jint width, jint height) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avpicture_1fill
(JNIEnv *jniEnv, jclass clazz, jlong picture, jlong ptr, jint pix_fmt,
jint width, jint height)
{
return (jint)
avpicture_fill ((AVPicture *) picture, (uint8_t *) ptr, (int) pix_fmt,
(int) width, (int) height);
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avpicture_1get_1data0 (
JNIEnv *jniEnv, jclass clazz, jlong picture) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_avpicture_1get_1size (
JNIEnv *jniEnv, jclass clazz, jint pix_fmt, jint width, jint height) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_memcpy___3IIIJ (
JNIEnv *jniEnv, jclass clazz, jintArray dst, jint dst_offset,
jint dst_length, jlong src) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_memcpy__J_3BII (
JNIEnv *jniEnv, jclass clazz, jlong dst, jbyteArray src,
jint src_offset, jint src_length) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_PIX_1FMT_1BGR32 (
JNIEnv *env, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_PIX_1FMT_1BGR32
(JNIEnv *env, jclass clazz)
{
return PIX_FMT_BGR32;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_PIX_1FMT_1BGR32_11 (
JNIEnv *env, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_PIX_1FMT_1RGB24 (
JNIEnv *jniEnv, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_PIX_1FMT_1RGB24
(JNIEnv *jniEnv, jclass clazz)
{
uint32_t test = 1;
int little_endian = *((uint8_t*)&test);
@ -554,30 +489,34 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_PIX_1FMT_1RGB24 (
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_PIX_1FMT_1RGB32 (
JNIEnv *env, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_PIX_1FMT_1RGB32
(JNIEnv *env, jclass clazz)
{
return PIX_FMT_RGB32;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_PIX_1FMT_1RGB32_11 (
JNIEnv *env, jclass clazz) {
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_PIX_1FMT_1RGB32_11
(JNIEnv *env, jclass clazz)
{
return PIX_FMT_RGB32_1;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1freeContext (
JNIEnv *jniEnv, jclass clazz, jlong context) {
Java_net_java_sip_communicator_impl_neomedia_codec_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_FFmpeg_sws_1getCachedContext (
JNIEnv *jniEnv, jclass clazz, jlong context, jint srcW, jint srcH,
jint srcFormat, jint dstW, jint dstH, jint dstFormat, jint flags) {
Java_net_java_sip_communicator_impl_neomedia_codec_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 (
sws_getCachedContext(
(struct SwsContext *) context,
(int) srcW, (int) srcH, (enum PixelFormat) srcFormat,
(int) dstW, (int) dstH, (enum PixelFormat) dstFormat,
@ -586,9 +525,10 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1getCachedContext
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_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) {
Java_net_java_sip_communicator_impl_neomedia_codec_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;
@ -599,10 +539,10 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1scale__JJIILjava_
AVPicture dstPicture;
/* Turn the bytes into an AVPicture. */
avpicture_fill (
avpicture_fill(
&dstPicture, dstPtr, (int) dstFormat, (int) dstW, (int) dstH);
ret
= sws_scale (
= sws_scale(
(struct SwsContext *) context,
(const uint8_t * const *) srcPicture->data, (int *) srcPicture->linesize,
(int) srcSliceY, (int) srcSliceH,
@ -616,10 +556,11 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1scale__JJIILjava_
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1scale__JLjava_lang_Object_2IIIIILjava_lang_Object_2III (
JNIEnv *jniEnv, jclass class, jlong context, jobject src,
Java_net_java_sip_communicator_impl_neomedia_codec_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) {
jobject dst, jint dstFormat, jint dstW, jint dstH)
{
uint8_t *srcPtr;
jint ret;
@ -627,10 +568,10 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1scale__JLjava_lan
if (srcPtr) {
AVPicture srcPicture;
avpicture_fill (
avpicture_fill(
&srcPicture, srcPtr, (int) srcFormat, (int) srcW, (int) srcH);
ret
= Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1scale__JJIILjava_lang_Object_2III (
= Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1scale__JJIILjava_lang_Object_2III(
jniEnv, class,
context,
(jlong) &srcPicture, srcSliceY, srcSliceH,
@ -642,103 +583,190 @@ Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_sws_1scale__JLjava_lan
return ret;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1register_1all
(JNIEnv *jniEnv, jclass clazz)
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1graph_1alloc
(JNIEnv *jniEnv, jclass clazz)
{
avfilter_register_all();
return (jlong) avfilter_graph_alloc();
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1alloc_1filtergraph
(JNIEnv *jniEnv, jclass clazz)
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1graph_1config
(JNIEnv *jniEnv, jclass clazz, jlong graph, jlong log_ctx)
{
AVFilterGraph* graph = av_mallocz(sizeof(AVFilterGraph));
return (jlong)graph;
return
(jint)
avfilter_graph_config((AVFilterGraph *) graph, (AVClass *) log_ctx);
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1free_1filtergraph
(JNIEnv *jniEnv, jclass clazz, jlong ptr)
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1graph_1free
(JNIEnv *jniEnv, jclass clazz, jlong graph)
{
AVFilterGraph* graph = (AVFilterGraph*)ptr;
AVFilterGraph *graph_ = (AVFilterGraph *) graph;
if(graph)
{
avfilter_graph_destroy(graph);
av_freep(graph);
}
avfilter_graph_free(&graph_);
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1alloc_1inputstream
(JNIEnv *jniEnv, jclass clazz)
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1graph_1get_1filter
(JNIEnv *jniEnv, jclass clazz, jlong graph, jstring name)
{
AVInputStream* avinputstream = av_mallocz(sizeof(AVInputStream));
return (jlong)avinputstream;
}
const char *name_ = (*jniEnv)->GetStringUTFChars(jniEnv, name, NULL);
AVFilterContext *filter;
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1free_1inputstream
(JNIEnv *jniEnv, jclass clazz, jlong ptr)
{
av_freep((void*)ptr);
if (name_)
{
filter = avfilter_graph_get_filter((AVFilterGraph *) graph, name_);
(*jniEnv)->ReleaseStringUTFChars(jniEnv, name, name_);
}
else
filter = NULL;
return (jlong) filter;
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1alloc_1outputstream
(JNIEnv *jniEnv, jclass clazz)
static int
ffsink_query_formats(AVFilterContext *ctx)
{
AVOutputStream* avoutputstream = av_mallocz(sizeof(AVOutputStream));
return (jlong)avoutputstream;
int err;
/* Make ffsink output in the format in which buffer inputs. */
if (ctx->priv)
{
AVFilterContext *src = ctx->priv;
const int pix_fmts[] = { src->outputs[0]->in_formats->formats[0], -1 };
avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
err = 0;
}
else
err = avfilter_default_query_formats(ctx);
return err;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1free_1outputstream
(JNIEnv *jniEnv, jclass clazz, jlong ptr)
static void
ffsink_uninit(AVFilterContext *ctx)
{
av_freep((void*)ptr);
/*
* Do not let FFmpeg libavfilter erroneously free the buffer video source
* thinking that it is the priv allocated to this ffsink video sink via
* priv_size.
*/
ctx->priv = NULL;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1configure_1filters
(JNIEnv *jniEnv, jclass clazz, jstring vfilters, jlong inputstream, jint pix_fmt,
jint width, jint height, jlong graph)
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1graph_1parse
(JNIEnv *jniEnv, jclass clazz,
jlong graph, jstring filters, jlong inputs, jlong outputs, jlong log_ctx)
{
jint ret = 0;
const char* filters = (*jniEnv)->GetStringUTFChars (jniEnv, vfilters, NULL);
const char *filters_ = (*jniEnv)->GetStringUTFChars(jniEnv, filters, NULL);
int ret;
ret = configure_filters((AVInputStream*)inputstream, pix_fmt, width, height,
(AVFilterGraph*)graph, filters);
if (filters_)
{
AVFilterGraph *graph_ = (AVFilterGraph *) graph;
(*jniEnv)->ReleaseStringUTFChars (jniEnv, vfilters, filters);
return ret;
ret
= avfilter_graph_parse(
graph_,
filters_,
(AVFilterInOut *) inputs, (AVFilterInOut *) outputs,
(AVClass *) log_ctx);
/*
* FIXME The implementation at the time of this writing presumes that
* the first filter is buffer, the last filter is nullsink meant to be
* ffsink and the ffsink is expected to output in the format in which
* the buffer inputs.
*/
if (0 == ret)
{
/* Turn nullsink into ffsink. */
unsigned filterCount = graph_->filter_count;
if (filterCount)
{
AVFilterContext *ffsink = (graph_->filters)[filterCount - 1];
AVFilterContext *buffer = (graph_->filters)[0];
/*
* Make sure query_format of ffsink outputs in the format in
* which buffer inputs. Otherwise, the output format may end up
* different on the C and Java sides.
*/
ffsink->filter->uninit = ffsink_uninit;
ffsink->priv = buffer;
ffsink->filter->query_formats = ffsink_query_formats;
ffsink->input_pads->min_perms = AV_PERM_READ;
ffsink->input_pads->start_frame = NULL;
}
}
(*jniEnv)->ReleaseStringUTFChars(jniEnv, filters, filters_);
}
else
ret = AVERROR(ENOMEM);
return (jint) ret;
}
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_av_1vsrc_1buffer_1add_1frame
(JNIEnv *jniEnv, jclass clazz, jlong inputstream, jlong avframe)
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1register_1all
(JNIEnv *jniEnv, jclass clazz)
{
AVInputStream* ist = (AVInputStream*)inputstream;
if(ist->picref)
{
avfilter_unref_buffer(ist->picref);
}
av_vsrc_buffer_add_frame(ist->input_video_filter, (AVFrame*)avframe,
ist->pts, AV_TIME_BASE_Q);
avfilter_register_all();
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_av_1get_1filtered_1video_1frame
(JNIEnv *jniEnv, jclass clazz, jlong inputstream, jlong avframe)
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_avfilter_1unref_1buffer
(JNIEnv *jniEnv, jclass clazz, jlong ref)
{
AVInputStream* ist = (AVInputStream*)inputstream;
AVRational ist_pts_tb;
get_filtered_video_frame(ist->output_video_filter, (AVFrame*)avframe, &ist->picref, &ist_pts_tb);
return 0;
avfilter_unref_buffer((AVFilterBufferRef *) ref);
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_neomedia_codec_FFmpeg_get_1filtered_1video_1frame
(JNIEnv *jniEnv, jclass clazz,
jlong input, jlong buffer, jlong ffsink, jlong output)
{
AVFilterContext *buffer_ = (AVFilterContext *) buffer;
AVFilterBufferRef *ref = NULL;
if (av_vsrc_buffer_add_frame(
buffer_,
(AVFrame *) input,
AV_NOPTS_VALUE,
(AVRational) { 1, 1 })
== 0)
{
AVFilterContext *ffsink_ = (AVFilterContext *) ffsink;
AVFilterLink *ffsinkLink = (ffsink_->inputs)[0];
if (avfilter_request_frame(ffsinkLink) == 0)
{
ref = ffsinkLink->cur_buf;
if (ref)
{
AVFrame *output_ = (AVFrame *) output;
/*
* The data of cur_buf will be returned into output so it needs
* to exist at least while output needs it. So take ownership of
* cur_buf and the user of output will unref it when they are
* done with output.
*/
ffsinkLink->cur_buf = NULL;
memcpy(output_->data, ref->data, sizeof(output_->data));
memcpy(
output_->linesize,
ref->linesize,
sizeof(output_->linesize));
output_->interlaced_frame = ref->video->interlaced;
output_->top_field_first = ref->video->top_field_first;
}
}
}
return (jlong) ref;
}

Loading…
Cancel
Save